<s> """<STR_LIT>""" <EOL> import json <EOL> import xml . etree . ElementTree as ET <EOL> from cafe . engine . models . base import AutoMarshallingModel <EOL> from cloudcafe . compute . common . constants import Constants <EOL> from cloudcafe . compute . common . models . metadata import Metadata <EOL> class CreateServer ( AutoMarshallingModel ) : <EOL> def __init__ ( self , name , image_ref , flavor_ref , admin_pass = None , <EOL> disk_config = None , metadata = None , personality = None , <EOL> block_device_mapping = None , user_data = None , accessIPv4 = None , <EOL> accessIPv6 = None , networks = None , key_name = None , <EOL> config_drive = None , scheduler_hints = None , <EOL> security_groups = None ) : <EOL> super ( CreateServer , self ) . __init__ ( ) <EOL> self . name = name <EOL> self . image_ref = image_ref <EOL> self . flavor_ref = flavor_ref <EOL> self . disk_config = disk_config <EOL> self . admin_pass = admin_pass <EOL> self . metadata = metadata <EOL> self . personality = personality <EOL> self . block_device_mapping = block_device_mapping <EOL> self . user_data = user_data <EOL> self . accessIPv4 = accessIPv4 <EOL> self . accessIPv6 = accessIPv6 <EOL> self . networks = networks <EOL> self . key_name = key_name <EOL> self . config_drive = config_drive <EOL> self . scheduler_hints = scheduler_hints <EOL> self . security_groups = security_groups <EOL> def _obj_to_json ( self ) : <EOL> if self . personality == [ ] : <EOL> self . personality = None <EOL> body = { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT>' : self . image_ref , <EOL> '<STR_LIT>' : self . flavor_ref , <EOL> '<STR_LIT>' : self . disk_config , <EOL> '<STR_LIT>' : self . admin_pass , <EOL> '<STR_LIT>' : self . metadata , <EOL> '<STR_LIT>' : self . accessIPv4 , <EOL> '<STR_LIT>' : self . accessIPv6 , <EOL> '<STR_LIT>' : self . personality , <EOL> '<STR_LIT>' : self . block_device_mapping , <EOL> '<STR_LIT>' : self . user_data , <EOL> '<STR_LIT>' : self . networks , <EOL> '<STR_LIT>' : self . key_name , <EOL> '<STR_LIT>' : self . config_drive , <EOL> '<STR_LIT>' : self . security_groups <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> main_body = { '<STR_LIT>' : body } <EOL> if self . scheduler_hints : <EOL> main_body [ '<STR_LIT>' ] = self . scheduler_hints <EOL> return json . dumps ( main_body ) <EOL> def _obj_to_xml ( self ) : <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> xml = Constants . XML_HEADER <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT:name>' , self . name ) <EOL> element . set ( '<STR_LIT>' , self . image_ref ) <EOL> element . set ( '<STR_LIT>' , self . flavor_ref ) <EOL> if self . admin_pass is not None : <EOL> element . set ( '<STR_LIT>' , self . admin_pass ) <EOL> if self . disk_config is not None : <EOL> element . set ( '<STR_LIT>' , <EOL> Constants . XML_API_DISK_CONFIG_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , self . disk_config ) <EOL> if self . metadata is not None : <EOL> meta_ele = ET . Element ( '<STR_LIT>' ) <EOL> for key , value in self . metadata . items ( ) : <EOL> meta_ele . append ( Metadata . _dict_to_xml ( key , value ) ) <EOL> element . append ( meta_ele ) <EOL> if self . networks is not None : <EOL> networks_ele = ET . Element ( '<STR_LIT>' ) <EOL> for network_id in self . networks : <EOL> network = ET . Element ( '<STR_LIT>' ) <EOL> network . set ( '<STR_LIT>' , network_id [ '<STR_LIT>' ] ) <EOL> networks_ele . append ( network ) <EOL> element . append ( networks_ele ) <EOL> if self . personality is not None : <EOL> personality_ele = ET . Element ( '<STR_LIT>' ) <EOL> personality_ele . append ( Personality . _obj_to_xml ( self . personality ) ) <EOL> element . append ( personality_ele ) <EOL> if self . block_device_mapping is not None : <EOL> block_device_ele = ET . Element ( '<STR_LIT>' ) <EOL> block_device_ele . append ( BlockDeviceMapping . _obj_to_xml ( <EOL> self . block_device_mapping ) ) <EOL> element . append ( block_device_ele ) <EOL> if self . user_data is not None : <EOL> element . set ( '<STR_LIT>' , self . user_data ) <EOL> if self . accessIPv4 is not None : <EOL> element . set ( '<STR_LIT>' , self . accessIPv4 ) <EOL> if self . accessIPv6 is not None : <EOL> element . set ( '<STR_LIT>' , self . accessIPv6 ) <EOL> if self . key_name is not None : <EOL> element . set ( '<STR_LIT>' , self . key_name ) <EOL> if self . config_drive is not None : <EOL> element . set ( '<STR_LIT>' , self . config_drive ) <EOL> if self . scheduler_hints is not None : <EOL> hints_ele = ET . Element ( '<STR_LIT>' ) <EOL> for key , value in self . metadata . iteritems ( ) : <EOL> meta_element = ET . Element ( key ) <EOL> meta_element . text = value <EOL> hints_ele . append ( meta_element ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class UpdateServer ( AutoMarshallingModel ) : <EOL> def __init__ ( self , name = None , metadata = None , <EOL> accessIPv4 = None , accessIPv6 = None ) : <EOL> super ( UpdateServer , self ) . __init__ ( ) <EOL> self . name = name <EOL> self . metadata = metadata <EOL> self . accessIPv4 = accessIPv4 <EOL> self . accessIPv6 = accessIPv6 <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT>' : self . metadata , <EOL> '<STR_LIT>' : self . accessIPv4 , <EOL> '<STR_LIT>' : self . accessIPv6 , <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> xml = Constants . XML_HEADER <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> if self . name is not None : <EOL> element . set ( '<STR_LIT:name>' , self . name ) <EOL> if self . metadata is not None : <EOL> meta_ele = ET . Element ( '<STR_LIT>' ) <EOL> for key , value in self . metadata . items ( ) : <EOL> meta_ele . append ( Metadata . _dict_to_xml ( key , value ) ) <EOL> element . append ( meta_ele ) <EOL> if self . accessIPv4 is not None : <EOL> element . set ( '<STR_LIT>' , self . accessIPv4 ) <EOL> if self . accessIPv6 is not None : <EOL> element . set ( '<STR_LIT>' , self . accessIPv6 ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Reboot ( AutoMarshallingModel ) : <EOL> def __init__ ( self , reboot_type ) : <EOL> super ( Reboot , self ) . __init__ ( ) <EOL> self . type = reboot_type <EOL> def _obj_to_json ( self ) : <EOL> body = { '<STR_LIT:type>' : self . type } <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT:type>' , self . type ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Personality ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> ROOT_TAG = '<STR_LIT>' <EOL> def __init__ ( self , type ) : <EOL> super ( Personality , self ) . __init__ ( ) <EOL> self . type = type <EOL> @ classmethod <EOL> def _obj_to_json ( self ) : <EOL> ret = self . _auto_to_dict ( ) <EOL> return json . dumps ( ret ) <EOL> @ classmethod <EOL> def _obj_to_xml ( self , list_dicts ) : <EOL> for pers_dict in list_dicts : <EOL> pers_element = ET . Element ( '<STR_LIT:file>' ) <EOL> pers_element . set ( '<STR_LIT:path>' , pers_dict . get ( '<STR_LIT:path>' ) ) <EOL> pers_element . text = pers_dict . get ( '<STR_LIT>' ) <EOL> return pers_element <EOL> class BlockDeviceMapping ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> ROOT_TAG = '<STR_LIT>' <EOL> def __init__ ( self , volume_id , delete_on_termination , device_name , <EOL> size = None , type = None ) : <EOL> super ( BlockDeviceMapping , self ) . __init__ ( ) <EOL> self . volume_id = volume_id <EOL> self . delete_on_termination = delete_on_termination <EOL> self . device_name = device_name <EOL> self . size = size <EOL> self . type = type <EOL> @ classmethod <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT>' : self . volume_id , <EOL> '<STR_LIT>' : self . delete_on_termination , <EOL> '<STR_LIT>' : self . device_name , <EOL> '<STR_LIT:size>' : self . size , <EOL> '<STR_LIT:type>' : self . type <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> @ classmethod <EOL> def _obj_to_xml ( self , list_dicts ) : <EOL> for pers_dict in list_dicts : <EOL> pers_element = ET . Element ( '<STR_LIT>' ) <EOL> pers_element . set ( '<STR_LIT>' , pers_dict . get ( '<STR_LIT>' ) ) <EOL> pers_element . set ( '<STR_LIT>' , <EOL> pers_dict . get ( '<STR_LIT>' ) ) <EOL> pers_element . set ( '<STR_LIT>' , pers_dict . get ( '<STR_LIT>' ) ) <EOL> if pers_dict . get ( '<STR_LIT:size>' ) is not None : <EOL> pers_element . set ( '<STR_LIT:size>' , pers_dict . get ( '<STR_LIT:size>' ) ) <EOL> if pers_dict . get ( '<STR_LIT:type>' ) is not None : <EOL> pers_element . set ( '<STR_LIT:type>' , pers_dict . get ( '<STR_LIT:type>' ) ) <EOL> return pers_element <EOL> class Rebuild ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , image_ref , admin_pass = None , <EOL> disk_config = None , metadata = None , personality = None , <EOL> block_device_mapping = None , user_data = None , accessIPv4 = None , <EOL> accessIPv6 = None , networks = None , key_name = None , <EOL> config_drive = None , security_groups = None ) : <EOL> super ( Rebuild , self ) . __init__ ( ) <EOL> self . name = name <EOL> self . image_ref = image_ref <EOL> self . disk_config = disk_config <EOL> self . admin_pass = admin_pass <EOL> self . metadata = metadata <EOL> self . personality = personality <EOL> self . block_device_mapping = block_device_mapping <EOL> self . user_data = user_data <EOL> self . accessIPv4 = accessIPv4 <EOL> self . accessIPv6 = accessIPv6 <EOL> self . networks = networks <EOL> self . key_name = key_name <EOL> self . config_drive = config_drive <EOL> self . security_groups = security_groups <EOL> def _obj_to_json ( self ) : <EOL> if self . personality == [ ] : <EOL> self . personality = None <EOL> body = { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT>' : self . image_ref , <EOL> '<STR_LIT>' : self . disk_config , <EOL> '<STR_LIT>' : self . admin_pass , <EOL> '<STR_LIT>' : self . metadata , <EOL> '<STR_LIT>' : self . accessIPv4 , <EOL> '<STR_LIT>' : self . accessIPv6 , <EOL> '<STR_LIT>' : self . personality , <EOL> '<STR_LIT>' : self . block_device_mapping , <EOL> '<STR_LIT>' : self . user_data , <EOL> '<STR_LIT>' : self . networks , <EOL> '<STR_LIT>' : self . key_name , <EOL> '<STR_LIT>' : self . config_drive , <EOL> '<STR_LIT>' : self . security_groups <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> xml = Constants . XML_HEADER <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT:name>' , self . name ) <EOL> element . set ( '<STR_LIT>' , self . image_ref ) <EOL> if self . admin_pass is not None : <EOL> element . set ( '<STR_LIT>' , self . admin_pass ) <EOL> if self . disk_config is not None : <EOL> element . set ( '<STR_LIT>' , <EOL> Constants . XML_API_DISK_CONFIG_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , self . disk_config ) <EOL> if self . metadata is not None : <EOL> meta_ele = ET . Element ( '<STR_LIT>' ) <EOL> for key , value in self . metadata . items ( ) : <EOL> meta_ele . append ( Metadata . _dict_to_xml ( key , value ) ) <EOL> element . append ( meta_ele ) <EOL> if self . networks is not None : <EOL> networks_ele = ET . Element ( '<STR_LIT>' ) <EOL> for network_id in self . networks : <EOL> network = ET . Element ( '<STR_LIT>' ) <EOL> network . set ( '<STR_LIT>' , network_id [ '<STR_LIT>' ] ) <EOL> networks_ele . append ( network ) <EOL> element . append ( networks_ele ) <EOL> if self . personality is not None : <EOL> personality_ele = ET . Element ( '<STR_LIT>' ) <EOL> personality_ele . append ( Personality . _obj_to_xml ( self . personality ) ) <EOL> element . append ( personality_ele ) <EOL> if self . block_device_mapping is not None : <EOL> block_device_ele = ET . Element ( '<STR_LIT>' ) <EOL> block_device_ele . append ( BlockDeviceMapping . _obj_to_xml ( <EOL> self . block_device_mapping ) ) <EOL> element . append ( block_device_ele ) <EOL> if self . user_data is not None : <EOL> element . set ( '<STR_LIT>' , self . user_data ) <EOL> if self . accessIPv4 is not None : <EOL> element . set ( '<STR_LIT>' , self . accessIPv4 ) <EOL> if self . accessIPv6 is not None : <EOL> element . set ( '<STR_LIT>' , self . accessIPv6 ) <EOL> if self . key_name is not None : <EOL> element . set ( '<STR_LIT>' , self . key_name ) <EOL> if self . config_drive is not None : <EOL> element . set ( '<STR_LIT>' , self . config_drive ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Resize ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , flavor_ref , disk_config = None ) : <EOL> super ( Resize , self ) . __init__ ( ) <EOL> self . flavor_ref = flavor_ref <EOL> self . disk_config = disk_config <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT>' : self . flavor_ref , <EOL> '<STR_LIT>' : self . disk_config <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , self . flavor_ref ) <EOL> if self . disk_config is not None : <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , self . disk_config ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class ResetState ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , state ) : <EOL> super ( ResetState , self ) . __init__ ( ) <EOL> self . state = state <EOL> def _obj_to_json ( self ) : <EOL> body = { '<STR_LIT:state>' : self . state } <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT:state>' , self . state ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class ConfirmResize ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class RevertResize ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class MigrateServer ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class LiveMigrateServer ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , disk_over_commit = None , <EOL> block_migration = None , host = None ) : <EOL> super ( LiveMigrateServer , self ) . __init__ ( ) <EOL> self . disk_over_commit = disk_over_commit <EOL> self . block_migration = block_migration <EOL> self . host = host <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT>' : self . disk_over_commit , <EOL> '<STR_LIT>' : self . block_migration , <EOL> '<STR_LIT:host>' : self . host <EOL> } <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , self . disk_over_commit ) <EOL> element . set ( '<STR_LIT>' , self . block_migration ) <EOL> element . set ( '<STR_LIT:host>' , self . host ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class ConfirmServerMigration ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Lock ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Unlock ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Start ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Stop ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Suspend ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Resume ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Pause ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class Unpause ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def _obj_to_json ( self ) : <EOL> return json . dumps ( { '<STR_LIT>' : { } } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class CreateImage ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , metadata = None ) : <EOL> super ( CreateImage , self ) . __init__ ( ) <EOL> self . name = name <EOL> self . metadata = metadata <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT>' : self . metadata <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> element . set ( '<STR_LIT:name>' , self . name ) <EOL> if self . metadata is not None : <EOL> meta_ele = ET . Element ( '<STR_LIT>' ) <EOL> for key , value in self . metadata . items ( ) : <EOL> meta_ele . append ( Metadata . _dict_to_xml ( key , value ) ) <EOL> element . append ( meta_ele ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class CreateBackup ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , backup_type , backup_rotation , metadata = None ) : <EOL> super ( CreateBackup , self ) . __init__ ( ) <EOL> self . name = name <EOL> self . backup_type = backup_type <EOL> self . rotation = backup_rotation <EOL> self . metadata = metadata <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT:name>' : self . name , <EOL> '<STR_LIT>' : self . backup_type , <EOL> '<STR_LIT>' : self . rotation , <EOL> '<STR_LIT>' : self . metadata <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( self . ROOT_TAG ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_ATOM_NAMESPACE ) <EOL> element . set ( '<STR_LIT:name>' , self . name ) <EOL> element . set ( '<STR_LIT>' , self . backup_type ) <EOL> element . set ( '<STR_LIT>' , self . rotation ) <EOL> if self . metadata is not None : <EOL> meta_ele = ET . Element ( '<STR_LIT>' ) <EOL> for key , value in self . metadata . items ( ) : <EOL> meta_ele . append ( Metadata . _dict_to_xml ( key , value ) ) <EOL> element . append ( meta_ele ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class ChangePassword ( AutoMarshallingModel ) : <EOL> def __init__ ( self , admin_password ) : <EOL> super ( ChangePassword , self ) . __init__ ( ) <EOL> self . admin_pass = admin_password <EOL> def _obj_to_json ( self ) : <EOL> body = { '<STR_LIT>' : self . admin_pass } <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( self . ROOT_TAG ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT>' , self . admin_pass ) <EOL> xml += ET . tostring ( element ) <EOL> return xml <EOL> class AddFixedIP ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , network_id ) : <EOL> super ( AddFixedIP , self ) . __init__ ( ) <EOL> self . network_id = network_id <EOL> def _obj_to_json ( self ) : <EOL> body = { '<STR_LIT>' : self . network_id } <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> class RemoveFixedIP ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , network_id ) : <EOL> super ( RemoveFixedIP , self ) . __init__ ( ) <EOL> self . network_id = network_id <EOL> def _obj_to_json ( self ) : <EOL> body = { '<STR_LIT>' : self . network_id } <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> class AddSecurityGroup ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name ) : <EOL> super ( AddSecurityGroup , self ) . __init__ ( ) <EOL> self . name = name <EOL> def _obj_to_json ( self ) : <EOL> json_dict = { "<STR_LIT:name>" : self . name } <EOL> return json . dumps ( { '<STR_LIT>' : json_dict } ) <EOL> def _obj_to_xml ( self ) : <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> name_ele = ET . Element ( '<STR_LIT:name>' ) <EOL> name_ele . text = self . name <EOL> element . append ( name_ele ) <EOL> xml = ET . tostring ( element ) <EOL> return xml <EOL> class Evacuate ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , host , on_shared_storage = None , admin_pass = None , <EOL> metadata = None ) : <EOL> super ( Evacuate , self ) . __init__ ( ) <EOL> self . host = host <EOL> self . on_shared_storage = on_shared_storage <EOL> self . admin_pass = admin_pass <EOL> self . metadata = metadata <EOL> def _obj_to_json ( self ) : <EOL> body = { <EOL> '<STR_LIT:host>' : self . host , <EOL> '<STR_LIT>' : self . on_shared_storage , <EOL> '<STR_LIT>' : self . admin_pass , <EOL> '<STR_LIT>' : self . metadata <EOL> } <EOL> body = self . _remove_empty_values ( body ) <EOL> return json . dumps ( { '<STR_LIT>' : body } ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( '<STR_LIT>' ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> element . set ( '<STR_LIT:host>' , self . host ) <EOL> if self . admin_pass is not None : <EOL> element . set ( '<STR_LIT>' , self . admin_pass ) <EOL> if self . metadata is not None : <EOL> element . set ( '<STR_LIT>' , self . metadata ) <EOL> if self . on_shared_storage is not None : <EOL> element . set ( '<STR_LIT>' , self . on_shared_storage ) <EOL> xml += ET . tostring ( element ) <EOL> return xml </s>
