Ejemplo n.º 1
0
    def test_load_file(self):
        dst_fd, dst_path = tempfile.mkstemp()
        try:
            os.close(dst_fd)

            with open(dst_path, 'w') as f:
                f.write('hello')
            self.assertEqual(libvirt_utils.load_file(dst_path), 'hello')
        finally:
            os.unlink(dst_path)
Ejemplo n.º 2
0
    def test_load_file(self):
        dst_fd, dst_path = tempfile.mkstemp()
        try:
            os.close(dst_fd)

            # We have a test for write_to_file. If that is sound, this suffices
            libvirt_utils.write_to_file(dst_path, 'hello')
            self.assertEqual(libvirt_utils.load_file(dst_path), 'hello')
        finally:
            os.unlink(dst_path)
Ejemplo n.º 3
0
    def get_console_output(self, instance):
        console_log = os.path.join(FLAGS.instances_path, instance["name"], "console.log")

        libvirt_utils.chown(console_log, os.getuid())

        fd = self._conn.find_domain(instance["name"])

        self.baremetal_nodes.get_console_output(console_log, fd["node_id"])

        fpath = console_log

        return libvirt_utils.load_file(fpath)
Ejemplo n.º 4
0
Archivo: vif.py Proyecto: Open-SFC/nova
 def _is_pci_device_available(self, instance_uuid):
     pci_devs = jsonutils.loads(utils.load_file(CONF.fsl_sriov.pci_devices))
     assignable_pci_device = None
     for dev in pci_devs:
         if dev['instance_uuid'] is None:
            assignable_pci_device = dev['dev_id']
            dev['instance_uuid'] = instance_uuid
            pfname = dev['pf_vf_name']
            intbridge = CONF.neutron.ovs_bridge
            utils.execute('ovs-vsctl', '--no-wait', 'add-port', intbridge , pfname , '--', 'set', 'interface', pfname, 'type=vf_inic', run_as_root=True)
            break
     utils.write_to_file(CONF.fsl_sriov.pci_devices, jsonutils.dumps(pci_devs))    
     return assignable_pci_device      
Ejemplo n.º 5
0
Archivo: vif.py Proyecto: Open-SFC/nova
    def _deallocate_pcidevice_for_instance(self, instance):
        """
        Remove the UUID from PCI device spec.
        """
        if CONF.pci_passthrough_whitelist and instance:
           pci_devs = jsonutils.loads(utils.load_file(CONF.fsl_sriov.pci_devices))
           for dev in pci_devs:
               if instance.uuid == dev['instance_uuid']:
                  dev['instance_uuid'] = None
                  pfname = dev['pf_vf_name']
                  intbridge = CONF.neutron.ovs_bridge
		  utils.execute('ovs-vsctl', '--no-wait', 'del-port', intbridge , pfname , run_as_root=True) 
           utils.write_to_file(CONF.fsl_sriov.pci_devices, jsonutils.dumps(pci_devs))
Ejemplo n.º 6
0
    def get_console_output(self, instance):
        console_log = os.path.join(FLAGS.instances_path, instance['name'],
                                   'console.log')

        libvirt_utils.chown(console_log, os.getuid())

        fd = self._conn.find_domain(instance['name'])

        self.baremetal_nodes.get_console_output(console_log, fd['node_id'])

        fpath = console_log

        return libvirt_utils.load_file(fpath)
Ejemplo n.º 7
0
    def get_console_output(self, instance):
        console_log = os.path.join(CONF.instances_path, instance['name'],
                                   'console.log')

        libvirt_utils.chown(console_log, os.getuid())

        fd = self._conn.find_domain(instance['name'])

        self.baremetal_nodes.get_console_output(console_log, fd['node_id'])

        fpath = console_log

        return libvirt_utils.load_file(fpath)