... versionadded:: 2017.7.0
    Show details of an existing GCE Subnetwork. Must specify name and region.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_subnetwork gce name=mysubnet region=us-west1
185389
def show_subnetwork(kwargs=None, call=None):
    '''
    

    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_subnetwork function must be called with -f or --function.'
        )

    if not kwargs or 'name' not in kwargs:
        log.error(
            'Must specify name of subnet.'
        )
        return False

    if 'region' not in kwargs:
        log.error(
            'Must specify region of subnet.'
        )
        return False

    name = kwargs['name']
    region = kwargs['region']
    conn = get_conn()
    return _expand_item(conn.ex_get_subnetwork(name, region))
1255063
def show_fwrule(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_fwrule function must be called with -f or --function.'
        )
    if not kwargs or 'name' not in kwargs:
        log.error(
            'Must specify name of network.'
        )
        return False

    conn = get_conn()
    return _expand_item(conn.ex_get_firewall(kwargs['name']))
266598
def create_address(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The create_address 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 an address.'
        )
        return False
    if 'region' not in kwargs:
        log.error(
            'A region must be specified for the address.'
        )
        return False

    name = kwargs['name']
    ex_region = kwargs['region']
    ex_address = kwargs.get("address", None)
    kwargs['region'] = _expand_region(kwargs['region'])

    conn = get_conn()

    __utils__['cloud.fire_event'](
        'event',
        'create address',
        'salt/cloud/address/creating',
        args=salt.utils.data.simple_types_filter(kwargs),
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    addy = conn.ex_create_address(name, ex_region, ex_address)

    __utils__['cloud.fire_event'](
        'event',
        'created address',
        'salt/cloud/address/created',
        args=salt.utils.data.simple_types_filter(kwargs),
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    log.info('Created GCE Address %s', name)

    return _expand_address(addy)
381065
function buildSubnet(name, position, zone, cidrBlock) {
  const cfName = `${name}Subnet${position}`;
  return {
    [cfName]: {
      Type: 'AWS::EC2::Subnet',
      Properties: {
        AvailabilityZone: zone,
        CidrBlock: cidrBlock,
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  name.toLowerCase(),
                  zone,
                ],
              ],
            },
          },
        ],
        VpcId: {
          Ref: 'VPC',
        },
      },
    },
  };
}
1332124
def fill_dcnm_subnet_info(self, tenant_id, subnet, start, end, gateway,
                              sec_gateway, direc):
        
        serv_obj = self.get_service_obj(tenant_id)
        fw_dict = serv_obj.get_fw_dict()
        fw_id = fw_dict.get('fw_id')
        if direc == 'in':
            name = fw_id[0:4] + fw_const.IN_SERVICE_SUBNET + (
                fw_id[len(fw_id) - 4:])
        else:
            name = fw_id[0:4] + fw_const.OUT_SERVICE_SUBNET + (
                fw_id[len(fw_id) - 4:])
        subnet_dict = {'enable_dhcp': False,
                       'tenant_id': tenant_id,
                       'name': name,
                       'cidr': subnet + '/24',
                       'gateway_ip': gateway,
                       'secondary_gw': sec_gateway,
                       'ip_version': 4}
        subnet_dict['allocation_pools'] = [{'start': start, 'end': end}]
        # TODO(padkrish) Network ID and subnet ID are not filled.
        return subnet_dict
1275517
def from_store_name(bucket_name, region=None):
    
    # Late-bind `region` for the sake of tests that inject the
    # AWS_REGION environment variable.
    if region is None:
        region = os.getenv('AWS_REGION')

    mostly_ok = _is_mostly_subdomain_compatible(bucket_name)

    if not mostly_ok:
        return CallingInfo(
            bucket_name=bucket_name,
            region=region,
            calling_format=connection.OrdinaryCallingFormat,
            ordinary_endpoint=must_resolve(region))
    else:
        if '.' in bucket_name:
            # The bucket_name might have been DNS compatible, but once
            # dots are involved TLS certificate validations will
            # certainly fail even if that's the case.
            return CallingInfo(
                bucket_name=bucket_name,
                calling_format=connection.OrdinaryCallingFormat,
                region=region,
                ordinary_endpoint=must_resolve(region))
        else:
            # If the bucket follows naming rules and has no dots in
            # the name, SubdomainCallingFormat can be used, with TLS,
            # world-wide.
            return CallingInfo(
                bucket_name=bucket_name,
                calling_format=connection.SubdomainCallingFormat,
                region=region,
                ordinary_endpoint=None)

    assert False
1123628
def show_affinity_group(kwargs=None, conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_affinity_group function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    if kwargs is None:
        kwargs = {}

    if 'name' not in kwargs:
        raise SaltCloudSystemExit('An affinity group name must be specified as "name"')

    data = conn.get_affinity_group_properties(affinity_group_name=kwargs['name'])
    return object_to_dict(data)
1148952
function(name, zoneLetter, cf, vpc, routeTable) {
  var self = this;

  self.isPublic         = false;

  base.Base.call(this, cf, 'EC2::Subnet', name);
  self.addProperty('VpcId', vpc.ref());

  self.zone = self.addProperty('AvailabilityZone', vpc.az(zoneLetter));

  self.cidrBlock = function(cidr) {
    self.cidr = vpc.mkSubnetCidrBlock(cidr);
    return self.addProperty('CidrBlock', self.cidr);
  };

  self.mapPublicIpOnLaunch = function(value) {
    if (arguments.length === 0) { value = true; }
    return self.addProperty('MapPublicIpOnLaunch', !!value);
  };

  var assocName = name+'RouteTableAssociation';
  cf.data.Resources[assocName] = subnet.makeSubnetRouteTableAssociation(assocName, cf, self, routeTable);

  //self.output(name+"CidrBlock", self.getAtt("CidrBlock"), "Subnet "+name+"CIDR block");   /* Do not know why CidrBlock is not available */
}
684727
def list_cache_subnet_groups(name=None, region=None, key=None,
                             keyid=None, profile=None):
    '''
    
    '''
    return [g['CacheSubnetGroupName'] for g in
            get_all_cache_subnet_groups(name, region, key, keyid, profile)]
627048
def show_storage_keys(kwargs=None, conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_storage_keys function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    if kwargs is None:
        kwargs = {}

    if 'name' not in kwargs:
        raise SaltCloudSystemExit('A name must be specified as "name"')

    try:
        data = conn.get_storage_account_keys(
            kwargs['name'],
        )
    except AzureMissingResourceHttpError as exc:
        storage_data = show_storage(kwargs={'name': kwargs['name']}, call='function')
        if storage_data['storage_service_properties']['status'] == 'Creating':
            raise SaltCloudSystemExit('The storage account keys have not yet been created.')
        else:
            raise SaltCloudSystemExit('{0}: {1}'.format(kwargs['name'], exc.message))
    return object_to_dict(data)
17456
def list_subnets(call=None, kwargs=None):
    '''
    
    '''
    if kwargs is None:
        kwargs = {}

    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_sizes function must be called with '
            '-f or --function'
        )

    netconn = get_conn(client_type='network')

    resource_group = kwargs.get('resource_group') or config.get_cloud_config_value(
                         'resource_group',
                         get_configured_provider(), __opts__, search_global=False
                     )

    if not resource_group and 'group' in kwargs and 'resource_group' not in kwargs:
        resource_group = kwargs['group']

    if not resource_group:
        raise SaltCloudSystemExit(
            'A resource group must be specified'
        )

    if kwargs.get('network') is None:
        kwargs['network'] = config.get_cloud_config_value(
            'network', get_configured_provider(), __opts__, search_global=False
        )

    if 'network' not in kwargs or kwargs['network'] is None:
        raise SaltCloudSystemExit(
            'A "network" must be specified'
        )

    ret = {}
    subnets = netconn.subnets.list(resource_group, kwargs['network'])
    for subnet in subnets:
        ret[subnet.name] = subnet.as_dict()
        ret[subnet.name]['ip_configurations'] = {}
        for ip_ in subnet.ip_configurations:
            comps = ip_.id.split('/')
            name = comps[-1]
            ret[subnet.name]['ip_configurations'][name] = ip_.as_dict()
            ret[subnet.name]['ip_configurations'][name]['subnet'] = subnet.name
        ret[subnet.name]['resource_group'] = resource_group
    return ret
1042105
def get_all_cache_subnet_groups(name=None, region=None, key=None,
                                keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    try:
        marker = ''
        groups = []
        while marker is not None:
            ret = conn.describe_cache_subnet_groups(cache_subnet_group_name=name,
                                                    marker=marker)
            trimmed = ret.get('DescribeCacheSubnetGroupsResponse',
                              {}).get('DescribeCacheSubnetGroupsResult', {})
            groups += trimmed.get('CacheSubnetGroups', [])
            marker = trimmed.get('Marker', None)
        if not groups:
            log.debug('No ElastiCache subnet groups found.')
        return groups
    except boto.exception.BotoServerError as e:
        log.error(e)
        return []
739676
def avail_locations(conn=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_locations function must be called with '
            '-f or --function, or with the --list-locations option'
        )

    datacenters = []

    if not conn:
        conn = get_conn()

    for datacenter in conn.list_datacenters():
        datacenters.append({datacenter['country_code']: datacenter})

    return {'Locations': datacenters}
1204718
def absent(name, auth=None):
    '''
    

    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}

    __salt__['neutronng.setup_clouds'](auth)

    subnet = __salt__['neutronng.subnet_get'](name=name)

    if subnet:
        if __opts__['test'] is True:
            ret['result'] = None
            ret['changes'] = {'id': subnet.id}
            ret['comment'] = 'Project will be deleted.'
            return ret

        __salt__['neutronng.subnet_delete'](name=subnet)
        ret['changes']['id'] = name
        ret['comment'] = 'Deleted subnet'

    return ret
