Create the storage profile for the instance.

        Image reference can be a custom image name or a published urn.
760136
def _create_storage_profile(self):
        
        if self.image_publisher:
            storage_profile = {
                'image_reference': {
                    'publisher': self.image_publisher,
                    'offer': self.image_offer,
                    'sku': self.image_sku,
                    'version': self.image_version
                },
            }
        else:
            for image in self.compute.images.list():
                if image.name == self.image_id:
                    image_id = image.id
                    break
            else:
                raise AzureCloudException(
                    'Image with name {0} not found.'.format(self.image_id)
                )

            storage_profile = {
                'image_reference': {
                    'id': image_id
                }
            }

        return storage_profile
299593
function createProfile(config, profileData) {
  const options = {
    method: "POST",
    uri: `${config.obServer}:${config.obPort}/ob/profile/`,
    body: profileData,
    json: true, // Automatically stringifies the body to JSON
    headers: {
      Authorization: config.apiCredentials,
    },
    // resolveWithFullResponse: true
  };

  return rp(options);
}
246383
def _create_body(self, name, size=None, volume_type=None, description=None,
             metadata=None, snapshot_id=None, clone_id=None,
             availability_zone=None, image=None):
        
        if not isinstance(size, six.integer_types):
            raise exc.InvalidSize("Volume sizes must be integers")

        if volume_type is None:
            volume_type = "SATA"
        if description is None:
            description = ""
        if metadata is None:
            metadata = {}
        if image is not None:
            image = utils.get_id(image)
        body = {"volume": {
                "size": size,
                "snapshot_id": snapshot_id,
                "source_volid": clone_id,
                "display_name": name,
                "display_description": description,
                "volume_type": volume_type,
                "metadata": metadata,
                "availability_zone": availability_zone,
                "imageRef": image,
                }}
        return body
1339039
def save(self, name, content, *args, **kwargs):
        
        super(ThumbnailerFieldFile, self).save(name, content, *args, **kwargs)
        self.get_source_cache(create=True, update=True)
651042
def image_url(self, pixel_size=None):
        
        if "profile" not in self._raw:
            return
        profile = self._raw["profile"]
        if (pixel_size):
            img_key = "image_%s" % pixel_size
            if img_key in profile:
                return profile[img_key]
        return profile[self._DEFAULT_IMAGE_KEY]
1050676
def upload_to_picture(instance, filename):
    
    extension = filename.split('.')[-1].lower()
    salt, hash = generate_sha1(instance.id)
    return '%(path)s/%(hash)s.%(extension)s' % {
                'path': getattr(defaults, 
                            'ACCOUNTS_PICTURE_PATH','%s/%s' % (
                                str(instance._meta.app_label), 
                                str(instance._meta.model_name))),
                'hash': hash[:10],
                'extension': extension}
1360650
def create_app(config_filename, instance_path=None):
    
    app_ = CustomFlask(
        __name__,
        instance_path=instance_path or os.environ.get(
            'VERIPRESS_INSTANCE_PATH') or os.getcwd(),
        instance_relative_config=True
    )
    app_.config.update(dict(STORAGE_TYPE='file',
                            THEME='default',
                            CACHE_TYPE='simple',
                            MODE='view-only',
                            ENTRIES_PER_PAGE=5,
                            FEED_COUNT=10,
                            SHOW_TOC=True,
                            TOC_DEPTH=3,
                            TOC_LOWEST_LEVEL=3,
                            ALLOW_SEARCH_PAGES=True,
                            PAGE_SOURCE_ACCESSIBLE=False))
    app_.config.from_pyfile(config_filename, silent=True)

    theme_folder = os.path.join(app_.instance_path,
                                'themes', app_.config['THEME'])
    # use templates in the selected theme's folder
    app_.template_folder = os.path.join(theme_folder, 'templates')
    # use static files in the selected theme's folder
    app_.theme_static_folder = os.path.join(theme_folder, 'static')
    # global static folder
    app_.static_folder = os.path.join(app_.instance_path, 'static')

    return app_
1061836
def create(self, name, **kwds):
        
        result = self._client.post("/album/create.json",
                                   name=name, **kwds)["result"]
        return Album(self._client, result)
945590
def custom_image(self, user):
        """"""
        for ext in self.valid_custom_image_extensions():
            image_location = self._custom_image_path(user, ext)
            if os.path.isfile(image_location):
                return image_location
        return None
