def _mdata():
 grains = {}
 mdata_list = salt.utils.which('mdata-list')
 mdata_get = salt.utils.which('mdata-get')
 grains['hypervisor_uuid'] = __salt__['cmd.run']('{0} sdc:server_uuid'.format(mdata_get))
 if (('FAILURE' in grains['hypervisor_uuid']) or ('No metadata' in grains['hypervisor_uuid'])):
  grains['hypervisor_uuid'] = 'Unknown'
 grains['datacenter'] = __salt__['cmd.run']('{0} sdc:datacenter_name'.format(mdata_get))
 if (('FAILURE' in grains['datacenter']) or ('No metadata' in grains['datacenter'])):
  grains['datacenter'] = 'Unknown'
 for mdata_grain in __salt__['cmd.run'](mdata_list).splitlines():
  grain_data = __salt__['cmd.run']('{0} {1}'.format(mdata_get, mdata_grain))
  if (mdata_grain == 'roles'):
   grain_data = grain_data.split(',')
   grains['roles'] = grain_data
  elif (not mdata_grain.startswith('sdc:')):
   if ('mdata' not in grains):
    grains['mdata'] = {}
   mdata_grain = mdata_grain.replace('-', '_')
   mdata_grain = mdata_grain.replace(':', '_')
   grains['mdata'][mdata_grain] = grain_data
 return grains

def _mdata ( ) : grains = { } mdata_list = salt . utils . which ( 'mdata-list' ) mdata_get = salt . utils . which ( 'mdata-get' ) grains [ 'hypervisor_uuid' ] = __salt__ [ 'cmd.run' ] ( '{0} sdc:server_uuid' . format ( mdata_get ) ) if ( ( 'FAILURE' in grains [ 'hypervisor_uuid' ] ) or ( 'No metadata' in grains [ 'hypervisor_uuid' ] ) ) : grains [ 'hypervisor_uuid' ] = 'Unknown' grains [ 'datacenter' ] = __salt__ [ 'cmd.run' ] ( '{0} sdc:datacenter_name' . format ( mdata_get ) ) if ( ( 'FAILURE' in grains [ 'datacenter' ] ) or ( 'No metadata' in grains [ 'datacenter' ] ) ) : grains [ 'datacenter' ] = 'Unknown' for mdata_grain in __salt__ [ 'cmd.run' ] ( mdata_list ) . splitlines ( ) : grain_data = __salt__ [ 'cmd.run' ] ( '{0} {1}' . format ( mdata_get , mdata_grain ) ) if ( mdata_grain == 'roles' ) : grain_data = grain_data . split ( ',' ) grains [ 'roles' ] = grain_data elif ( not mdata_grain . startswith ( 'sdc:' ) ) : if ( 'mdata' not in grains ) : grains [ 'mdata' ] = { } mdata_grain = mdata_grain . replace ( '-' , '_' ) mdata_grain = mdata_grain . replace ( ':' , '_' ) grains [ 'mdata' ] [ mdata_grain ] = grain_data return grains
provide grains from the smartos metadata .