def perform_mapping(self, ifname): proc = subprocess.Popen((self.script, ifname), stdin=subprocess.PIPE, stdout=subprocess.PIPE) output = proc.communicate(input=''.join(self.script_input)) ## Ensure the mapping script completed successfully if proc.returncode < 0: LOGGER.warning('Mapping script died with signal %d' % -proc.returncode) return None if proc.returncode > 0: LOGGER.debug('Mapping script exited with code %d' % proc.returncode) return None if output[0] is None: LOGGER.warning('Mapping script succeeded with no output') return None ## Check that it produced a valid interface config name config_name = output[0].split('\n')[0] if utils.valid_interface_name(config_name): return ifname LOGGER.error('Mapped %s to invalid interface config name: %s' % (ifname, config_name)) return None
def validate_interface_name(self, ifname): """Report an error if an interface name is not valid""" if utils.valid_interface_name(ifname): return True self.error('Invalid interface name: %s' % ifname) return False
def perform_mapping(self, ifname): proc = subprocess.Popen((self.script, ifname), stdin=subprocess.PIPE, stdout=subprocess.PIPE) output = proc.communicate(input=''.join(self.script_input)) ## Ensure the mapping script completed successfully if proc.returncode < 0: LOGGER.warning('Mapping script died with signal %d' % -proc.returncode) return None if proc.returncode > 0: LOGGER.debug('Mapping script exited with code %d' % proc.returncode) return None if output[0] is None: LOGGER.warning('Mapping script succeeded with no output') return None ## Check that it produced a valid interface config name config_name = output[0].split('\n')[0] if utils.valid_interface_name(config_name): return ifname LOGGER.error('Mapped %s to invalid interface config name: %s' % (ifname, config_name)) return None
def validate_interface_name(self, ifname): """Report an error if an interface name is not valid""" if utils.valid_interface_name(ifname): return True self.error('Invalid interface name: %s' % ifname) return False