Capture one or all disks from a virtual server to a SoftLayer image.
484388
def cli(env, identifier, name, all, note):
    """"""

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')

    capture = vsi.capture(vs_id, name, all, note)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['vs_id', capture['guestId']])
    table.add_row(['date', capture['createDate'][:10]])
    table.add_row(['time', capture['createDate'][11:19]])
    table.add_row(['transaction', formatting.transaction_status(capture)])
    table.add_row(['transaction_id', capture['id']])
    table.add_row(['all_disks', all])
    env.fout(table)
773948
def cli(env, identifier, postinstall, key, image):
    """"""

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    keys = []
    if key:
        for single_key in key:
            resolver = SoftLayer.SshKeyManager(env.client).resolve_ids
            key_id = helpers.resolve_id(resolver, single_key, 'SshKey')
            keys.append(key_id)
    if not (env.skip_confirmations or formatting.no_going_back(vs_id)):
        raise exceptions.CLIAbort('Aborted')

    vsi.reload_instance(vs_id,
                        post_uri=postinstall,
                        ssh_keys=keys,
                        image_id=image)
76224
def attach_model(subscription, rgname, vmssvm_model, diskname, lun):
    ''''''
    disk_id = '/subscriptions/' + subscription + '/resourceGroups/' + rgname + \
        '/providers/Microsoft.Compute/disks/' + diskname
    disk_model = {'lun': lun, 'createOption': 'Attach', 'caching': 'None',
                  'managedDisk': {'storageAccountType': 'Standard_LRS', 'id': disk_id}}
    vmssvm_model['properties']['storageProfile']['dataDisks'].append(
        disk_model)
    return vmssvm_model
176764
def _get_vqa_v2_image_raw_dataset(directory, image_root_url, image_urls):
  """"""
  for url in image_urls:
    filename = os.path.basename(url)
    download_url = os.path.join(image_root_url, url)
    path = generator_utils.maybe_download(directory, filename, download_url)
    unzip_dir = os.path.join(directory, filename.strip(".zip"))
    if not tf.gfile.Exists(unzip_dir):
      zipfile.ZipFile(path, "r").extractall(directory)
714765
def get_image(conn, vm_):
    '''
    
    '''
    vm_image = config.get_cloud_config_value('image', vm_, __opts__, default='').encode(
        'ascii', 'salt-cloud-force-ascii'
    )
    if not vm_image:
        log.debug('No image set, must be boot from volume')
        return None

    image_list = conn.image_list()

    for img in image_list:
        if vm_image in (image_list[img]['id'], img):
            return image_list[img]['id']

    try:
        image = conn.image_show(vm_image)
        return image['id']
    except novaclient.exceptions.NotFound as exc:
        raise SaltCloudNotFound(
            'The specified image, \'{0}\', could not be found: {1}'.format(
                vm_image,
                exc
            )
        )
379524
def cli(env, identifier, hardware_identifier, virtual_identifier):
    """"""
    ticket_mgr = SoftLayer.TicketManager(env.client)

    if hardware_identifier and virtual_identifier:
        raise exceptions.ArgumentError("Cannot attach hardware and a virtual server at the same time")

    if hardware_identifier:
        hardware_mgr = SoftLayer.HardwareManager(env.client)
        hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids, hardware_identifier, 'hardware')
        ticket_mgr.attach_hardware(identifier, hardware_id)
    elif virtual_identifier:
        vs_mgr = SoftLayer.VSManager(env.client)
        vs_id = helpers.resolve_id(vs_mgr.resolve_ids, virtual_identifier, 'VS')
        ticket_mgr.attach_virtual_server(identifier, vs_id)
    else:
        raise exceptions.ArgumentError("Must have a hardware or virtual server identifier to attach")
194612
def from_sysdisk(cls, label):
        """"""
        disks = cls.safe_call('hosting.disk.list', {'name': label})
        if len(disks):
            return disks[0]['id']
906028
def get_capture(self):
        """"""
        # game
        game_image = self._game_image_from_screen('capture')
        if game_image is None:
            return
        # board
        board = self._board_from_game_image(game_image)
        if board is None:
            return
        if board.is_empty():
            return
        return board
