def extract_flavor(instance, prefix=''):
 flavor = objects.Flavor()
 sys_meta = utils.instance_sys_meta(instance)
 if (not sys_meta):
  return None
 for key in system_metadata_flavor_props.keys():
  type_key = ('%sinstance_type_%s' % (prefix, key))
  setattr(flavor, key, sys_meta[type_key])
 extra_specs = [(k, v) for (k, v) in sys_meta.items() if k.startswith(('%sinstance_type_extra_' % prefix))]
 if extra_specs:
  flavor.extra_specs = {}
  for (key, value) in extra_specs:
   extra_key = key[len(('%sinstance_type_extra_' % prefix)):]
   flavor.extra_specs[extra_key] = value
 return flavor

def extract_flavor ( instance , prefix = '' ) : flavor = objects . Flavor ( ) sys_meta = utils . instance_sys_meta ( instance ) if ( not sys_meta ) : return None for key in system_metadata_flavor_props . keys ( ) : type_key = ( '%sinstance_type_%s' % ( prefix , key ) ) setattr ( flavor , key , sys_meta [ type_key ] ) extra_specs = [ ( k , v ) for ( k , v ) in sys_meta . items ( ) if k . startswith ( ( '%sinstance_type_extra_' % prefix ) ) ] if extra_specs : flavor . extra_specs = { } for ( key , value ) in extra_specs : extra_key = key [ len ( ( '%sinstance_type_extra_' % prefix ) ) : ] flavor . extra_specs [ extra_key ] = value return flavor
create a flavor object from instances system_metadata information .