コード例 #1
0
    def test_vm_is_remembered(self):
        vm_id = "VM-1"
        tenant_id = "test"
        network_id = "123"
        port_id = 456
        host_id = "ubuntu1"

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id, network_id, tenant_id)
        self.assertTrue(vm_provisioned, "VM must be provisioned")
コード例 #2
0
    def test_vm_is_remembered(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id,
                                              network_id, tenant_id)
        self.assertTrue(vm_provisioned, 'VM must be provisioned')
コード例 #3
0
    def test_vm_is_remembered(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id,
                                              network_id, tenant_id)
        self.assertTrue(vm_provisioned, 'VM must be provisioned')
コード例 #4
0
    def test_vm_is_removed(self):
        vm_id = "VM-1"
        tenant_id = "test"
        network_id = "123"
        port_id = 456
        host_id = "ubuntu1"

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id, network_id, tenant_id)
        self.assertFalse(vm_provisioned, "The vm should be deleted")
コード例 #5
0
    def test_vm_is_removed(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id,
                                              network_id, tenant_id)
        self.assertFalse(vm_provisioned, 'The vm should be deleted')
コード例 #6
0
    def test_vm_is_removed(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id,
                                              network_id, tenant_id)
        self.assertFalse(vm_provisioned, 'The vm should be deleted')
コード例 #7
0
    def update_port_postcommit(self, context):
        """Update the name of a given port in EOS.

        At the moment we only support port name change
        Any other change to port is not supported at this time.
        """
        port = context.current
        orig_port = context.original
        if port['name'] == orig_port['name']:
            # nothing to do
            return

        device_id = port['device_id']
        device_owner = port['device_owner']
        host = port[portbindings.HOST_ID]
        is_vm_boot = device_id and device_owner

        if host and is_vm_boot:
            port_id = port['id']
            port_name = port['name']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                hostname = self._host_name(host)
                segmentation_id = db.get_segmentation_id(tenant_id,
                                                         network_id)
                vm_provisioned = db.is_vm_provisioned(device_id,
                                                      host,
                                                      port_id,
                                                      network_id,
                                                      tenant_id)
                net_provisioned = db.is_network_provisioned(tenant_id,
                                                            network_id,
                                                            segmentation_id)
                if vm_provisioned and net_provisioned:
                    try:
                        self.rpc.plug_port_into_network(device_id,
                                                        hostname,
                                                        port_id,
                                                        network_id,
                                                        tenant_id,
                                                        port_name,
                                                        device_owner)
                    except arista_exc.AristaRpcError:
                        LOG.info(EOS_UNREACHABLE_MSG)
                        raise ml2_exc.MechanismDriverError()
                else:
                    msg = _('VM %s is not updated as it is not found in '
                            'Arista DB') % device_id
                    LOG.info(msg)
コード例 #8
0
    def update_port_postcommit(self, context):
        """At the moment we only support port name change

        Any other change to port is not supported at this time.
        """
        port = context.current
        orig_port = context.original
        if port['name'] == orig_port['name']:
            # nothing to do
            return

        device_id = port['device_id']
        device_owner = port['device_owner']
        host = port['binding:host_id']
        is_vm_boot = device_id and device_owner

        if host and is_vm_boot:
            port_id = port['id']
            port_name = port['name']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                hostname = self._host_name(host)
                segmentation_id = db.get_segmentation_id(tenant_id,
                                                         network_id)
                vm_provisioned = db.is_vm_provisioned(device_id,
                                                      host,
                                                      port_id,
                                                      network_id,
                                                      tenant_id)
                net_provisioned = db.is_network_provisioned(tenant_id,
                                                            network_id,
                                                            segmentation_id)
                if vm_provisioned and net_provisioned:
                    try:
                        self.rpc.plug_port_into_network(device_id,
                                                        hostname,
                                                        port_id,
                                                        network_id,
                                                        tenant_id,
                                                        port_name,
                                                        device_owner)
                    except arista_exc.AristaRpcError:
                        LOG.info(EOS_UNREACHABLE_MSG)
                        raise ml2_exc.MechanismDriverError()
                else:
                    msg = _('VM %s is not updated as it is not found in '
                            'Arista DB') % device_id
                    LOG.info(msg)
