code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
userid = userid with get_guest_conn() as conn: res = conn.execute("SELECT * FROM guests " "WHERE userid=?", (userid,)) guest = res.fetchall() if len(guest) == 1: return guest[0][2] elif len(guest) == 0: ...
def get_metadata_by_userid(self, userid)
get metadata record. output should be like: "a=1,b=2,c=3"
4.199959
3.885274
1.080994
dic = {} arr = meta.strip(' ,').split(',') for i in arr: temp = i.split('=') key = temp[0].strip() value = temp[1].strip() dic[key] = value return dic
def transfer_metadata_to_dict(self, meta)
transfer str to dict. output should be like: {'a':1, 'b':2, 'c':3}
3.024451
2.423966
1.247728
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)...
def face_index(vertices)
Takes an MxNx3 array and returns a 2D vertices and MxN face_indices arrays
2.415078
2.252126
1.072354
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)
def fan_triangulate(indices)
Return an array of vertices in triangular order using a fan triangulation algorithm.
4.803725
4.716185
1.018562
# Put header in string wavefront_str = "o {name}\n".format(name=mesh_name) # Write Vertex data from vert_dict for wall in vert_dict: for vert in vert_dict[wall]: wavefront_str += "v {0} {1} {2}\n".format(*vert) # Write (false) UV Texture da...
def from_dicts(cls, mesh_name, vert_dict, normal_dict)
Returns a wavefront .obj string using pre-triangulated vertex dict and normal dict as reference.
3.176265
3.013098
1.054152
# Put header in string wavefront_str = "o {name}\n".format(name=name) # Write Vertex data from vert_dict for vert in verts: wavefront_str += "v {0} {1} {2}\n".format(*vert) # Write (false) UV Texture data wavefront_str += "vt 1.0 1.0\n" f...
def from_arrays(cls, name, verts, normals, n_verts=3)
Returns a wavefront .obj string using pre-triangulated vertex dict and normal dict as reference.
3.24836
3.109045
1.04481
# Put header in string 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) #...
def from_indexed_arrays(cls, name, verts, normals)
Takes MxNx3 verts, Mx3 normals to build obj file
3.422419
3.30479
1.035593
try: f.write(self._data) except AttributeError: with open(f, 'w') as wf: wf.write(self._data)
def dump(self, f)
Write Wavefront data to file. Takes File object or filename.
3.537041
2.762523
1.280366
check_args(password, salt, N, r, p, olen) try: return _scrypt(password=password, salt=salt, N=N, r=r, p=p, buflen=olen) except: raise ValueError
def scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64)
Returns a key derived using the scrypt key-derivarion function N must be a power of two larger than 1 but no larger than 2 ** 63 (insane) r and p must be positive numbers such that r * p < 2 ** 30 The default values are: N -- 2**14 (~16k) r -- 8 p -- 1 Memory usage is proportional to N*r....
2.778547
3.752536
0.740445
rh.printSysLog("Enter cmdVM.doIt") # Show the invocation parameters, if requested. 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]) + "(reqH...
def doIt(rh)
Perform the requested function by invoking the subfunction handler. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error
3.22415
3.071153
1.049818
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(results) rh.printSy...
def invokeCmd(rh)
Invoke the command in the virtual machine's operating system. Input: Request Handle with the following properties: function - 'CMDVM' subfunction - 'CMD' userid - userid of the virtual machine parms['cmd'] - Command to send Output: Request Handle...
4.752437
4.224451
1.124983
rh.printSysLog("Enter cmdVM.parseCmdline") if rh.totalParms >= 2: rh.userid = rh.request[1].upper() else: # Userid is missing. msg = msgs.msg['0010'][1] % modId rh.printLn("ES", msg) rh.updateResults(msgs.msg['0010'][0]) rh.printSysLog("Exit cmdVM.parse...
def parseCmdline(rh)
Parse the request command input. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error
3.600775
3.694795
0.974553
vdev = hex(int(base, 16) + offset)[2:] return vdev.rjust(4, '0')
def _generate_vdev(self, base, offset)
Generate virtual device number based on base vdev :param base: base virtual device number, string of 4 bit hex. :param offset: offset to base, integer.
3.782304
3.984444
0.949268
if not start_vdev: start_vdev = CONF.zvm.user_root_vdev vdev = self._generate_vdev(start_vdev, offset) if offset >= 0 and offset < 254: return vdev else: msg = ("Failed to generate disk vdev, invalid virtual device" "number ...
def generate_disk_vdev(self, start_vdev=None, offset=0)
Generate virtual device number for disks :param offset: offset of user_root_vdev. :return: virtual device number, string of 4 bit hex.
4.11921
3.705045
1.111784
for idx, disk in enumerate(disk_list): if 'vdev' in disk: # this means user want to create their own device number vdev = disk['vdev'] else: vdev = self.generate_disk_vdev(start_vdev=start_vdev, ...
def add_mdisks(self, userid, disk_list, start_vdev=None)
Add disks for the userid :disks: A list dictionary to describe disk info, for example: disk: [{'size': '1g', 'format': 'ext3', 'disk_pool': 'ECKD:eckdpool1'}]
3.197147
3.103006
1.030339
# dedicate device to directory entry self._dedicate_device(userid, vaddr, raddr, mode)
def dedicate_device(self, userid, vaddr, raddr, mode)
dedicate device :userid: The name of the image obtaining a dedicated device :vaddr: The virtual device number of the device :raddr: A real device number to be dedicated or attached to the specified image :mode: Specify a 1 if the virtual device is to be in read-only mode...
7.394629
10.690138
0.691724
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_failed(ac...
def _dedicate_device(self, userid, vaddr, raddr, mode)
dedicate device.
5.646445
5.484709
1.029488
results = self._get_fcp_info_by_status(userid, status) return results
def get_fcp_info_by_status(self, userid, status)
get fcp information by the status. :userid: The name of the image to query fcp info :status: The status of target fcps. eg:'active', 'free' or 'offline'.
3.557258
3.772171
0.943027
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...
def _undedicate_device(self, userid, vaddr)
undedicate device.
7.767353
7.061591
1.099944
pi_dict = self.image_performance_query([userid]) return pi_dict.get(userid, None)
def get_image_performance_info(self, userid)
Get CPU and memory usage information. :userid: the zvm userid to be queried
7.166845
9.479013
0.756075
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(): # vswitch count idx = 0 idx, vsw_count = _parse_value(rd_list, i...
def _parse_vswitch_inspect_data(self, rd_list)
Parse the Virtual_Network_Vswitch_Query_Byte_Stats data to get inspect data.
1.847692
1.839171
1.004633
LOG.debug('Querying power stat of %s' % userid) requestData = "PowerVM " + userid + " status" action = "query power state of '%s'" % userid with zvmutils.log_and_reraise_smt_request_failed(action): results = self._request(requestData) with zvmutils.expect_inv...
def get_power_state(self, userid)
Get power status of a z/VM instance.
7.205467
6.547759
1.100448
requestData = "PowerVM " + userid + " on" with zvmutils.log_and_reraise_smt_request_failed(): self._request(requestData)
def guest_start(self, userid)
Power on VM.
14.402805
10.739968
1.341047
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(kwargs['poll_in...
def guest_stop(self, userid, **kwargs)
Power off VM.
4.738067
4.133292
1.146318
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['maxquiesce'])) ...
def live_migrate_move(self, userid, destination, parms)
moves the specified virtual machine, while it continues to run, to the specified system within the SSI cluster.
3.628766
3.548831
1.022524
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': memory, 'pri': const.ZVM_USER_DEFAULT_PRIVILEGE, ...
def create_vm(self, userid, cpu, memory, disk_list, profile, max_cpu, max_mem, ipl_from, ipl_param, ipl_loadparam)
Create VM and add disks if specified.
4.315441
4.33023
0.996585
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 = 'ad...
def _add_mdisk(self, userid, disk, vdev)
Create one disk for userid NOTE: No read, write and multi password specified, and access mode default as 'MR'.
5.538025
5.253919
1.054075
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() # db query return value in tuple (uuid, userid, me...
def get_vm_list(self)
Get the list of guests that are created by SDK return userid list
4.084373
3.62773
1.125876
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) try: ...
def guest_authorize_iucv_client(self, userid, client=None)
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. :param str ...
4.034456
4.140055
0.974493
# (TODO: add the support of multiple disks deploy) msg = ('Start to deploy image %(img)s to guest %(vm)s' % {'img': image_name, 'vm': userid}) LOG.info(msg) image_file = '/'.join([self._get_image_path_by_name(image_name), CONF.zvm.u...
def guest_deploy(self, userid, image_name, transportfiles=None, remotehost=None, vdev=None)
Deploy image and punch config driver to target
3.857805
3.765992
1.02438
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")) ...
def grant_user_to_vswitch(self, vswitch_name, userid)
Set vswitch to grant user.
4.741667
4.610382
1.028476
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"'...
def image_performance_query(self, uid_list)
Call Image_Performance_Query to get guest current status. :uid_list: A list of zvm userids to be queried
4.668785
4.529343
1.030786
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_failed...
def system_image_performance_query(self, namelist)
Call System_Image_Performance_Query to get guest current status. :namelist: A namelist that defined in smapi namelist file.
5.125838
5.127048
0.999764
smt_userid = zvmutils.get_smt_userid() rd = ' '.join(( "SMAPI %s API Virtual_Network_Vswitch_Set_Extended" % smt_userid, "--operands", "-k switch_name=%s" % switch_name)) for k, v in kwargs.items(): rd = ' '.join((rd, ...
def set_vswitch(self, switch_name, **kwargs)
Set vswitch
4.114514
4.06064
1.013267
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' ...
def _couple_nic(self, userid, vdev, vswitch_name, active=False)
Couple NIC to vswitch by adding vswitch into user direct.
2.91168
2.872681
1.013576
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, msg)...
def couple_nic_to_vswitch(self, userid, nic_vdev, vswitch_name, active=False)
Couple nic to vswitch.
4.462264
4.516687
0.987951
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_Disconn...
def _uncouple_nic(self, userid, vdev, active=False)
Uncouple NIC from vswitch
3.064581
3.052058
1.004103
requestData = 'cmdVM ' + userid + ' CMD \'' + cmdStr + '\'' with zvmutils.log_and_reraise_smt_request_failed(action='execute ' 'command on vm via iucv channel'): results = self._request(requestData) ret = results['response'] return ret
def execute_cmd(self, userid, cmdStr)
cmdVM.
16.81459
14.534642
1.156863
requestData = 'cmdVM ' + userid + ' CMD \'' + cmdStr + '\'' results = self._smt.request(requestData) return results
def execute_cmd_direct(self, userid, cmdStr)
cmdVM.
16.523062
11.754284
1.405706
image_info = self._ImageDbOperator.image_query_record(image_name) if not image_info: msg = ("The image %s does not exist in image repository" % image_name) LOG.error(msg) raise exception.SDKImageOperationError(rs=20, img=image_name) ...
def image_export(self, image_name, dest_url, remote_host=None)
Export the specific image to remote host or local file system :param image_name: image name that can be uniquely identify an image :param dest_path: the location to store exported image, eg. /opt/images, the image will be stored in folder /opt/images/ :param remote_host: the ser...
5.811836
5.395778
1.077108
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) s...
def _get_image_size(self, image_path)
Return disk size in bytes
5.898362
5.149073
1.145519
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.__c...
def _get_md5sum(self, fpath)
Calculate the md5sum of the specific image file
2.927766
2.740828
1.068205
image_info = self.image_query(image_name) if not image_info: raise exception.SDKImageOperationError(rs=20, img=image_name) disk_size_units = image_info[0]['disk_size_units'].split(':')[0] return disk_size_units
def image_get_root_disk_size(self, image_name)
Return the root disk units of the specified image image_name: the unique image name in db Return the disk units in format like 3339:CYL or 467200:BLK
4.941398
3.680382
1.342632
'''Get guest vm connection status.''' rd = ' '.join(('getvm', userid, 'isreachable')) results = self._request(rd) if results['rs'] == 1: return True else: return False
def get_guest_connection_status(self, userid)
Get guest vm connection status.
9.788977
9.968303
0.98201
'''Generate and punch the scripts used to process additional disk into target vm's reader. ''' for idx, disk in enumerate(disk_info): vdev = disk.get('vdev') or self.generate_disk_vdev( offset = (idx + 1)) fmt = ...
def process_additional_minidisks(self, userid, disk_info)
Generate and punch the scripts used to process additional disk into target vm's reader.
9.053312
6.096836
1.48492
try: return self._request(rd) except Exception as err: # log as warning and ignore namelist operation failures LOG.warning(six.text_type(err))
def _request_with_error_ignored(self, rd)
Send smt request, log and ignore any errors.
8.103653
7.158419
1.132045
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_s...
def image_import(cls, image_name, url, target, **kwargs)
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
3.404751
3.254238
1.046251
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 ...
def image_export(cls, source_path, dest_url, **kwargs)
Export the specific image to remote host or local file system
3.135015
3.033736
1.033384
if isinstance(func, types.MethodType) and not six.PY3: func = func.im_func func.__doc__ = func.__doc__ and dedents(func.__doc__) return func
def dedent(func)
Dedent the docstring of a function and substitute with :attr:`params` Parameters ---------- func: function function with the documentation to dedent
3.940216
5.169736
0.76217
str_indent = ' ' * num return str_indent + ('\n' + str_indent).join(text.splitlines())
def indent(text, num=4)
Indet the given string
3.455046
3.585438
0.963633
def func(func): func.__doc__ = func.__doc__ and func.__doc__ + indent( parent.__doc__, num) return func return func
def append_original_doc(parent, num=0)
Return an iterator that append the docstring of the given `parent` function to the applied function
6.028645
5.143379
1.172118
return super(PsyplotDocstringProcessor, self).get_sections(s, base, sections)
def get_sections(self, s, base, sections=[ 'Parameters', 'Other Parameters', 'Possible types'])
Extract the specified sections out of the given string The same as the :meth:`docrep.DocstringProcessor.get_sections` method but uses the ``'Possible types'`` section by default, too Parameters ---------- %(DocstringProcessor.get_sections.parameters)s Returns -...
12.210078
14.301933
0.853736
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(cfg_dir, 'content') latest_dir = os.path.join(cfg_dir, 'latest'...
def create_config_drive(network_interface_info, os_version)
Generate config driver for zVM guest vm. :param dict network_interface_info: Required keys: ip_addr - (str) IP address nic_vdev - (str) VDEV of the nic gateway_v4 - IPV4 gateway broadcast_v4 - IPV4 broadcast address netmask_v4 - IPV4 netmask :param str os_version: operat...
1.98254
2.036571
0.97347
check_args(password, salt, N, r, p, olen) # Set the memory required based on parameter values m = 128 * r * (N + p + 2) try: return _scrypt( password=password, salt=salt, n=N, r=r, p=p, maxmem=m, dklen=olen) except: raise ValueError
def scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64)
Returns a key derived using the scrypt key-derivarion function N must be a power of two larger than 1 but no larger than 2 ** 63 (insane) r and p must be positive numbers such that r * p < 2 ** 30 The default values are: N -- 2**14 (~16k) r -- 8 p -- 1 Memory usage is proportional to N*r....
4.177002
5.219968
0.800197
with zvmutils.acquire_lock(self._lock): target_cache = self._get_ctype_cache(ctype) target_cache['data'][key] = data
def set(self, ctype, key, data)
Set or update cache content. :param ctype: cache type :param key: the key to be set value :param data: cache data
7.584624
9.013647
0.84146
response = Response() response.url = request.url response.raw = BytesIO(body) if status_code: response.status_code = status_code else: response.status_code = DEFAULT_GOOD_STATUS_CODE if headers: response.headers = headers ...
def GoodResponse(body, request, status_code=None, headers=None)
Construct a Good HTTP response (defined in DEFAULT_GOOD_RESPONSE_CODE) :param body: The body of the response :type body: ``str`` :param request: The HTTP request :type request: :class:`requests.Request` :param status_code: The return status code, defaults to DEFA...
2.092929
2.192428
0.954617
response = Response() response.url = request.url response.raw = BytesIO(body) if status_code: response.status_code = status_code else: response.status_code = DEFAULT_BAD_STATUS_CODE if headers: response.headers = headers ...
def BadResponse(body, request, status_code=None, headers=None)
Construct a Bad HTTP response (defined in DEFAULT_BAD_RESPONSE_CODE) :param body: The body of the response :type body: ``str`` :param request: The HTTP request :type request: :class:`requests.Request` :param status_code: The return status code, defaults to DEFAUL...
2.03541
2.306472
0.882478
warnings.filterwarnings('ignore', '\w', PsyPlotWarning, 'psyplot', 0) if critical: warnings.filterwarnings('ignore', '\w', PsyPlotCritical, 'psyplot', 0)
def disable_warnings(critical=False)
Function that disables all warnings and all critical warnings (if critical evaluates to True) related to the psyplot Module. Please note that you can also configure the warnings via the psyplot.warning logger (logging.getLogger(psyplot.warning)).
5.752654
3.660847
1.5714
if logger is not None: message = "[Warning by %s]\n%s" % (logger.name, message) warnings.warn(message, category, stacklevel=3)
def warn(message, category=PsyPlotWarning, logger=None)
wrapper around the warnings.warn function for non-critical warnings. logger may be a logging.Logger instance
3.582042
3.325703
1.077078
if logger is not None: message = "[Critical warning by %s]\n%s" % (logger.name, message) warnings.warn(message, category, stacklevel=2)
def critical(message, category=PsyPlotCritical, logger=None)
wrapper around the warnings.warn function for critical warnings. logger may be a logging.Logger instance
3.988194
3.399969
1.173009
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, filename, lineno), exc_info=True) ...
def customwarn(message, category, filename, lineno, *args, **kwargs)
Use the psyplot.warning logger for categories being out of PsyPlotWarning and PsyPlotCritical and the default warnings.showwarning function for all the others.
3.36696
2.435145
1.382653
try: if six.PY2 and sys.platform == 'win32': path = os.path.expanduser(b"~").decode(sys.getfilesystemencoding()) else: path = os.path.expanduser("~") except ImportError: # This happens on Google App Engine (pwd module is not present). pass else: ...
def _get_home()
Find user's home directory if possible. Otherwise, returns None. :see: http://mail.python.org/pipermail/python-list/2005-February/325395.html This function is copied from matplotlib version 1.4.3, Jan 2016
3.068606
3.049037
1.006418
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_p...
def match_url(self, request)
Match the request against a file in the adapter directory :param request: The request :type request: :class:`requests.Request` :return: Path to the file :rtype: ``str``
3.504227
3.559132
0.984574
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....
def _reindex(self)
Create a case-insensitive index of the paths
2.897617
2.370753
1.222235
rh.printSysLog("Enter changeVM.add3390") results, cyl = generalUtils.cvtToCyl(rh, rh.parms['diskSize']) if results['overallRC'] != 0: # message already sent. Only need to update the final results. rh.updateResults(results) if results['overallRC'] == 0: parms = [ ...
def add3390(rh)
Adds a 3390 (ECKD) disk to a virtual machine's directory entry. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'ADD3390' userid - userid of the virtual machine parms['diskPool'] - Disk pool parms['diskSize'...
3.491719
3.005613
1.161733
rh.printSysLog("Enter changeVM.add9336") results, blocks = generalUtils.cvtToBlocks(rh, rh.parms['diskSize']) if results['overallRC'] != 0: # message already sent. Only need to update the final results. rh.updateResults(results) if results['overallRC'] == 0: parms = [ ...
def add9336(rh)
Adds a 9336 (FBA) disk to virtual machine's directory entry. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'ADD9336' userid - userid of the virtual machine parms['diskPool'] - Disk pool parms['diskSize'] ...
3.305647
2.855294
1.157726
rh.printSysLog("Enter changeVM.dedicate") parms = [ "-T", rh.userid, "-v", rh.parms['vaddr'], "-r", rh.parms['raddr'], "-R", rh.parms['mode']] hideList = [] results = invokeSMCLI(rh, "Image_Device_Dedicate_DM", pa...
def dedicate(rh)
Dedicate device. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'DEDICATEDM' userid - userid of the virtual machine parms['vaddr'] - Virtual address parms['raddr'] - Real address parms['mo...
3.704536
3.305955
1.120564
rh.printSysLog("Enter changeVM.addAEMOD") invokeScript = "invokeScript.sh" trunkFile = "aemod.doscript" fileClass = "X" tempDir = tempfile.mkdtemp() if os.path.isfile(rh.parms['aeScript']): # Get the short name of our activation engine modifier script if rh.parms['aeScript'...
def addAEMOD(rh)
Send an Activation Modification Script to the virtual machine. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'AEMOD' userid - userid of the virtual machine parms['aeScript'] - File specification of the AE script ...
4.449135
4.079845
1.090516
rh.printSysLog("Enter changeVM.addLOADDEV") # scpDataType and scpData must appear or disappear concurrently if ('scpData' in rh.parms and 'scpDataType' not in rh.parms): msg = msgs.msg['0014'][1] % (modId, "scpData", "scpDataType") rh.printLn("ES", msg) rh.updateResults(msgs.ms...
def addLOADDEV(rh)
Sets the LOADDEV statement in the virtual machine's directory entry. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'ADDLOADDEV' userid - userid of the virtual machine parms['boot'] - Boot program number ...
2.721197
2.462804
1.104918
rh.printSysLog("Enter changeVM.punchFile") # Default spool class in "A" , if specified change to specified class spoolClass = "A" if 'class' in rh.parms: spoolClass = str(rh.parms['class']) punch2reader(rh, rh.userid, rh.parms['file'], spoolClass) rh.printSysLog("Exit changeVM.p...
def punchFile(rh)
Punch a file to a virtual reader of the specified virtual machine. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'PUNCHFILE' userid - userid of the virtual machine parms['class'] - Spool class (optional) ...
7.114504
5.187318
1.371519
rh.printSysLog("Enter changeVM.purgeRDR") results = purgeReader(rh) rh.updateResults(results) rh.printSysLog("Exit changeVM.purgeRDR, rc: " + str(rh.results['overallRC'])) return rh.results['overallRC']
def purgeRDR(rh)
Purge the reader belonging to the virtual machine. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'PURGERDR' userid - userid of the virtual machine Output: Request Handle updated with the results. Return code ...
6.194362
5.252001
1.179429
rh.printSysLog("Enter changeVM.removeDisk") results = {'overallRC': 0, 'rc': 0, 'rs': 0} # Is image logged on loggedOn = False results = isLoggedOn(rh, rh.userid) if results['overallRC'] == 0: if results['rs'] == 0: loggedOn = True results = disableEnable...
def removeDisk(rh)
Remove a disk from a virtual machine. Input: Request Handle with the following properties: function - 'CHANGEVM' subfunction - 'REMOVEDISK' userid - userid of the virtual machine parms['vaddr'] - Virtual address Output: Request Han...
3.835336
3.549261
1.080601
if rh.subfunction != '': rh.printLn("N", "Usage:") rh.printLn("N", " python " + rh.cmdName + " ChangeVM <userid> add3390 <diskPool> <vAddr>") rh.printLn("N", " <diskSize3390> --mode " + "<mode> --readpw <read_pw>") rh.printLn("N", " ...
def showInvLines(rh)
Produce help output related to command synopsis Input: Request Handle
3.320379
3.300881
1.005907
return self.conn.request(api_name, *api_args, **api_kwargs)
def send_request(self, api_name, *api_args, **api_kwargs)
Refer to SDK API documentation. :param api_name: SDK API name :param *api_args: SDK API sequence parameters :param **api_kwargs: SDK API keyword parameters
3.481391
4.510071
0.771915
rh.printSysLog("Enter getHost.getDiskPoolNames") parms = ["-q", "1", "-e", "3", "-T", "dummy"] results = invokeSMCLI(rh, "Image_Volume_Space_Query_DM", parms) if results['overallRC'] == 0: for line in results['response'].splitlines(): poolName = line.partition(' ')[0] ...
def getDiskPoolNames(rh)
Obtain the list of disk pools known to the directory manager. Input: Request Handle with the following properties: function - 'GETHOST' subfunction - 'DISKPOOLNAMES' Output: Request Handle updated with the results. Return code - 0: ok, non-zero: error
5.505259
5.577496
0.987049
rh.printSysLog("Enter getHost.getDiskPoolSpace") results = {'overallRC': 0} if 'poolName' not in rh.parms: poolNames = ["*"] else: if isinstance(rh.parms['poolName'], list): poolNames = rh.parms['poolName'] else: poolNames = [rh.parms['poolName']] ...
def getDiskPoolSpace(rh)
Obtain disk pool space information for all or a specific disk pool. Input: Request Handle with the following properties: function - 'GETHOST' subfunction - 'DISKPOOLSPACE' parms['poolName'] - Name of the disk pool. Optional, ...
3.440682
3.30977
1.039553
rh.printSysLog("Enter getHost.getFcpDevices") parms = ["-T", "dummy"] results = invokeSMCLI(rh, "System_WWPN_Query", parms) if results['overallRC'] == 0: rh.printLn("N", results['response']) else: # SMAPI API failed. rh.printLn("ES", results['response']) rh.upd...
def getFcpDevices(rh)
Lists the FCP device channels that are active, free, or offline. Input: Request Handle with the following properties: function - 'GETHOST' subfunction - 'FCPDEVICES' Output: Request Handle updated with the results. Return code - 0: ok, non-zero: error
5.777411
6.022162
0.959358
rh.printSysLog("Enter getHost.parseCmdline") rh.userid = '' if rh.totalParms >= 2: rh.subfunction = rh.request[1].upper() # Verify the subfunction is valid. if rh.subfunction not in subfuncHandler: # Subfunction is missing. subList = ', '.join(sorted(subfuncHandler.k...
def parseCmdline(rh)
Parse the request command input. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error
6.075495
6.436729
0.943879
if rh.subfunction != '': rh.printLn("N", "Usage:") rh.printLn("N", " python " + rh.cmdName + " GetHost " + "diskpoolnames") rh.printLn("N", " python " + rh.cmdName + " GetHost " + "diskpoolspace <poolName>") rh.printLn("N", " python " + rh.cmdName + " GetHost fcpdevices"...
def showInvLines(rh)
Produce help output related to command synopsis Input: Request Handle
3.428859
3.360486
1.020346
if rh.function == 'HELP': rh.printLn("N", " For the GetHost function:") else: rh.printLn("N", "Sub-Functions(s):") rh.printLn("N", " diskpoolnames - " + "Returns the names of the directory manager disk pools.") rh.printLn("N", " diskpoolspace - " + "Retur...
def showOperandLines(rh)
Produce help output related to operands. Input: Request Handle
5.335499
5.41255
0.985764
rh.printSysLog("Enter deleteVM.deleteMachine") results = {'overallRC': 0, 'rc': 0, 'rs': 0} # Is image logged on ? state = 'on' # Assume 'on'. results = isLoggedOn(rh, rh.userid) if results['overallRC'] != 0: # Cannot determine the log on/off state. # Message already i...
def deleteMachine(rh)
Delete a virtual machine from the user directory. Input: Request Handle with the following properties: function - 'DELETEVM' subfunction - 'DIRECTORY' userid - userid of the virtual machine to be deleted. Output: Request Handle updated with the results. ...
4.654396
4.527716
1.027979
rh.printSysLog("Enter powerVM.activate, userid: " + rh.userid) parms = ["-T", rh.userid] smcliResults = invokeSMCLI(rh, "Image_Activate", parms) if smcliResults['overallRC'] == 0: pass elif (smcliResults['overallRC'] == 8 and smcliResults['rc'] == 200 and smcliResults['rs'] == ...
def activate(rh)
Activate a virtual machine. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'ON' userid - userid of the virtual machine parms['desiredState'] - Desired state. Optional, unless 'maxQu...
4.267367
3.624418
1.177394
rh.printSysLog("Enter powerVM.checkIsReachable, userid: " + rh.userid) strCmd = "echo 'ping'" results = execCmdThruIUCV(rh, rh.userid, strCmd) if results['overallRC'] == 0: rh.printLn("N", rh.userid + ": reachable") reachable = 1 else: # A failure from execCmd...
def checkIsReachable(rh)
Check if a virtual machine is reachable. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'ISREACHABLE' userid - userid of the virtual machine Output: Request Handle updated with the results. overallRC - 0: deter...
6.893519
4.809241
1.43339
rh.printSysLog("Enter powerVM.deactivate, userid: " + rh.userid) parms = ["-T", rh.userid, "-f", "IMMED"] results = invokeSMCLI(rh, "Image_Deactivate", parms) if results['overallRC'] == 0: pass elif (results['overallRC'] == 8 and results['rc'] == 200 and (results['rs']...
def deactivate(rh)
Deactivate a virtual machine. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'OFF' userid - userid of the virtual machine parms['maxQueries'] - Maximum number of queries to issue. ...
5.221801
4.517604
1.155878
rh.printSysLog("Enter powerVM.getStatus, userid: " + rh.userid) results = isLoggedOn(rh, rh.userid) if results['overallRC'] != 0: # Unexpected error pass elif results['rs'] == 0: rh.printLn("N", rh.userid + ": on") else: rh.printLn("N", rh.userid + ": o...
def getStatus(rh)
Get the power (logon/off) status of a virtual machine. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'STATUS' userid - userid of the virtual machine Output: Request Handle updated with the results. results['ov...
4.728148
3.587468
1.317962
rh.printSysLog("Enter powerVM.parseCmdline") if rh.totalParms >= 2: rh.userid = rh.request[1].upper() else: # Userid is missing. msg = msgs.msg['0010'][1] % modId rh.printLn("ES", msg) rh.updateResults(msgs.msg['0010'][0]) rh.printSysLog("Exit powerVM.p...
def parseCmdline(rh)
Parse the request command input. Input: Request Handle Output: Request Handle updated with parsed input. Return code - 0: ok, non-zero: error
2.700041
2.716708
0.993865
rh.printSysLog("Enter powerVM.pause, userid: " + rh.userid) parms = ["-T", rh.userid, "-k", "PAUSE=YES"] results = invokeSMCLI(rh, "Image_Pause", parms) if results['overallRC'] != 0: # SMAPI API failed. rh.printLn("ES", results['response']) rh.updateResults(results) # U...
def pause(rh)
Pause a virtual machine. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'PAUSE' userid - userid of the virtual machine Output: Request Handle updated with the results. Return code - 0: ok, non-zero: error
6.827798
5.918174
1.1537
rh.printSysLog("Enter powerVM.reboot, userid: " + rh.userid) strCmd = "shutdown -r now" results = execCmdThruIUCV(rh, rh.userid, strCmd) if results['overallRC'] != 0: # Command failed to execute using IUCV. rh.printLn("ES", results['response']) rh.updateResults(results) ...
def reboot(rh)
Reboot a virtual machine. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'REBOOT' userid - userid of the virtual machine parms['desiredState'] - Desired state. Optional, unless 'max...
3.866278
3.381688
1.143298
rh.printSysLog("Enter powerVM.reset, userid: " + rh.userid) # Log off the user parms = ["-T", rh.userid] results = invokeSMCLI(rh, "Image_Deactivate", parms) if results['overallRC'] != 0: if results['rc'] == 200 and results['rs'] == 12: # Tolerated error. Machine is alrea...
def reset(rh)
Reset a virtual machine. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'RESET' userid - userid of the virtual machine parms['maxQueries'] - Maximum number of queries to issue. Op...
3.033777
2.737158
1.108367
rh.printSysLog("Enter powerVM.softDeactivate, userid: " + rh.userid) strCmd = "echo 'ping'" iucvResults = execCmdThruIUCV(rh, rh.userid, strCmd) if iucvResults['overallRC'] == 0: # We could talk to the machine, tell it to shutdown nicely. strCmd = "shutdown -h now" ...
def softDeactivate(rh)
Deactivate a virtual machine by first shutting down Linux and then log it off. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'SOFTOFF' userid - userid of the virtual machine parms['maxQueries'] - Maximum number...
4.477768
4.058493
1.103308
rh.printSysLog("Enter powerVM.wait, userid: " + rh.userid) if (rh.parms['desiredState'] == 'off' or rh.parms['desiredState'] == 'on'): results = waitForVMState( rh, rh.userid, rh.parms['desiredState'], maxQueries=rh.parms['maxQueries'], ...
def wait(rh)
Wait for the virtual machine to go into the specified state. Input: Request Handle with the following properties: function - 'POWERVM' subfunction - 'WAIT' userid - userid of the virtual machine parms['desiredState'] - Desired state parms['maxQueri...
3.205073
2.536017
1.263822
if not isinstance(func, str) or (func == ''): msg = ('Invalid input for API name, should be a' 'string, type: %s specified.') % type(func) return self._construct_api_name_error(msg) # Create client socket try: cs = socket.socket(so...
def call(self, func, *api_args, **api_kwargs)
Send API call to SDK server and return results
3.404553
3.294471
1.033414
json_results = json.dumps(results) json_results = json_results.encode() sent = 0 total_len = len(json_results) got_error = False while (sent < total_len): this_sent = client.send(json_results[sent:]) if this_sent == 0: got...
def send_results(self, client, addr, results)
send back results to client in the json format of: {'overallRC': x, 'modID': x, 'rc': x, 'rs': x, 'errmsg': 'msg', 'output': 'out'}
2.406259
2.311813
1.040853
self.log_debug("(%s:%s) Handling new request from client." % (addr[0], addr[1])) results = None try: data = client.recv(4096) data = bytes.decode(data) # When client failed to send the data or quit before sending the ...
def serve_API(self, client, addr)
Read client request and call target SDK API
2.849032
2.806929
1.015
result = mapper.match(environ=environ) if result is None: info = environ.get('PATH_INFO', '') LOG.debug('The route for %s can not be found', info) raise webob.exc.HTTPNotFound( json_formatter=util.json_error_formatter) handler = result.pop('action') environ['ws...
def dispatch(environ, start_response, mapper)
Find a matching route for the current request. :raises: 404(not found) if no match request 405(method not allowed) if route exist but method not provided.
4.243739
4.352006
0.975122
_methods = util.wsgi_path_item(environ, '_methods') headers = {} if _methods: headers['allow'] = str(_methods) raise webob.exc.HTTPMethodNotAllowed( ('The method specified is not allowed for this resource.'), headers=headers, json_formatter=util.json_error_formatter)
def handle_not_allowed(environ, start_response)
Return a 405 response when method is not allowed. If _methods are in routing_args, send an allow header listing the methods that are possible on the provided URL.
5.605319
4.996944
1.121749
mapper = routes.Mapper() for route, methods in ROUTE_LIST: allowed_methods = [] for method, func in methods.items(): mapper.connect(route, action=func, conditions=dict(method=[method])) allowed_methods.append(method) allowed_methods...
def make_map(declarations)
Process route declarations to create a Route Mapper.
3.45943
3.09552
1.11756
offline_dev = 'chccwdev -d %s' % fcp delete_records = self._delete_zfcp_config_records(fcp, target_wwpn, target_lun) return '\n'.join((offline_dev, ...
def _offline_fcp_device(self, fcp, target_wwpn, target_lun, multipath)
rhel offline zfcp. sampe to all rhel distro.
8.311924
7.109338
1.169156
device = '0.0.%s' % fcp data = {'wwpn': target_wwpn, 'lun': target_lun, 'device': device, 'zfcpConf': '/etc/zfcp.conf'} delete_records_cmd = ('sed -i -e ' '\"/%(device)s %(wwpn)s %(lun)s/d\" ' '%(zfcpConf)s\n' %...
def _delete_zfcp_config_records(self, fcp, target_wwpn, target_lun)
rhel
4.187899
4.117767
1.017031
device = '0.0.%s' % fcp data = {'device': device, 'wwpn': target_wwpn, 'lun': target_lun} var_source_device = ('SourceDevice="/dev/disk/by-path/ccw-%(device)s-' 'zfcp-%(wwpn)s:%(lun)s"\n' % data) return var_source_device
def _get_source_device_path(self, fcp, target_wwpn, target_lun)
rhel
4.407884
4.275271
1.031019