def __init__(self, mgmt, interfaces=None, cores=None):
        self.enable = True
        self.cores = validate_non_string_sequence(cores, default=[])
        self._queue = multiprocessing.Queue()
        self.amqp_client = None
        self.interfaces = validate_non_string_sequence(interfaces, default=[])

        # why the host or ip?
        self.vnfip = mgmt.get("host", mgmt["ip"])
        self.connection = ssh.SSH.from_node(mgmt, overrides={"ip": self.vnfip})
        self.connection.wait()
Example #2
0
    def __init__(self,
                 mgmt,
                 port_names=None,
                 plugins=None,
                 interval=None,
                 timeout=None,
                 reset_mq_flag=True):

        if plugins is None:
            self.plugins = {}
        else:
            self.plugins = plugins

        if interval is None:
            self.interval = self.DEFAULT_INTERVAL
        else:
            self.interval = interval

        if timeout is None:
            self.timeout = self.DEFAULT_TIMEOUT
        else:
            self.timeout = timeout

        self.enable = True
        self._queue = multiprocessing.Queue()
        self.amqp_client = None
        self.port_names = validate_non_string_sequence(port_names, default=[])

        # we need to save mgmt so we can connect to port 5672
        self.mgmt = mgmt
        self.connection = ssh.AutoConnectSSH.from_node(mgmt)
        self._reset_mq_flag = reset_mq_flag
Example #3
0
    def test_validate_non_string_sequence(self):
        self.assertEqual(utils.validate_non_string_sequence([1, 2, 3]), [1, 2, 3])
        self.assertIsNone(utils.validate_non_string_sequence('123'))
        self.assertIsNone(utils.validate_non_string_sequence(1))

        self.assertEqual(utils.validate_non_string_sequence(1, 2), 2)
        self.assertEqual(utils.validate_non_string_sequence(1, default=2), 2)

        with self.assertRaises(RuntimeError):
            utils.validate_non_string_sequence(1, raise_exc=RuntimeError)
Example #4
0
    def bind(self, pci_addresses, driver, force=True):
        # accept single PCI or sequence of PCI
        pci_addresses = validate_non_string_sequence(pci_addresses, [pci_addresses])

        cmd = self.DPDK_BIND_CMD.format(dpdk_devbind=self.dpdk_devbind,
                                        driver=driver,
                                        vpci=' '.join(list(pci_addresses)),
                                        force='--force' if force else '')
        LOG.debug(cmd)
        self._dpdk_execute(cmd)

        # update the inner status dict
        self.read_status()