1111182
def copy_images(images, source, target):
    
    image_err = False
    if len(images) > 0:
        images_dir = os.path.join(target, 'images')
        os.makedirs(images_dir)
        for image in images:
            if os.path.isabs(image):
                old_image_file = image
            else:
                old_image_file = os.path.join(source, image)

            new_image_file = os.path.join(images_dir,
                                          os.path.basename(image))
            if os.path.isfile(os.path.abspath(old_image_file)):
                shutil.copy(old_image_file, new_image_file)
            else:
                image_err = True
                logging.error('Unable to find %s' % old_image_file)
    return image_err
654885
def Disks(self):
		

		if not self.disks:  self.disks = clc.v2.Disks(server=self,disks_lst=self.data['details']['disks'],session=self.session)

		return(self.disks)
737286
def copy_dependency_images(tile):
    """"""

    env = Environment(tools=[])

    outputbase = os.path.join('build', 'output')
    depbase = os.path.join('build', 'deps')
    for dep in tile.dependencies:
        depdir = os.path.join(depbase, dep['unique_id'])
        outputdir = os.path.join(outputbase)

        deptile = IOTile(depdir)

        for image in deptile.find_products('firmware_image'):
            name = os.path.basename(image)
            input_path = os.path.join(depdir, name)
            output_path = os.path.join(outputdir, name)
            env.Command([output_path], [input_path], Copy("$TARGET", "$SOURCE"))
205819
def show_disk(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_disks action must be called with -a or --action.'
        )

    ret = {}
    params = {
        'Action': 'DescribeInstanceDisks',
        'InstanceId': name
    }
    items = query(params=params)

    for disk in items['Disks']['Disk']:
        ret[disk['DiskId']] = {}
        for item in disk:
            ret[disk['DiskId']][item] = six.text_type(disk[item])

    return ret
98925
def get_image(vm_):
    '''
    
    '''
    vm_image = config.get_cloud_config_value('image', vm_, __opts__).encode(
        'ascii', 'salt-cloud-force-ascii'
    )

    images = avail_images()
    for key, value in six.iteritems(images):
        if vm_image and vm_image in (images[key]['id'], images[key]['name']):
            return images[key]

    raise SaltCloudNotFound(
        'The specified image, \'{0}\', could not be found.'.format(vm_image)
    )
540245
def to_vobject(self, filename=None, uid=None):
        
        self._update()
        return self._to_vcard(self._book[uid.split('@')[0]])
1233669
def from_label(cls, label, datacenter=None):
        """"""
        result = cls.list(datacenter=datacenter)
        image_labels = dict([(image['label'], image['disk_id'])
                             for image in result])

        return image_labels.get(label)
1338961
def avail_images(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_images function must be called with '
            '-f or --function, or with the --list-images option.'
        )

    templates = {}
    vm_properties = [
        "name",
        "config.template",
        "config.guestFullName",
        "config.hardware.numCPU",
        "config.hardware.memoryMB"
    ]

    vm_list = salt.utils.vmware.get_mors_with_properties(_get_si(), vim.VirtualMachine, vm_properties)

    for vm in vm_list:
        if "config.template" in vm and vm["config.template"]:
            templates[vm["name"]] = {
                'name': vm["name"],
                'guest_fullname': vm["config.guestFullName"] if "config.guestFullName" in vm else "N/A",
                'cpus': vm["config.hardware.numCPU"] if "config.hardware.numCPU" in vm else "N/A",
                'ram': vm["config.hardware.memoryMB"] if "config.hardware.memoryMB" in vm else "N/A"
            }

    return templates
806015
def layered(self, images, only_pushable=False):
        """"""
        if only_pushable:
            operate_on = dict((image, instance) for image, instance in images.items() if instance.image_index)
        else:
            operate_on = images

        layers = Layers(operate_on, all_images=images)
        layers.add_all_to_layers()
        for layer in layers.layered:
            buf = []
            for image_name, image in layer:
                if image.image_index:
                    buf.append((image_name, image))
            if buf:
                yield buf