def _edit_config(self, nos_host, target='running', config='', allowed_exc_strs=None): """Modify switch config for a target config type. :param nos_host: IP address of switch to configure :param target: Target config type :param config: Configuration string in XML format :param allowed_exc_strs: Exceptions which have any of these strings as a subset of their exception message (str(exception)) can be ignored :raises: NOSConfigFailed """ if not allowed_exc_strs: allowed_exc_strs = [] mgr = self._nos_connect(nos_host) try: mgr.edit_config(target=target, config=config, format='text') except Exception as e: for exc_str in allowed_exc_strs: if exc_str in str(e): break else: # Raise a Neutron exception. Include a description of # the original ncclient exception. raise cexc.NOSConfigFailed(config=config, exc=e)
def disable_vlan_on_trunk_int(self, host, vlan_id, intf_type, interface): """Disable a VLAN on a trunk interface.""" dbg_str = self._dbg_str(host, "disable", vlan_id, interface=interface, intf_type=intf_type) LOG.debug(dbg_str) conn = self._connect(host) try: if_name = self._get_ifname(intf_type, interface) self._rem_intf_from_vlan(conn, vlan_id, if_name) except Exception as e: raise cexc.NOSConfigFailed(config=dbg_str, exc=e) conn.close()
def create_and_trunk_vlan(self, host, vlan_id, vlan_name, intf_type, interface): """Create VLAN and trunk it on the specified ports.""" dbg_str = self._dbg_str(host, "create and enable", vlan_id, vlan_name=vlan_name, interface=interface, intf_type=intf_type) LOG.debug(dbg_str) conn = self._connect(host) try: if_name = self._get_ifname(intf_type, interface) self._create_vlan(conn, vlan_id, vlan_name) self._add_intf_to_vlan(conn, vlan_id, if_name) except Exception as e: raise cexc.NOSConfigFailed(config=dbg_str, exc=e) conn.close()
def enable_vlan_on_trunk_int(self, host, vlan_id, intf_type, interface): """Enable a VLAN on a trunk interface.""" dbg_str = self._dbg_str(host, "enable", vlan_id, interface=interface, intf_type=intf_type) LOG.debug(dbg_str) conn = self._connect(host) try: if_name = self._get_ifname(intf_type, interface) self._add_intf_to_vlan(conn, vlan_id, if_name, self._support_old_release(host)) except Exception as e: raise cexc.NOSConfigFailed(config=dbg_str, exc=e) conn.close()