1024817
def show_instance(name, conn=None, call=None):
    '''
    

    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )
    if conn is None:
        conn = get_conn()

    node = conn.get_server(name, bare=True)
    ret = dict(node)
    ret['id'] = node.id
    ret['name'] = node.name
    ret['size'] = conn.get_flavor(node.flavor.id).name
    ret['state'] = node.status
    ret['private_ips'] = _get_ips(node, 'private')
    ret['public_ips'] = _get_ips(node, 'public')
    ret['floating_ips'] = _get_ips(node, 'floating')
    ret['fixed_ips'] = _get_ips(node, 'fixed')
    if isinstance(node.image, six.string_types):
        ret['image'] = node.image
    else:
        ret['image'] = conn.get_image(node.image.id).name
    return ret
879768
def show_storage(kwargs=None, conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_storage function must be called with -f or --function.'
        )

    if not conn:
        conn = get_conn()

    if kwargs is None:
        kwargs = {}

    if 'name' not in kwargs:
        raise SaltCloudSystemExit('A name must be specified as "name"')

    data = conn.get_storage_account_properties(
        kwargs['name'],
    )
    return object_to_dict(data)
432768
def create(vm_=None, call=None):
    '''
    
    '''
    if call:
        raise SaltCloudSystemExit(
            'You cannot create an instance with -a or -f.'
        )

    node_info = request_instance(vm_)
    if isinstance(node_info, bool):
        raise SaltCloudSystemExit(
            'There was an error creating the GCE instance.'
        )
    node_dict = node_info[0]
    node_data = node_info[1]

    ssh_user, ssh_key = __get_ssh_credentials(vm_)
    vm_['ssh_host'] = __get_host(node_data, vm_)
    vm_['key_filename'] = ssh_key

    ret = __utils__['cloud.bootstrap'](vm_, __opts__)

    ret.update(node_dict)

    log.info('Created Cloud VM \'%s\'', vm_['name'])
    log.trace(
        '\'%s\' VM creation details:\n%s',
        vm_['name'], pprint.pformat(node_dict)
    )

    __utils__['cloud.fire_event'](
        'event',
        'created instance',
        'salt/cloud/{0}/created'.format(vm_['name']),
        args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']),
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    return ret