Exemplo n.º 1
0
    def _verify_disks(self, vm):
        persistent_disks = [
            disk for disk in vm.layout.disk
            if is_persistent_disk(disk.diskFile)
        ]

        if persistent_disks:
            raise OperationNotAllowedException("persistent disks attached")
Exemplo n.º 2
0
    def get_mks_ticket(self, vm_id):
        if self._get_vm(vm_id).state != 'on':
            raise OperationNotAllowedException()

        return MksTicket(cfg_file='/vmfs/volumes/%s.vmdk' % vm_id,
                         ssl_thumbprint='33:F5:6F:FB:07:A9:EB:6E:5E:9B:E6:AF'
                         ':00:BB:DA:69:FF:BA:20:34',
                         port=902,
                         ticket='52579d02-a80d-55eb-648b-f7ae461a7505')
Exemplo n.º 3
0
 def get_mks_ticket(self, vm_id):
     vm = self.vim_client.get_vm(vm_id)
     if vm.runtime.powerState != 'poweredOn':
         raise OperationNotAllowedException('Not allowed on vm that is '
                                            'not powered on.')
     mks = vm.AcquireMksTicket()
     return MksTicket(cfg_file=mks.cfgFile,
                      host=mks.host,
                      port=mks.port,
                      ssl_thumbprint=mks.sslThumbprint,
                      ticket=mks.ticket)
Exemplo n.º 4
0
 def delete_vm(self, vm_id, force=False):
     self._assert_exists(vm_id)
     vm = self._resources[vm_id]
     if vm.state != "off":
         raise VmPowerStateException()
     # fake_vm_spec.disks are all persistent disks.
     # TODO(agui): This looks hacky. FakeVm should have its own device
     # list, as opposed to play spec around.
     if not force and len(self._resources[vm_id].fake_vm_spec.disks) != 0:
         raise OperationNotAllowedException("persistent disks attached")
     fake_vm_spec = self._resources[vm_id].fake_vm_spec
     for disk_id in fake_vm_spec.vm_disks:
         self._disk_manager().delete_disk(fake_vm_spec.datastore, disk_id)
     del self._resources[vm_id]
     self._trigger_vm_listeners()