Ejemplo n.º 1
0
 def get_resource(self, vm_id):
     vm = self._get_vm(vm_id)
     resource = Vm(vm_id)
     resource.flavor = vm.fake_vm_spec.flavor
     resource.state = self._power_state_to_resource_state(vm.state)
     resource.datastore = vm.fake_vm_spec.datastore
     resource.environment = vm.fake_vm_spec.env
     return resource
Ejemplo n.º 2
0
 def get_resource(self, vm_id):
     vm = self._get_vm(vm_id)
     resource = Vm(vm_id)
     resource.flavor = vm.fake_vm_spec.flavor
     resource.state = self._power_state_to_resource_state(vm.state)
     resource.datastore = vm.fake_vm_spec.datastore
     resource.environment = vm.fake_vm_spec.env
     return resource
Ejemplo n.º 3
0
    def _get_resource_from_vmcache(self, vmcache):
        """Translate to vm resource from vm cache
        """
        vm_resource = Vm(vmcache.name)
        vm_resource.flavor = Flavor("default")  # TODO
        vm_resource.disks = []

        for disk in vmcache.disks:
            disk_id = os.path.splitext(os.path.basename(disk))[0]
            datastore_name = self._get_datastore_name_from_ds_path(disk)
            datastore_uuid = self._get_datastore_uuid(datastore_name)
            if datastore_uuid:
                disk_resource = Disk(disk_id, Flavor("default"), False, False,
                                     -1, None, datastore_uuid)
                vm_resource.disks.append(disk_resource)

        vm_resource.state = vmcache.power_state

        datastore_name = self._get_datastore_name_from_ds_path(vmcache.path)
        vm_resource.datastore = self._get_datastore_uuid(datastore_name)

        return vm_resource
Ejemplo n.º 4
0
    def _get_resource_from_vmcache(self, vmcache):
        """Translate to vm resource from vm cache
        """
        vm_resource = Vm(vmcache.name)
        vm_resource.flavor = Flavor("default")  # TODO
        vm_resource.disks = []

        for disk in vmcache.disks:
            disk_id = os.path.splitext(os.path.basename(disk))[0]
            datastore_name = self._get_datastore_name_from_ds_path(disk)
            datastore_uuid = self._get_datastore_uuid(datastore_name)
            if datastore_uuid:
                disk_resource = Disk(disk_id, Flavor("default"), False,
                                     False, -1, None, datastore_uuid)
                vm_resource.disks.append(disk_resource)

        vm_resource.state = vmcache.power_state

        datastore_name = self._get_datastore_name_from_ds_path(vmcache.path)
        vm_resource.datastore = self._get_datastore_uuid(datastore_name)

        return vm_resource