<s> """<STR_LIT>""" <EOL> import oslo_messaging as messaging <EOL> from oslo_serialization import jsonutils <EOL> from oslo_versionedobjects import base as ovo_base <EOL> import nova . conf <EOL> from nova . objects import base as objects_base <EOL> from nova import rpc <EOL> CONF = nova . conf . CONF <EOL> class ConductorAPI ( object ) : <EOL> """<STR_LIT>""" <EOL> VERSION_ALIASES = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def __init__ ( self ) : <EOL> super ( ConductorAPI , self ) . __init__ ( ) <EOL> target = messaging . Target ( topic = CONF . conductor . topic , version = '<STR_LIT>' ) <EOL> version_cap = self . VERSION_ALIASES . get ( CONF . upgrade_levels . conductor , <EOL> CONF . upgrade_levels . conductor ) <EOL> serializer = objects_base . NovaObjectSerializer ( ) <EOL> self . client = rpc . get_client ( target , <EOL> version_cap = version_cap , <EOL> serializer = serializer ) <EOL> def object_class_action ( self , context , objname , objmethod , objver , <EOL> args , kwargs ) : <EOL> versions = ovo_base . obj_tree_get_versions ( objname ) <EOL> return self . object_class_action_versions ( context , <EOL> objname , <EOL> objmethod , <EOL> versions , <EOL> args , kwargs ) <EOL> def object_class_action_versions ( self , context , objname , objmethod , <EOL> object_versions , args , kwargs ) : <EOL> cctxt = self . client . prepare ( ) <EOL> return cctxt . call ( context , '<STR_LIT>' , <EOL> objname = objname , objmethod = objmethod , <EOL> object_versions = object_versions , <EOL> args = args , kwargs = kwargs ) <EOL> def object_action ( self , context , objinst , objmethod , args , kwargs ) : <EOL> cctxt = self . client . prepare ( ) <EOL> return cctxt . call ( context , '<STR_LIT>' , objinst = objinst , <EOL> objmethod = objmethod , args = args , kwargs = kwargs ) <EOL> def object_backport_versions ( self , context , objinst , object_versions ) : <EOL> cctxt = self . client . prepare ( ) <EOL> return cctxt . call ( context , '<STR_LIT>' , objinst = objinst , <EOL> object_versions = object_versions ) <EOL> class ComputeTaskAPI ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( ComputeTaskAPI , self ) . __init__ ( ) <EOL> target = messaging . Target ( topic = CONF . conductor . topic , <EOL> namespace = '<STR_LIT>' , <EOL> version = '<STR_LIT:1.0>' ) <EOL> serializer = objects_base . NovaObjectSerializer ( ) <EOL> self . client = rpc . get_client ( target , serializer = serializer ) <EOL> def migrate_server ( self , context , instance , scheduler_hint , live , rebuild , <EOL> flavor , block_migration , disk_over_commit , <EOL> reservations = None , clean_shutdown = True , request_spec = None ) : <EOL> kw = { '<STR_LIT>' : instance , '<STR_LIT>' : scheduler_hint , <EOL> '<STR_LIT>' : live , '<STR_LIT>' : rebuild , '<STR_LIT>' : flavor , <EOL> '<STR_LIT>' : block_migration , <EOL> '<STR_LIT>' : disk_over_commit , <EOL> '<STR_LIT>' : reservations , <EOL> '<STR_LIT>' : clean_shutdown , <EOL> '<STR_LIT>' : request_spec , <EOL> } <EOL> version = '<STR_LIT>' <EOL> if not self . client . can_send_version ( version ) : <EOL> del kw [ '<STR_LIT>' ] <EOL> version = '<STR_LIT>' <EOL> if not self . client . can_send_version ( version ) : <EOL> del kw [ '<STR_LIT>' ] <EOL> version = '<STR_LIT>' <EOL> if not self . client . can_send_version ( version ) : <EOL> kw [ '<STR_LIT>' ] = objects_base . obj_to_primitive ( flavor ) <EOL> version = '<STR_LIT>' <EOL> if not self . client . can_send_version ( version ) : <EOL> kw [ '<STR_LIT>' ] = jsonutils . to_primitive ( <EOL> objects_base . obj_to_primitive ( instance ) ) <EOL> version = '<STR_LIT>' <EOL> cctxt = self . client . prepare ( version = version ) <EOL> return cctxt . call ( context , '<STR_LIT>' , ** kw ) <EOL> def build_instances ( self , context , instances , image , filter_properties , <EOL> admin_password , injected_files , requested_networks , <EOL> security_groups , block_device_mapping , legacy_bdm = True ) : <EOL> image_p = jsonutils . to_primitive ( image ) <EOL> version = '<STR_LIT>' <EOL> if not self . client . can_send_version ( version ) : <EOL> version = '<STR_LIT>' <EOL> if '<STR_LIT>' in filter_properties : <EOL> flavor = filter_properties [ '<STR_LIT>' ] <EOL> flavor_p = objects_base . obj_to_primitive ( flavor ) <EOL> filter_properties = dict ( filter_properties , <EOL> instance_type = flavor_p ) <EOL> kw = { '<STR_LIT>' : instances , '<STR_LIT:image>' : image_p , <EOL> '<STR_LIT>' : filter_properties , <EOL> '<STR_LIT>' : admin_password , <EOL> '<STR_LIT>' : injected_files , <EOL> '<STR_LIT>' : requested_networks , <EOL> '<STR_LIT>' : security_groups } <EOL> if not self . client . can_send_version ( version ) : <EOL> version = '<STR_LIT>' <EOL> kw [ '<STR_LIT>' ] = kw [ '<STR_LIT>' ] . as_tuples ( ) <EOL> if not self . client . can_send_version ( '<STR_LIT>' ) : <EOL> version = '<STR_LIT>' <EOL> bdm_p = objects_base . obj_to_primitive ( block_device_mapping ) <EOL> kw . update ( { '<STR_LIT>' : bdm_p , <EOL> '<STR_LIT>' : legacy_bdm } ) <EOL> cctxt = self . client . prepare ( version = version ) <EOL> cctxt . cast ( context , '<STR_LIT>' , ** kw ) <EOL> def unshelve_instance ( self , context , instance , request_spec = None ) : <EOL> version = '<STR_LIT>' <EOL> kw = { '<STR_LIT>' : instance , <EOL> '<STR_LIT>' : request_spec <EOL> } <EOL> if not self . client . can_send_version ( version ) : <EOL> version = '<STR_LIT>' <EOL> del kw [ '<STR_LIT>' ] <EOL> cctxt = self . client . prepare ( version = version ) <EOL> cctxt . cast ( context , '<STR_LIT>' , ** kw ) <EOL> def rebuild_instance ( self , ctxt , instance , new_pass , injected_files , <EOL> image_ref , orig_image_ref , orig_sys_metadata , bdms , <EOL> recreate = False , on_shared_storage = False , host = None , <EOL> preserve_ephemeral = False , request_spec = None , kwargs = None ) : <EOL> version = '<STR_LIT>' <EOL> kw = { '<STR_LIT>' : instance , <EOL> '<STR_LIT>' : new_pass , <EOL> '<STR_LIT>' : injected_files , <EOL> '<STR_LIT>' : image_ref , <EOL> '<STR_LIT>' : orig_image_ref , <EOL> '<STR_LIT>' : orig_sys_metadata , <EOL> '<STR_LIT>' : bdms , <EOL> '<STR_LIT>' : recreate , <EOL> '<STR_LIT>' : on_shared_storage , <EOL> '<STR_LIT>' : preserve_ephemeral , <EOL> '<STR_LIT:host>' : host , <EOL> '<STR_LIT>' : request_spec , <EOL> } <EOL> if not self . client . can_send_version ( version ) : <EOL> version = '<STR_LIT>' <EOL> del kw [ '<STR_LIT>' ] <EOL> cctxt = self . client . prepare ( version = version ) <EOL> cctxt . cast ( ctxt , '<STR_LIT>' , ** kw ) </s>