コード例 #9
0
ファイル: mechanism_arista.py プロジェクト: pjh03/quantum
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = port[portbindings.HOST_ID]
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id, network_id,
                                    tenant_id):
                db.forget_vm(device_id, host_id, port_id, network_id,
                             tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
コード例 #10
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = port[portbindings.HOST_ID]
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id,
                                    network_id, tenant_id):
                db.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
コード例 #11
0
ファイル: mechanism_arista.py プロジェクト: ader1990/neutron
    def create_port_postcommit(self, context):
        """Plug a physical host into a network.

        Send provisioning request to Arista Hardware to plug a host
        into appropriate network.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']

        # TODO(sukhdev) revisit this once port biniding support is implemented
        host = port['binding:host_id']

        # device_id and device_owner are set on VM boot
        is_vm_boot = device_id and device_owner
        if host and is_vm_boot:
            port_id = port['id']
            port_name = port['name']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                hostname = self._host_name(host)
                segmentation_id = db.get_segmentation_id(tenant_id,
                                                         network_id)
                vm_provisioned = db.is_vm_provisioned(device_id,
                                                      host,
                                                      port_id,
                                                      network_id,
                                                      tenant_id)
                net_provisioned = db.is_network_provisioned(tenant_id,
                                                            network_id,
                                                            segmentation_id)
                if vm_provisioned and net_provisioned:
                    try:
                        self.rpc.plug_host_into_network(device_id,
                                                        hostname,
                                                        port_id,
                                                        network_id,
                                                        tenant_id,
                                                        port_name)
                    except arista_exc.AristaRpcError:
                        LOG.info(EOS_UNREACHABLE_MSG)
                        raise ml2_exc.MechanismDriverError()
                else:
                    msg = _('VM %s is not created as it is not found in'
                            'Arista DB') % device_id
                    LOG.info(msg)
コード例 #12
0
ファイル: mechanism_arista.py プロジェクト: zioc/neutron
    def create_port_postcommit(self, context):
        """Plug a physical host into a network.

        Send provisioning request to Arista Hardware to plug a host
        into appropriate network.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']

        # TODO(sukhdev) revisit this once port biniding support is implemented
        host = port['binding:host_id']

        # device_id and device_owner are set on VM boot
        is_vm_boot = device_id and device_owner
        if host and is_vm_boot:
            port_id = port['id']
            port_name = port['name']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                hostname = self._host_name(host)
                segmentation_id = db.get_segmentation_id(tenant_id,
                                                         network_id)
                vm_provisioned = db.is_vm_provisioned(device_id,
                                                      host,
                                                      port_id,
                                                      network_id,
                                                      tenant_id)
                net_provisioned = db.is_network_provisioned(tenant_id,
                                                            network_id,
                                                            segmentation_id)
                if vm_provisioned and net_provisioned:
                    try:
                        self.rpc.plug_host_into_network(device_id,
                                                        hostname,
                                                        port_id,
                                                        network_id,
                                                        tenant_id,
                                                        port_name)
                    except arista_exc.AristaRpcError:
                        LOG.info(EOS_UNREACHABLE_MSG)
                        raise ml2_exc.MechanismDriverError()
                else:
                    msg = _('VM %s is not created as it is not found in'
                            'Arista DB') % device_id
                    LOG.info(msg)
コード例 #13
0
ファイル: mechanism_arista.py プロジェクト: ader1990/neutron
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        # TODO(sukhdev) revisit this once port biniding support is implemented
        host_id = port['binding:host_id']
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id,
                                    network_id, tenant_id):
                db.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
コード例 #14
0
ファイル: mechanism_arista.py プロジェクト: zioc/neutron
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        # TODO(sukhdev) revisit this once port biniding support is implemented
        host_id = port['binding:host_id']
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id,
                                    network_id, tenant_id):
                db.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)