def test_vm_is_removed(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db_lib.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db_lib.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db_lib.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_lib.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db_lib.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db_lib.is_vm_provisioned(vm_id, host_id, port_id,
                                                  network_id, tenant_id)
        self.assertFalse(vm_provisioned, 'The vm should be deleted')
Beispiel #3
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = context.host
        device_id = port["device_id"]
        tenant_id = port["tenant_id"]
        if not tenant_id:
            tenant_id = context._plugin_context.tenant_id
        network_id = port["network_id"]
        port_id = port["id"]
        with self.eos_sync_lock:
            if db_lib.is_vm_provisioned(device_id, host_id, port_id, network_id, tenant_id):
                db_lib.forget_vm(device_id, host_id, port_id, network_id, tenant_id)
Beispiel #4
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = context.host
        device_id = port['device_id']
        tenant_id = port['tenant_id'] or INTERNAL_TENANT_ID
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db_lib.is_vm_provisioned(device_id, host_id, port_id,
                                        network_id, tenant_id):
                db_lib.forget_vm(device_id, host_id, port_id,
                                 network_id, tenant_id)
Beispiel #5
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = context.host
        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_lib.is_vm_provisioned(device_id, host_id, port_id,
                                        network_id, tenant_id):
                db_lib.forget_vm(device_id, host_id, port_id, network_id,
                                 tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
Beispiel #6
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = context.host
        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_lib.is_vm_provisioned(device_id, host_id, port_id,
                                        network_id, tenant_id):
                db_lib.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(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_lib.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db_lib.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db_lib.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_lib.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_lib.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db_lib.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db_lib.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_lib.forget_vm('vm3', host_id, port_id, network_id, tenant_id)