def create_node(**kwargs):
 name = kwargs['name']
 size = kwargs['size']
 image = kwargs['image']
 location = kwargs['location']
 networks = kwargs.get('networks')
 tag = kwargs.get('tag')
 locality = kwargs.get('locality')
 metadata = kwargs.get('metadata')
 firewall_enabled = kwargs.get('firewall_enabled')
 create_data = {'name': name, 'package': size['name'], 'image': image['name']}
 if (networks is not None):
  create_data['networks'] = networks
 if (locality is not None):
  create_data['locality'] = locality
 if (metadata is not None):
  for (key, value) in metadata.iteritems():
   create_data['metadata.{0}'.format(key)] = value
 if (tag is not None):
  for (key, value) in tag.iteritems():
   create_data['tag.{0}'.format(key)] = value
 if (firewall_enabled is not None):
  create_data['firewall_enabled'] = firewall_enabled
 data = json.dumps(create_data)
 ret = query(command='/my/machines', data=data, method='POST', location=location)
 if (ret[0] in VALID_RESPONSE_CODES):
  return ret[1]
 else:
  log.error('Failed to create node {0}: {1}'.format(name, ret[1]))
 return {}

def create_node ( ** kwargs ) : name = kwargs [ 'name' ] size = kwargs [ 'size' ] image = kwargs [ 'image' ] location = kwargs [ 'location' ] networks = kwargs . get ( 'networks' ) tag = kwargs . get ( 'tag' ) locality = kwargs . get ( 'locality' ) metadata = kwargs . get ( 'metadata' ) firewall_enabled = kwargs . get ( 'firewall_enabled' ) create_data = { 'name' : name , 'package' : size [ 'name' ] , 'image' : image [ 'name' ] } if ( networks is not None ) : create_data [ 'networks' ] = networks if ( locality is not None ) : create_data [ 'locality' ] = locality if ( metadata is not None ) : for ( key , value ) in metadata . iteritems ( ) : create_data [ 'metadata.{0}' . format ( key ) ] = value if ( tag is not None ) : for ( key , value ) in tag . iteritems ( ) : create_data [ 'tag.{0}' . format ( key ) ] = value if ( firewall_enabled is not None ) : create_data [ 'firewall_enabled' ] = firewall_enabled data = json . dumps ( create_data ) ret = query ( command = '/my/machines' , data = data , method = 'POST' , location = location ) if ( ret [ 0 ] in VALID_RESPONSE_CODES ) : return ret [ 1 ] else : log . error ( 'Failed to create node {0}: {1}' . format ( name , ret [ 1 ] ) ) return { }
create a node .