VOL-289: Create xPON interfaces at ONU adapter(s)
Creating xPON interfaces at ONU adapter(s)
* create_interface (v_ont_ani/ont_ani/v_enet)
Verify pon_sim ONU adapter is called with appropriate adapter interface(s)
Includes changes to fix delete ordering of xPON interfaces at OLT adapter. The correct order of delete scenario:
* VEnet
* Ont_Ani
* VOnt_Ani
* ChannelterminationConfig
* ChannelpairConfig
* ChannelpartitionConfig
* ChannelgroupConfig
Change-Id: Ieff304274768406781ce27975b8b94412aff5b51
diff --git a/voltha/adapters/ponsim_onu/ponsim_onu.py b/voltha/adapters/ponsim_onu/ponsim_onu.py
index 499b825..87fb0e0 100644
--- a/voltha/adapters/ponsim_onu/ponsim_onu.py
+++ b/voltha/adapters/ponsim_onu/ponsim_onu.py
@@ -32,6 +32,9 @@
OFPPF_1GB_FD
from voltha.protos.openflow_13_pb2 import ofp_port
from voltha.protos.ponsim_pb2 import FlowTable
+from voltha.protos.ponsim_pb2 import InterfaceConfig
+from voltha.protos.bbf_fiber_base_pb2 import OntaniConfig, VOntaniConfig, \
+ VEnetConfig
_ = third_party
log = structlog.get_logger()
@@ -50,6 +53,10 @@
device_type='ponsim_onu',
vendor_id='PSMO')
+ def create_interface(self, device, data):
+ log.info('create-interface', device_id=device.id)
+ self.devices_handlers[device.id].create_interface(data)
+
class PonSimOnuHandler(object):
def __init__(self, adapter, device_id):
self.adapter = adapter
@@ -349,3 +356,22 @@
# 2) Remove the device from ponsim
self.log.info('deleted', device_id=self.device_id)
+
+ def get_interface_config(self, data):
+ interfaceConfig = InterfaceConfig()
+ if isinstance(data, OntaniConfig):
+ interfaceConfig.ont_ani_config.CopyFrom(data)
+ elif isinstance(data, VOntaniConfig):
+ interfaceConfig.vont_ani_config.CopyFrom(data)
+ elif isinstance(data, VEnetConfig):
+ interfaceConfig.venet_config.CopyFrom(data)
+ else:
+ return None
+ return interfaceConfig
+
+ def create_interface(self, data):
+ interfaceConfig = self.get_interface_config(data)
+ if interfaceConfig is not None:
+ self.log.info(
+ 'forwarding-create-interface-request-to-onu-interface-type',
+ interface_type=type(data))
diff --git a/voltha/core/xpon_agent.py b/voltha/core/xpon_agent.py
index 024008a..43ae1b6 100644
--- a/voltha/core/xpon_agent.py
+++ b/voltha/core/xpon_agent.py
@@ -29,38 +29,22 @@
class XponAgent(object):
- interfaces = {ChannelgroupConfig: {
- 'path': '/channel_groups/{}', 'path_keys': ['name'],
- 'device_id' : ''},
- ChannelpartitionConfig: {
- 'path': '/channel_partitions/{}', 'path_keys': ['name'],
- 'device_id' : ''},
- ChannelpairConfig: {
- 'path': '/channel_pairs/{}', 'path_keys': ['name'],
- 'device_id' : ''},
- ChannelterminationConfig: {
- 'path': '/devices/{}/channel_terminations/{}',
- 'path_keys': ['id', 'name'], 'device_id' : 'id'},
- OntaniConfig: {
- 'path': '/ont_anis/{}', 'path_keys': ['name'],
- 'device_id' : ''},
- VOntaniConfig: {
- 'path': '/v_ont_anis/{}', 'path_keys': ['name'],
- 'device_id' : ''},
- VEnetConfig: {
- 'path': '/v_enets/{}', 'path_keys': ['name'],
- 'device_id' : ''}
- }
-
interface_stack = {ChannelgroupConfig: {
+ 'path': '/channel_groups/{}',
+ 'path_keys': ['name'],
'parent': None, 'parent_path': None,
'parent_path_keys': [None],
'child': ChannelpartitionConfig,
'child_path': ['/channel_partitions'],
'olt_link': None, 'olt_link_path': None,
'olt_link_path_keys': [None],
- 'olt_device_id': 'from_child'},
+ 'olt_device_id': 'from_child',
+ 'onu_link': None, 'onu_link_path': None,
+ 'onu_link_path_keys': [None],
+ 'onu_device_id': 'na'},
ChannelpartitionConfig: {
+ 'path': '/channel_partitions/{}',
+ 'path_keys': ['name'],
'parent': ChannelgroupConfig,
'parent_path': '/channel_groups/{}',
'parent_path_keys': ['data.channelgroup_ref'],
@@ -68,8 +52,12 @@
'child_path': ['/channel_pairs'],
'olt_link': None, 'olt_link_path': None,
'olt_link_path_keys': [None],
- 'olt_device_id': 'from_child'},
+ 'olt_device_id': 'from_child',
+ 'onu_link': None, 'onu_link_path': None,
+ 'onu_link_path_keys': [None],
+ 'onu_device_id': 'na'},
ChannelpairConfig: {
+ 'path': '/channel_pairs/{}', 'path_keys': ['name'],
'parent': ChannelpartitionConfig,
'parent_path': '/channel_partitions/{}',
'parent_path_keys':\
@@ -79,8 +67,14 @@
['/devices', 'channel_terminations'],
'olt_link': None, 'olt_link_path': None,
'olt_link_path_keys': [None],
- 'olt_device_id': 'from_child'},
+ 'olt_device_id': 'from_child',
+ 'onu_link': None,
+ 'onu_link_path': None,
+ 'onu_link_path_keys': [None],
+ 'onu_device_id': 'na'},
ChannelterminationConfig: {
+ 'path': '/devices/{}/channel_terminations/{}',
+ 'path_keys': ['id', 'name'],
'parent': ChannelpairConfig,
'parent_path': '/channel_pairs/{}',
'parent_path_keys':\
@@ -88,8 +82,12 @@
'child': None, 'child_path': [None],
'olt_link': None, 'olt_link_path': None,
'olt_link_path_keys': [None],
- 'olt_device_id': 'self'},
+ 'olt_device_id': 'self',
+ 'onu_link': None, 'onu_link_path': None,
+ 'onu_link_path_keys': [None],
+ 'onu_device_id': 'na'},
VOntaniConfig: {
+ 'path': '/v_ont_anis/{}', 'path_keys': ['name'],
'parent': ChannelpartitionConfig,
'parent_path': '/channel_partitions/{}',
'parent_path_keys': ['data.parent_ref'],
@@ -98,23 +96,35 @@
'olt_link_path': '/channel_pairs/{}',
'olt_link_path_keys':\
['data.preferred_chanpair'],
- 'olt_device_id': 'from_link'},
+ 'olt_device_id': 'from_link',
+ 'onu_link': None, 'onu_link_path': None,
+ 'onu_link_path_keys': [None],
+ 'onu_device_id': 'self'},
OntaniConfig: {
+ 'path': '/ont_anis/{}', 'path_keys': ['name'],
'parent': None, 'parent_path': None,
'parent_path_keys': [None],
'child': None, 'child_path': [None],
'olt_link': VOntaniConfig,
'olt_link_path': '/v_ont_anis/{}',
'olt_link_path_keys': ['name'],
- 'olt_device_id' : 'from_link'},
+ 'olt_device_id' : 'from_link',
+ 'onu_link': VOntaniConfig,
+ 'onu_link_path': '/v_ont_anis/{}',
+ 'onu_link_path_keys': ['name'],
+ 'onu_device_id': 'from_link'},
VEnetConfig: {
+ 'path': '/v_enets/{}', 'path_keys': ['name'],
'parent': VOntaniConfig,
'parent_path': '/v_ont_anis/{}',
'parent_path_keys': ['data.v_ontani_ref'],
'child': None, 'child_path': [None],
'olt_link': None, 'olt_link_path': None,
'olt_link_path_keys': [None],
- 'olt_device_id': 'from_parent'}
+ 'olt_device_id': 'from_parent',
+ 'onu_link': None, 'onu_link_path': None,
+ 'onu_link_path_keys': [None],
+ 'onu_device_id': 'from_parent'}
}
def __init__(self, core):
@@ -123,16 +133,15 @@
self.inReplay = False
return
- def get_device_adapter_agent(self, device_id):
- device = self.core.get_proxy('/devices/{}'.format(device_id)).get()
+ def get_device_adapter_agent(self, device):
assert device.adapter != ''
adapter_agent = registry('adapter_loader').get_agent(device.adapter)
log.debug('get-device-adapter-agent', device=device,
adapter_agent=adapter_agent)
- return device, adapter_agent
+ return adapter_agent
def get_interface_path(self, data):
- interface = self.interfaces[type(data)]
+ interface = self.interface_stack[type(data)]
id_val = {}
count = 0
for key in interface['path_keys']:
@@ -149,21 +158,35 @@
return next((child for child in children
if self._child_predicate(data, child)), None)
- def get_olt_device_id(self, data):
+ def get_device(self, data, device_type):
if data is None:
return None
- interface = self.interfaces[type(data)]
interface_node = self.interface_stack[type(data)]
- device_id = None if interface['device_id'] is '' \
- else getattr(data, interface['device_id'])
- if device_id is None:
- if interface_node['olt_device_id'] == 'from_parent':
- device_id = self.get_olt_device_id(self.get_parent_data(data))
- elif interface_node['olt_device_id'] == 'from_child':
- device_id = self.get_olt_device_id(self.get_child_data(data))
- elif interface_node['olt_device_id'] == 'from_link':
- device_id = self.get_olt_device_id(self.get_link_data(data))
- return device_id
+ device = None
+ if interface_node['{}_device_id'.format(device_type)] == 'self':
+ if device_type == 'olt':
+ device = self.core.get_proxy('/').get('/devices/{}'.
+ format(data.id))
+ return device
+ elif device_type == 'onu':
+ devs = self.core.get_proxy('/').get('/devices')
+ for dev in devs:
+ if dev.serial_number == data.data.expected_serial_number:
+ return dev
+ if device is None:
+ if interface_node['{}_device_id'.
+ format(device_type)] == 'from_parent':
+ device = self.get_device(self.get_parent_data(data),
+ device_type)
+ elif interface_node['{}_device_id'.
+ format(device_type)] == 'from_child':
+ device = self.get_device(self.get_child_data(data),
+ device_type)
+ elif interface_node['{}_device_id'.
+ format(device_type)] == 'from_link':
+ device = self.get_device(self.get_link_data(data, device_type),
+ device_type)
+ return device
def get_parent_data(self, data):
if data is None:
@@ -180,7 +203,7 @@
try:
parent_data = self.core.get_proxy('/').get(parent_path)
return parent_data
- except ValueError:
+ except KeyError:
log.info('xpon-agent-warning-interface-cannot-get-parent',
data=data)
return None
@@ -204,23 +227,23 @@
data=data)
return child
- def get_link_data(self, data):
+ def get_link_data(self, data, device_type):
interface_node = self.interface_stack[type(data)]
- if interface_node['olt_link'] is None:
+ if interface_node['{}_link'.format(device_type)] is None:
return None
id_val = {}
count = 0
- for key in interface_node['olt_link_path_keys']:
+ for key in interface_node['{}_link_path_keys'.format(device_type)]:
id_val[count] = self.rgetattr(data, key)
count+=1
- olt_link_path = interface_node['olt_link_path'].format(
+ link_path = interface_node['{}_link_path'.format(device_type)].format(
*id_val.values())
try:
- link_data = self.core.get_proxy('/').get(olt_link_path)
+ link_data = self.core.get_proxy('/').get(link_path)
return link_data
- except ValueError:
- log.info('xpon-agent-warning-interface-cannot-get-link-data',
- data=data)
+ except KeyError:
+ log.info('xpon-agent-warning-interface-cannot-get-{}-link-data'.
+ format(device_type), data=data)
return None
def rgetattr(self, obj, attr):
@@ -230,7 +253,7 @@
def is_valid_interface(self, data):
valid = False
- for key in self.interfaces.keys():
+ for key in self.interface_stack.keys():
valid |= isinstance(data, key)
return valid
@@ -270,26 +293,39 @@
except:
print "Unexpected error:", sys.exc_info()[0]
+ def create_interface_in_device(self, device, data):
+ adapter_agent = self.get_device_adapter_agent(device)
+ adapter_agent.create_interface(device=device, data=data)
+
def create_interface(self, data, device_id=None):
if device_id is None:
- device_id = self.get_olt_device_id(data)
+ device = self.get_device(data, 'olt')
+ else:
+ device = self.core.get_proxy('/').get('/devices/{}'.
+ format(device_id))
if not self.is_valid_interface(data):
log.info('xpon-agent-create-interface-invalid-interface-type',
type=type(data).__name__)
return
self.register_interface(device_id=device_id,
path=self.get_interface_path(data))
- if device_id is not None:
+ if device is not None:
if(isinstance(data, ChannelterminationConfig)):
- self.create_channel_termination(data, device_id)
+ self.create_channel_termination(device, data)
elif(isinstance(data, VOntaniConfig)):
- self.create_v_ont_ani(data, device_id)
+ self.create_onu_interfaces(device, data)
else:
- log.info('xpon-agent-create-interface:', device_id=device_id,
- data=data)
- device, adapter_agent = \
- self.get_device_adapter_agent(device_id)
- adapter_agent.create_interface(device=device, data=data)
+ log.info(
+ 'xpon-agent-creating-interface-at-olt-device:',
+ device_id=device_id, data=data)
+ self.create_interface_in_device(device, data)
+ interface_node = self.interface_stack[type(data)]
+ if interface_node['onu_device_id'] != 'na':
+ onu_device = self.get_device(data, 'onu')
+ log.info(
+ 'xpon-agent-creating-interface-at-onu-device:',
+ onu_device_id=onu_device.id, data=data)
+ self.create_interface_in_device(onu_device, data)
def update_interface(self, data, device_id):
if not self.is_valid_interface(data):
@@ -297,10 +333,11 @@
type=type(data).__name__)
return
if device_id is None:
- device_id = self.get_olt_device_id(data)
+ device_id = self.get_device(data, 'olt').id
if device_id is not None:
- # This can be any interface
- device, adapter_agent = self.get_device_adapter_agent(device_id)
+ device = self.core.get_proxy('/').get('/devices/{}'.
+ format(device_id))
+ adapter_agent = self.get_device_adapter_agent(device)
interfaces = []
ont_interfaces = []
parent_data = self.get_parent_data(data)
@@ -313,147 +350,166 @@
for interface in interfaces:
log.info('xpon-agent-creating-interface',
device_id=device_id, data=interface)
- adapter_agent.create_interface(device=device,
- data=interface)
-
+ self.create_interface_in_device(device, interface)
venet_items = self.core.get_proxy('/').get('/v_enets')
for venet in venet_items:
- if device_id == self.get_olt_device_id(venet):
+ if device_id == self.get_device(venet, 'olt').id:
ont_interfaces.insert(0, venet)
parent_data = self.get_parent_data(venet)
while not isinstance(parent_data, ChannelpairConfig):
ont_interfaces.insert(0, parent_data)
parent_data = self.get_parent_data(parent_data)
-
for ont_interface in ont_interfaces:
log.info('xpon-agent-creating-ont-interface',
device_id=device_id, data=ont_interface)
- adapter_agent.create_interface(device=device,
- data=ont_interface)
-
- log.info('xpon-agent-updating-interface', device_id=device_id,
- data=data)
+ self.create_interface_in_device(device,
+ ont_interface)
+ log.info('xpon-agent-updating-interface',
+ device_id=device_id, data=data)
adapter_agent.update_interface(device=device, data=data)
def remove_interface(self, data, device_id=None):
if device_id is None:
- device_id = self.get_olt_device_id(data)
+ device = self.get_device(data, 'olt')
+ else:
+ device = self.core.get_proxy('/').get('/devices/{}'.
+ format(device_id))
if not self.is_valid_interface(data):
log.info('xpon-agent-remove-interface-invalid-interface-type',
type=type(data).__name__)
return
- log.info('xpon-agent-remove-interface:', device_id=device_id,
- data=data)
- if device_id is not None:
+ if device is not None:
+ log.info('xpon-agent-remove-interface:',
+ device_id=device.id, data=data)
if(isinstance(data, ChannelterminationConfig)):
self.remove_channel_termination(data, device_id)
else:
- device, adapter_agent = \
- self.get_device_adapter_agent(device_id)
+ adapter_agent = self.get_device_adapter_agent(device)
adapter_agent.remove_interface(device=device, data=data)
if isinstance(data, VOntaniConfig):
- self.delete_onu_device(device_id=device_id, v_ont_ani=data)
+ self.delete_onu_device(device=device, v_ont_ani=data)
- def create_channel_termination(self, data, device_id):
- device, adapter_agent = self.get_device_adapter_agent(device_id)
+ def create_channel_termination(self, device, data):
channel_pair = self.get_parent_data(data)
channel_part = self.get_parent_data(channel_pair)
channel_group = self.get_parent_data(channel_part)
- if channel_group:
- log.info('xpon-agent-creating-channel-group', device_id=device_id,
- data=channel_group)
- adapter_agent.create_interface(device=device, data=channel_group)
- if channel_part:
+ if channel_group is not None:
+ log.info('xpon-agent-creating-channel-group',
+ device_id=device.id, channel_group=channel_group)
+ self.create_interface_in_device(device, channel_group)
+ if channel_part is not None:
log.info('xpon-agent-creating-channel-partition:',
- device_id=device_id, data=channel_part)
- adapter_agent.create_interface(device=device, data=channel_part)
- if channel_pair:
- log.info('xpon-agent-creating-channel-pair:', device_id=device_id,
- data=channel_pair)
- adapter_agent.create_interface(device=device, data=channel_pair)
+ device_id=device.id, channel_part=channel_part)
+ self.create_interface_in_device(device, channel_part)
+ if channel_pair is not None:
+ log.info('xpon-agent-creating-channel-pair:',
+ device_id=device.id, channel_pair=channel_pair)
+ self.create_interface_in_device(device, channel_pair)
log.info('xpon-agent-creating-channel-termination:',
- device_id=device_id, data=data)
- adapter_agent.create_interface(device=device, data=data)
- # Take care of ont ani and v ont ani
- vont_items = self.core.get_proxy('/').get('/v_ont_anis')
- for vont in vont_items:
- vont_id = self.get_olt_device_id(vont)
- if device_id == vont_id:
- self.create_v_ont_ani(vont, device_id)
+ device_id=device.id, data=data)
+ self.create_interface_in_device(device, data)
+ v_ont_anis = self.core.get_proxy('/').get('/v_ont_anis')
+ for v_ont_ani in v_ont_anis:
+ olt_device = self.get_device(v_ont_ani, 'olt')
+ if olt_device.id == device.id:
+ self.create_onu_interfaces(olt_device, v_ont_ani)
- def create_v_ont_ani(self, data, device_id):
+ def create_onu_interfaces(self, olt_device, data):
if not self.inReplay:
- self.create_onu_device(device_id=device_id, v_ont_ani=data)
- device, adapter_agent = self.get_device_adapter_agent(device_id)
- venets = self.core.get_proxy('/').get('/v_enets')
- log.info('xpon-agent-creating-vont-ani:', device_id=device_id,
- data=data)
- adapter_agent.create_interface(device=device, data=data)
+ self.create_onu_device(device=olt_device, v_ont_ani=data)
+ log.info(
+ 'xpon-agent-creating-v-ont-ani-at-olt-device:',
+ olt_device_id=olt_device.id, v_ont_ani=data)
+ self.create_interface_in_device(olt_device, data)
+ onu_device = self.get_device(data, 'onu')
+ log.info(
+ 'xpon-agent-creating-v-ont-ani-at-onu-device:',
+ onu_device_id=onu_device.id, data=data)
+ self.create_interface_in_device(onu_device, data)
try:
- ont_ani = self.core.get_proxy('/').get('/ont_anis/{}'
- .format(data.name))
- log.info('xpon-agent-create-v-ont-ani-creating-ont-ani:',
- device_id=device_id, data=ont_ani)
- adapter_agent.create_interface(device=device, data=ont_ani)
+ ont_ani = self.core.get_proxy('/').get('/ont_anis/{}'.
+ format(data.name))
+ if ont_ani is not None:
+ log.info(
+ 'xpon-agent-creating-ont-ani-at-olt-device:',
+ olt_device_id=olt_device.id, ont_ani=ont_ani)
+ self.create_interface_in_device(olt_device, ont_ani)
+ log.info(
+ 'xpon-agent-creating-ont-ani-at-onu-device:',
+ onu_device_id=onu_device.id, ont_ani=ont_ani)
+ self.create_interface_in_device(onu_device, ont_ani)
+ v_enets = self.core.get_proxy('/').get('/v_enets')
+ for v_enet in v_enets:
+ if self.get_parent_data(v_enet).name == data.name:
+ log.info(
+ 'xpon-agent-creating-v-enet-at-olt-device:',
+ olt_device_id=olt_device.id, v_enet=v_enet)
+ self.create_interface_in_device(olt_device, v_enet)
+ log.info(
+ 'xpon-agent-creating-v-enet-at-onu-device:',
+ onu_device_id=onu_device.id, v_enet=v_enet)
+ self.create_interface_in_device(onu_device, v_enet)
except KeyError:
log.info(
- 'xpon-agent-create-v-ont-ani-there-is-no-ont-ani-to-create')
- for venet in venets:
- if venet.data.v_ontani_ref == data.name:
- log.info('xpon-agent-create-v-ont-ani-creating-v-enet:',
- device_id=device_id, data=venet)
- adapter_agent.create_interface(device=device, data=venet)
+ 'xpon-agent-create-onu-interfaces-no-ont-ani-link-exists')
def remove_channel_termination(self, data, device_id):
- device, adapter_agent = self.get_device_adapter_agent(device_id)
- log.info('xpon-agent-removing-channel-termination:',
- device_id=device_id, data=data)
+ device = self.core.get_proxy('/').get('/devices/{}'.format(device_id))
+ adapter_agent = self.get_device_adapter_agent(device)
+ channel_pair = self.get_parent_data(data)
+ if channel_pair is None:
+ log.info(
+ 'xpon-agent-removing-channel-termination:',
+ device_id=device_id, data=data)
+ adapter_agent.remove_interface(device=device, data=data)
+ return
+ v_ont_anis = self.core.get_proxy('/').get('/v_ont_anis')
+ for v_ont_ani in v_ont_anis:
+ if self.get_link_data(v_ont_ani, 'olt').name == channel_pair.name:
+ v_enets = self.core.get_proxy('/').get('/v_enets')
+ for v_enet in v_enets:
+ if self.get_parent_data(v_enet).name == v_ont_ani.name:
+ log.info(
+ 'xpon-agent-removing-v-enet:',
+ device_id=device_id, data=v_enet)
+ adapter_agent.remove_interface(device=device,
+ data=v_enet)
+ try:
+ ont_ani = self.core.get_proxy('/').get(
+ '/ont_anis/{}'.format(v_ont_ani.name))
+ log.info(
+ 'xpon-agent-removing-ont-ani:',
+ device_id=device_id, data=ont_ani)
+ adapter_agent.remove_interface(device=device, data=ont_ani)
+ except KeyError:
+ log.info(
+ 'xpon-agent-remove-channel-termination-ont-ani-not-found')
+ log.info(
+ 'xpon-agent-removing-vont-ani:',
+ device_id=device_id, data=v_ont_ani)
+ adapter_agent.remove_interface(device=device, data=v_ont_ani)
+ self.delete_onu_device(device=device, v_ont_ani=v_ont_ani)
+ log.info(
+ 'xpon-agent-removing-channel-termination:',
+ device_id=device_id, data=data)
adapter_agent.remove_interface(device=device, data=data)
-
- if data.data.channelpair_ref:
- channel_pair = self.get_parent_data(data)
- log.info('xpon-agent-removing-channel-pair:', device_id=device_id,
- data=channel_pair)
- adapter_agent.remove_interface(device=device, data=channel_pair)
- # Remove vontani and ontani if it has reference to cpair
- items = self.core.get_proxy('/').get('/v_ont_anis')
- for item in items:
- if (item.data.preferred_chanpair == channel_pair.name or \
- item.data.protection_chanpair == channel_pair.name):
- log.info('xpon-agent-removing-vont-ani:',
- device_id=device_id, data=item)
- adapter_agent.remove_interface(device=device, data=item)
- self.delete_onu_device(device_id=device_id, v_ont_ani=item)
-
- venets_items = self.core.get_proxy('/').get('/v_enets')
- for venet in venets_items:
- if item.name == venet.data.v_ontani_ref:
- log.info('xpon-agent-removing-v-enet:',
- device_id=device_id, data=venet)
- adapter_agent.remove_interface(device=device,
- data=venet)
-
- ontani_items = self.core.get_proxy('/').get('/ont_anis')
- for ontani_item in ontani_items:
- if ontani_item.name == item.name:
- log.info('xpon-agent-removing-ont-ani:',
- device_id=device_id, data=ontani_item)
- adapter_agent.remove_interface(device=device,
- data=ontani_item)
- # Remove cpart if exists
- if channel_pair.data.channelpartition_ref:
- channel_part = self.get_parent_data(channel_pair)
- log.info('xpon-agent-removing-channel-partition:',
- device_id=device_id, data=channel_part)
- adapter_agent.remove_interface(device=device,
- data=channel_part)
-
- if channel_part.data.channelgroup_ref:
- channel_group = self.get_parent_data(channel_part)
- log.info('xpon-agent-removing-channel-group:',
- device_id=device_id, data=channel_group)
- adapter_agent.remove_interface(device=device,
- data=channel_group)
+ log.info(
+ 'xpon-agent-removing-channel-pair:',
+ device_id=device_id, data=channel_pair)
+ adapter_agent.remove_interface(device=device, data=channel_pair)
+ channel_partition = self.get_parent_data(channel_pair)
+ if channel_partition is not None:
+ log.info(
+ 'xpon-agent-removing-channel-partition:',
+ device_id=device_id, data=channel_partition)
+ adapter_agent.remove_interface(device=device,
+ data=channel_partition)
+ channel_group = self.get_parent_data(channel_partition)
+ if channel_group is not None:
+ log.info(
+ 'xpon-agent-removing-channel-group:',
+ device_id=device_id, data=channel_group)
+ adapter_agent.remove_interface(device=device, data=channel_group)
def replay_interface(self, device_id):
self.inReplay = True
@@ -474,9 +530,9 @@
return port.port_no
return 0
- def create_onu_device(self, device_id, v_ont_ani):
- log.info('create-onu-device', v_ont_ani=v_ont_ani, device=device_id)
- device, adapter_agent = self.get_device_adapter_agent(device_id)
+ def create_onu_device(self, device, v_ont_ani):
+ log.info('create-onu-device', device_id=device.id, v_ont_ani=v_ont_ani)
+ adapter_agent = self.get_device_adapter_agent(device)
parent_chnl_pair_id = self.get_port_num(
device.id, v_ont_ani.data.preferred_chanpair)
log.info('create-onu-device:', parent_chnl_pair_id=parent_chnl_pair_id)
@@ -492,12 +548,12 @@
else AdminState.DISABLED)
return
- def delete_onu_device(self, device_id, v_ont_ani):
- log.info('delete-onu-device', v_ont_ani=v_ont_ani, device=device_id)
- device, adapter_agent = self.get_device_adapter_agent(device_id)
+ def delete_onu_device(self, device, v_ont_ani):
+ log.info('delete-onu-device', device_id=device.id, v_ont_ani=v_ont_ani)
+ adapter_agent = self.get_device_adapter_agent(device)
onu_device = adapter_agent.get_child_device(
- parent_device_id=device_id,
+ parent_device_id=device.id,
serial_number=v_ont_ani.data.expected_serial_number)
if onu_device is not None:
- adapter_agent.delete_child_device(device_id, onu_device.id)
+ adapter_agent.delete_child_device(device.id, onu_device.id)
return