Changelog:
- Fix Bug 1030 checking that task and note exists
- Treat only osm_managed configlets
- Modified connection method without parameters. Used in the execution
directly from an external script.
- Change code, according to comments.
Change-Id: Ic3045315db2e84bc2bc1c6b9b665ed6d4518017c
Signed-off-by: Francisco Garcia Alvarez <francisco.galvarez@atos.net>
__VLAN_PARAM = "vlan"
__VNI_PARAM = "vni"
__SEPARATOR = '_'
__VLAN_PARAM = "vlan"
__VNI_PARAM = "vni"
__SEPARATOR = '_'
+ __MANAGED_BY_OSM = '## Managed by OSM '
__OSM_PREFIX = "osm_"
__OSM_METADATA = "OSM_metadata"
__METADATA_PREFIX = '!## Service'
__OSM_PREFIX = "osm_"
__OSM_METADATA = "OSM_metadata"
__METADATA_PREFIX = '!## Service'
for s in self.s_api:
if (len(cls_perSw[s]) > 0):
for cl in cls_perSw[s]:
for s in self.s_api:
if (len(cls_perSw[s]) > 0):
for cl in cls_perSw[s]:
- if len(cls_perSw[s][0]['config']) == 0:
+ # Fix 1030 SDN-ARISTA Key error note when deploy a NS
+ # Added protection to check that 'note' exists and additionally
+ # verify that it is managed by OSM
+ if (not cls_perSw[s][0]['config'] or
+ not cl.get('note') or
+ self.__MANAGED_BY_OSM not in cl['note']):
continue
note = cl['note']
t_id = note.split(self.__SEPARATOR)[1]
continue
note = cl['note']
t_id = note.split(self.__SEPARATOR)[1]
if not switch_id:
point_mac = encap_info.get(self.__MAC_PARAM)
switches = self.__lldp_find_neighbor("chassisId", point_mac)
if not switch_id:
point_mac = encap_info.get(self.__MAC_PARAM)
switches = self.__lldp_find_neighbor("chassisId", point_mac)
-
- if len(switches) == 0:
- raise SdnConnectorError(message="Connection point MAC address {} not found in the switches".format(point_mac),
- http_code=406)
self.logger.debug("Found connection point for MAC {}: {}".
format(point_mac, switches))
self.logger.debug("Found connection point for MAC {}: {}".
format(point_mac, switches))
- port_channel = self.__get_switch_po(switch['name'],
- switch['interface'])
- if len(port_channel) > 0:
- interface = port_channel[0]
- else:
- interface = switch['interface']
else:
interface = encap_info.get(self.__SW_PORT_PARAM)
switches = [{'name': switch_id, 'interface': interface}]
else:
interface = encap_info.get(self.__SW_PORT_PARAM)
switches = [{'name': switch_id, 'interface': interface}]
- if not interface:
- raise SdnConnectorError(message="Connection point switch port empty for switch_dpid {}".format(switch_id),
- http_code=406)
+ if len(switches) == 0:
+ raise SdnConnectorError(message="Connection point MAC address {} not found in the switches".format(point_mac),
+ http_code=406)
+
# remove those connections that are equal. This happens when several sriovs are located in the same
# compute node interface, that is, in the same switch and interface
switches = [x for x in switches if x not in processed_connection_points]
# remove those connections that are equal. This happens when several sriovs are located in the same
# compute node interface, that is, in the same switch and interface
switches = [x for x in switches if x not in processed_connection_points]
continue
processed_connection_points += switches
for switch in switches:
continue
processed_connection_points += switches
for switch in switches:
+ if not switch_id:
+ port_channel = self.__get_switch_po(switch['name'],
+ switch['interface'])
+ if len(port_channel) > 0:
+ interface = port_channel[0]
+ else:
+ interface = switch['interface']
+ if not interface:
+ raise SdnConnectorError(message="Connection point switch port empty for switch_dpid {}".format(switch_id),
+ http_code=406)
# it should be only one switch where the mac is attached
if encap_type == 'dot1q':
# SRIOV configLet for Leaf switch mac's attached to
# it should be only one switch where the mac is attached
if encap_type == 'dot1q':
# SRIOV configLet for Leaf switch mac's attached to
for t_id in res[1]['tasks']:
tasks[t_id] = {'workOrderId': t_id}
if not toDelete_in_cvp:
for t_id in res[1]['tasks']:
tasks[t_id] = {'workOrderId': t_id}
if not toDelete_in_cvp:
- note_msg = "## Managed by OSM {}{}{}##".format(self.__SEPARATOR,
- t_id,
- self.__SEPARATOR)
+ note_msg = "{}{}{}{}##".format(self.__MANAGED_BY_OSM,
+ self.__SEPARATOR,
+ t_id,
+ self.__SEPARATOR)
self.client.api.add_note_to_configlet(
cls_perSw[s][0]['key'],
note_msg)
self.client.api.add_note_to_configlet(
cls_perSw[s][0]['key'],
note_msg)
else:
changed = True
if 'taskIds' in str(dev_action):
else:
changed = True
if 'taskIds' in str(dev_action):
+ # Fix 1030 SDN-ARISTA Key error note when deploy a NS
+ if not dev_action['data']['taskIds']:
+ raise Exception("No taskIds found: Device {} Configlets couldnot be updated".format(
+ up_device['hostname']))
for taskId in dev_action['data']['taskIds']:
updated.append({up_device['hostname']:
"Configlets-{}".format(
for taskId in dev_action['data']['taskIds']:
updated.append({up_device['hostname']:
"Configlets-{}".format(
self.client = self.__connect()
self.client.api.get_cvp_info()
except (CvpSessionLogOutError, RequestException) as e:
self.client = self.__connect()
self.client.api.get_cvp_info()
except (CvpSessionLogOutError, RequestException) as e:
- self.logger.debug("Connection error '{}'. Reconnencting".format(e))
+ self.logger.debug("Connection error '{}'. Reconnecting".format(e))
self.client = self.__connect()
self.client.api.get_cvp_info()
self.client = self.__connect()
self.client.api.get_cvp_info()
self.__user,
self.__passwd,
protocol=protocol or "https",
self.__user,
self.__passwd,
protocol=protocol or "https",