Esempio n. 1
0
    def test_lookup(self):
        """NETWORK Network lookup passes correct parameters to hypervisor."""
        xml = """<domain><interface type="network">""" +\
              """<source network="foo" /></interface></domain>"""
        domain = mock.Mock()
        hypervisor = mock.Mock()
        domain.XMLDesc.return_value = xml
        domain.connect.return_value = hypervisor

        network.lookup(domain)
        hypervisor.networkLookupByName.assert_called_with('foo')
Esempio n. 2
0
    def test_lookup(self):
        """NETWORK Network lookup passes correct parameters to hypervisor."""
        xml = """<domain><interface type="network">""" +\
              """<source network="foo" /></interface></domain>"""
        domain = mock.Mock()
        hypervisor = mock.Mock()
        domain.XMLDesc.return_value = xml
        domain.connect.return_value = hypervisor

        network.lookup(domain)
        hypervisor.networkLookupByName.assert_called_with('foo')
Esempio n. 3
0
    def allocate(self):
        """Initializes libvirt resources."""
        network_name = None

        self._hypervisor = libvirt.open(
            self.configuration.get('hypervisor', 'qemu:///system'))

        self._storage_pool = self._retrieve_pool()

        if 'network' in self.configuration:
            self._network = network.create(self._hypervisor, self.identifier,
                                           self.configuration['network'])
            network_name = self._network.name()

        disk_path = self._retrieve_disk_path()

        if self._storage_pool is not None:
            self._storage_pool.refresh()

        self._domain = domain_create(self._hypervisor,
                                     self.identifier,
                                     self.configuration['domain'],
                                     disk_path,
                                     network_name=network_name)

        if self._network is None:
            self._network = network.lookup(self._domain)
Esempio n. 4
0
    def test_lookup_no_network(self):
        """NETWORK None is return if domain is not associated with any Network."""
        xml = """<domain></domain>"""
        domain = mock.Mock()
        hypervisor = mock.Mock()
        domain.XMLDesc.return_value = xml
        domain.connect.return_value = hypervisor

        self.assertEqual(network.lookup(domain), None)
Esempio n. 5
0
    def test_lookup_no_network(self):
        """NETWORK None is return if domain is not associated with any Network."""
        xml = """<domain></domain>"""
        domain = mock.Mock()
        hypervisor = mock.Mock()
        domain.XMLDesc.return_value = xml
        domain.connect.return_value = hypervisor

        self.assertEqual(network.lookup(domain), None)
Esempio n. 6
0
    def allocate(self):
        """Initializes libvirt resources."""
        self._hypervisor = libvirt.open(
            self.configuration.get('hypervisor', 'lxc:///'))

        network_name = self._retrieve_network_name(
            self.configuration.get('network'))

        self._domain = domain_create(self._hypervisor, self.identifier,
                                     self.configuration['domain'],
                                     network_name=network_name)

        self._network = network.lookup(self._domain)
Esempio n. 7
0
    def allocate(self):
        """Initializes libvirt resources."""
        self._hypervisor = libvirt.open(
            self.configuration.get('hypervisor', 'qemu:///system'))

        self._storage_pool = self._retrieve_pool(self.configuration['disk'])

        disk_path = self._retrieve_disk_path(self.configuration['disk'])
        network_name = self._retrieve_network_name(
            self.configuration.get('network'))

        self._domain = domain_create(self._hypervisor, self.identifier,
                                     self.configuration['domain'],
                                     disk_path, network_name=network_name)

        self._network = network.lookup(self._domain)
Esempio n. 8
0
    def allocate(self):
        """Initializes libvirt resources."""
        network_name = None

        self._hypervisor = libvirt.open(
            self.configuration.get('hypervisor', 'lxc:///'))

        if 'network' in self.configuration:
            self._network = network.create(self._hypervisor, self.identifier,
                                           self.configuration['network'])
            network_name = self._network.name()

        self._domain = domain_create(self._hypervisor, self.identifier,
                                     self.configuration['domain'],
                                     network_name=network_name)
        if self._network is None:
            self._network = network.lookup(self._domain)
Esempio n. 9
0
File: qemu.py Progetto: koivunen/see
    def allocate(self):
        """Initializes libvirt resources."""
        self._hypervisor = libvirt.open(
            self.configuration.get('hypervisor', 'qemu:///system'))

        self._storage_pool = self._retrieve_pool(self.configuration['disk'])

        disk_path = self._retrieve_disk_path(self.configuration['disk'])
        network_name = self._retrieve_network_name(
            self.configuration.get('network'))

        self._domain = domain_create(self._hypervisor,
                                     self.identifier,
                                     self.configuration['domain'],
                                     disk_path,
                                     network_name=network_name)

        self._network = network.lookup(self._domain)
Esempio n. 10
0
File: qemu.py Progetto: noxdafox/see
    def allocate(self):
        """Initializes libvirt resources."""
        network_name = None

        self._hypervisor = libvirt.open(self.configuration.get("hypervisor", "qemu:///system"))

        self._storage_pool = self._retrieve_pool()

        if "network" in self.configuration:
            self._network = network.create(self._hypervisor, self.identifier, self.configuration["network"])
            network_name = self._network.name()

        disk_path = self._retrieve_disk_path()

        self._domain = domain_create(
            self._hypervisor, self.identifier, self.configuration["domain"], disk_path, network_name=network_name
        )

        if self._network is None:
            self._network = network.lookup(self._domain)