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 | |
| 15 | class bbsim_utils(object): |
| 16 | |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 17 | def generate_subscribers(self, num_subs, rcord_service_id, stag=999, ctag_start=900, pon_id=0): |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 18 | """ |
| 19 | :param num_subs: Number of subscribers to create |
| 20 | :param rcord_service_id: ID of the rcord service |
| 21 | :param stag: S_tag of subscriber |
| 22 | :param ctag: C_tag of first subscriber (to be incremented by num_subs) |
| 23 | :return: List of subscribers to POST |
| 24 | """ |
| 25 | subscribers = [] |
Kailash | 3944340 | 2019-03-19 13:21:04 -0700 | [diff] [blame] | 26 | for index in xrange(1, int(num_subs) + 1): |
| 27 | sub = { |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 28 | "name" : "Sub_BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)), |
Kailash | 3944340 | 2019-03-19 13:21:04 -0700 | [diff] [blame] | 29 | "status" : "pre-provisioned", |
| 30 | "c_tag" : ctag_start + int(index)-1, |
| 31 | "s_tag" : stag, |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 32 | "onu_device" : "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)), |
| 33 | "circuit_id" : "circuit" + '{0:02x}'.format(int(index)), |
| 34 | "remote_id" : "remote" + '{0:02x}'.format(int(index)), |
| 35 | "nas_port_id" : "PON 2/1/01/1:1.1." + '{0:0x}'.format(int(index)), |
| 36 | "upstream_bps_id" : 1, |
Kailash | c97c1f5 | 2019-03-26 11:31:56 -0700 | [diff] [blame] | 37 | "downstream_bps_id" : 1 |
Kailash | 3944340 | 2019-03-19 13:21:04 -0700 | [diff] [blame] | 38 | } |
| 39 | subscribers.append(sub) |
| 40 | if index == 10: |
| 41 | break |
| 42 | for index in range(11, int(num_subs) + 1): |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 43 | sub = { |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 44 | "name" : "Sub_BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)), |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 45 | "status" : "pre-provisioned", |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 46 | "c_tag" : ctag_start + int(index), |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 47 | "s_tag" : stag, |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 48 | "onu_device" : "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)), |
| 49 | "circuit_id" : "circuit" + '{0:02x}'.format(int(index)), |
| 50 | "remote_id" : "remote" + '{0:02x}'.format(int(index)), |
| 51 | "nas_port_id" : "PON 2/1/01/1:1.1." + str(pon_id) + '{0:02x}'.format(int(index)), |
Kailash | c97c1f5 | 2019-03-26 11:31:56 -0700 | [diff] [blame] | 52 | "upstream_bps_id" : 1, |
| 53 | "downstream_bps_id" : 1 |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 54 | } |
| 55 | subscribers.append(sub) |
| 56 | return subscribers |
| 57 | |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 58 | def generate_whitelists(self, num_onus, att_service_id, pon_id=0): |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 59 | """ |
| 60 | :param num_onus: Number of ONUs to be added to the whitelist |
| 61 | :param att_service_id: ID of the att workflow service |
| 62 | :param olt_id: ID of the pon_port |
| 63 | :return: List of whitelists to POST |
| 64 | """ |
| 65 | whitelists = [] |
| 66 | for index in range(1, int(num_onus) + 1): |
| 67 | onu = { |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 68 | "serial_number": "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)), |
Kailash | dc5e78b | 2019-03-19 09:24:23 -0700 | [diff] [blame] | 69 | "device_id" : "of:0000626273696d76", |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 70 | "pon_port_id" : 536870912, |
Kailash | 2217967 | 2019-03-18 20:24:55 -0700 | [diff] [blame] | 71 | "owner_id" : att_service_id |
| 72 | } |
| 73 | whitelists.append(onu) |
Kailash | 45ab7e9 | 2019-06-10 13:12:05 -0700 | [diff] [blame] | 74 | return whitelists |