def create_port_precommit(self, context):
        """Remember the infromation about a VM and its ports

        A VM information, along with the physical host information
        is saved.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']
        host = context.host

        # 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']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            if not tenant_id:
                tenant_id = context._plugin_context.tenant_id
            with self.eos_sync_lock:
                if not db.is_network_provisioned(tenant_id, network_id):
                    # Ignore this request if network is not provisioned
                    return
                db.remember_tenant(tenant_id)
                db.remember_vm(device_id, host, port_id,
                               network_id, tenant_id)
    def create_port_precommit(self, context):
        """Remember the infromation about a VM and its ports

        A VM information, along with the physical host information
        is saved.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']
        host = context.host

        # 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']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            if not tenant_id:
                tenant_id = context._plugin_context.tenant_id
            with self.eos_sync_lock:
                if not db.is_network_provisioned(tenant_id, network_id):
                    # Ignore this request if network is not provisioned
                    return
                db.remember_tenant(tenant_id)
                db.remember_vm(device_id, host, port_id, network_id, tenant_id)
    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")
    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')
    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')
    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")
    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')
    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')
Esempio n. 9
0
    def create_port_precommit(self, context):
        """Remember the infromation about a VM and its ports

        A VM information, along with the physical host information
        is saved.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']
        host = context.host

        # 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']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                db.remember_vm(device_id, host, port_id, network_id, tenant_id)
Esempio n. 10
0
    def create_port_precommit(self, context):
        """Remember the infromation about a VM and its ports

        A VM information, along with the physical host information
        is saved.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']
        host = context.host

        # 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']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                db.remember_vm(device_id, host, port_id,
                               network_id, tenant_id)
    def test_num_vm_is_valid(self):
        tenant_id = "test"
        network_id = "123"
        port_id = 456
        host_id = "ubuntu1"

        vm_to_remember = ["vm1", "vm2", "vm3"]
        vm_to_forget = ["vm2", "vm1"]

        for vm in vm_to_remember:
            db.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db.get_vms(tenant_id))
        expected = len(vm_to_remember) - len(vm_to_forget)

        self.assertEqual(expected, num_vms, "There should be %d records, " "got %d records" % (expected, num_vms))
        # clean up afterwards
        db.forget_vm("vm3", host_id, port_id, network_id, tenant_id)
    def test_num_vm_is_valid(self):
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        vm_to_remember = ['vm1', 'vm2', 'vm3']
        vm_to_forget = ['vm2', 'vm1']

        for vm in vm_to_remember:
            db.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db.get_vms(tenant_id))
        expected = len(vm_to_remember) - len(vm_to_forget)

        self.assertEqual(expected, num_vms,
                         'There should be %d records, '
                         'got %d records' % (expected, num_vms))
        # clean up afterwards
        db.forget_vm('vm3', host_id, port_id, network_id, tenant_id)
    def test_num_vm_is_valid(self):
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        vm_to_remember = ['vm1', 'vm2', 'vm3']
        vm_to_forget = ['vm2', 'vm1']

        for vm in vm_to_remember:
            db.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db.get_vms(tenant_id))
        expected = len(vm_to_remember) - len(vm_to_forget)

        self.assertEqual(expected, num_vms,
                         'There should be %d records, '
                         'got %d records' % (expected, num_vms))
        # clean up afterwards
        db.forget_vm('vm3', host_id, port_id, network_id, tenant_id)