Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Zack Williams | c6722d5 | 2020-01-13 16:34:33 -0700 | [diff] [blame^] | 15 | from __future__ import absolute_import |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 16 | |
Zack Williams | c6722d5 | 2020-01-13 16:34:33 -0700 | [diff] [blame^] | 17 | from six.moves import range |
| 18 | |
| 19 | |
| 20 | class bbsim_utils(object): |
| 21 | def generate_subscribers( |
| 22 | self, num_subs, rcord_service_id, stag=999, ctag_start=900, pon_id=0 |
| 23 | ): |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 24 | """ |
| 25 | :param num_subs: Number of subscribers to create |
| 26 | :param rcord_service_id: ID of the rcord service |
| 27 | :param stag: S_tag of subscriber |
| 28 | :param ctag: C_tag of first subscriber (to be incremented by num_subs) |
| 29 | :return: List of subscribers to POST |
| 30 | """ |
| 31 | subscribers = [] |
Zack Williams | c6722d5 | 2020-01-13 16:34:33 -0700 | [diff] [blame^] | 32 | for index in range(1, int(num_subs) + 1): |
Kailash | 3944340 | 2019-03-19 13:21:04 -0700 | [diff] [blame] | 33 | sub = { |
Zack Williams | c6722d5 | 2020-01-13 16:34:33 -0700 | [diff] [blame^] | 34 | "name": "Sub_BBSM" |
| 35 | + str("00000") |
| 36 | + str(pon_id) |
| 37 | + "{0:02x}".format(int(index)), |
| 38 | "status": "pre-provisioned", |
| 39 | "c_tag": ctag_start + int(index), |
| 40 | "s_tag": stag, |
| 41 | "onu_device": "BBSM" |
| 42 | + str("00000") |
| 43 | + str(pon_id) |
| 44 | + "{0:02x}".format(int(index)), |
| 45 | "circuit_id": "circuit" + "{0:02x}".format(int(index)), |
| 46 | "remote_id": "remote" + "{0:02x}".format(int(index)), |
| 47 | "nas_port_id": "PON 2/1/01/1:1.1." + "{0:0x}".format(int(index)), |
| 48 | "upstream_bps_id": 1, |
| 49 | "downstream_bps_id": 1, |
| 50 | "tech_profile_id": 64, |
Kailash | 3944340 | 2019-03-19 13:21:04 -0700 | [diff] [blame] | 51 | } |
| 52 | subscribers.append(sub) |
| 53 | if index == 10: |
| 54 | break |
| 55 | for index in range(11, int(num_subs) + 1): |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 56 | sub = { |
Zack Williams | c6722d5 | 2020-01-13 16:34:33 -0700 | [diff] [blame^] | 57 | "name": "Sub_BBSM" |
| 58 | + str("00000") |
| 59 | + str(pon_id) |
| 60 | + "{0:02x}".format(int(index)), |
| 61 | "status": "pre-provisioned", |
| 62 | "c_tag": ctag_start + int(index), |
| 63 | "s_tag": stag, |
| 64 | "onu_device": "BBSM" |
| 65 | + str("00000") |
| 66 | + str(pon_id) |
| 67 | + "{0:02x}".format(int(index)), |
| 68 | "circuit_id": "circuit" + "{0:02x}".format(int(index)), |
| 69 | "remote_id": "remote" + "{0:02x}".format(int(index)), |
| 70 | "nas_port_id": "PON 2/1/01/1:1.1." |
| 71 | + str(pon_id) |
| 72 | + "{0:02x}".format(int(index)), |
| 73 | "upstream_bps_id": 1, |
| 74 | "downstream_bps_id": 1, |
| 75 | "tech_profile_id": 64, |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 76 | } |
| 77 | subscribers.append(sub) |
| 78 | return subscribers |
| 79 | |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 80 | def generate_whitelists(self, num_onus, att_service_id, pon_id=0): |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 81 | """ |
| 82 | :param num_onus: Number of ONUs to be added to the whitelist |
| 83 | :param att_service_id: ID of the att workflow service |
| 84 | :param olt_id: ID of the pon_port |
| 85 | :return: List of whitelists to POST |
| 86 | """ |
| 87 | whitelists = [] |
| 88 | for index in range(1, int(num_onus) + 1): |
| 89 | onu = { |
Zack Williams | c6722d5 | 2020-01-13 16:34:33 -0700 | [diff] [blame^] | 90 | "serial_number": "BBSM" |
| 91 | + str("00000") |
| 92 | + str(pon_id) |
| 93 | + "{0:02x}".format(int(index)), |
| 94 | "device_id": "of:0000626273696d76", |
| 95 | "pon_port_id": 536870912, |
| 96 | "owner_id": att_service_id, |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 97 | } |
| 98 | whitelists.append(onu) |
Kailash | b022c40 | 2019-06-21 12:08:32 -0700 | [diff] [blame] | 99 | return whitelists |