def create_snapshot(kwargs=None, call=None):
    '''
    Create a new disk snapshot. Must specify `name` and  `disk_name`.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_snapshot gce name=snap1 disk_name=pd
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The create_snapshot function must be called with -f or --function.'
        )

    if not kwargs or 'name' not in kwargs:
        log.error(
            'A name must be specified when creating a snapshot.'
        )
        return False

    if 'disk_name' not in kwargs:
        log.error(
            'A disk_name must be specified when creating a snapshot.'
        )
        return False

    conn = get_conn()

    name = kwargs.get('name')
    disk_name = kwargs.get('disk_name')

    try:
        disk = conn.ex_get_volume(disk_name)
    except ResourceNotFoundError as exc:
        log.error(
            'Disk %s was not found. Exception was: %s',
            disk_name, exc, exc_info_on_loglevel=logging.DEBUG
        )
        return False

    __utils__['cloud.fire_event'](
        'event',
        'create snapshot',
        'salt/cloud/snapshot/creating',
        args={
            'name': name,
            'disk_name': disk_name,
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    snapshot = conn.create_volume_snapshot(disk, name)

    __utils__['cloud.fire_event'](
        'event',
        'created snapshot',
        'salt/cloud/snapshot/created',
        args={
            'name': name,
            'disk_name': disk_name,
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
    return _expand_item(snapshot)
def create_snapshot ( kwargs = None , call = None ) : if call != 'function' : raise SaltCloudSystemExit ( 'The create_snapshot function must be called with -f or --function.' ) if not kwargs or 'name' not in kwargs : log . error ( 'A name must be specified when creating a snapshot.' ) return False if 'disk_name' not in kwargs : log . error ( 'A disk_name must be specified when creating a snapshot.' ) return False conn = get_conn ( ) name = kwargs . get ( 'name' ) disk_name = kwargs . get ( 'disk_name' ) try : disk = conn . ex_get_volume ( disk_name ) except ResourceNotFoundError as exc : log . error ( 'Disk %s was not found. Exception was: %s' , disk_name , exc , exc_info_on_loglevel = logging . DEBUG ) return False __utils__ [ 'cloud.fire_event' ] ( 'event' , 'create snapshot' , 'salt/cloud/snapshot/creating' , args = { 'name' : name , 'disk_name' : disk_name , } , sock_dir = __opts__ [ 'sock_dir' ] , transport = __opts__ [ 'transport' ] ) snapshot = conn . create_volume_snapshot ( disk , name ) __utils__ [ 'cloud.fire_event' ] ( 'event' , 'created snapshot' , 'salt/cloud/snapshot/created' , args = { 'name' : name , 'disk_name' : disk_name , } , sock_dir = __opts__ [ 'sock_dir' ] , transport = __opts__ [ 'transport' ] ) return _expand_item ( snapshot )
Create a new disk snapshot. Must specify `name` and  `disk_name`.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_snapshot gce name=snap1 disk_name=pd