Beispiel #1
0
    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
Beispiel #2
0
	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
Beispiel #3
0
	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
Beispiel #4
0
    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