def show_pricing(kwargs=None, call=None):
 profile = __opts__['profiles'].get(kwargs['profile'], {})
 if (not profile):
  return {'Error': 'The requested profile was not found'}
 provider = profile.get('provider', '0:0')
 comps = provider.split(':')
 if ((len(comps) < 2) or (comps[1] != 'gce')):
  return {'Error': 'The requested profile does not belong to GCE'}
 comps = profile.get('location', 'us').split('-')
 region = comps[0]
 size = 'CP-COMPUTEENGINE-VMIMAGE-{0}'.format(profile['size'].upper())
 pricefile = os.path.join(__opts__['cachedir'], 'gce-pricing.p')
 if (not os.path.exists(pricefile)):
  update_pricing()
 with salt.utils.fopen(pricefile, 'r') as fho:
  sizes = msgpack.load(fho)
 per_hour = float(sizes['gcp_price_list'][size][region])
 week1_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.25'])
 week2_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.50'])
 week3_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['0.75'])
 week4_discount = float(sizes['gcp_price_list']['sustained_use_tiers']['1.0'])
 week1 = ((per_hour * (730 / 4)) * week1_discount)
 week2 = ((per_hour * (730 / 4)) * week2_discount)
 week3 = ((per_hour * (730 / 4)) * week3_discount)
 week4 = ((per_hour * (730 / 4)) * week4_discount)
 raw = sizes
 ret = {}
 ret['per_hour'] = per_hour
 ret['per_day'] = (ret['per_hour'] * 24)
 ret['per_week'] = (ret['per_day'] * 7)
 ret['per_month'] = (((week1 + week2) + week3) + week4)
 ret['per_year'] = (ret['per_month'] * 12)
 if kwargs.get('raw', False):
  ret['_raw'] = raw
 return {profile['profile']: ret}

def show_pricing ( kwargs = None , call = None ) : profile = __opts__ [ 'profiles' ] . get ( kwargs [ 'profile' ] , { } ) if ( not profile ) : return { 'Error' : 'The requested profile was not found' } provider = profile . get ( 'provider' , '0:0' ) comps = provider . split ( ':' ) if ( ( len ( comps ) < 2 ) or ( comps [ 1 ] != 'gce' ) ) : return { 'Error' : 'The requested profile does not belong to GCE' } comps = profile . get ( 'location' , 'us' ) . split ( '-' ) region = comps [ 0 ] size = 'CP-COMPUTEENGINE-VMIMAGE-{0}' . format ( profile [ 'size' ] . upper ( ) ) pricefile = os . path . join ( __opts__ [ 'cachedir' ] , 'gce-pricing.p' ) if ( not os . path . exists ( pricefile ) ) : update_pricing ( ) with salt . utils . fopen ( pricefile , 'r' ) as fho : sizes = msgpack . load ( fho ) per_hour = float ( sizes [ 'gcp_price_list' ] [ size ] [ region ] ) week1_discount = float ( sizes [ 'gcp_price_list' ] [ 'sustained_use_tiers' ] [ '0.25' ] ) week2_discount = float ( sizes [ 'gcp_price_list' ] [ 'sustained_use_tiers' ] [ '0.50' ] ) week3_discount = float ( sizes [ 'gcp_price_list' ] [ 'sustained_use_tiers' ] [ '0.75' ] ) week4_discount = float ( sizes [ 'gcp_price_list' ] [ 'sustained_use_tiers' ] [ '1.0' ] ) week1 = ( ( per_hour * ( 730 / 4 ) ) * week1_discount ) week2 = ( ( per_hour * ( 730 / 4 ) ) * week2_discount ) week3 = ( ( per_hour * ( 730 / 4 ) ) * week3_discount ) week4 = ( ( per_hour * ( 730 / 4 ) ) * week4_discount ) raw = sizes ret = { } ret [ 'per_hour' ] = per_hour ret [ 'per_day' ] = ( ret [ 'per_hour' ] * 24 ) ret [ 'per_week' ] = ( ret [ 'per_day' ] * 7 ) ret [ 'per_month' ] = ( ( ( week1 + week2 ) + week3 ) + week4 ) ret [ 'per_year' ] = ( ret [ 'per_month' ] * 12 ) if kwargs . get ( 'raw' , False ) : ret [ '_raw' ] = raw return { profile [ 'profile' ] : ret }
show pricing for a particular profile .