blob: a813624fd358b296d038889986d152e82c1c58e9 [file] [log] [blame]
Kailash22179672019-03-18 20:24:55 -07001# 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
15class bbsim_utils(object):
16
17 def generate_subscribers(self, num_subs, rcord_service_id, stag=999, ctag_start=900, pon_id=1):
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 = []
26 for index in range(1, int(num_subs) + 1):
27 sub = {
28 "name" : "Sub_BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)-1),
29 "status" : "pre-provisioned",
30 "c_tag" : ctag_start + int(index)-1,
31 "s_tag" : stag,
32 "onu_device" : "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)-1),
33 "circuit_id" : "circuit" + '{0:02x}'.format(int(index)-1),
34 "remote_id" : "remote" + '{0:02x}'.format(int(index)-1),
35 "nas_port_id" : "PON 2/1/01/1:1.1." + str(pon_id) + '{0:02x}'.format(int(index)-1)
36 }
37 subscribers.append(sub)
38 return subscribers
39
40 def generate_whitelists(self, num_onus, att_service_id, pon_id=1):
41 """
42 :param num_onus: Number of ONUs to be added to the whitelist
43 :param att_service_id: ID of the att workflow service
44 :param olt_id: ID of the pon_port
45 :return: List of whitelists to POST
46 """
47 whitelists = []
48 for index in range(1, int(num_onus) + 1):
49 onu = {
50 "serial_number": "BBSM" + str("00000") + str(pon_id) + '{0:02x}'.format(int(index)-1),
51 "device_id" : "of:000000000ac004ce",
52 "pon_port_id" : 536870913,
53 "owner_id" : att_service_id
54 }
55 whitelists.append(onu)
56 return whitelists
57
58#test=whitelists()
59#wls = test.generate_whitelists(64, 1, 1)
60#for i in wls:
61# print i
62
63#test=bbsim_utils()
64#subs = test.generate_subscribers(16, 1)
65#for i in subs:
66# print i