636834
def _add_image(collection, image):
    '''
    
    '''
    image_prep = {
            'id': image.id,
            'name': image.name,
            'created_at': image.created_at,
            'file': image.file,
            'min_disk': image.min_disk,
            'min_ram': image.min_ram,
            'owner': image.owner,
            'protected': image.protected,
            'status': image.status,
            'tags': image.tags,
            'updated_at': image.updated_at,
            'visibility': image.visibility,
        }
    # Those cause AttributeErrors in Icehouse' glanceclient
    for attr in ['container_format', 'disk_format', 'size']:
        if attr in image:
            image_prep[attr] = image[attr]
    if type(collection) is dict:
        collection[image.name] = image_prep
    elif type(collection) is list:
        collection.append(image_prep)
    else:
        msg = '"collection" is {0}'.format(type(collection)) +\
            'instead of dict or list.'
        log.error(msg)
        raise TypeError(msg)
    return collection
441996
def create_image_metadata(data):
    """"""

    # Default metadata
    meta = {'protected': data.get('protected', False),
            'disk_format': data.get('disk_format', 'raw'),
            'container_format': data.get('container_format', 'bare'),
            'min_disk': data.get('min_disk') or 0,
            'min_ram': data.get('min_ram') or 0,
            'name': data.get('name', '')}

    # Glance does not really do anything with container_format at the
    # moment. It requires it is set to the same disk_format for the three
    # Amazon image types, otherwise it just treats them as 'bare.' As such
    # we will just set that to be that here instead of bothering the user
    # with asking them for information we can already determine.
    if meta['disk_format'] in ('ami', 'aki', 'ari',):
        meta['container_format'] = meta['disk_format']
    elif meta['disk_format'] == 'docker':
        # To support docker containers we allow the user to specify
        # 'docker' as the format. In that case we really want to use
        # 'raw' as the disk format and 'docker' as the container format.
        meta['disk_format'] = 'raw'
        meta['container_format'] = 'docker'
    elif meta['disk_format'] == 'ova':
        # If the user wishes to upload an OVA using Horizon, then
        # 'ova' must be the container format and 'vmdk' must be the disk
        # format.
        meta['container_format'] = 'ova'
        meta['disk_format'] = 'vmdk'

    properties = {}

    for prop, key in [('description', 'description'),
                      ('kernel_id', 'kernel'),
                      ('ramdisk_id', 'ramdisk'),
                      ('architecture', 'architecture')]:
        if data.get(key):
            properties[prop] = data[key]

    _handle_unknown_properties(data, properties)

    if ('visibility' in data and
            data['visibility'] not in ['public', 'private', 'community',
                                       'shared']):
        raise KeyError('invalid visibility option: %s' % data['visibility'])
    _normalize_is_public_filter(data)

    if VERSIONS.active < 2:
        meta['properties'] = properties
        meta['is_public'] = data.get('is_public', False)
    else:
        meta['visibility'] = data.get('visibility', 'private')
        meta.update(properties)

    return meta
448272
function reprovisionInstance(uuid, image_uuid, callback) {
    assert.string(uuid, 'uuid');
    assert.string(image_uuid, 'image_uuid');

    var opts = {};
    opts.image_uuid = image_uuid;

    return (this.put(sprintf('/instances/%s/upgrade', uuid), opts, callback));
}
1291360
def create_rbd_image(service, pool, image, sizemb):
    """"""
    cmd = ['rbd', 'create', image, '--size', str(sizemb), '--id', service,
           '--pool', pool]
    check_call(cmd)
406314
def profile_file(self):
        
        if 'profile' in self._kwargs and self._kwargs['profile']:
            profile_path = path.normpath(self._kwargs['profile'])
            if os.path.exists(profile_path) and os.path.isdir(profile_path):
                return path.join(
                    profile_path, '{}-{}.prof'.format(
                        os.getpid(), self._kwargs['consumer_name']))
1302372
def create_backup(self, instance, name, description=None):
        
        return instance.create_backup(name, description=description)
1358105
def setProfile( self, profile ):
        
        self._profile = profile
        
        if not profile:
            self.uiNameTXT.setText('')
            self.uiVersionSPN.setValue(1.0)
            self.uiDescriptionTXT.setText('')
            self.uiIconBTN.setFilepath(resources.find('img/profile_48.png'))
        else:
            self.uiNameTXT.setText(profile.name())
            self.uiVersionSPN.setValue(profile.version())
            self.uiDescriptionTXT.setText(profile.description())
            
            filepath = profile.icon()
            if ( not filepath ):
                filepath = resources.find('img/profile_48.png')
            self.uiIconBTN.setFilepath(filepath)
1259154
def saveProfileAs( self ):
        
        name, ok = QInputDialog.getText(self, 'Create Profile', 'Name:')
        if ( not name ):
            return
        
        manager = self.parent()
        prof    = manager.viewWidget().saveProfile()
        prof.setName(nativestring(name))
        self.parent().addProfile(prof)