def _edit_config(self, nexus_host, target='running', config='', allowed_exc_strs=None): """Modify switch config for a target config type. :param nexus_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: NexusConfigFailed """ if not allowed_exc_strs: allowed_exc_strs = [] mgr = self.nxos_connect(nexus_host) try: mgr.edit_config(target, config=config) 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.NexusConfigFailed(config=config, exc=e)
def _edit_config(self, nexus_host, target='running', config='', allowed_exc_strs=None): """Modify switch config for a target config type. :param nexus_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 :returns None: if config was edited successfully Exception object: if _edit_config() encountered an exception containing one of allowed_exc_strs :raises: NexusConfigFailed: if _edit_config() encountered an exception not containing one of allowed_exc_strs """ if not allowed_exc_strs: allowed_exc_strs = [] mgr = self.nxos_connect(nexus_host) try: LOG.debug("NexusDriver config: %s", config) mgr.edit_config(target=target, config=config) except Exception as e: for exc_str in allowed_exc_strs: if exc_str in str(e): return e # Raise a Neutron exception. Include a description of # the original ncclient exception. raise cexc.NexusConfigFailed(config=config, exc=e)