idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
43,500
def _plot_methods ( self ) : ret = { } for attr in filter ( lambda s : not s . startswith ( "_" ) , dir ( self ) ) : obj = getattr ( self , attr ) if isinstance ( obj , PlotterInterface ) : ret [ attr ] = obj . _summary return ret
A dictionary with mappings from plot method to their summary
43,501
def show_plot_methods ( self ) : print_func = PlotterInterface . _print_func if print_func is None : print_func = six . print_ s = "\n" . join ( "%s\n %s" % t for t in six . iteritems ( self . _plot_methods ) ) return print_func ( s )
Print the plotmethods of this instance
43,502
def _register_plotter ( cls , identifier , module , plotter_name , plotter_cls = None , summary = '' , prefer_list = False , default_slice = None , default_dims = { } , show_examples = True , example_call = "filename, name=['my_variable'], ..." , plugin = None ) : full_name = '%s.%s' % ( module , plotter_name ) if plot...
Register a plotter for making plots
43,503
def plotter_cls ( self ) : ret = self . _plotter_cls if ret is None : self . _logger . debug ( 'importing %s' , self . module ) mod = import_module ( self . module ) plotter = self . plotter_name if plotter not in vars ( mod ) : raise ImportError ( "Module %r does not have a %r plotter!" % ( mod , plotter ) ) ret = sel...
The plotter class
43,504
def _add_data ( self , plotter_cls , * args , ** kwargs ) : return super ( DatasetPlotter , self ) . _add_data ( plotter_cls , self . _ds , * args , ** kwargs )
Add new plots to the project
43,505
def check_data ( self , * args , ** kwargs ) : plotter_cls = self . plotter_cls da_list = self . _project_plotter . _da . psy . to_interactive_list ( ) return plotter_cls . check_data ( da_list . all_names , da_list . all_dims , da_list . is_unstructured )
Check whether the plotter of this plot method can visualize the data
43,506
def _add_data ( self , plotter_cls , * args , ** kwargs ) : return plotter_cls ( self . _da , * args , ** kwargs )
Visualize this data array
43,507
def yaml_from_file ( self , fpath ) : lookup = self . _load_param_file ( fpath ) if not lookup : return content = "\n" . join ( self . content ) parsed = yaml . safe_load ( content ) new_content = list ( ) for paramlist in parsed : if not isinstance ( paramlist , dict ) : self . app . warn ( ( "Invalid parameter defini...
Collect Parameter stanzas from inline + file .
43,508
def get_libsodium ( ) : __SONAMES = ( 13 , 10 , 5 , 4 ) sys_sodium = ctypes . util . find_library ( 'sodium' ) if sys_sodium is None : sys_sodium = ctypes . util . find_library ( 'libsodium' ) if sys_sodium : try : return ctypes . CDLL ( sys_sodium ) except OSError : pass if sys . platform . startswith ( 'win' ) : try ...
Locate the libsodium C library
43,509
def main ( args = None ) : try : from psyplot_gui import get_parser as _get_parser except ImportError : logger . debug ( 'Failed to import gui' , exc_info = True ) parser = get_parser ( create = False ) parser . update_arg ( 'output' , required = True ) parser . create_arguments ( ) parser . parse2func ( args ) else : ...
Main function for usage of psyplot from the command line
43,510
def make_plot ( fnames = [ ] , name = [ ] , dims = None , plot_method = None , output = None , project = None , engine = None , formatoptions = None , tight = False , rc_file = None , encoding = None , enable_post = False , seaborn_style = None , output_project = None , concat_dim = get_default_value ( xr . open_mfdata...
Eventually start the QApplication or only make a plot
43,511
def check_key ( key , possible_keys , raise_error = True , name = 'formatoption keyword' , msg = ( "See show_fmtkeys function for possible formatopion " "keywords" ) , * args , ** kwargs ) : if key not in possible_keys : similarkeys = get_close_matches ( key , possible_keys , * args , ** kwargs ) if similarkeys : msg =...
Checks whether the key is in a list of possible keys
43,512
def sort_kwargs ( kwargs , * param_lists ) : return chain ( ( { key : kwargs . pop ( key ) for key in params . intersection ( kwargs ) } for params in map ( set , param_lists ) ) , [ kwargs ] )
Function to sort keyword arguments and sort them into dictionaries
43,513
def hashable ( val ) : if val is None : return val try : hash ( val ) except TypeError : return repr ( val ) else : return val
Test if val is hashable and if not get it s string representation
43,514
def join_dicts ( dicts , delimiter = None , keep_all = False ) : if not dicts : return { } if keep_all : all_keys = set ( chain ( * ( d . keys ( ) for d in dicts ) ) ) else : all_keys = set ( dicts [ 0 ] ) for d in dicts [ 1 : ] : all_keys . intersection_update ( d ) ret = { } for key in all_keys : vals = { hashable ( ...
Join multiple dictionaries into one
43,515
def check_guest_exist ( check_index = 0 ) : def outer ( f ) : @ six . wraps ( f ) def inner ( self , * args , ** kw ) : userids = args [ check_index ] if isinstance ( userids , list ) : userids = [ uid . upper ( ) for uid in userids ] new_args = ( args [ : check_index ] + ( userids , ) + args [ check_index + 1 : ] ) el...
Check guest exist in database .
43,516
def guest_start ( self , userid ) : action = "start guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . guest_start ( userid )
Power on a virtual machine .
43,517
def guest_stop ( self , userid , ** kwargs ) : action = "stop guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . guest_stop ( userid , ** kwargs )
Power off a virtual machine .
43,518
def guest_unpause ( self , userid ) : action = "unpause guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . guest_unpause ( userid )
Unpause a virtual machine .
43,519
def guest_get_power_state ( self , userid ) : action = "get power state of guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _vmops . get_power_state ( userid )
Returns power state .
43,520
def guest_get_info ( self , userid ) : action = "get info of guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _vmops . get_info ( userid )
Get the status of a virtual machine .
43,521
def image_delete ( self , image_name ) : try : self . _imageops . image_delete ( image_name ) except exception . SDKBaseException : LOG . error ( "Failed to delete image '%s'" % image_name ) raise
Delete image from image repository
43,522
def image_get_root_disk_size ( self , image_name ) : try : return self . _imageops . image_get_root_disk_size ( image_name ) except exception . SDKBaseException : LOG . error ( "Failed to get root disk size units of image '%s'" % image_name ) raise
Get the root disk size of the image
43,523
def image_import ( self , image_name , url , image_meta , remote_host = None ) : try : self . _imageops . image_import ( image_name , url , image_meta , remote_host = remote_host ) except exception . SDKBaseException : LOG . error ( "Failed to import image '%s'" % image_name ) raise
Import image to zvmsdk image repository
43,524
def image_query ( self , imagename = None ) : try : return self . _imageops . image_query ( imagename ) except exception . SDKBaseException : LOG . error ( "Failed to query image" ) raise
Get the list of image info in image repository
43,525
def guest_deploy ( self , userid , image_name , transportfiles = None , remotehost = None , vdev = None , hostname = None ) : action = ( "deploy image '%(img)s' to guest '%(vm)s'" % { 'img' : image_name , 'vm' : userid } ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . guest_deploy ( userid ...
Deploy the image to vm .
43,526
def guest_capture ( self , userid , image_name , capture_type = 'rootonly' , compress_level = 6 ) : action = ( "capture guest '%(vm)s' to generate image '%(img)s'" % { 'vm' : userid , 'img' : image_name } ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . guest_capture ( userid , image_name , ...
Capture the guest to generate a image
43,527
def guest_create_nic ( self , userid , vdev = None , nic_id = None , mac_addr = None , active = False ) : if mac_addr is not None : if not zvmutils . valid_mac_addr ( mac_addr ) : raise exception . SDKInvalidInputFormat ( msg = ( "Invalid mac address, format should be " "xx:xx:xx:xx:xx:xx, and x is a hexadecimal digit"...
Create the nic for the vm add NICDEF record into the user direct .
43,528
def guest_delete_nic ( self , userid , vdev , active = False ) : self . _networkops . delete_nic ( userid , vdev , active = active )
delete the nic for the vm
43,529
def guest_get_definition_info ( self , userid , ** kwargs ) : action = "get the definition info of guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _vmops . get_definition_info ( userid , ** kwargs )
Get definition info for the specified guest vm also could be used to check specific info .
43,530
def guest_live_resize_cpus ( self , userid , cpu_cnt ) : action = "live resize guest '%s' to have '%i' virtual cpus" % ( userid , cpu_cnt ) LOG . info ( "Begin to %s" % action ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . live_resize_cpus ( userid , cpu_cnt ) LOG . info ( "%s successfully...
Live resize virtual cpus of guests .
43,531
def guest_resize_cpus ( self , userid , cpu_cnt ) : action = "resize guest '%s' to have '%i' virtual cpus" % ( userid , cpu_cnt ) LOG . info ( "Begin to %s" % action ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . resize_cpus ( userid , cpu_cnt ) LOG . info ( "%s successfully." % action )
Resize virtual cpus of guests .
43,532
def guest_live_resize_mem ( self , userid , size ) : action = "live resize guest '%s' to have '%s' memory" % ( userid , size ) LOG . info ( "Begin to %s" % action ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . live_resize_memory ( userid , size ) LOG . info ( "%s successfully." % action )
Live resize memory of guests .
43,533
def guest_resize_mem ( self , userid , size ) : action = "resize guest '%s' to have '%s' memory" % ( userid , size ) LOG . info ( "Begin to %s" % action ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . resize_memory ( userid , size ) LOG . info ( "%s successfully." % action )
Resize memory of guests .
43,534
def guest_create_disks ( self , userid , disk_list ) : if disk_list == [ ] or disk_list is None : LOG . debug ( "No disk specified when calling guest_create_disks, " "nothing happened" ) return action = "create disks '%s' for guest '%s'" % ( str ( disk_list ) , userid ) with zvmutils . log_and_reraise_sdkbase_error ( a...
Add disks to an existing guest vm .
43,535
def guest_delete_disks ( self , userid , disk_vdev_list ) : action = "delete disks '%s' from guest '%s'" % ( str ( disk_vdev_list ) , userid ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . delete_disks ( userid , disk_vdev_list )
Delete disks from an existing guest vm .
43,536
def guest_nic_couple_to_vswitch ( self , userid , nic_vdev , vswitch_name , active = False ) : self . _networkops . couple_nic_to_vswitch ( userid , nic_vdev , vswitch_name , active = active )
Couple nic device to specified vswitch .
43,537
def guest_nic_uncouple_from_vswitch ( self , userid , nic_vdev , active = False ) : self . _networkops . uncouple_nic_from_vswitch ( userid , nic_vdev , active = active )
Disonnect nic device with network .
43,538
def vswitch_create ( self , name , rdev = None , controller = '*' , connection = 'CONNECT' , network_type = 'ETHERNET' , router = "NONROUTER" , vid = 'UNAWARE' , port_type = 'ACCESS' , gvrp = 'GVRP' , queue_mem = 8 , native_vid = 1 , persist = True ) : if ( ( queue_mem < 1 ) or ( queue_mem > 8 ) ) : errmsg = ( 'API vsw...
Create vswitch .
43,539
def guest_get_console_output ( self , userid ) : action = "get the console output of guest '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : output = self . _vmops . get_console_output ( userid ) return output
Get the console output of the guest virtual machine .
43,540
def guest_delete ( self , userid ) : userid = userid . upper ( ) if not self . _vmops . check_guests_exist_in_db ( userid , raise_exc = False ) : if zvmutils . check_userid_exist ( userid ) : LOG . error ( "Guest '%s' does not exist in guests database" % userid ) raise exception . SDKObjectNotExistError ( obj_desc = ( ...
Delete guest .
43,541
def guest_inspect_stats ( self , userid_list ) : if not isinstance ( userid_list , list ) : userid_list = [ userid_list ] action = "get the statistics of guest '%s'" % str ( userid_list ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _monitor . inspect_stats ( userid_list )
Get the statistics including cpu and mem of the guests
43,542
def guest_inspect_vnics ( self , userid_list ) : if not isinstance ( userid_list , list ) : userid_list = [ userid_list ] action = "get the vnics statistics of guest '%s'" % str ( userid_list ) with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _monitor . inspect_vnics ( userid_list )
Get the vnics statistics of the guest virtual machines
43,543
def vswitch_set_vlan_id_for_user ( self , vswitch_name , userid , vlan_id ) : self . _networkops . set_vswitch_port_vlan_id ( vswitch_name , userid , vlan_id )
Set vlan id for user when connecting to the vswitch
43,544
def guest_config_minidisks ( self , userid , disk_info ) : action = "config disks for userid '%s'" % userid with zvmutils . log_and_reraise_sdkbase_error ( action ) : self . _vmops . guest_config_minidisks ( userid , disk_info )
Punch the script that used to process additional disks to vm
43,545
def vswitch_set ( self , vswitch_name , ** kwargs ) : for k in kwargs . keys ( ) : if k not in constants . SET_VSWITCH_KEYWORDS : errmsg = ( 'API vswitch_set: Invalid keyword %s' % k ) raise exception . SDKInvalidInputFormat ( msg = errmsg ) self . _networkops . set_vswitch ( vswitch_name , ** kwargs )
Change the configuration of an existing virtual switch
43,546
def vswitch_delete ( self , vswitch_name , persist = True ) : self . _networkops . delete_vswitch ( vswitch_name , persist )
Delete vswitch .
43,547
def guests_get_nic_info ( self , userid = None , nic_id = None , vswitch = None ) : action = "get nic information" with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _networkops . get_nic_info ( userid = userid , nic_id = nic_id , vswitch = vswitch )
Retrieve nic information in the network database according to the requirements the nic information will include the guest name nic device number vswitch name that the nic is coupled to nic identifier and the comments .
43,548
def vswitch_query ( self , vswitch_name ) : action = "get virtual switch information" with zvmutils . log_and_reraise_sdkbase_error ( action ) : return self . _networkops . vswitch_query ( vswitch_name )
Check the virtual switch status
43,549
def guest_delete_network_interface ( self , userid , os_version , vdev , active = False ) : self . _networkops . delete_nic ( userid , vdev , active = active ) self . _networkops . delete_network_configuration ( userid , os_version , vdev , active = active )
delete the nic and network configuration for the vm
43,550
def _fixpath ( self , p ) : return os . path . abspath ( os . path . expanduser ( p ) )
Apply tilde expansion and absolutization to a path .
43,551
def scrypt_mcf ( scrypt , password , salt = None , N = SCRYPT_N , r = SCRYPT_r , p = SCRYPT_p , prefix = SCRYPT_MCF_PREFIX_DEFAULT ) : if isinstance ( password , unicode ) : password = password . encode ( 'utf8' ) elif not isinstance ( password , bytes ) : raise TypeError ( 'password must be a unicode or byte string' )...
Derives a Modular Crypt Format hash using the scrypt KDF given
43,552
def new_plugin ( odir , py_name = None , version = '0.0.1.dev0' , description = 'New plugin' ) : name = osp . basename ( odir ) if py_name is None : py_name = name . replace ( '-' , '_' ) src = osp . join ( osp . dirname ( __file__ ) , 'plugin-template-files' ) shutil . copytree ( src , odir ) os . rename ( osp . join ...
Create a new plugin for the psyplot package
43,553
def get_versions ( requirements = True , key = None ) : from pkg_resources import iter_entry_points ret = { 'psyplot' : _get_versions ( requirements ) } for ep in iter_entry_points ( group = 'psyplot' , name = 'plugin' ) : if str ( ep ) in rcParams . _plugins : logger . debug ( 'Loading entrypoint %s' , ep ) if key is ...
Get the version information for psyplot the plugins and its requirements
43,554
def switch_add_record ( self , userid , interface , port = None , switch = None , comments = None ) : with get_network_conn ( ) as conn : conn . execute ( "INSERT INTO switch VALUES (?, ?, ?, ?, ?)" , ( userid , interface , switch , port , comments ) ) LOG . debug ( "New record in the switch table: user %s, " "nic %s, ...
Add userid and nic name address into switch table .
43,555
def switch_update_record_with_switch ( self , userid , interface , switch = None ) : if not self . _get_switch_by_user_interface ( userid , interface ) : msg = "User %s with nic %s does not exist in DB" % ( userid , interface ) LOG . error ( msg ) obj_desc = ( 'User %s with nic %s' % ( userid , interface ) ) raise exce...
Update information in switch table .
43,556
def image_query_record ( self , imagename = None ) : if imagename : with get_image_conn ( ) as conn : result = conn . execute ( "SELECT * FROM image WHERE " "imagename=?" , ( imagename , ) ) image_list = result . fetchall ( ) if not image_list : obj_desc = "Image with name: %s" % imagename raise exception . SDKObjectNo...
Query the image record from database if imagename is None all of the image records will be returned otherwise only the specified image record will be returned .
43,557
def face_index ( vertices ) : new_verts = [ ] face_indices = [ ] for wall in vertices : face_wall = [ ] for vert in wall : if new_verts : if not np . isclose ( vert , new_verts ) . all ( axis = 1 ) . any ( ) : new_verts . append ( vert ) else : new_verts . append ( vert ) face_index = np . where ( np . isclose ( vert ,...
Takes an MxNx3 array and returns a 2D vertices and MxN face_indices arrays
43,558
def fan_triangulate ( indices ) : if len ( indices [ 0 ] ) != 4 : raise ValueError ( "Assumes working with a sequence of quad indices" ) new_indices = [ ] for face in indices : new_indices . extend ( [ face [ : - 1 ] , face [ 1 : ] ] ) return np . array ( new_indices )
Return an array of vertices in triangular order using a fan triangulation algorithm .
43,559
def from_indexed_arrays ( cls , name , verts , normals ) : wavefront_str = "o {name}\n" . format ( name = name ) new_verts , face_indices = face_index ( verts ) assert new_verts . shape [ 1 ] == 3 , "verts should be Nx3 array" assert face_indices . ndim == 2 face_indices = fan_triangulate ( face_indices ) for vert in n...
Takes MxNx3 verts Mx3 normals to build obj file
43,560
def dump ( self , f ) : try : f . write ( self . _data ) except AttributeError : with open ( f , 'w' ) as wf : wf . write ( self . _data )
Write Wavefront data to file . Takes File object or filename .
43,561
def doIt ( rh ) : rh . printSysLog ( "Enter cmdVM.doIt" ) if 'showParms' in rh . parms and rh . parms [ 'showParms' ] is True : rh . printLn ( "N" , "Invocation parameters: " ) rh . printLn ( "N" , " Routine: cmdVM." + str ( subfuncHandler [ rh . subfunction ] [ 0 ] ) + "(reqHandle)" ) rh . printLn ( "N" , " function...
Perform the requested function by invoking the subfunction handler .
43,562
def invokeCmd ( rh ) : rh . printSysLog ( "Enter cmdVM.invokeCmd, userid: " + rh . userid ) results = execCmdThruIUCV ( rh , rh . userid , rh . parms [ 'cmd' ] ) if results [ 'overallRC' ] == 0 : rh . printLn ( "N" , results [ 'response' ] ) else : rh . printLn ( "ES" , results [ 'response' ] ) rh . updateResults ( res...
Invoke the command in the virtual machine s operating system .
43,563
def add_mdisks ( self , userid , disk_list , start_vdev = None ) : for idx , disk in enumerate ( disk_list ) : if 'vdev' in disk : vdev = disk [ 'vdev' ] else : vdev = self . generate_disk_vdev ( start_vdev = start_vdev , offset = idx ) self . _add_mdisk ( userid , disk , vdev ) disk [ 'vdev' ] = vdev if disk . get ( '...
Add disks for the userid
43,564
def _dedicate_device ( self , userid , vaddr , raddr , mode ) : action = 'dedicate' rd = ( 'changevm %(uid)s %(act)s %(va)s %(ra)s %(mod)i' % { 'uid' : userid , 'act' : action , 'va' : vaddr , 'ra' : raddr , 'mod' : mode } ) action = "dedicate device to userid '%s'" % userid with zvmutils . log_and_reraise_smt_request_...
dedicate device .
43,565
def get_fcp_info_by_status ( self , userid , status ) : results = self . _get_fcp_info_by_status ( userid , status ) return results
get fcp information by the status .
43,566
def _undedicate_device ( self , userid , vaddr ) : action = 'undedicate' rd = ( 'changevm %(uid)s %(act)s %(va)s' % { 'uid' : userid , 'act' : action , 'va' : vaddr } ) action = "undedicate device from userid '%s'" % userid with zvmutils . log_and_reraise_smt_request_failed ( action ) : self . _request ( rd )
undedicate device .
43,567
def get_image_performance_info ( self , userid ) : pi_dict = self . image_performance_query ( [ userid ] ) return pi_dict . get ( userid , None )
Get CPU and memory usage information .
43,568
def _parse_vswitch_inspect_data ( self , rd_list ) : def _parse_value ( data_list , idx , keyword , offset ) : return idx + offset , data_list [ idx ] . rpartition ( keyword ) [ 2 ] . strip ( ) vsw_dict = { } with zvmutils . expect_invalid_resp_data ( ) : idx = 0 idx , vsw_count = _parse_value ( rd_list , idx , 'vswitc...
Parse the Virtual_Network_Vswitch_Query_Byte_Stats data to get inspect data .
43,569
def guest_start ( self , userid ) : requestData = "PowerVM " + userid + " on" with zvmutils . log_and_reraise_smt_request_failed ( ) : self . _request ( requestData )
Power on VM .
43,570
def guest_stop ( self , userid , ** kwargs ) : requestData = "PowerVM " + userid + " off" if 'timeout' in kwargs . keys ( ) and kwargs [ 'timeout' ] : requestData += ' --maxwait ' + str ( kwargs [ 'timeout' ] ) if 'poll_interval' in kwargs . keys ( ) and kwargs [ 'poll_interval' ] : requestData += ' --poll ' + str ( kw...
Power off VM .
43,571
def live_migrate_move ( self , userid , destination , parms ) : rd = ( 'migratevm %(uid)s move --destination %(dest)s ' % { 'uid' : userid , 'dest' : destination } ) if 'maxtotal' in parms : rd += ( '--maxtotal ' + str ( parms [ 'maxTotal' ] ) ) if 'maxquiesce' in parms : rd += ( '--maxquiesce ' + str ( parms [ 'maxqui...
moves the specified virtual machine while it continues to run to the specified system within the SSI cluster .
43,572
def create_vm ( self , userid , cpu , memory , disk_list , profile , max_cpu , max_mem , ipl_from , ipl_param , ipl_loadparam ) : rd = ( 'makevm %(uid)s directory LBYONLY %(mem)im %(pri)s ' '--cpus %(cpu)i --profile %(prof)s --maxCPU %(max_cpu)i ' '--maxMemSize %(max_mem)s --setReservedMem' % { 'uid' : userid , 'mem' :...
Create VM and add disks if specified .
43,573
def _add_mdisk ( self , userid , disk , vdev ) : size = disk [ 'size' ] fmt = disk . get ( 'format' , 'ext4' ) disk_pool = disk . get ( 'disk_pool' ) or CONF . zvm . disk_pool [ diskpool_type , diskpool_name ] = disk_pool . split ( ':' ) if ( diskpool_type . upper ( ) == 'ECKD' ) : action = 'add3390' else : action = 'a...
Create one disk for userid
43,574
def get_vm_list ( self ) : action = "list all guests in database" with zvmutils . log_and_reraise_sdkbase_error ( action ) : guests_in_db = self . _GuestDbOperator . get_guest_list ( ) guests_migrated = self . _GuestDbOperator . get_migrated_guest_list ( ) userids_in_db = [ g [ 1 ] . upper ( ) for g in guests_in_db ] u...
Get the list of guests that are created by SDK return userid list
43,575
def guest_authorize_iucv_client ( self , userid , client = None ) : client = client or zvmutils . get_smt_userid ( ) iucv_path = "/tmp/" + userid if not os . path . exists ( iucv_path ) : os . makedirs ( iucv_path ) iucv_auth_file = iucv_path + "/iucvauth.sh" zvmutils . generate_iucv_authfile ( iucv_auth_file , client ...
Punch a script that used to set the authorized client userid in vm If the guest is in log off status the change will take effect when the guest start up at first time . If the guest is in active status power off and power on are needed for the change to take effect .
43,576
def grant_user_to_vswitch ( self , vswitch_name , userid ) : smt_userid = zvmutils . get_smt_userid ( ) requestData = ' ' . join ( ( 'SMAPI %s API Virtual_Network_Vswitch_Set_Extended' % smt_userid , "--operands" , "-k switch_name=%s" % vswitch_name , "-k grant_userid=%s" % userid , "-k persist=YES" ) ) try : self . _r...
Set vswitch to grant user .
43,577
def image_performance_query ( self , uid_list ) : if uid_list == [ ] : return { } if not isinstance ( uid_list , list ) : uid_list = [ uid_list ] smt_userid = zvmutils . get_smt_userid ( ) rd = ' ' . join ( ( "SMAPI %s API Image_Performance_Query" % smt_userid , "--operands" , '-T "%s"' % ( ' ' . join ( uid_list ) ) , ...
Call Image_Performance_Query to get guest current status .
43,578
def system_image_performance_query ( self , namelist ) : smt_userid = zvmutils . get_smt_userid ( ) rd = ' ' . join ( ( "SMAPI %s API System_Image_Performance_Query" % smt_userid , "--operands -T %s" % namelist ) ) action = "get performance info of namelist '%s'" % namelist with zvmutils . log_and_reraise_smt_request_f...
Call System_Image_Performance_Query to get guest current status .
43,579
def _couple_nic ( self , userid , vdev , vswitch_name , active = False ) : if active : self . _is_active ( userid ) msg = ( 'Start to couple nic device %(vdev)s of guest %(vm)s ' 'with vswitch %(vsw)s' % { 'vdev' : vdev , 'vm' : userid , 'vsw' : vswitch_name } ) LOG . info ( msg ) requestData = ' ' . join ( ( 'SMAPI %s...
Couple NIC to vswitch by adding vswitch into user direct .
43,580
def couple_nic_to_vswitch ( self , userid , nic_vdev , vswitch_name , active = False ) : if active : msg = ( "both in the user direct of guest %s and on " "the active guest system" % userid ) else : msg = "in the user direct of guest %s" % userid LOG . debug ( "Connect nic %s to switch %s %s" , nic_vdev , vswitch_name ...
Couple nic to vswitch .
43,581
def _uncouple_nic ( self , userid , vdev , active = False ) : if active : self . _is_active ( userid ) msg = ( 'Start to uncouple nic device %(vdev)s of guest %(vm)s' % { 'vdev' : vdev , 'vm' : userid } ) LOG . info ( msg ) requestData = ' ' . join ( ( 'SMAPI %s' % userid , "API Virtual_Network_Adapter_Disconnect_DM" ,...
Uncouple NIC from vswitch
43,582
def _get_image_size ( self , image_path ) : command = 'du -b %s' % image_path ( rc , output ) = zvmutils . execute ( command ) if rc : msg = ( "Error happened when executing command du -b with" "reason: %s" % output ) LOG . error ( msg ) raise exception . SDKImageOperationError ( rs = 8 ) size = output . split ( ) [ 0 ...
Return disk size in bytes
43,583
def _get_md5sum ( self , fpath ) : try : current_md5 = hashlib . md5 ( ) if isinstance ( fpath , six . string_types ) and os . path . exists ( fpath ) : with open ( fpath , "rb" ) as fh : for chunk in self . _read_chunks ( fh ) : current_md5 . update ( chunk ) elif ( fpath . __class__ . __name__ in [ "StringIO" , "Stri...
Calculate the md5sum of the specific image file
43,584
def get_guest_connection_status ( self , userid ) : rd = ' ' . join ( ( 'getvm' , userid , 'isreachable' ) ) results = self . _request ( rd ) if results [ 'rs' ] == 1 : return True else : return False
Get guest vm connection status .
43,585
def process_additional_minidisks ( self , userid , disk_info ) : for idx , disk in enumerate ( disk_info ) : vdev = disk . get ( 'vdev' ) or self . generate_disk_vdev ( offset = ( idx + 1 ) ) fmt = disk . get ( 'format' ) mount_dir = disk . get ( 'mntdir' ) or '' . join ( [ '/mnt/ephemeral' , str ( vdev ) ] ) disk_parm...
Generate and punch the scripts used to process additional disk into target vm s reader .
43,586
def _request_with_error_ignored ( self , rd ) : try : return self . _request ( rd ) except Exception as err : LOG . warning ( six . text_type ( err ) )
Send smt request log and ignore any errors .
43,587
def image_import ( cls , image_name , url , target , ** kwargs ) : source = urlparse . urlparse ( url ) . path if kwargs [ 'remote_host' ] : if '@' in kwargs [ 'remote_host' ] : source_path = ':' . join ( [ kwargs [ 'remote_host' ] , source ] ) command = ' ' . join ( [ '/usr/bin/scp' , "-P" , CONF . zvm . remotehost_ss...
Import image from remote host to local image repository using scp . If remote_host not specified it means the source file exist in local file system just copy the image to image repository
43,588
def image_export ( cls , source_path , dest_url , ** kwargs ) : dest_path = urlparse . urlparse ( dest_url ) . path if kwargs [ 'remote_host' ] : target_path = ':' . join ( [ kwargs [ 'remote_host' ] , dest_path ] ) command = ' ' . join ( [ '/usr/bin/scp' , "-P" , CONF . zvm . remotehost_sshd_port , "-o StrictHostKeyCh...
Export the specific image to remote host or local file system
43,589
def indent ( text , num = 4 ) : str_indent = ' ' * num return str_indent + ( '\n' + str_indent ) . join ( text . splitlines ( ) )
Indet the given string
43,590
def append_original_doc ( parent , num = 0 ) : def func ( func ) : func . __doc__ = func . __doc__ and func . __doc__ + indent ( parent . __doc__ , num ) return func return func
Return an iterator that append the docstring of the given parent function to the applied function
43,591
def get_sections ( self , s , base , sections = [ 'Parameters' , 'Other Parameters' , 'Possible types' ] ) : return super ( PsyplotDocstringProcessor , self ) . get_sections ( s , base , sections )
Extract the specified sections out of the given string
43,592
def create_config_drive ( network_interface_info , os_version ) : temp_path = CONF . guest . temp_path if not os . path . exists ( temp_path ) : os . mkdir ( temp_path ) cfg_dir = os . path . join ( temp_path , 'openstack' ) if os . path . exists ( cfg_dir ) : shutil . rmtree ( cfg_dir ) content_dir = os . path . join ...
Generate config driver for zVM guest vm .
43,593
def set ( self , ctype , key , data ) : with zvmutils . acquire_lock ( self . _lock ) : target_cache = self . _get_ctype_cache ( ctype ) target_cache [ 'data' ] [ key ] = data
Set or update cache content .
43,594
def warn ( message , category = PsyPlotWarning , logger = None ) : if logger is not None : message = "[Warning by %s]\n%s" % ( logger . name , message ) warnings . warn ( message , category , stacklevel = 3 )
wrapper around the warnings . warn function for non - critical warnings . logger may be a logging . Logger instance
43,595
def critical ( message , category = PsyPlotCritical , logger = None ) : if logger is not None : message = "[Critical warning by %s]\n%s" % ( logger . name , message ) warnings . warn ( message , category , stacklevel = 2 )
wrapper around the warnings . warn function for critical warnings . logger may be a logging . Logger instance
43,596
def customwarn ( message , category , filename , lineno , * args , ** kwargs ) : if category is PsyPlotWarning : logger . warning ( warnings . formatwarning ( "\n%s" % message , category , filename , lineno ) ) elif category is PsyPlotCritical : logger . critical ( warnings . formatwarning ( "\n%s" % message , category...
Use the psyplot . warning logger for categories being out of PsyPlotWarning and PsyPlotCritical and the default warnings . showwarning function for all the others .
43,597
def _get_home ( ) : try : if six . PY2 and sys . platform == 'win32' : path = os . path . expanduser ( b"~" ) . decode ( sys . getfilesystemencoding ( ) ) else : path = os . path . expanduser ( "~" ) except ImportError : pass else : if os . path . isdir ( path ) : return path for evar in ( 'HOME' , 'USERPROFILE' , 'TMP...
Find user s home directory if possible . Otherwise returns None .
43,598
def match_url ( self , request ) : parsed_url = urlparse ( request . path_url ) path_url = parsed_url . path query_params = parsed_url . query match = None for path in self . paths : for item in self . index : target_path = os . path . join ( BASE_PATH , path , path_url [ 1 : ] ) query_path = target_path . lower ( ) + ...
Match the request against a file in the adapter directory
43,599
def _reindex ( self ) : self . index = [ ] for path in self . paths : target_path = os . path . normpath ( os . path . join ( BASE_PATH , path ) ) for root , subdirs , files in os . walk ( target_path ) : for f in files : self . index . append ( ( os . path . join ( root , f ) . lower ( ) , os . path . join ( root , f ...
Create a case - insensitive index of the paths