Exemplo n.º 1
0
    def attach_interface(self, instance, vif):
        if not self._check_hotplug_available(instance):
            raise exception.InterfaceAttachFailed(instance_uuid=instance.uuid)

        LOG.debug('Attaching vif: %s', vif['id'], instance=instance)
        self._vmutils.create_nic(instance.name, vif['id'], vif['address'])
        self._vif_driver.plug(instance, vif)
Exemplo n.º 2
0
    def _check_hotplug_is_available(self, instance):
        if (self._get_vm_state(
                instance.name) == constants.HYPERV_VM_STATE_DISABLED):
            return False

        if not self._hostutils.check_min_windows_version(6, 4):
            LOG.error(
                _LE("This version of Windows does not support vNIC "
                    "hot plugging."))
            raise exception.InterfaceAttachFailed(instance_uuid=instance.uuid)

        if (self._vmutils.get_vm_gen(instance.name) == constants.VM_GEN_1):
            LOG.error(_LE("Cannot hot plug vNIC to a first generation " "VM."))
            raise exception.InterfaceAttachFailed(instance_uuid=instance.uuid)

        return True
Exemplo n.º 3
0
    def _attach_interface_physical(self, instance, image_meta, vif):
        icli = client_wrapper.IronicClientWrapper()
        try:
            node = icli.call("node.get", instance['node'])
        except ironic.exc.NotFound:
            return None
        ports = icli.call("node.list_ports", node.uuid)

        try:
            for p in ports:
                port = icli.call("port.get", p.uuid)
                if port.extra.get('type', None) == 'pxe':
                    continue

                port_id = unicode(vif['id'])
                patch = [{
                    'op': 'add',
                    'path': '/extra/vif_port_id',
                    'value': port_id
                }]
                icli.call("port.update", p.uuid, patch)
                break
        except Exception as e:
            LOG.error(
                _("Error plugging vif: %s, instance is %s, "
                  "Traceback is %s") %
                (e, instance['uuid'], traceback.format_exc()))
            self._detach_interface_physical(instance, vif)
            raise exception.InterfaceAttachFailed(
                instance_uuid=instance['uuid'])
Exemplo n.º 4
0
    def _attach_interface_virtual(self, instance, image_meta, vif):
        node = self._transfer_instance_to_node(instance)
        host_id = node.extra.get('cps_id')

        kwargs = {"instance": instance, "image_meta": image_meta, "vif": vif}
        try:
            self.ironicAgent.attach_interface(host_id, kwargs)
        except Exception as e:
            LOG.error(
                _("Error plugging vif: %s, instance is %s, "
                  "Traceback is %s") %
                (e, instance['uuid'], traceback.format_exc()))
            self._detach_interface_virtual(instance, vif)
            raise exception.InterfaceAttachFailed(
                instance_uuid=instance['uuid'])
Exemplo n.º 5
0
 def attach_interface(self, context, instance, image_meta, vif):
     if vif['id'] in self._interfaces:
         raise exception.InterfaceAttachFailed(instance_uuid=instance.uuid)
     self._interfaces[vif['id']] = vif
Exemplo n.º 6
0
Arquivo: fake.py Projeto: pengkui/nova
 def attach_interface(self, instance, image_meta, vif):
     if vif['id'] in self._interfaces:
         raise exception.InterfaceAttachFailed('duplicate')
     self._interfaces[vif['id']] = vif
Exemplo n.º 7
0
 def attach_interface(self, instance, image_meta, network_info):
     for (network, mapping) in network_info:
         if mapping['vif_uuid'] in self._interfaces:
             raise exception.InterfaceAttachFailed('duplicate')
         self._interfaces[mapping['vif_uuid']] = mapping
Exemplo n.º 8
0
 def attach_interface(self, instance, image_meta, network_info):
     for vif in [network_info]:
         if vif['id'] in self._interfaces:
             raise exception.InterfaceAttachFailed('duplicate')
         self._interfaces[vif['id']] = vif
Exemplo n.º 9
0
 def attach_interface(self, instance, image_meta, vif):
     LOG.debug("AWS: Attaching interface", instance=instance)
     if vif['id'] in self._interfaces:
         raise exception.InterfaceAttachFailed('duplicate')
     self._interfaces[vif['id']] = vif
Exemplo n.º 10
0
 def attach_interface(self, instance, image_meta, vif):
     LOG.debug("******* ATTTACH INTERFACE *******")
     if vif['id'] in self._interfaces:
         raise exception.InterfaceAttachFailed('duplicate')
     self._interfaces[vif['id']] = vif