コード例 #1
0
ファイル: hyperv.py プロジェクト: wendy-king/x7_venv
    def spawn(self,
              context,
              instance,
              image_meta,
              network_info=None,
              block_device_info=None):
        """ Create a new VM and start it."""
        vm = self._lookup(instance.name)
        if vm is not None:
            raise exception.InstanceExists(name=instance.name)

        #Fetch the file, assume it is a VHD file.
        base_vhd_filename = os.path.join(FLAGS.instances_path, instance.name)
        vhdfile = "%s.vhd" % (base_vhd_filename)
        images.fetch(instance['image_ref'], vhdfile, instance['user_id'],
                     instance['project_id'])

        try:
            self._create_vm(instance)

            self._create_disk(instance['name'], vhdfile)

            mac_address = None
            if instance['mac_addresses']:
                mac_address = instance['mac_addresses'][0]['address']

            self._create_nic(instance['name'], mac_address)

            LOG.debug(_('Starting VM %s '), instance.name)
            self._set_vm_state(instance['name'], 'Enabled')
            LOG.info(_('Started VM %s '), instance.name)
        except Exception as exn:
            LOG.exception(_('spawn vm failed: %s'), exn)
            self.destroy(instance)
コード例 #2
0
ファイル: hyperv.py プロジェクト: wendy-king/x7_compute_venv
    def spawn(self, context, instance, image_meta,
              network_info=None, block_device_info=None):
        """ Create a new VM and start it."""
        vm = self._lookup(instance.name)
        if vm is not None:
            raise exception.InstanceExists(name=instance.name)

        #Fetch the file, assume it is a VHD file.
        base_vhd_filename = os.path.join(FLAGS.instances_path,
                                         instance.name)
        vhdfile = "%s.vhd" % (base_vhd_filename)
        images.fetch(instance['image_ref'], vhdfile,
                     instance['user_id'], instance['project_id'])

        try:
            self._create_vm(instance)

            self._create_disk(instance['name'], vhdfile)

            mac_address = None
            if instance['mac_addresses']:
                mac_address = instance['mac_addresses'][0]['address']

            self._create_nic(instance['name'], mac_address)

            LOG.debug(_('Starting VM %s '), instance.name)
            self._set_vm_state(instance['name'], 'Enabled')
            LOG.info(_('Started VM %s '), instance.name)
        except Exception as exn:
            LOG.exception(_('spawn vm failed: %s'), exn)
            self.destroy(instance)
コード例 #3
0
def fetch_image(context, target, image_id, user_id, project_id, size=None):
    """Grab image and optionally attempt to resize it"""
    images.fetch(context, image_id, target, user_id, project_id)
    if size:
        disk.extend(target, size)
コード例 #4
0
ファイル: utils.py プロジェクト: wendy-king/x7_compute_venv
def fetch_image(context, target, image_id, user_id, project_id, size=None):
    """Grab image and optionally attempt to resize it"""
    images.fetch(context, image_id, target, user_id, project_id)
    if size:
        disk.extend(target, size)