query
stringlengths 5
1.23k
| positive
stringlengths 53
15.2k
| id_
int64 0
252k
| task_name
stringlengths 87
242
| negative
sequencelengths 20
553
|
---|---|---|---|---|
Updates the Ethernet interconnect settings for the logical interconnect . | def update_ethernet_settings ( self , configuration , force = False , timeout = - 1 ) : uri = "{}/ethernetSettings" . format ( self . data [ "uri" ] ) return self . _helper . update ( configuration , uri = uri , force = force , timeout = timeout ) | 251,400 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L153-L168 | [
"def",
"create_stream_subscription",
"(",
"self",
",",
"stream",
",",
"on_data",
",",
"timeout",
"=",
"60",
")",
":",
"options",
"=",
"rest_pb2",
".",
"StreamSubscribeRequest",
"(",
")",
"options",
".",
"stream",
"=",
"stream",
"manager",
"=",
"WebSocketSubscriptionManager",
"(",
"self",
".",
"_client",
",",
"resource",
"=",
"'stream'",
",",
"options",
"=",
"options",
")",
"# Represent subscription as a future",
"subscription",
"=",
"WebSocketSubscriptionFuture",
"(",
"manager",
")",
"wrapped_callback",
"=",
"functools",
".",
"partial",
"(",
"_wrap_callback_parse_stream_data",
",",
"subscription",
",",
"on_data",
")",
"manager",
".",
"open",
"(",
"wrapped_callback",
",",
"instance",
"=",
"self",
".",
"_instance",
")",
"# Wait until a reply or exception is received",
"subscription",
".",
"reply",
"(",
"timeout",
"=",
"timeout",
")",
"return",
"subscription"
] |
Updates internal networks on the logical interconnect . | def update_internal_networks ( self , network_uri_list , force = False , timeout = - 1 ) : uri = "{}/internalNetworks" . format ( self . data [ "uri" ] ) return self . _helper . update ( network_uri_list , uri = uri , force = force , timeout = timeout ) | 251,401 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L171-L186 | [
"def",
"remove_mentions",
"(",
"self",
",",
"string",
")",
":",
"def",
"replace",
"(",
"obj",
",",
"*",
",",
"transforms",
"=",
"self",
".",
"MENTION_TRANSFORMS",
")",
":",
"return",
"transforms",
".",
"get",
"(",
"obj",
".",
"group",
"(",
"0",
")",
",",
"'@invalid'",
")",
"return",
"self",
".",
"MENTION_PATTERN",
".",
"sub",
"(",
"replace",
",",
"string",
")"
] |
Asynchronously applies or re - applies the logical interconnect configuration to all managed interconnects . | def update_configuration ( self , timeout = - 1 ) : uri = "{}/configuration" . format ( self . data [ "uri" ] ) return self . _helper . update ( None , uri = uri , timeout = timeout ) | 251,402 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L232-L244 | [
"def",
"retrieve_mtm_results",
"(",
"self",
",",
"book_id",
",",
"asset_manager_id",
",",
"paramaters",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Retrieving mtm Positions - Asset Manager: %s'",
",",
"asset_manager_id",
")",
"url",
"=",
"'%s/mtm/%s'",
"%",
"(",
"self",
".",
"endpoint",
",",
"asset_manager_id",
")",
"paramaters",
".",
"update",
"(",
"{",
"'book_id'",
":",
"book_id",
"}",
")",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
",",
"params",
"=",
"paramaters",
")",
"if",
"response",
".",
"ok",
":",
"mtm_results",
"=",
"[",
"json_to_mtm_result",
"(",
"json_mtm_result",
")",
"for",
"json_mtm_result",
"in",
"response",
".",
"json",
"(",
")",
"]",
"self",
".",
"logger",
".",
"info",
"(",
"'Returned %s mtm results.'",
",",
"len",
"(",
"mtm_results",
")",
")",
"return",
"mtm_results",
"else",
":",
"self",
".",
"logger",
".",
"error",
"(",
"response",
".",
"text",
")",
"response",
".",
"raise_for_status",
"(",
")"
] |
Gets the SNMP configuration for a logical interconnect . | def get_snmp_configuration ( self ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . SNMP_CONFIGURATION_PATH ) return self . _helper . do_get ( uri ) | 251,403 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L247-L255 | [
"def",
"enable_notebook",
"(",
"verbose",
"=",
"0",
")",
":",
"libs",
"=",
"[",
"'objexporter.js'",
",",
"'ArcballControls.js'",
",",
"'filesaver.js'",
",",
"'base64-arraybuffer.js'",
",",
"'context.js'",
",",
"'chemview.js'",
",",
"'three.min.js'",
",",
"'jquery-ui.min.js'",
",",
"'context.standalone.css'",
",",
"'chemview_widget.js'",
",",
"'trajectory_controls_widget.js'",
",",
"\"layout_widget.js\"",
",",
"\"components/jquery-fullscreen/jquery.fullscreen.js\"",
",",
"'scales.js'",
"]",
"fns",
"=",
"[",
"resource_filename",
"(",
"'chemview'",
",",
"os",
".",
"path",
".",
"join",
"(",
"'static'",
",",
"f",
")",
")",
"for",
"f",
"in",
"libs",
"]",
"[",
"install_nbextension",
"(",
"fn",
",",
"verbose",
"=",
"verbose",
",",
"overwrite",
"=",
"True",
",",
"user",
"=",
"True",
")",
"for",
"fn",
"in",
"fns",
"]"
] |
Updates the SNMP configuration of a logical interconnect . Changes to the SNMP configuration are asynchronously applied to all managed interconnects . | def update_snmp_configuration ( self , configuration , timeout = - 1 ) : data = configuration . copy ( ) if 'type' not in data : data [ 'type' ] = 'snmp-configuration' uri = "{}{}" . format ( self . data [ "uri" ] , self . SNMP_CONFIGURATION_PATH ) return self . _helper . update ( data , uri = uri , timeout = timeout ) | 251,404 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L258-L274 | [
"def",
"_parseElfHeader",
"(",
"self",
",",
"data",
")",
":",
"ehdr",
"=",
"self",
".",
"__classes",
".",
"EHDR",
".",
"from_buffer",
"(",
"data",
")",
"return",
"EhdrData",
"(",
"header",
"=",
"ehdr",
")"
] |
Gets the collection ports from the member interconnects which are eligible for assignment to an anlyzer port | def get_unassigned_ports ( self ) : uri = "{}/unassignedPortsForPortMonitor" . format ( self . data [ "uri" ] ) response = self . _helper . do_get ( uri ) return self . _helper . get_members ( response ) | 251,405 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L277-L288 | [
"def",
"__get_registry_key",
"(",
"self",
",",
"key",
")",
":",
"import",
"winreg",
"root",
"=",
"winreg",
".",
"OpenKey",
"(",
"winreg",
".",
"HKEY_CURRENT_USER",
",",
"r'SOFTWARE\\GSettings\\org\\gnucash\\general'",
",",
"0",
",",
"winreg",
".",
"KEY_READ",
")",
"[",
"pathname",
",",
"regtype",
"]",
"=",
"(",
"winreg",
".",
"QueryValueEx",
"(",
"root",
",",
"key",
")",
")",
"winreg",
".",
"CloseKey",
"(",
"root",
")",
"return",
"pathname"
] |
Gets the port monitor configuration of a logical interconnect . | def get_port_monitor ( self ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . PORT_MONITOR_PATH ) return self . _helper . do_get ( uri ) | 251,406 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L306-L314 | [
"def",
"_generate_examples_validation",
"(",
"self",
",",
"archive",
",",
"labels",
")",
":",
"# Get the current random seeds.",
"numpy_st0",
"=",
"np",
".",
"random",
".",
"get_state",
"(",
")",
"# Set new random seeds.",
"np",
".",
"random",
".",
"seed",
"(",
"135",
")",
"logging",
".",
"warning",
"(",
"'Overwriting cv2 RNG seed.'",
")",
"tfds",
".",
"core",
".",
"lazy_imports",
".",
"cv2",
".",
"setRNGSeed",
"(",
"357",
")",
"for",
"example",
"in",
"super",
"(",
"Imagenet2012Corrupted",
",",
"self",
")",
".",
"_generate_examples_validation",
"(",
"archive",
",",
"labels",
")",
":",
"with",
"tf",
".",
"Graph",
"(",
")",
".",
"as_default",
"(",
")",
":",
"tf_img",
"=",
"tf",
".",
"image",
".",
"decode_jpeg",
"(",
"example",
"[",
"'image'",
"]",
".",
"read",
"(",
")",
",",
"channels",
"=",
"3",
")",
"image_np",
"=",
"tfds",
".",
"as_numpy",
"(",
"tf_img",
")",
"example",
"[",
"'image'",
"]",
"=",
"self",
".",
"_get_corrupted_example",
"(",
"image_np",
")",
"yield",
"example",
"# Reset the seeds back to their original values.",
"np",
".",
"random",
".",
"set_state",
"(",
"numpy_st0",
")"
] |
Updates the port monitor configuration of a logical interconnect . | def update_port_monitor ( self , resource , timeout = - 1 ) : data = resource . copy ( ) if 'type' not in data : data [ 'type' ] = 'port-monitor' uri = "{}{}" . format ( self . data [ "uri" ] , self . PORT_MONITOR_PATH ) return self . _helper . update ( data , uri = uri , timeout = timeout ) | 251,407 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L317-L332 | [
"def",
"_generate_examples_validation",
"(",
"self",
",",
"archive",
",",
"labels",
")",
":",
"# Get the current random seeds.",
"numpy_st0",
"=",
"np",
".",
"random",
".",
"get_state",
"(",
")",
"# Set new random seeds.",
"np",
".",
"random",
".",
"seed",
"(",
"135",
")",
"logging",
".",
"warning",
"(",
"'Overwriting cv2 RNG seed.'",
")",
"tfds",
".",
"core",
".",
"lazy_imports",
".",
"cv2",
".",
"setRNGSeed",
"(",
"357",
")",
"for",
"example",
"in",
"super",
"(",
"Imagenet2012Corrupted",
",",
"self",
")",
".",
"_generate_examples_validation",
"(",
"archive",
",",
"labels",
")",
":",
"with",
"tf",
".",
"Graph",
"(",
")",
".",
"as_default",
"(",
")",
":",
"tf_img",
"=",
"tf",
".",
"image",
".",
"decode_jpeg",
"(",
"example",
"[",
"'image'",
"]",
".",
"read",
"(",
")",
",",
"channels",
"=",
"3",
")",
"image_np",
"=",
"tfds",
".",
"as_numpy",
"(",
"tf_img",
")",
"example",
"[",
"'image'",
"]",
"=",
"self",
".",
"_get_corrupted_example",
"(",
"image_np",
")",
"yield",
"example",
"# Reset the seeds back to their original values.",
"np",
".",
"random",
".",
"set_state",
"(",
"numpy_st0",
")"
] |
Creates an interconnect at the given location . | def create_interconnect ( self , location_entries , timeout = - 1 ) : return self . _helper . create ( location_entries , uri = self . locations_uri , timeout = timeout ) | 251,408 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L334-L351 | [
"def",
"strip_system_metadata",
"(",
"etree_obj",
")",
":",
"for",
"series_id_el",
"in",
"etree_obj",
".",
"findall",
"(",
"'seriesId'",
")",
":",
"etree_obj",
".",
"remove",
"(",
"series_id_el",
")",
"for",
"media_type_el",
"in",
"etree_obj",
".",
"findall",
"(",
"'mediaType'",
")",
":",
"etree_obj",
".",
"remove",
"(",
"media_type_el",
")",
"for",
"file_name_el",
"in",
"etree_obj",
".",
"findall",
"(",
"'fileName'",
")",
":",
"etree_obj",
".",
"remove",
"(",
"file_name_el",
")"
] |
Deletes an interconnect from a location . | def delete_interconnect ( self , enclosure_uri , bay , timeout = - 1 ) : uri = "{path}?location=Enclosure:{enclosure_uri},Bay:{bay}" . format ( path = self . LOCATIONS_PATH , enclosure_uri = enclosure_uri , bay = bay ) return self . _helper . delete ( uri , timeout = timeout ) | 251,409 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L353-L374 | [
"def",
"pack_turret",
"(",
"turret",
",",
"temp_files",
",",
"base_config_path",
",",
"path",
"=",
"None",
")",
":",
"file_name",
"=",
"turret",
"[",
"'name'",
"]",
"files",
"=",
"temp_files",
"[",
":",
"]",
"for",
"fname",
"in",
"turret",
".",
"get",
"(",
"'extra_files'",
",",
"[",
"]",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"fname",
")",
"or",
"path",
"is",
"None",
":",
"files",
".",
"append",
"(",
"fname",
")",
"else",
":",
"files",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"fname",
")",
")",
"if",
"path",
"is",
"not",
"None",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"file_name",
")",
"tar_file",
"=",
"tarfile",
".",
"open",
"(",
"file_name",
"+",
"\".tar.gz\"",
",",
"'w:gz'",
")",
"for",
"f",
"in",
"files",
":",
"tar_file",
".",
"add",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"f",
")",
",",
"arcname",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"f",
")",
")",
"script_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"base_config_path",
")",
",",
"turret",
"[",
"'script'",
"]",
")",
"tar_file",
".",
"add",
"(",
"script_path",
",",
"arcname",
"=",
"turret",
"[",
"'script'",
"]",
")",
"for",
"f",
"in",
"tar_file",
".",
"getnames",
"(",
")",
":",
"print",
"(",
"\"Added %s\"",
"%",
"f",
")",
"tar_file",
".",
"close",
"(",
")",
"print",
"(",
"\"Archive %s created\"",
"%",
"(",
"tar_file",
".",
"name",
")",
")",
"print",
"(",
"\"=========================================\"",
")"
] |
Gets the installed firmware for a logical interconnect . | def get_firmware ( self ) : firmware_uri = self . _helper . build_subresource_uri ( self . data [ "uri" ] , subresource_path = self . FIRMWARE_PATH ) return self . _helper . do_get ( firmware_uri ) | 251,410 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L377-L385 | [
"def",
"remove_mentions",
"(",
"self",
",",
"string",
")",
":",
"def",
"replace",
"(",
"obj",
",",
"*",
",",
"transforms",
"=",
"self",
".",
"MENTION_TRANSFORMS",
")",
":",
"return",
"transforms",
".",
"get",
"(",
"obj",
".",
"group",
"(",
"0",
")",
",",
"'@invalid'",
")",
"return",
"self",
".",
"MENTION_PATTERN",
".",
"sub",
"(",
"replace",
",",
"string",
")"
] |
Gets the forwarding information base data for a logical interconnect . A maximum of 100 entries is returned . Optional filtering criteria might be specified . | def get_forwarding_information_base ( self , filter = '' ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . FORWARDING_INFORMATION_PATH ) return self . _helper . get_collection ( uri , filter = filter ) | 251,411 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L404-L420 | [
"def",
"_wait_and_except_if_failed",
"(",
"self",
",",
"event",
",",
"timeout",
"=",
"None",
")",
":",
"event",
".",
"wait",
"(",
"timeout",
"or",
"self",
".",
"__sync_timeout",
")",
"self",
".",
"_except_if_failed",
"(",
"event",
")"
] |
Generates the forwarding information base dump file for a logical interconnect . | def create_forwarding_information_base ( self , timeout = - 1 ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . FORWARDING_INFORMATION_PATH ) return self . _helper . do_post ( uri , None , timeout , None ) | 251,412 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L423-L435 | [
"def",
"get_n_config_to_keep",
"(",
"self",
",",
"n_suggestions",
",",
"bracket_iteration",
")",
":",
"n_configs",
"=",
"n_suggestions",
"*",
"(",
"self",
".",
"eta",
"**",
"-",
"bracket_iteration",
")",
"return",
"int",
"(",
"n_configs",
"/",
"self",
".",
"eta",
")"
] |
Gets the QoS aggregated configuration for the logical interconnect . | def get_qos_aggregated_configuration ( self ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . QOS_AGGREGATED_CONFIGURATION ) return self . _helper . do_get ( uri ) | 251,413 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L438-L446 | [
"def",
"main",
"(",
"args",
")",
":",
"random",
".",
"seed",
"(",
")",
"temp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"logging",
".",
"info",
"(",
"'Created temporary directory: %s'",
",",
"temp_dir",
")",
"validator",
"=",
"SubmissionValidator",
"(",
"source_dir",
"=",
"args",
".",
"source_dir",
",",
"target_dir",
"=",
"args",
".",
"target_dir",
",",
"temp_dir",
"=",
"temp_dir",
",",
"do_copy",
"=",
"args",
".",
"copy",
",",
"use_gpu",
"=",
"args",
".",
"use_gpu",
",",
"containers_file",
"=",
"args",
".",
"containers_file",
")",
"validator",
".",
"run",
"(",
")",
"logging",
".",
"info",
"(",
"'Deleting temporary directory: %s'",
",",
"temp_dir",
")",
"subprocess",
".",
"call",
"(",
"[",
"'rm'",
",",
"'-rf'",
",",
"temp_dir",
"]",
")"
] |
Updates the QoS aggregated configuration for the logical interconnect . | def update_qos_aggregated_configuration ( self , qos_configuration , timeout = - 1 ) : uri = "{}{}" . format ( self . data [ "uri" ] , self . QOS_AGGREGATED_CONFIGURATION ) return self . _helper . update ( qos_configuration , uri = uri , timeout = timeout ) | 251,414 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L449-L464 | [
"def",
"main",
"(",
"args",
")",
":",
"random",
".",
"seed",
"(",
")",
"temp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"logging",
".",
"info",
"(",
"'Created temporary directory: %s'",
",",
"temp_dir",
")",
"validator",
"=",
"SubmissionValidator",
"(",
"source_dir",
"=",
"args",
".",
"source_dir",
",",
"target_dir",
"=",
"args",
".",
"target_dir",
",",
"temp_dir",
"=",
"temp_dir",
",",
"do_copy",
"=",
"args",
".",
"copy",
",",
"use_gpu",
"=",
"args",
".",
"use_gpu",
",",
"containers_file",
"=",
"args",
".",
"containers_file",
")",
"validator",
".",
"run",
"(",
")",
"logging",
".",
"info",
"(",
"'Deleting temporary directory: %s'",
",",
"temp_dir",
")",
"subprocess",
".",
"call",
"(",
"[",
"'rm'",
",",
"'-rf'",
",",
"temp_dir",
"]",
")"
] |
Updates the telemetry configuration of a logical interconnect . Changes to the telemetry configuration are asynchronously applied to all managed interconnects . | def update_telemetry_configurations ( self , configuration , timeout = - 1 ) : telemetry_conf_uri = self . _get_telemetry_configuration_uri ( ) default_values = self . _get_default_values ( self . SETTINGS_TELEMETRY_CONFIG_DEFAULT_VALUES ) configuration = self . _helper . update_resource_fields ( configuration , default_values ) return self . _helper . update ( configuration , uri = telemetry_conf_uri , timeout = timeout ) | 251,415 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L485-L504 | [
"def",
"create",
"(",
"cls",
",",
"destination",
")",
":",
"mdb_gz_b64",
"=",
"\"\"\"\\\n H4sICIenn1gC/25ldzIwMDMubWRiAO2de2wcRx3Hf7O7Pt/d3u6eLyEtVaOaqg+EkjQvuVVDwa9a\n jWXHdZxQQlCJ7fOrfp3OTpqkhVxTItFWIhVQVFBRVNIKRaColVpAUKGKRwwFqUAhKiBIpUaoVWP+\n qKgIIHL8Znb39u72znWJiWP3+9l473fzm/nNY3cdf2fmbBJEPdO9E+nebLq+fWC6vrWZOImen9D7\n 9sR+vPPNE0PZxo/TE5879mj+yNc3/OzAD2bXv3DmV9/o/8PZnxxr+/fDL2w79ulzN7e+/sS/zvzz\n w3+N1z28p3PTfQ3nfn/m2YmeFS2no89uWnvqwO5HUvd/5Phr938tes3j/zm5+qT41J8/P/iZx87/\n +qHrjgyduubG1t/+7eWB2XztTNuT+1clZt9c2/e7HRGizevWEwAAAAAAAACAhUEIwvE+PoRIO8K7\n FzT6obPPwTMBAAAAAAAAAABcfpzPXwya+Ispo1xlEO2KEEX9eaGyWnrqyKQ60tQ0AcNZRcR1RYuy\n +XZCxoqRzmaMI6cKGRJuJVrIEZUOQ9UrHStUYpyzKkdNmSPFDkM6aguhXMdVHCMuHXE2Suu4IFQJ\n l6CErNWUDouDlbdKOZIcrKLD4S5WdNhqIEodqlVaofKgVTHpiBQ6uLG0uaKsuYbf3IS8BmV1qFAm\n j1Z5Hbp06GWDKC+DTS00SRN8DFA/TXNfW6mXX3upj7+mOHWllzLAObN8du0gdSdlKO3ZcWqjMbaH\n uOQqtidViRF+P0HbOH2c3xm0lfMb1EH7uHZ5vp32c+ks+5PqfSeXS9NejjTAvZQpd7J3kuuJFqLE\n qYvuVa3Ocqk7OVXWNMFxZPRVtJ1zSXuCBrlkh+rjEF1Zlt5Dw6qN0xx5Bx3gGgbowVo56EIjkc9T\n xX9Jdd+5PKDOD6q3VQvwv7qiZ8st419cdYHlo6iuriF8X4HA590AsodXhvrsj0yMDPnAuI+ZvOrq\n 1o7K51Hdy7a8cdXNm5AedbfG5W3j3lOybxFZKb6zAgAAAAAAsNzQxAlbvnYJV3VcUU3/S2luBIKF\n ha+IlWp+wxW4IiRXRSXxKeNU1eOxUuUbSOIINbEM7WT506ZE3LASgCOeYJWCMcnCsI/u8eSsFEYR\n lnlbWa6+u0jTYqSkvuQL9G5CLFwTRBMAAAAAAAAAgMtW/79lyVdLKxW7oqDF3bXOniib0UD/m/xq\n loWqvFwt3DX/mrLNALIu3V35NkpK1JDmL+2XOmr9pf1gKiFY4I672wc0mveaf6zaenyKmljPT6t5\n hT7a6y13y0XqjFpwneJjRC0oRwvL3eUL2fHCcuyGIntjhTkDuZCd5Vc5j+HNUMyx+myYcpHW5YG5\n ZijUdbg2VFu4ZzzcHFM3seQLAAAAAAAAAMtc//9S6cm1emX97ytK1v81rHelhtfVfAFnseZXRdV9\n Ad7+dhGS5kbl3eqe/K8pU/nnYwX5X2VeoLbCZwHi7txD6aTELabnoLJ5AfPFC8JmFd3Pun+MlfM4\n q/846/4s62i5+8Dmc7EvSVN0UG2tL00p1uPXqZTt/G5QqX+5lbufz+mSctVzFce6upBrTG3Fd+cn\n pmiYrUyw8+GNfL4hn8/k83qZrVlyGzgPeqbhjcOqx7KMEZRpU/MPQ+rsldEtuYm8vExkznoMS+6b\n KC5TZRt8wVf4xEkFX4V5D/X2vYz1/EcR8yMAAAAAAACAJY0Qf/d3vLPUlb//b4Nzzv6W3Wevtl+1\n vmxts2LWTxOHErcm3jGfMUfNG0yMGQAAAAAAeJ/8rLwAMXIYRgCARFv8IIaYtKpGqCdqlN/2kupD\n /ob67qXhsi0lDh2Vp6728faO9tHuUflfWJ1wE0e6724f35XuG71r16Dr0FwH573by6rKi0N7RveN\n tnd6aTVBWrpjd3fnuJtsBMnDk90ju7zckSA5XGGtdGrK2dWhUnRcMgAAAAAAAAD4v2CIV6vqf82I\n Jusbcwsy7wkWSf/n1JQNq/Oc+uQGq/ecmsphYZ6Tn6XwRLjwxb7mTxDoakLgURUFshwAAAAAAAAA\n ljpCrHZ8W/f2/2NUAAAAAAAAAAAAhXH5RLm4IIbotqot7hbW/0MGWCp46/+pgpHwjZS3IyAlfMPy\n tgakNN+wfcPxNgukdN9I+kadt30gZfhGjW+s8I2V3s6CVNTbWZCK+Eatb3zAN1Z5mw5SMd+I+wZ+\n +QQAAAAAAAAA/K8IcdT27Zqi3/+HkQEAAAAAAAAAsGgkMQQLjSHqbQPDAAAAAAAAAAAALGuw/g8A\n AAAAAAAA4DJUqwsQI7cQDWlcLiMq1/9rcGMBAAAAAAAAAADLGuh/AAAAAAAAAAAA+h8AAAAAAAAA\n AABLHyHusDTPjtLzTtoxnRftUftqe8YatDA+AAAAAAAAAPDeqJN/KVt+et0R9PYnzz7W8PrZRv+V\n HblO6qEDNEXbaYDGqJemaYQmaYJThtnK8Gvzb1opfDRTPZmUlxUY86qgm/ZyFVkOOqCC3kLhoyEI\n qs8raBO10O0q3EYKH+uDcNq8wnVRH93D7evnYZhHG5kkB3a0OYO2ctCWV9ZR+FhT0l2HCzl6xVBz\n XZyPUvi4taTjcwRuVUF7uYW9HMy9MJspfGwMAoo5A+5Qwca8UHN2WogeU/fu0ito1vmjM+M85zzp\n fNG5zxl2djrNzk3O9+0m+yWrx2q0fpH4buJ4Yk3ig4lvmkfxx9gBAAAAAAC4OAylQfJ5h5pfSVCc\n f853gqSmWPSZux6xjUznltH2HT/flNu7++0NZ7/07cg/vnPbVu30y6d/NLvlabPh+j81v/Xc5g9l\n 1h2f+epn9+VPdN90OHHvU50fm94y/ZXvWQ/tP/yJG/NH3llz8A79tlNPG72DHSePHdzz2s3XPzVj\n vzSUvSHjVys1Rv5CSUv8pEvcEqkbV/KX35JaQ+npikmRS9o4rtYIt8RYnJa4Ou6SV6stTm+l7rcX\n q9qSy+23pCVIcgV/SZKuJj5CSRc4Y/PpkiesLJcI53J37NvFuQzv4peGL0/SypP+C+45xVAAMAEA\n \"\"\"",
"pristine",
"=",
"StringIO",
"(",
")",
"pristine",
".",
"write",
"(",
"base64",
".",
"b64decode",
"(",
"mdb_gz_b64",
")",
")",
"pristine",
".",
"seek",
"(",
"0",
")",
"pristine",
"=",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"pristine",
",",
"mode",
"=",
"'rb'",
")",
"with",
"open",
"(",
"destination",
",",
"'wb'",
")",
"as",
"handle",
":",
"shutil",
".",
"copyfileobj",
"(",
"pristine",
",",
"handle",
")",
"return",
"cls",
"(",
"destination",
")"
] |
Gets the Ethernet interconnect settings for the Logical Interconnect . | def get_ethernet_settings ( self ) : uri = "{}/ethernetSettings" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,416 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnects.py#L507-L515 | [
"def",
"_to_unit_base",
"(",
"self",
",",
"base_unit",
",",
"values",
",",
"unit",
",",
"from_unit",
")",
":",
"self",
".",
"_is_numeric",
"(",
"values",
")",
"namespace",
"=",
"{",
"'self'",
":",
"self",
",",
"'values'",
":",
"values",
"}",
"if",
"not",
"from_unit",
"==",
"base_unit",
":",
"self",
".",
"is_unit_acceptable",
"(",
"from_unit",
",",
"True",
")",
"statement",
"=",
"'[self._{}_to_{}(val) for val in values]'",
".",
"format",
"(",
"self",
".",
"_clean",
"(",
"from_unit",
")",
",",
"self",
".",
"_clean",
"(",
"base_unit",
")",
")",
"values",
"=",
"eval",
"(",
"statement",
",",
"namespace",
")",
"namespace",
"[",
"'values'",
"]",
"=",
"values",
"if",
"not",
"unit",
"==",
"base_unit",
":",
"self",
".",
"is_unit_acceptable",
"(",
"unit",
",",
"True",
")",
"statement",
"=",
"'[self._{}_to_{}(val) for val in values]'",
".",
"format",
"(",
"self",
".",
"_clean",
"(",
"base_unit",
")",
",",
"self",
".",
"_clean",
"(",
"unit",
")",
")",
"values",
"=",
"eval",
"(",
"statement",
",",
"namespace",
")",
"return",
"values"
] |
Download archived logs of the OS Volume . | def download_archive ( self , name , file_path ) : uri = self . URI + "/archive/" + name return self . _client . download ( uri , file_path ) | 251,417 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/os_volumes.py#L110-L122 | [
"def",
"create_token_response",
"(",
"self",
",",
"request",
",",
"token_handler",
")",
":",
"headers",
"=",
"self",
".",
"_get_default_headers",
"(",
")",
"try",
":",
"if",
"self",
".",
"request_validator",
".",
"client_authentication_required",
"(",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Authenticating client, %r.'",
",",
"request",
")",
"if",
"not",
"self",
".",
"request_validator",
".",
"authenticate_client",
"(",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Client authentication failed, %r.'",
",",
"request",
")",
"raise",
"errors",
".",
"InvalidClientError",
"(",
"request",
"=",
"request",
")",
"elif",
"not",
"self",
".",
"request_validator",
".",
"authenticate_client_id",
"(",
"request",
".",
"client_id",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Client authentication failed, %r.'",
",",
"request",
")",
"raise",
"errors",
".",
"InvalidClientError",
"(",
"request",
"=",
"request",
")",
"log",
".",
"debug",
"(",
"'Validating access token request, %r.'",
",",
"request",
")",
"self",
".",
"validate_token_request",
"(",
"request",
")",
"except",
"errors",
".",
"OAuth2Error",
"as",
"e",
":",
"log",
".",
"debug",
"(",
"'Client error in token request, %s.'",
",",
"e",
")",
"headers",
".",
"update",
"(",
"e",
".",
"headers",
")",
"return",
"headers",
",",
"e",
".",
"json",
",",
"e",
".",
"status_code",
"token",
"=",
"token_handler",
".",
"create_token",
"(",
"request",
",",
"self",
".",
"refresh_token",
")",
"for",
"modifier",
"in",
"self",
".",
"_token_modifiers",
":",
"token",
"=",
"modifier",
"(",
"token",
")",
"self",
".",
"request_validator",
".",
"save_token",
"(",
"token",
",",
"request",
")",
"log",
".",
"debug",
"(",
"'Issuing token %r to client id %r (%r) and username %s.'",
",",
"token",
",",
"request",
".",
"client_id",
",",
"request",
".",
"client",
",",
"request",
".",
"username",
")",
"return",
"headers",
",",
"json",
".",
"dumps",
"(",
"token",
")",
",",
"200"
] |
Get storage details of an OS Volume . | def get_storage ( self , id_or_uri ) : uri = self . URI + "/{}/storage" . format ( extract_id_from_uri ( id_or_uri ) ) return self . _client . get ( uri ) | 251,418 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/os_volumes.py#L124-L135 | [
"def",
"real_main",
"(",
"release_url",
"=",
"None",
",",
"tests_json_path",
"=",
"None",
",",
"upload_build_id",
"=",
"None",
",",
"upload_release_name",
"=",
"None",
")",
":",
"coordinator",
"=",
"workers",
".",
"get_coordinator",
"(",
")",
"fetch_worker",
".",
"register",
"(",
"coordinator",
")",
"coordinator",
".",
"start",
"(",
")",
"data",
"=",
"open",
"(",
"FLAGS",
".",
"tests_json_path",
")",
".",
"read",
"(",
")",
"tests",
"=",
"load_tests",
"(",
"data",
")",
"item",
"=",
"DiffMyImages",
"(",
"release_url",
",",
"tests",
",",
"upload_build_id",
",",
"upload_release_name",
",",
"heartbeat",
"=",
"workers",
".",
"PrintWorkflow",
")",
"item",
".",
"root",
"=",
"True",
"coordinator",
".",
"input_queue",
".",
"put",
"(",
"item",
")",
"coordinator",
".",
"wait_one",
"(",
")",
"coordinator",
".",
"stop",
"(",
")",
"coordinator",
".",
"join",
"(",
")"
] |
Retrieves the topology information for the rack resource specified by ID or URI . | def get_device_topology ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/deviceTopology" return self . _client . get ( uri ) | 251,419 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/facilities/racks.py#L91-L102 | [
"def",
"removeAllEntitlements",
"(",
"self",
",",
"appId",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"appId\"",
":",
"appId",
"}",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/licenses/removeAllEntitlements\"",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
Gets a Managed SAN by name . | def get_by_name ( self , name ) : managed_sans = self . get_all ( ) result = [ x for x in managed_sans if x [ 'name' ] == name ] resource = result [ 0 ] if result else None if resource : resource = self . new ( self . _connection , resource ) return resource | 251,420 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/managed_sans.py#L71-L88 | [
"def",
"recv_raw",
"(",
"self",
",",
"timeout",
",",
"opcodes",
",",
"*",
"*",
"kwargs",
")",
":",
"orig_timeout",
"=",
"self",
".",
"get_timeout",
"(",
"timeout",
")",
"timeout",
"=",
"orig_timeout",
"while",
"timeout",
">",
"0.0",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"if",
"not",
"self",
".",
"connected",
":",
"self",
".",
"connect",
"(",
"timeout",
"=",
"timeout",
",",
"*",
"*",
"kwargs",
")",
"with",
"self",
".",
"wstimeout",
"(",
"timeout",
",",
"*",
"*",
"kwargs",
")",
"as",
"timeout",
":",
"logger",
".",
"debug",
"(",
"'{} waiting to receive for {} seconds'",
".",
"format",
"(",
"self",
".",
"client_id",
",",
"timeout",
")",
")",
"try",
":",
"opcode",
",",
"data",
"=",
"self",
".",
"ws",
".",
"recv_data",
"(",
")",
"if",
"opcode",
"in",
"opcodes",
":",
"timeout",
"=",
"0.0",
"break",
"else",
":",
"if",
"opcode",
"==",
"websocket",
".",
"ABNF",
".",
"OPCODE_CLOSE",
":",
"raise",
"websocket",
".",
"WebSocketConnectionClosedException",
"(",
")",
"except",
"websocket",
".",
"WebSocketTimeoutException",
":",
"pass",
"except",
"websocket",
".",
"WebSocketConnectionClosedException",
":",
"# bug in Websocket.recv_data(), this should be done by Websocket",
"try",
":",
"self",
".",
"ws",
".",
"shutdown",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"#raise EOFError(\"websocket closed by server and reconnection did nothing\")",
"if",
"timeout",
":",
"stop",
"=",
"time",
".",
"time",
"(",
")",
"timeout",
"-=",
"(",
"stop",
"-",
"start",
")",
"else",
":",
"break",
"if",
"timeout",
"<",
"0.0",
":",
"raise",
"IOError",
"(",
"\"recv timed out in {} seconds\"",
".",
"format",
"(",
"orig_timeout",
")",
")",
"return",
"opcode",
",",
"data"
] |
Gets a list of endpoints in a SAN . | def get_endpoints ( self , start = 0 , count = - 1 , filter = '' , sort = '' ) : uri = "{}/endpoints/" . format ( self . data [ "uri" ] ) return self . _helper . get_all ( start , count , filter = filter , sort = sort , uri = uri ) | 251,421 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/managed_sans.py#L99-L122 | [
"async",
"def",
"register",
"(",
"self",
",",
"request",
")",
":",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"user_id",
"=",
"session",
".",
"get",
"(",
"'user_id'",
")",
"if",
"user_id",
":",
"return",
"redirect",
"(",
"request",
",",
"'timeline'",
")",
"error",
"=",
"None",
"form",
"=",
"None",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"form",
"=",
"await",
"request",
".",
"post",
"(",
")",
"user_id",
"=",
"await",
"db",
".",
"get_user_id",
"(",
"self",
".",
"mongo",
".",
"user",
",",
"form",
"[",
"'username'",
"]",
")",
"if",
"not",
"form",
"[",
"'username'",
"]",
":",
"error",
"=",
"'You have to enter a username'",
"elif",
"not",
"form",
"[",
"'email'",
"]",
"or",
"'@'",
"not",
"in",
"form",
"[",
"'email'",
"]",
":",
"error",
"=",
"'You have to enter a valid email address'",
"elif",
"not",
"form",
"[",
"'password'",
"]",
":",
"error",
"=",
"'You have to enter a password'",
"elif",
"form",
"[",
"'password'",
"]",
"!=",
"form",
"[",
"'password2'",
"]",
":",
"error",
"=",
"'The two passwords do not match'",
"elif",
"user_id",
"is",
"not",
"None",
":",
"error",
"=",
"'The username is already taken'",
"else",
":",
"await",
"self",
".",
"mongo",
".",
"user",
".",
"insert",
"(",
"{",
"'username'",
":",
"form",
"[",
"'username'",
"]",
",",
"'email'",
":",
"form",
"[",
"'email'",
"]",
",",
"'pw_hash'",
":",
"generate_password_hash",
"(",
"form",
"[",
"'password'",
"]",
")",
"}",
")",
"return",
"redirect",
"(",
"request",
",",
"'login'",
")",
"return",
"{",
"\"error\"",
":",
"error",
",",
"\"form\"",
":",
"form",
"}"
] |
Creates an endpoints CSV file for a SAN . | def create_endpoints_csv_file ( self , timeout = - 1 ) : uri = "{}/endpoints/" . format ( self . data [ "uri" ] ) return self . _helper . do_post ( uri , { } , timeout , None ) | 251,422 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/managed_sans.py#L125-L138 | [
"def",
"bulk_remove_entities",
"(",
"self",
",",
"entities_and_kinds",
")",
":",
"criteria",
"=",
"[",
"Q",
"(",
"entity",
"=",
"entity",
",",
"sub_entity_kind",
"=",
"entity_kind",
")",
"for",
"entity",
",",
"entity_kind",
"in",
"entities_and_kinds",
"]",
"criteria",
"=",
"reduce",
"(",
"lambda",
"q1",
",",
"q2",
":",
"q1",
"|",
"q2",
",",
"criteria",
",",
"Q",
"(",
")",
")",
"EntityGroupMembership",
".",
"objects",
".",
"filter",
"(",
"criteria",
",",
"entity_group",
"=",
"self",
")",
".",
"delete",
"(",
")"
] |
Creates an unexpected zoning report for a SAN . | def create_issues_report ( self , timeout = - 1 ) : uri = "{}/issues/" . format ( self . data [ "uri" ] ) return self . _helper . create_report ( uri , timeout ) | 251,423 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/managed_sans.py#L141-L154 | [
"def",
"add_metadata",
"(",
"file_name",
",",
"title",
",",
"artist",
",",
"album",
")",
":",
"tags",
"=",
"EasyMP3",
"(",
"file_name",
")",
"if",
"title",
":",
"tags",
"[",
"\"title\"",
"]",
"=",
"title",
"if",
"artist",
":",
"tags",
"[",
"\"artist\"",
"]",
"=",
"artist",
"if",
"album",
":",
"tags",
"[",
"\"album\"",
"]",
"=",
"album",
"tags",
".",
"save",
"(",
")",
"return",
"file_name"
] |
Adds the specified trap forwarding destination . The trap destination associated with the specified id will be created if trap destination with that id does not exists . The id can only be an integer greater than 0 . | def create ( self , resource , id = None , timeout = - 1 ) : if not id : available_id = self . __get_first_available_id ( ) uri = '%s/%s' % ( self . URI , str ( available_id ) ) else : uri = '%s/%s' % ( self . URI , str ( id ) ) return self . _client . create ( resource , uri = uri , timeout = timeout ) | 251,424 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/appliance_device_snmp_v1_trap_destinations.py#L46-L67 | [
"def",
"to",
"(",
"self",
",",
"unit",
")",
":",
"u",
"=",
"Unit",
"(",
"\"0cm\"",
")",
"u",
".",
"value",
"=",
"self",
".",
"value",
"/",
"self",
".",
"per_inch",
"[",
"self",
".",
"unit",
"]",
"*",
"self",
".",
"per_inch",
"[",
"unit",
"]",
"u",
".",
"unit",
"=",
"unit",
"return",
"u"
] |
Find the smallest elements missing in a sorted array . | def __findFirstMissing ( self , array , start , end ) : if ( start > end ) : return end + 1 if ( start != array [ start ] ) : return start mid = int ( ( start + end ) / 2 ) if ( array [ mid ] == mid ) : return self . __findFirstMissing ( array , mid + 1 , end ) return self . __findFirstMissing ( array , start , mid ) | 251,425 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/appliance_device_snmp_v1_trap_destinations.py#L69-L87 | [
"def",
"_connect",
"(",
"self",
")",
":",
"try",
":",
"# Open Connection",
"self",
".",
"influx",
"=",
"InfluxDBClient",
"(",
"self",
".",
"hostname",
",",
"self",
".",
"port",
",",
"self",
".",
"username",
",",
"self",
".",
"password",
",",
"self",
".",
"database",
",",
"self",
".",
"ssl",
")",
"# Log",
"self",
".",
"log",
".",
"debug",
"(",
"\"InfluxdbHandler: Established connection to \"",
"\"%s:%d/%s.\"",
",",
"self",
".",
"hostname",
",",
"self",
".",
"port",
",",
"self",
".",
"database",
")",
"except",
"Exception",
"as",
"ex",
":",
"# Log Error",
"self",
".",
"_throttle_error",
"(",
"\"InfluxdbHandler: Failed to connect to \"",
"\"%s:%d/%s. %s\"",
",",
"self",
".",
"hostname",
",",
"self",
".",
"port",
",",
"self",
".",
"database",
",",
"ex",
")",
"# Close Socket",
"self",
".",
"_close",
"(",
")",
"return"
] |
Private method to get the first available id . The id can only be an integer greater than 0 . | def __get_first_available_id ( self ) : traps = self . get_all ( ) if traps : used_ids = [ 0 ] for trap in traps : used_uris = trap . get ( 'uri' ) used_ids . append ( int ( used_uris . split ( '/' ) [ - 1 ] ) ) used_ids . sort ( ) return self . __findFirstMissing ( used_ids , 0 , len ( used_ids ) - 1 ) else : return 1 | 251,426 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/appliance_device_snmp_v1_trap_destinations.py#L89-L106 | [
"def",
"write_biom_table",
"(",
"table",
",",
"biom_fp",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"'write_biom_table to file %s'",
"%",
"biom_fp",
")",
"with",
"biom_open",
"(",
"biom_fp",
",",
"'w'",
")",
"as",
"f",
":",
"table",
".",
"to_hdf5",
"(",
"h5grp",
"=",
"f",
",",
"generated_by",
"=",
"\"deblur\"",
")",
"logger",
".",
"debug",
"(",
"'wrote to BIOM file %s'",
"%",
"biom_fp",
")"
] |
Edit an IPv4 Range . | def update ( self , information , timeout = - 1 ) : return self . _client . update ( information , timeout = timeout ) | 251,427 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/id_pools_ipv4_ranges.py#L92-L105 | [
"def",
"_get_container_dirs",
"(",
"source_dir",
",",
"manifest_dir",
")",
":",
"base",
"=",
"\"/tmp/samcli\"",
"result",
"=",
"{",
"\"source_dir\"",
":",
"\"{}/source\"",
".",
"format",
"(",
"base",
")",
",",
"\"artifacts_dir\"",
":",
"\"{}/artifacts\"",
".",
"format",
"(",
"base",
")",
",",
"\"scratch_dir\"",
":",
"\"{}/scratch\"",
".",
"format",
"(",
"base",
")",
",",
"\"manifest_dir\"",
":",
"\"{}/manifest\"",
".",
"format",
"(",
"base",
")",
"}",
"if",
"pathlib",
".",
"PurePath",
"(",
"source_dir",
")",
"==",
"pathlib",
".",
"PurePath",
"(",
"manifest_dir",
")",
":",
"# It is possible that the manifest resides within the source. In that case, we won't mount the manifest",
"# directory separately.",
"result",
"[",
"\"manifest_dir\"",
"]",
"=",
"result",
"[",
"\"source_dir\"",
"]",
"return",
"result"
] |
Wait for task execution and return associated resource . | def wait_for_task ( self , task , timeout = - 1 ) : self . __wait_task_completion ( task , timeout ) task = self . get ( task ) logger . debug ( "Waiting for task. Percentage complete: " + str ( task . get ( 'computedPercentComplete' ) ) ) logger . debug ( "Waiting for task. Task state: " + str ( task . get ( 'taskState' ) ) ) task_response = self . __get_task_response ( task ) logger . debug ( 'Task completed' ) return task_response | 251,428 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/task_monitor.py#L70-L90 | [
"def",
"find_apikey",
"(",
")",
":",
"env_keys",
"=",
"[",
"'TINYPNG_APIKEY'",
",",
"'TINYPNG_API_KEY'",
"]",
"paths",
"=",
"[",
"]",
"paths",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"\".\"",
")",
",",
"\"tinypng.key\"",
")",
")",
"# local directory",
"paths",
".",
"append",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.tinypng.key\"",
")",
")",
"# home directory",
"for",
"env_key",
"in",
"env_keys",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"env_key",
")",
":",
"return",
"os",
".",
"environ",
".",
"get",
"(",
"env_key",
")",
"for",
"path",
"in",
"paths",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"open",
"(",
"path",
",",
"'rt'",
")",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
"return",
"None"
] |
Waits until the task is completed and returns the task resource . | def get_completed_task ( self , task , timeout = - 1 ) : self . __wait_task_completion ( task , timeout ) return self . get ( task ) | 251,429 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/task_monitor.py#L92-L105 | [
"def",
"public_dsn",
"(",
"dsn",
")",
":",
"m",
"=",
"RE_DSN",
".",
"match",
"(",
"dsn",
")",
"if",
"not",
"m",
":",
"log",
".",
"error",
"(",
"'Unable to parse Sentry DSN'",
")",
"public",
"=",
"'{scheme}://{client_id}@{domain}/{site_id}'",
".",
"format",
"(",
"*",
"*",
"m",
".",
"groupdict",
"(",
")",
")",
"return",
"public"
] |
Retrieve a resource associated with a task . | def get_associated_resource ( self , task ) : if not task : raise HPOneViewUnknownType ( MSG_INVALID_TASK ) if task [ 'category' ] != 'tasks' and task [ 'category' ] != 'backups' : # it is an error if type is not in obj, so let the except flow raise HPOneViewUnknownType ( MSG_UNKNOWN_OBJECT_TYPE ) if task [ 'type' ] == 'TaskResourceV2' : resource_uri = task [ 'associatedResource' ] [ 'resourceUri' ] if resource_uri and resource_uri . startswith ( "/rest/appliance/support-dumps/" ) : # Specific for support dumps return task , resource_uri elif task [ 'type' ] == 'BACKUP' : task = self . _connection . get ( task [ 'taskUri' ] ) resource_uri = task [ 'uri' ] else : raise HPOneViewInvalidResource ( MSG_TASK_TYPE_UNRECONIZED % task [ 'type' ] ) entity = { } if resource_uri : entity = self . _connection . get ( resource_uri ) return task , entity | 251,430 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/task_monitor.py#L225-L261 | [
"def",
"get_or_generate_vocabulary",
"(",
"data_dir",
",",
"tmp_dir",
",",
"data_prefix",
",",
"max_page_size_exp",
",",
"approx_vocab_size",
"=",
"32768",
",",
"strip",
"=",
"True",
")",
":",
"num_pages_for_vocab_generation",
"=",
"approx_vocab_size",
"//",
"3",
"vocab_file",
"=",
"vocab_filename",
"(",
"approx_vocab_size",
",",
"strip",
")",
"def",
"my_generator",
"(",
"data_prefix",
")",
":",
"\"\"\"Line generator for vocab.\"\"\"",
"count",
"=",
"0",
"for",
"page",
"in",
"corpus_page_generator",
"(",
"all_corpus_files",
"(",
"data_prefix",
")",
"[",
":",
":",
"-",
"1",
"]",
",",
"tmp_dir",
",",
"max_page_size_exp",
")",
":",
"revisions",
"=",
"page",
"[",
"\"revisions\"",
"]",
"if",
"revisions",
":",
"text",
"=",
"get_text",
"(",
"revisions",
"[",
"-",
"1",
"]",
",",
"strip",
"=",
"strip",
")",
"yield",
"text",
"count",
"+=",
"1",
"if",
"count",
"%",
"100",
"==",
"0",
":",
"tf",
".",
"logging",
".",
"info",
"(",
"\"reading pages for vocab %d\"",
"%",
"count",
")",
"if",
"count",
">",
"num_pages_for_vocab_generation",
":",
"break",
"return",
"generator_utils",
".",
"get_or_generate_vocab_inner",
"(",
"data_dir",
",",
"vocab_file",
",",
"approx_vocab_size",
",",
"my_generator",
"(",
"data_prefix",
")",
")"
] |
Updates the remote server configuration and the automatic backup schedule for backup . | def update_config ( self , config , timeout = - 1 ) : return self . _client . update ( config , uri = self . URI + "/config" , timeout = timeout ) | 251,431 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/backups.py#L125-L139 | [
"def",
"zlib_decompress_all_frames",
"(",
"data",
")",
":",
"frames",
"=",
"bytearray",
"(",
")",
"data",
"=",
"bytes",
"(",
"data",
")",
"while",
"data",
":",
"decomp",
"=",
"zlib",
".",
"decompressobj",
"(",
")",
"try",
":",
"frames",
".",
"extend",
"(",
"decomp",
".",
"decompress",
"(",
"data",
")",
")",
"data",
"=",
"decomp",
".",
"unused_data",
"except",
"zlib",
".",
"error",
":",
"frames",
".",
"extend",
"(",
"data",
")",
"break",
"return",
"frames"
] |
Saves a backup of the appliance to a previously - configured remote location . | def update_remote_archive ( self , save_uri , timeout = - 1 ) : return self . _client . update_with_zero_body ( uri = save_uri , timeout = timeout ) | 251,432 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/backups.py#L141-L155 | [
"def",
"detail_dict",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"dict",
"def",
"aug_col",
"(",
"c",
")",
":",
"d",
"=",
"c",
".",
"dict",
"d",
"[",
"'stats'",
"]",
"=",
"[",
"s",
".",
"dict",
"for",
"s",
"in",
"c",
".",
"stats",
"]",
"return",
"d",
"d",
"[",
"'table'",
"]",
"=",
"self",
".",
"table",
".",
"dict",
"d",
"[",
"'table'",
"]",
"[",
"'columns'",
"]",
"=",
"[",
"aug_col",
"(",
"c",
")",
"for",
"c",
"in",
"self",
".",
"table",
".",
"columns",
"]",
"return",
"d"
] |
Gets a list of associated ethernet networks of an uplink set . | def get_ethernet_networks ( self ) : network_uris = self . data . get ( 'networkUris' ) networks = [ ] if network_uris : for uri in network_uris : networks . append ( self . _ethernet_networks . get_by_uri ( uri ) ) return networks | 251,433 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/uplink_sets.py#L60-L75 | [
"def",
"RunOnce",
"(",
"self",
")",
":",
"# pylint: disable=unused-variable,g-import-not-at-top",
"from",
"grr_response_server",
".",
"gui",
"import",
"gui_plugins",
"# pylint: enable=unused-variable,g-import-not-at-top",
"if",
"config",
".",
"CONFIG",
".",
"Get",
"(",
"\"AdminUI.django_secret_key\"",
",",
"None",
")",
":",
"logging",
".",
"warning",
"(",
"\"The AdminUI.django_secret_key option has been deprecated, \"",
"\"please use AdminUI.csrf_secret_key instead.\"",
")"
] |
Updates network uris . | def __set_ethernet_uris ( self , ethernet_names , operation = "add" ) : if not isinstance ( ethernet_names , list ) : ethernet_names = [ ethernet_names ] associated_enets = self . data . get ( 'networkUris' , [ ] ) ethernet_uris = [ ] for i , enet in enumerate ( ethernet_names ) : enet_exists = self . _ethernet_networks . get_by_name ( enet ) if enet_exists : ethernet_uris . append ( enet_exists . data [ 'uri' ] ) else : raise HPOneViewResourceNotFound ( "Ethernet: {} does not exist" . foramt ( enet ) ) if operation == "remove" : enets_to_update = sorted ( list ( set ( associated_enets ) - set ( ethernet_uris ) ) ) elif operation == "add" : enets_to_update = sorted ( list ( set ( associated_enets ) . union ( set ( ethernet_uris ) ) ) ) else : raise ValueError ( "Value {} is not supported as operation. The supported values are: ['add', 'remove']" ) if set ( enets_to_update ) != set ( associated_enets ) : updated_network = { 'networkUris' : enets_to_update } self . update ( updated_network ) | 251,434 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/uplink_sets.py#L110-L134 | [
"def",
"detach_storage",
"(",
"self",
",",
"server",
",",
"address",
")",
":",
"body",
"=",
"{",
"'storage_device'",
":",
"{",
"'address'",
":",
"address",
"}",
"}",
"url",
"=",
"'/server/{0}/storage/detach'",
".",
"format",
"(",
"server",
")",
"res",
"=",
"self",
".",
"post_request",
"(",
"url",
",",
"body",
")",
"return",
"Storage",
".",
"_create_storage_objs",
"(",
"res",
"[",
"'server'",
"]",
"[",
"'storage_devices'",
"]",
",",
"cloud_manager",
"=",
"self",
")"
] |
Gets the interconnect settings for a logical interconnect group . | def get_settings ( self ) : uri = "{}/settings" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,435 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_interconnect_groups.py#L93-L101 | [
"def",
"DocbookMan",
"(",
"env",
",",
"target",
",",
"source",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# Init list of targets/sources",
"target",
",",
"source",
"=",
"__extend_targets_sources",
"(",
"target",
",",
"source",
")",
"# Init XSL stylesheet",
"__init_xsl_stylesheet",
"(",
"kw",
",",
"env",
",",
"'$DOCBOOK_DEFAULT_XSL_MAN'",
",",
"[",
"'manpages'",
",",
"'docbook.xsl'",
"]",
")",
"# Setup builder",
"__builder",
"=",
"__select_builder",
"(",
"__lxml_builder",
",",
"__libxml2_builder",
",",
"__xsltproc_builder",
")",
"# Create targets",
"result",
"=",
"[",
"]",
"for",
"t",
",",
"s",
"in",
"zip",
"(",
"target",
",",
"source",
")",
":",
"volnum",
"=",
"\"1\"",
"outfiles",
"=",
"[",
"]",
"srcfile",
"=",
"__ensure_suffix",
"(",
"str",
"(",
"s",
")",
",",
"'.xml'",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"srcfile",
")",
":",
"try",
":",
"import",
"xml",
".",
"dom",
".",
"minidom",
"dom",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"parse",
"(",
"__ensure_suffix",
"(",
"str",
"(",
"s",
")",
",",
"'.xml'",
")",
")",
"# Extract volume number, default is 1",
"for",
"node",
"in",
"dom",
".",
"getElementsByTagName",
"(",
"'refmeta'",
")",
":",
"for",
"vol",
"in",
"node",
".",
"getElementsByTagName",
"(",
"'manvolnum'",
")",
":",
"volnum",
"=",
"__get_xml_text",
"(",
"vol",
")",
"# Extract output filenames",
"for",
"node",
"in",
"dom",
".",
"getElementsByTagName",
"(",
"'refnamediv'",
")",
":",
"for",
"ref",
"in",
"node",
".",
"getElementsByTagName",
"(",
"'refname'",
")",
":",
"outfiles",
".",
"append",
"(",
"__get_xml_text",
"(",
"ref",
")",
"+",
"'.'",
"+",
"volnum",
")",
"except",
":",
"# Use simple regex parsing ",
"f",
"=",
"open",
"(",
"__ensure_suffix",
"(",
"str",
"(",
"s",
")",
",",
"'.xml'",
")",
",",
"'r'",
")",
"content",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"close",
"(",
")",
"for",
"m",
"in",
"re_manvolnum",
".",
"finditer",
"(",
"content",
")",
":",
"volnum",
"=",
"m",
".",
"group",
"(",
"1",
")",
"for",
"m",
"in",
"re_refname",
".",
"finditer",
"(",
"content",
")",
":",
"outfiles",
".",
"append",
"(",
"m",
".",
"group",
"(",
"1",
")",
"+",
"'.'",
"+",
"volnum",
")",
"if",
"not",
"outfiles",
":",
"# Use stem of the source file",
"spath",
"=",
"str",
"(",
"s",
")",
"if",
"not",
"spath",
".",
"endswith",
"(",
"'.xml'",
")",
":",
"outfiles",
".",
"append",
"(",
"spath",
"+",
"'.'",
"+",
"volnum",
")",
"else",
":",
"stem",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"spath",
")",
"outfiles",
".",
"append",
"(",
"stem",
"+",
"'.'",
"+",
"volnum",
")",
"else",
":",
"# We have to completely rely on the given target name",
"outfiles",
".",
"append",
"(",
"t",
")",
"__builder",
".",
"__call__",
"(",
"env",
",",
"outfiles",
"[",
"0",
"]",
",",
"s",
",",
"*",
"*",
"kw",
")",
"env",
".",
"Depends",
"(",
"outfiles",
"[",
"0",
"]",
",",
"kw",
"[",
"'DOCBOOK_XSL'",
"]",
")",
"result",
".",
"append",
"(",
"outfiles",
"[",
"0",
"]",
")",
"if",
"len",
"(",
"outfiles",
")",
">",
"1",
":",
"env",
".",
"Clean",
"(",
"outfiles",
"[",
"0",
"]",
",",
"outfiles",
"[",
"1",
":",
"]",
")",
"return",
"result"
] |
Upload an SPP ISO image file or a hotfix file to the appliance . The API supports upload of one hotfix at a time into the system . For the successful upload of a hotfix ensure its original name and extension are not altered . | def upload ( self , file_path , timeout = - 1 ) : return self . _client . upload ( file_path , timeout = timeout ) | 251,436 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/firmware_bundles.py#L48-L62 | [
"def",
"tables",
"(",
"self",
")",
":",
"with",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"as",
"cur",
":",
"cur",
".",
"execute",
"(",
"self",
".",
"TABLES_QUERY",
")",
"for",
"row",
"in",
"cur",
":",
"yield",
"row"
] |
Gets an index resource by URI . | def get ( self , uri ) : uri = self . URI + uri return self . _client . get ( uri ) | 251,437 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/search/index_resources.py#L104-L115 | [
"def",
"connect",
"(",
"dsn",
"=",
"None",
",",
"turbodbc_options",
"=",
"None",
",",
"connection_string",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"turbodbc_options",
"is",
"None",
":",
"turbodbc_options",
"=",
"make_options",
"(",
")",
"if",
"connection_string",
"is",
"not",
"None",
"and",
"(",
"dsn",
"is",
"not",
"None",
"or",
"len",
"(",
"kwargs",
")",
">",
"0",
")",
":",
"raise",
"ParameterError",
"(",
"\"Both connection_string and dsn or kwargs specified\"",
")",
"if",
"connection_string",
"is",
"None",
":",
"connection_string",
"=",
"_make_connection_string",
"(",
"dsn",
",",
"*",
"*",
"kwargs",
")",
"connection",
"=",
"Connection",
"(",
"intern_connect",
"(",
"connection_string",
",",
"turbodbc_options",
")",
")",
"return",
"connection"
] |
Gets the storage pools that are connected on the specified networks based on the storage system port s expected network connectivity . | def get_reachable_storage_pools ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , networks = None , scope_exclusions = None , scope_uris = '' ) : uri = self . URI + "/reachable-storage-pools" if networks : elements = "\'" for n in networks : elements += n + ',' elements = elements [ : - 1 ] + "\'" uri = uri + "?networks=" + elements if scope_exclusions : storage_pools_uris = "," . join ( scope_exclusions ) uri = uri + "?" if "?" not in uri else uri + "&" uri += "scopeExclusions={}" . format ( storage_pools_uris ) return self . _client . get ( self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri , scope_uris = scope_uris ) ) | 251,438 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/storage_pools.py#L138-L181 | [
"def",
"subtract",
"(",
"self",
")",
":",
"if",
"self",
".",
"moc",
"is",
"None",
":",
"raise",
"CommandError",
"(",
"'No MOC information present for subtraction'",
")",
"filename",
"=",
"self",
".",
"params",
".",
"pop",
"(",
")",
"self",
".",
"moc",
"-=",
"MOC",
"(",
"filename",
"=",
"filename",
")"
] |
Generates a self signed certificate or an internal CA signed certificate for RabbitMQ clients . | def generate ( self , information , timeout = - 1 ) : return self . _client . create ( information , timeout = timeout ) | 251,439 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/certificate_rabbitmq.py#L44-L57 | [
"def",
"delete_datapoints_in_time_range",
"(",
"self",
",",
"start_dt",
"=",
"None",
",",
"end_dt",
"=",
"None",
")",
":",
"start_dt",
"=",
"to_none_or_dt",
"(",
"validate_type",
"(",
"start_dt",
",",
"datetime",
".",
"datetime",
",",
"type",
"(",
"None",
")",
")",
")",
"end_dt",
"=",
"to_none_or_dt",
"(",
"validate_type",
"(",
"end_dt",
",",
"datetime",
".",
"datetime",
",",
"type",
"(",
"None",
")",
")",
")",
"params",
"=",
"{",
"}",
"if",
"start_dt",
"is",
"not",
"None",
":",
"params",
"[",
"'startTime'",
"]",
"=",
"isoformat",
"(",
"start_dt",
")",
"if",
"end_dt",
"is",
"not",
"None",
":",
"params",
"[",
"'endTime'",
"]",
"=",
"isoformat",
"(",
"end_dt",
")",
"self",
".",
"_conn",
".",
"delete",
"(",
"\"/ws/DataPoint/{stream_id}{querystring}\"",
".",
"format",
"(",
"stream_id",
"=",
"self",
".",
"get_stream_id",
"(",
")",
",",
"querystring",
"=",
"\"?\"",
"+",
"urllib",
".",
"parse",
".",
"urlencode",
"(",
"params",
")",
"if",
"params",
"else",
"\"\"",
",",
")",
")"
] |
Retrieves the public and private key pair associated with the specified alias name . | def get_key_pair ( self , alias_name ) : uri = self . URI + "/keypair/" + alias_name return self . _client . get ( uri ) | 251,440 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/certificate_rabbitmq.py#L71-L82 | [
"def",
"__run_sql_file",
"(",
"self",
",",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"'r'",
")",
"as",
"delta_file",
":",
"sql",
"=",
"delta_file",
".",
"read",
"(",
")",
"if",
"self",
".",
"variables",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"sql",
",",
"self",
".",
"variables",
")",
"else",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"sql",
")",
"self",
".",
"connection",
".",
"commit",
"(",
")"
] |
Retrieves the contents of PKCS12 file in the format specified . This PKCS12 formatted file contains both the certificate as well as the key file data . Valid key formats are Base64 and PKCS12 . | def get_keys ( self , alias_name , key_format ) : uri = self . URI + "/keys/" + alias_name + "?format=" + key_format return self . _client . get ( uri ) | 251,441 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/certificate_rabbitmq.py#L84-L97 | [
"def",
"reduce_sort",
"(",
"self",
",",
"js_cmp",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"dict",
"(",
")",
"if",
"js_cmp",
":",
"options",
"[",
"'arg'",
"]",
"=",
"js_cmp",
"return",
"self",
".",
"reduce",
"(",
"\"Riak.reduceSort\"",
",",
"options",
"=",
"options",
")"
] |
Validates an ID pool . | def validate_id_pool ( self , id_or_uri , ids_pools ) : uri = self . _client . build_uri ( id_or_uri ) + "/validate?idList=" + "&idList=" . join ( ids_pools ) return self . _client . get ( uri ) | 251,442 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/id_pools.py#L73-L87 | [
"def",
"getMetastable",
"(",
"rates",
",",
"ver",
":",
"np",
".",
"ndarray",
",",
"lamb",
",",
"br",
",",
"reactfn",
":",
"Path",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"reactfn",
",",
"'r'",
")",
"as",
"f",
":",
"A",
"=",
"f",
"[",
"'/metastable/A'",
"]",
"[",
":",
"]",
"lambnew",
"=",
"f",
"[",
"'/metastable/lambda'",
"]",
".",
"value",
".",
"ravel",
"(",
"order",
"=",
"'F'",
")",
"# some are not 1-D!",
"vnew",
"=",
"np",
".",
"concatenate",
"(",
"(",
"A",
"[",
":",
"2",
"]",
"*",
"rates",
".",
"loc",
"[",
"...",
",",
"'no1s'",
"]",
".",
"values",
"[",
":",
",",
"None",
"]",
",",
"A",
"[",
"2",
":",
"4",
"]",
"*",
"rates",
".",
"loc",
"[",
"...",
",",
"'no1d'",
"]",
".",
"values",
"[",
":",
",",
"None",
"]",
",",
"A",
"[",
"4",
":",
"]",
"*",
"rates",
".",
"loc",
"[",
"...",
",",
"'noii2p'",
"]",
".",
"values",
"[",
":",
",",
"None",
"]",
")",
",",
"axis",
"=",
"-",
"1",
")",
"assert",
"vnew",
".",
"shape",
"==",
"(",
"rates",
".",
"shape",
"[",
"0",
"]",
",",
"A",
".",
"size",
")",
"return",
"catvl",
"(",
"rates",
".",
"alt_km",
",",
"ver",
",",
"vnew",
",",
"lamb",
",",
"lambnew",
",",
"br",
")"
] |
Generates and returns a random range . | def generate ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/generate" return self . _client . get ( uri ) | 251,443 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/id_pools.py#L169-L181 | [
"def",
"cudnnSetPooling2dDescriptor",
"(",
"poolingDesc",
",",
"mode",
",",
"windowHeight",
",",
"windowWidth",
",",
"verticalPadding",
",",
"horizontalPadding",
",",
"verticalStride",
",",
"horizontalStride",
")",
":",
"status",
"=",
"_libcudnn",
".",
"cudnnSetPooling2dDescriptor",
"(",
"poolingDesc",
",",
"mode",
",",
"windowHeight",
",",
"windowWidth",
",",
"verticalPadding",
",",
"horizontalPadding",
",",
"verticalStride",
",",
"horizontalStride",
")",
"cudnnCheckStatus",
"(",
"status",
")"
] |
Gets the storage volume templates that are available on the specified networks based on the storage system port s expected network connectivity . If there are no storage volume templates that meet the specified connectivity criteria an empty collection will be returned . | def get_connectable_volume_templates ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' ) : uri = self . URI + "/connectable-volume-templates" get_uri = self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri ) return self . _client . get ( get_uri ) | 251,444 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/storage_volume_templates.py#L107-L120 | [
"def",
"count",
"(",
"self",
",",
"event_str",
",",
"inc_int",
"=",
"1",
")",
":",
"self",
".",
"_event_dict",
".",
"setdefault",
"(",
"event_str",
",",
"0",
")",
"self",
".",
"_event_dict",
"[",
"event_str",
"]",
"+=",
"inc_int"
] |
Gets the storage templates that are connected on the specified networks based on the storage system port s expected network connectivity . | def get_reachable_volume_templates ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , networks = None , scope_uris = '' , private_allowed_only = False ) : uri = self . URI + "/reachable-volume-templates" uri += "?networks={}&privateAllowedOnly={}" . format ( networks , private_allowed_only ) get_uri = self . _client . build_query_uri ( start = start , count = count , filter = filter , query = query , sort = sort , uri = uri , scope_uris = scope_uris ) return self . _client . get ( get_uri ) | 251,445 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/storage_volume_templates.py#L122-L137 | [
"def",
"subtract",
"(",
"self",
")",
":",
"if",
"self",
".",
"moc",
"is",
"None",
":",
"raise",
"CommandError",
"(",
"'No MOC information present for subtraction'",
")",
"filename",
"=",
"self",
".",
"params",
".",
"pop",
"(",
")",
"self",
".",
"moc",
"-=",
"MOC",
"(",
"filename",
"=",
"filename",
")"
] |
Retrieves a collection of all storage systems that is applicable to this storage volume template . | def get_compatible_systems ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/compatible-systems" return self . _client . get ( uri ) | 251,446 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/storage_volume_templates.py#L139-L151 | [
"def",
"reindex",
"(",
"series1",
",",
"series2",
")",
":",
"# turns out the merge is much faster than the .loc below",
"df",
"=",
"pd",
".",
"merge",
"(",
"pd",
".",
"DataFrame",
"(",
"{",
"\"left\"",
":",
"series2",
"}",
")",
",",
"pd",
".",
"DataFrame",
"(",
"{",
"\"right\"",
":",
"series1",
"}",
")",
",",
"left_on",
"=",
"\"left\"",
",",
"right_index",
"=",
"True",
",",
"how",
"=",
"\"left\"",
")",
"return",
"df",
".",
"right"
] |
Adds a volume that already exists in the Storage system | def add_from_existing ( self , resource , timeout = - 1 ) : uri = self . URI + "/from-existing" return self . _client . create ( resource , uri = uri , timeout = timeout ) | 251,447 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L136-L151 | [
"def",
"get_csrf_token",
"(",
"response",
")",
":",
"cookie_headers",
"=",
"[",
"h",
".",
"decode",
"(",
"'ascii'",
")",
"for",
"h",
"in",
"response",
".",
"headers",
".",
"getlist",
"(",
"\"Set-Cookie\"",
")",
"]",
"if",
"not",
"cookie_headers",
":",
"return",
"None",
"csrf_headers",
"=",
"[",
"h",
"for",
"h",
"in",
"cookie_headers",
"if",
"h",
".",
"startswith",
"(",
"\"csrftoken=\"",
")",
"]",
"if",
"not",
"csrf_headers",
":",
"return",
"None",
"match",
"=",
"re",
".",
"match",
"(",
"\"csrftoken=([^ ;]+);\"",
",",
"csrf_headers",
"[",
"-",
"1",
"]",
")",
"return",
"match",
".",
"group",
"(",
"1",
")"
] |
Creates a new volume on the storage system from a snapshot of a volume . A volume template must also be specified when creating a volume from a snapshot . | def create_from_snapshot ( self , data , timeout = - 1 ) : uri = self . URI + "/from-snapshot" return self . _client . create ( data , uri = uri , timeout = timeout ) | 251,448 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L153-L175 | [
"def",
"cleanup",
"(",
"self",
")",
":",
"if",
"self",
".",
"sock",
"is",
"not",
"None",
":",
"self",
".",
"sock",
".",
"close",
"(",
")",
"if",
"self",
".",
"outfile",
"is",
"not",
"None",
":",
"self",
".",
"outfile",
".",
"close",
"(",
")",
"if",
"self",
".",
"bar",
"is",
"not",
"None",
":",
"self",
".",
"update_progress",
"(",
"complete",
"=",
"True",
")"
] |
Deletes a managed volume . | def delete ( self , resource , force = False , export_only = None , suppress_device_updates = None , timeout = - 1 ) : custom_headers = { 'If-Match' : '*' } if 'uri' in resource : uri = resource [ 'uri' ] else : uri = self . _client . build_uri ( resource ) if suppress_device_updates : uri += '?suppressDeviceUpdates=true' if export_only : custom_headers [ 'exportOnly' ] = True return self . _client . delete ( uri , force = force , timeout = timeout , custom_headers = custom_headers ) | 251,449 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L197-L231 | [
"def",
"world_series_logs",
"(",
")",
":",
"file_name",
"=",
"'GLWS.TXT'",
"z",
"=",
"get_zip_file",
"(",
"world_series_url",
")",
"data",
"=",
"pd",
".",
"read_csv",
"(",
"z",
".",
"open",
"(",
"file_name",
")",
",",
"header",
"=",
"None",
",",
"sep",
"=",
"','",
",",
"quotechar",
"=",
"'\"'",
")",
"data",
".",
"columns",
"=",
"gamelog_columns",
"return",
"data"
] |
Gets all snapshots of a volume . Returns a list of snapshots based on optional sorting and filtering and constrained by start and count parameters . | def get_snapshots ( self , volume_id_or_uri , start = 0 , count = - 1 , filter = '' , sort = '' ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri ) return self . _client . get_all ( start , count , filter = filter , sort = sort , uri = uri ) | 251,450 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L242-L268 | [
"def",
"inspect_workers",
"(",
"self",
")",
":",
"workers",
"=",
"tuple",
"(",
"self",
".",
"workers",
".",
"values",
"(",
")",
")",
"expired",
"=",
"tuple",
"(",
"w",
"for",
"w",
"in",
"workers",
"if",
"not",
"w",
".",
"is_alive",
"(",
")",
")",
"for",
"worker",
"in",
"expired",
":",
"self",
".",
"workers",
".",
"pop",
"(",
"worker",
".",
"pid",
")",
"return",
"(",
"(",
"w",
".",
"pid",
",",
"w",
".",
"exitcode",
")",
"for",
"w",
"in",
"expired",
"if",
"w",
".",
"exitcode",
"!=",
"0",
")"
] |
Creates a snapshot for the specified volume . | def create_snapshot ( self , volume_id_or_uri , snapshot , timeout = - 1 ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri ) return self . _client . create ( snapshot , uri = uri , timeout = timeout , default_values = self . DEFAULT_VALUES_SNAPSHOT ) | 251,451 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L270-L288 | [
"def",
"jtag_configure",
"(",
"self",
",",
"instr_regs",
"=",
"0",
",",
"data_bits",
"=",
"0",
")",
":",
"if",
"not",
"util",
".",
"is_natural",
"(",
"instr_regs",
")",
":",
"raise",
"ValueError",
"(",
"'IR value is not a natural number.'",
")",
"if",
"not",
"util",
".",
"is_natural",
"(",
"data_bits",
")",
":",
"raise",
"ValueError",
"(",
"'Data bits is not a natural number.'",
")",
"self",
".",
"_dll",
".",
"JLINKARM_ConfigJTAG",
"(",
"instr_regs",
",",
"data_bits",
")",
"return",
"None"
] |
Gets a snapshot of a volume . | def get_snapshot ( self , snapshot_id_or_uri , volume_id_or_uri = None ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri , snapshot_id_or_uri ) return self . _client . get ( uri ) | 251,452 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L290-L305 | [
"def",
"jwt_decode_token",
"(",
"token",
")",
":",
"try",
":",
"return",
"decode",
"(",
"token",
",",
"current_app",
".",
"config",
"[",
"'ACCOUNTS_JWT_SECRET_KEY'",
"]",
",",
"algorithms",
"=",
"[",
"current_app",
".",
"config",
"[",
"'ACCOUNTS_JWT_ALOGORITHM'",
"]",
"]",
")",
"except",
"DecodeError",
"as",
"exc",
":",
"raise_from",
"(",
"JWTDecodeError",
"(",
")",
",",
"exc",
")",
"except",
"ExpiredSignatureError",
"as",
"exc",
":",
"raise_from",
"(",
"JWTExpiredToken",
"(",
")",
",",
"exc",
")"
] |
Gets all snapshots that match the filter . | def get_snapshot_by ( self , volume_id_or_uri , field , value ) : uri = self . __build_volume_snapshot_uri ( volume_id_or_uri ) return self . _client . get_by ( field , value , uri = uri ) | 251,453 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L327-L342 | [
"def",
"convert_ascii_field",
"(",
"string",
")",
":",
"values",
"=",
"[",
"]",
"for",
"codepoint",
"in",
"[",
"s",
"for",
"s",
"in",
"string",
".",
"split",
"(",
"DATA_FILE_CODEPOINT_SEPARATOR",
")",
"if",
"(",
"s",
"!=",
"DATA_FILE_VALUE_NOT_AVAILABLE",
")",
"and",
"(",
"len",
"(",
"s",
")",
">",
"0",
")",
"]",
":",
"#if DATA_FILE_CODEPOINT_JOINER in codepoint:",
"# values.append(u\"\".join([hex_to_unichr(c) for c in codepoint.split(DATA_FILE_CODEPOINT_JOINER)]))",
"if",
"(",
"codepoint",
".",
"startswith",
"(",
"DATA_FILE_ASCII_NUMERICAL_CODEPOINT_START",
")",
")",
"or",
"(",
"codepoint",
".",
"startswith",
"(",
"DATA_FILE_ASCII_UNICODE_CODEPOINT_START",
")",
")",
":",
"values",
".",
"append",
"(",
"hex_to_unichr",
"(",
"codepoint",
")",
")",
"else",
":",
"values",
".",
"append",
"(",
"codepoint",
")",
"return",
"values"
] |
Gets the list of extra managed storage volume paths . | def get_extra_managed_storage_volume_paths ( self , start = 0 , count = - 1 , filter = '' , sort = '' ) : uri = self . URI + '/repair?alertFixType=ExtraManagedStorageVolumePaths' return self . _client . get_all ( start , count , filter = filter , sort = sort , uri = uri ) | 251,454 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L344-L367 | [
"def",
"calculate",
"(",
"cls",
",",
"byte_arr",
",",
"crc",
"=",
"0",
")",
":",
"for",
"byte",
"in",
"byte_iter",
"(",
"byte_arr",
")",
":",
"# Taken verbatim from FIT SDK docs",
"tmp",
"=",
"cls",
".",
"CRC_TABLE",
"[",
"crc",
"&",
"0xF",
"]",
"crc",
"=",
"(",
"crc",
">>",
"4",
")",
"&",
"0x0FFF",
"crc",
"=",
"crc",
"^",
"tmp",
"^",
"cls",
".",
"CRC_TABLE",
"[",
"byte",
"&",
"0xF",
"]",
"tmp",
"=",
"cls",
".",
"CRC_TABLE",
"[",
"crc",
"&",
"0xF",
"]",
"crc",
"=",
"(",
"crc",
">>",
"4",
")",
"&",
"0x0FFF",
"crc",
"=",
"crc",
"^",
"tmp",
"^",
"cls",
".",
"CRC_TABLE",
"[",
"(",
"byte",
">>",
"4",
")",
"&",
"0xF",
"]",
"return",
"crc"
] |
Removes extra presentations from a specified volume on the storage system . | def repair ( self , volume_id_or_uri , timeout = - 1 ) : data = { "type" : "ExtraManagedStorageVolumePaths" , "resourceUri" : self . _client . build_uri ( volume_id_or_uri ) } custom_headers = { 'Accept-Language' : 'en_US' } uri = self . URI + '/repair' return self . _client . create ( data , uri = uri , timeout = timeout , custom_headers = custom_headers ) | 251,455 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L369-L389 | [
"def",
"download_sample_and_align",
"(",
"job",
",",
"sample",
",",
"inputs",
",",
"ids",
")",
":",
"uuid",
",",
"urls",
"=",
"sample",
"r1_url",
",",
"r2_url",
"=",
"urls",
"if",
"len",
"(",
"urls",
")",
"==",
"2",
"else",
"(",
"urls",
"[",
"0",
"]",
",",
"None",
")",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Downloaded sample: {0}. R1 {1}\\nR2 {2}\\nStarting BWA Run'",
".",
"format",
"(",
"uuid",
",",
"r1_url",
",",
"r2_url",
")",
")",
"# Read fastq samples from file store",
"ids",
"[",
"'r1'",
"]",
"=",
"job",
".",
"addChildJobFn",
"(",
"download_url_job",
",",
"r1_url",
",",
"s3_key_path",
"=",
"inputs",
".",
"ssec",
",",
"disk",
"=",
"inputs",
".",
"file_size",
")",
".",
"rv",
"(",
")",
"if",
"r2_url",
":",
"ids",
"[",
"'r2'",
"]",
"=",
"job",
".",
"addChildJobFn",
"(",
"download_url_job",
",",
"r2_url",
",",
"s3_key_path",
"=",
"inputs",
".",
"ssec",
",",
"disk",
"=",
"inputs",
".",
"file_size",
")",
".",
"rv",
"(",
")",
"else",
":",
"ids",
"[",
"'r2'",
"]",
"=",
"None",
"# Create config for bwakit",
"inputs",
".",
"cores",
"=",
"min",
"(",
"inputs",
".",
"maxCores",
",",
"multiprocessing",
".",
"cpu_count",
"(",
")",
")",
"inputs",
".",
"uuid",
"=",
"uuid",
"config",
"=",
"dict",
"(",
"*",
"*",
"vars",
"(",
"inputs",
")",
")",
"# Create config as a copy of inputs since it has values we want",
"config",
".",
"update",
"(",
"ids",
")",
"# Overwrite attributes with the FileStoreIDs from ids",
"config",
"=",
"argparse",
".",
"Namespace",
"(",
"*",
"*",
"config",
")",
"# Define and wire job functions",
"bam_id",
"=",
"job",
".",
"wrapJobFn",
"(",
"run_bwakit",
",",
"config",
",",
"sort",
"=",
"inputs",
".",
"sort",
",",
"trim",
"=",
"inputs",
".",
"trim",
",",
"disk",
"=",
"inputs",
".",
"file_size",
",",
"cores",
"=",
"inputs",
".",
"cores",
")",
"job",
".",
"addFollowOn",
"(",
"bam_id",
")",
"output_name",
"=",
"uuid",
"+",
"'.bam'",
"+",
"str",
"(",
"inputs",
".",
"suffix",
")",
"if",
"inputs",
".",
"suffix",
"else",
"uuid",
"+",
"'.bam'",
"if",
"urlparse",
"(",
"inputs",
".",
"output_dir",
")",
".",
"scheme",
"==",
"'s3'",
":",
"bam_id",
".",
"addChildJobFn",
"(",
"s3am_upload_job",
",",
"file_id",
"=",
"bam_id",
".",
"rv",
"(",
")",
",",
"file_name",
"=",
"output_name",
",",
"s3_dir",
"=",
"inputs",
".",
"output_dir",
",",
"s3_key_path",
"=",
"inputs",
".",
"ssec",
",",
"cores",
"=",
"inputs",
".",
"cores",
",",
"disk",
"=",
"inputs",
".",
"file_size",
")",
"else",
":",
"mkdir_p",
"(",
"inputs",
".",
"ouput_dir",
")",
"bam_id",
".",
"addChildJobFn",
"(",
"copy_file_job",
",",
"name",
"=",
"output_name",
",",
"file_id",
"=",
"bam_id",
".",
"rv",
"(",
")",
",",
"output_dir",
"=",
"inputs",
".",
"output_dir",
",",
"disk",
"=",
"inputs",
".",
"file_size",
")"
] |
Gets the volumes that are connected on the specified networks based on the storage system port s expected network connectivity . | def get_attachable_volumes ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , scope_uris = '' , connections = '' ) : uri = self . URI + '/attachable-volumes' if connections : uri += str ( '?' + 'connections=' + connections . __str__ ( ) ) return self . _client . get_all ( start , count , filter = filter , query = query , sort = sort , uri = uri , scope_uris = scope_uris ) | 251,456 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L391-L429 | [
"def",
"sample_pixels",
"(",
"img",
",",
"options",
")",
":",
"pixels",
"=",
"img",
".",
"reshape",
"(",
"(",
"-",
"1",
",",
"3",
")",
")",
"num_pixels",
"=",
"pixels",
".",
"shape",
"[",
"0",
"]",
"num_samples",
"=",
"int",
"(",
"num_pixels",
"*",
"options",
".",
"sample_fraction",
")",
"idx",
"=",
"np",
".",
"arange",
"(",
"num_pixels",
")",
"np",
".",
"random",
".",
"shuffle",
"(",
"idx",
")",
"return",
"pixels",
"[",
"idx",
"[",
":",
"num_samples",
"]",
"]"
] |
Reapplies the appliance s configuration on the enclosure . This includes running the same configure steps that were performed as part of the enclosure add . | def update_configuration ( self , timeout = - 1 ) : uri = "{}/configuration" . format ( self . data [ 'uri' ] ) return self . update_with_zero_body ( uri = uri , timeout = timeout ) | 251,457 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/enclosures.py#L106-L119 | [
"def",
"FindFileByName",
"(",
"self",
",",
"file_name",
")",
":",
"try",
":",
"return",
"self",
".",
"_file_descriptors",
"[",
"file_name",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"file_proto",
"=",
"self",
".",
"_internal_db",
".",
"FindFileByName",
"(",
"file_name",
")",
"except",
"KeyError",
"as",
"error",
":",
"if",
"self",
".",
"_descriptor_db",
":",
"file_proto",
"=",
"self",
".",
"_descriptor_db",
".",
"FindFileByName",
"(",
"file_name",
")",
"else",
":",
"raise",
"error",
"if",
"not",
"file_proto",
":",
"raise",
"KeyError",
"(",
"'Cannot find a file named %s'",
"%",
"file_name",
")",
"return",
"self",
".",
"_ConvertFileProtoToFileDescriptor",
"(",
"file_proto",
")"
] |
Get enclosure by it s hostname | def get_by_hostname ( self , hostname ) : def filter_by_hostname ( hostname , enclosure ) : is_primary_ip = ( 'activeOaPreferredIP' in enclosure and enclosure [ 'activeOaPreferredIP' ] == hostname ) is_standby_ip = ( 'standbyOaPreferredIP' in enclosure and enclosure [ 'standbyOaPreferredIP' ] == hostname ) return is_primary_ip or is_standby_ip enclosures = self . get_all ( ) result = [ x for x in enclosures if filter_by_hostname ( hostname , x ) ] if result : new_resource = self . new ( self . _connection , result [ 0 ] ) else : new_resource = None return new_resource | 251,458 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/enclosures.py#L121-L136 | [
"def",
"generate_http_manifest",
"(",
"self",
")",
":",
"base_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"translate_path",
"(",
"self",
".",
"path",
")",
")",
"self",
".",
"dataset",
"=",
"dtoolcore",
".",
"DataSet",
".",
"from_uri",
"(",
"base_path",
")",
"admin_metadata_fpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base_path",
",",
"\".dtool\"",
",",
"\"dtool\"",
")",
"with",
"open",
"(",
"admin_metadata_fpath",
")",
"as",
"fh",
":",
"admin_metadata",
"=",
"json",
".",
"load",
"(",
"fh",
")",
"http_manifest",
"=",
"{",
"\"admin_metadata\"",
":",
"admin_metadata",
",",
"\"manifest_url\"",
":",
"self",
".",
"generate_url",
"(",
"\".dtool/manifest.json\"",
")",
",",
"\"readme_url\"",
":",
"self",
".",
"generate_url",
"(",
"\"README.yml\"",
")",
",",
"\"overlays\"",
":",
"self",
".",
"generate_overlay_urls",
"(",
")",
",",
"\"item_urls\"",
":",
"self",
".",
"generate_item_urls",
"(",
")",
"}",
"return",
"bytes",
"(",
"json",
".",
"dumps",
"(",
"http_manifest",
")",
",",
"\"utf-8\"",
")"
] |
Sets the calibrated max power of an unmanaged or unsupported enclosure . | def update_environmental_configuration ( self , configuration , timeout = - 1 ) : uri = '{}/environmentalConfiguration' . format ( self . data [ 'uri' ] ) return self . _helper . do_put ( uri , configuration , timeout , None ) | 251,459 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/enclosures.py#L151-L164 | [
"def",
"get_results",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"query",
"=",
"None",
",",
"admin_name",
"=",
"None",
",",
"row_number",
"=",
"False",
")",
":",
"add_extra_ids",
"=",
"(",
"admin_name",
"is",
"not",
"None",
")",
"if",
"not",
"query",
":",
"sql",
"=",
"self",
".",
"get_raw_query",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
",",
"add_extra_ids",
"=",
"add_extra_ids",
")",
"else",
":",
"sql",
"=",
"query",
"if",
"settings",
".",
"DEBUG",
":",
"print",
"(",
"sql",
")",
"cursor",
"=",
"self",
".",
"_db_connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"sql",
",",
"tuple",
"(",
"self",
".",
"_params",
")",
")",
"query_results",
"=",
"cursor",
".",
"fetchall",
"(",
")",
"if",
"admin_name",
"and",
"not",
"self",
".",
"_groups_by",
":",
"selects",
"=",
"self",
".",
"_get_selects_with_extra_ids",
"(",
")",
"results",
"=",
"[",
"]",
"try",
":",
"offset",
"=",
"int",
"(",
"offset",
")",
"except",
"ValueError",
":",
"offset",
"=",
"0",
"for",
"r",
",",
"row",
"in",
"enumerate",
"(",
"query_results",
")",
":",
"i",
"=",
"0",
"l",
"=",
"len",
"(",
"row",
")",
"if",
"row_number",
":",
"result",
"=",
"[",
"(",
"r",
"+",
"offset",
"+",
"1",
",",
"u\"#row%s\"",
"%",
"(",
"r",
"+",
"offset",
"+",
"1",
")",
")",
"]",
"else",
":",
"result",
"=",
"[",
"]",
"while",
"i",
"<",
"l",
":",
"appmodel",
",",
"field",
"=",
"selects",
"[",
"i",
"]",
".",
"split",
"(",
"\".\"",
")",
"appmodel",
"=",
"self",
".",
"_unquote_name",
"(",
"appmodel",
")",
"field",
"=",
"self",
".",
"_unquote_name",
"(",
"field",
")",
"try",
":",
"if",
"appmodel",
"in",
"self",
".",
"_models",
":",
"_model",
"=",
"self",
".",
"_models",
"[",
"appmodel",
"]",
"_appmodel",
"=",
"u\"%s_%s\"",
"%",
"(",
"_model",
".",
"_meta",
".",
"app_label",
",",
"_model",
".",
"_meta",
".",
"model_name",
")",
"else",
":",
"_appmodel",
"=",
"appmodel",
"admin_url",
"=",
"reverse",
"(",
"\"%s:%s_change\"",
"%",
"(",
"admin_name",
",",
"_appmodel",
")",
",",
"args",
"=",
"[",
"row",
"[",
"i",
"+",
"1",
"]",
"]",
")",
"except",
"NoReverseMatch",
":",
"admin_url",
"=",
"None",
"result",
".",
"append",
"(",
"(",
"row",
"[",
"i",
"]",
",",
"admin_url",
")",
")",
"i",
"+=",
"2",
"results",
".",
"append",
"(",
"result",
")",
"return",
"results",
"else",
":",
"if",
"row_number",
":",
"results",
"=",
"[",
"]",
"for",
"r",
",",
"row",
"in",
"enumerate",
"(",
"query_results",
")",
":",
"result",
"=",
"[",
"r",
"+",
"1",
"]",
"for",
"cell",
"in",
"row",
":",
"result",
".",
"append",
"(",
"cell",
")",
"results",
".",
"append",
"(",
"result",
")",
"return",
"results",
"else",
":",
"return",
"query_results"
] |
Imports a signed server certificate into the enclosure . | def import_certificate ( self , certificate_data , bay_number = None ) : uri = "{}/https/certificaterequest" . format ( self . data [ 'uri' ] ) if bay_number : uri += "?bayNumber=%d" % ( bay_number ) headers = { 'Content-Type' : 'application/json' } return self . _helper . do_put ( uri , certificate_data , - 1 , headers ) | 251,460 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/enclosures.py#L251-L268 | [
"def",
"_PurgeTable",
"(",
"self",
",",
"tableName",
")",
":",
"goodlogging",
".",
"Log",
".",
"Info",
"(",
"\"DB\"",
",",
"\"Deleting all entries from table {0}\"",
".",
"format",
"(",
"tableName",
")",
",",
"verbosity",
"=",
"self",
".",
"logVerbosity",
")",
"self",
".",
"_ActionDatabase",
"(",
"\"DELETE FROM {0}\"",
".",
"format",
"(",
"tableName",
")",
")"
] |
Revokes a certificate signed by the internal CA . If client certificate to be revoked is RabbitMQ_readonly then the internal CA root certificate RabbitMQ client certificate and RabbitMQ server certificate will be regenerated . This will invalidate the previous version of RabbitMQ client certificate and the RabbitMQ server will be restarted to read the latest certificates . | def delete ( self , alias_name , timeout = - 1 ) : uri = self . URI + "/" + alias_name return self . _client . delete ( uri , timeout = timeout ) | 251,461 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/certificate_authority.py#L67-L81 | [
"def",
"dataframes",
"(",
"self",
")",
":",
"frames",
"=",
"[",
"]",
"for",
"team",
"in",
"self",
".",
"__iter__",
"(",
")",
":",
"frames",
".",
"append",
"(",
"team",
".",
"dataframe",
")",
"return",
"pd",
".",
"concat",
"(",
"frames",
")"
] |
Gets a Scope by name . | def get_by_name ( self , name ) : scopes = self . _client . get_all ( ) result = [ x for x in scopes if x [ 'name' ] == name ] return result [ 0 ] if result else None | 251,462 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/scopes.py#L95-L107 | [
"def",
"mock_xray_client",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"_wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"(",
"\"Starting X-Ray Patch\"",
")",
"old_xray_context_var",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'AWS_XRAY_CONTEXT_MISSING'",
")",
"os",
".",
"environ",
"[",
"'AWS_XRAY_CONTEXT_MISSING'",
"]",
"=",
"'LOG_ERROR'",
"old_xray_context",
"=",
"aws_xray_sdk",
".",
"core",
".",
"xray_recorder",
".",
"_context",
"old_xray_emitter",
"=",
"aws_xray_sdk",
".",
"core",
".",
"xray_recorder",
".",
"_emitter",
"aws_xray_sdk",
".",
"core",
".",
"xray_recorder",
".",
"_context",
"=",
"AWSContext",
"(",
")",
"aws_xray_sdk",
".",
"core",
".",
"xray_recorder",
".",
"_emitter",
"=",
"MockEmitter",
"(",
")",
"try",
":",
"return",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"finally",
":",
"if",
"old_xray_context_var",
"is",
"None",
":",
"del",
"os",
".",
"environ",
"[",
"'AWS_XRAY_CONTEXT_MISSING'",
"]",
"else",
":",
"os",
".",
"environ",
"[",
"'AWS_XRAY_CONTEXT_MISSING'",
"]",
"=",
"old_xray_context_var",
"aws_xray_sdk",
".",
"core",
".",
"xray_recorder",
".",
"_emitter",
"=",
"old_xray_emitter",
"aws_xray_sdk",
".",
"core",
".",
"xray_recorder",
".",
"_context",
"=",
"old_xray_context",
"return",
"_wrapped"
] |
Creates a scope . | def create ( self , resource , timeout = - 1 ) : return self . _client . create ( resource , timeout = timeout , default_values = self . DEFAULT_VALUES ) | 251,463 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/scopes.py#L109-L123 | [
"def",
"unbind",
"(",
"self",
",",
"devices_to_unbind",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"url",
"=",
"self",
".",
"base_url",
"+",
"\"api/0.1.0/subscribe/unbind\"",
"headers",
"=",
"{",
"\"apikey\"",
":",
"self",
".",
"entity_api_key",
"}",
"data",
"=",
"{",
"\"exchange\"",
":",
"\"amq.topic\"",
",",
"\"keys\"",
":",
"devices_to_unbind",
",",
"\"queue\"",
":",
"self",
".",
"entity_id",
"}",
"with",
"self",
".",
"no_ssl_verification",
"(",
")",
":",
"r",
"=",
"requests",
".",
"delete",
"(",
"url",
",",
"json",
"=",
"data",
",",
"headers",
"=",
"headers",
")",
"print",
"(",
"r",
")",
"response",
"=",
"dict",
"(",
")",
"if",
"\"No API key\"",
"in",
"str",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"failure\"",
"r",
"=",
"json",
".",
"loads",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
"[",
"'message'",
"]",
"elif",
"'unbind'",
"in",
"str",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"success\"",
"r",
"=",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"else",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"failure\"",
"r",
"=",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"response",
"[",
"\"response\"",
"]",
"=",
"str",
"(",
"r",
")",
"return",
"response"
] |
Deletes a Scope . | def delete ( self , resource , timeout = - 1 ) : if type ( resource ) is dict : headers = { 'If-Match' : resource . get ( 'eTag' , '*' ) } else : headers = { 'If-Match' : '*' } return self . _client . delete ( resource , timeout = timeout , custom_headers = headers ) | 251,464 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/scopes.py#L143-L161 | [
"def",
"unbind",
"(",
"self",
",",
"devices_to_unbind",
")",
":",
"if",
"self",
".",
"entity_api_key",
"==",
"\"\"",
":",
"return",
"{",
"'status'",
":",
"'failure'",
",",
"'response'",
":",
"'No API key found in request'",
"}",
"url",
"=",
"self",
".",
"base_url",
"+",
"\"api/0.1.0/subscribe/unbind\"",
"headers",
"=",
"{",
"\"apikey\"",
":",
"self",
".",
"entity_api_key",
"}",
"data",
"=",
"{",
"\"exchange\"",
":",
"\"amq.topic\"",
",",
"\"keys\"",
":",
"devices_to_unbind",
",",
"\"queue\"",
":",
"self",
".",
"entity_id",
"}",
"with",
"self",
".",
"no_ssl_verification",
"(",
")",
":",
"r",
"=",
"requests",
".",
"delete",
"(",
"url",
",",
"json",
"=",
"data",
",",
"headers",
"=",
"headers",
")",
"print",
"(",
"r",
")",
"response",
"=",
"dict",
"(",
")",
"if",
"\"No API key\"",
"in",
"str",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"failure\"",
"r",
"=",
"json",
".",
"loads",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
"[",
"'message'",
"]",
"elif",
"'unbind'",
"in",
"str",
"(",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
")",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"success\"",
"r",
"=",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"else",
":",
"response",
"[",
"\"status\"",
"]",
"=",
"\"failure\"",
"r",
"=",
"r",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"response",
"[",
"\"response\"",
"]",
"=",
"str",
"(",
"r",
")",
"return",
"response"
] |
Modifies scope membership by adding or removing resource assignments . | def update_resource_assignments ( self , id_or_uri , resource_assignments , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) + "/resource-assignments" headers = { 'Content-Type' : 'application/json' } return self . _client . patch_request ( uri , resource_assignments , timeout = timeout , custom_headers = headers ) | 251,465 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/scopes.py#L163-L181 | [
"def",
"_error_messages",
"(",
"self",
",",
"driver_id",
")",
":",
"assert",
"isinstance",
"(",
"driver_id",
",",
"ray",
".",
"DriverID",
")",
"message",
"=",
"self",
".",
"redis_client",
".",
"execute_command",
"(",
"\"RAY.TABLE_LOOKUP\"",
",",
"ray",
".",
"gcs_utils",
".",
"TablePrefix",
".",
"ERROR_INFO",
",",
"\"\"",
",",
"driver_id",
".",
"binary",
"(",
")",
")",
"# If there are no errors, return early.",
"if",
"message",
"is",
"None",
":",
"return",
"[",
"]",
"gcs_entries",
"=",
"ray",
".",
"gcs_utils",
".",
"GcsTableEntry",
".",
"GetRootAsGcsTableEntry",
"(",
"message",
",",
"0",
")",
"error_messages",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"gcs_entries",
".",
"EntriesLength",
"(",
")",
")",
":",
"error_data",
"=",
"ray",
".",
"gcs_utils",
".",
"ErrorTableData",
".",
"GetRootAsErrorTableData",
"(",
"gcs_entries",
".",
"Entries",
"(",
"i",
")",
",",
"0",
")",
"assert",
"driver_id",
".",
"binary",
"(",
")",
"==",
"error_data",
".",
"DriverId",
"(",
")",
"error_message",
"=",
"{",
"\"type\"",
":",
"decode",
"(",
"error_data",
".",
"Type",
"(",
")",
")",
",",
"\"message\"",
":",
"decode",
"(",
"error_data",
".",
"ErrorMessage",
"(",
")",
")",
",",
"\"timestamp\"",
":",
"error_data",
".",
"Timestamp",
"(",
")",
",",
"}",
"error_messages",
".",
"append",
"(",
"error_message",
")",
"return",
"error_messages"
] |
Gets the Golden Images API client . | def golden_images ( self ) : if not self . __golden_images : self . __golden_images = GoldenImages ( self . __connection ) return self . __golden_images | 251,466 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L69-L78 | [
"def",
"get_python_args",
"(",
"fname",
",",
"python_args",
",",
"interact",
",",
"debug",
",",
"end_args",
")",
":",
"p_args",
"=",
"[",
"]",
"if",
"python_args",
"is",
"not",
"None",
":",
"p_args",
"+=",
"python_args",
".",
"split",
"(",
")",
"if",
"interact",
":",
"p_args",
".",
"append",
"(",
"'-i'",
")",
"if",
"debug",
":",
"p_args",
".",
"extend",
"(",
"[",
"'-m'",
",",
"'pdb'",
"]",
")",
"if",
"fname",
"is",
"not",
"None",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
"and",
"debug",
":",
"# When calling pdb on Windows, one has to replace backslashes by\r",
"# slashes to avoid confusion with escape characters (otherwise, \r",
"# for example, '\\t' will be interpreted as a tabulation):\r",
"p_args",
".",
"append",
"(",
"osp",
".",
"normpath",
"(",
"fname",
")",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"'/'",
")",
")",
"else",
":",
"p_args",
".",
"append",
"(",
"fname",
")",
"if",
"end_args",
":",
"p_args",
".",
"extend",
"(",
"shell_split",
"(",
"end_args",
")",
")",
"return",
"p_args"
] |
Gets the Plan Scripts API client . | def plan_scripts ( self ) : if not self . __plan_scripts : self . __plan_scripts = PlanScripts ( self . __connection ) return self . __plan_scripts | 251,467 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L81-L90 | [
"def",
"num_in_memory",
"(",
"self",
")",
":",
"n",
"=",
"len",
"(",
"self",
".",
"_data",
")",
"-",
"1",
"while",
"n",
">=",
"0",
":",
"if",
"isinstance",
"(",
"self",
".",
"_data",
"[",
"n",
"]",
",",
"_TensorValueDiscarded",
")",
":",
"break",
"n",
"-=",
"1",
"return",
"len",
"(",
"self",
".",
"_data",
")",
"-",
"1",
"-",
"n"
] |
Gets the Build Plans API client . | def build_plans ( self ) : if not self . __build_plans : self . __build_plans = BuildPlans ( self . __connection ) return self . __build_plans | 251,468 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L93-L102 | [
"def",
"remove_backslash_r",
"(",
"filename",
",",
"encoding",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
",",
"encoding",
"=",
"encoding",
",",
"newline",
"=",
"r'\\n'",
")",
"as",
"filereader",
":",
"contents",
"=",
"filereader",
".",
"read",
"(",
")",
"contents",
"=",
"re",
".",
"sub",
"(",
"r'\\r'",
",",
"''",
",",
"contents",
")",
"with",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"as",
"filewriter",
":",
"filewriter",
".",
"truncate",
"(",
")",
"filewriter",
".",
"write",
"(",
"contents",
")"
] |
Gets the OS Volumes API client . | def os_volumes ( self ) : if not self . __os_volumes : self . __os_volumes = OsVolumes ( self . __connection ) return self . __os_volumes | 251,469 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L105-L114 | [
"def",
"json_splitter",
"(",
"buffer",
")",
":",
"buffer",
"=",
"buffer",
".",
"strip",
"(",
")",
"try",
":",
"obj",
",",
"index",
"=",
"json_decoder",
".",
"raw_decode",
"(",
"buffer",
")",
"rest",
"=",
"buffer",
"[",
"json",
".",
"decoder",
".",
"WHITESPACE",
".",
"match",
"(",
"buffer",
",",
"index",
")",
".",
"end",
"(",
")",
":",
"]",
"return",
"obj",
",",
"rest",
"except",
"ValueError",
":",
"return",
"None"
] |
Gets the Deployment Plans API client . | def deployment_plans ( self ) : if not self . __deployment_plans : self . __deployment_plans = DeploymentPlans ( self . __connection ) return self . __deployment_plans | 251,470 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L117-L126 | [
"def",
"wid_to_gid",
"(",
"wid",
")",
":",
"widval",
"=",
"wid",
"[",
"1",
":",
"]",
"if",
"len",
"(",
"wid",
")",
">",
"3",
"else",
"wid",
"xorval",
"=",
"474",
"if",
"len",
"(",
"wid",
")",
">",
"3",
"else",
"31578",
"return",
"str",
"(",
"int",
"(",
"widval",
",",
"36",
")",
"^",
"xorval",
")"
] |
Gets the Artifact Bundles API client . | def artifact_bundles ( self ) : if not self . __artifact_bundles : self . __artifact_bundles = ArtifactBundles ( self . __connection ) return self . __artifact_bundles | 251,471 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L129-L138 | [
"def",
"clean_tenant_url",
"(",
"url_string",
")",
":",
"if",
"hasattr",
"(",
"settings",
",",
"'PUBLIC_SCHEMA_URLCONF'",
")",
":",
"if",
"(",
"settings",
".",
"PUBLIC_SCHEMA_URLCONF",
"and",
"url_string",
".",
"startswith",
"(",
"settings",
".",
"PUBLIC_SCHEMA_URLCONF",
")",
")",
":",
"url_string",
"=",
"url_string",
"[",
"len",
"(",
"settings",
".",
"PUBLIC_SCHEMA_URLCONF",
")",
":",
"]",
"return",
"url_string"
] |
Gets the Deployment Groups API client . | def deployment_groups ( self ) : if not self . __deployment_groups : self . __deployment_groups = DeploymentGroups ( self . __connection ) return self . __deployment_groups | 251,472 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/image_streamer_client.py#L141-L150 | [
"def",
"clean_except_files",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_finalized",
":",
"self",
".",
"warn",
"(",
"\"Can't clean; bundle is finalized\"",
")",
"return",
"False",
"self",
".",
"log",
"(",
"'---- Cleaning ----'",
")",
"self",
".",
"state",
"=",
"self",
".",
"STATES",
".",
"CLEANING",
"self",
".",
"commit",
"(",
")",
"self",
".",
"clean_sources",
"(",
")",
"self",
".",
"clean_tables",
"(",
")",
"self",
".",
"clean_partitions",
"(",
")",
"self",
".",
"clean_build",
"(",
")",
"self",
".",
"clean_ingested",
"(",
")",
"self",
".",
"clean_build_state",
"(",
")",
"self",
".",
"state",
"=",
"self",
".",
"STATES",
".",
"CLEANED",
"self",
".",
"commit",
"(",
")",
"self",
".",
"log",
"(",
"'---- Done Cleaning ----'",
")",
"return",
"True"
] |
Creates a Golden Image resource from the deployed OS Volume as per the attributes specified . | def create ( self , resource , timeout = - 1 ) : data = self . __default_values . copy ( ) data . update ( resource ) return self . _client . create ( data , timeout = timeout ) | 251,473 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/golden_images.py#L73-L88 | [
"def",
"kendalltau",
"(",
"X",
")",
":",
"corrs",
"=",
"np",
".",
"zeros",
"(",
"(",
"X",
".",
"shape",
"[",
"1",
"]",
",",
"X",
".",
"shape",
"[",
"1",
"]",
")",
")",
"for",
"idx",
",",
"cola",
"in",
"enumerate",
"(",
"X",
".",
"T",
")",
":",
"for",
"jdx",
",",
"colb",
"in",
"enumerate",
"(",
"X",
".",
"T",
")",
":",
"corrs",
"[",
"idx",
",",
"jdx",
"]",
"=",
"sp_kendalltau",
"(",
"cola",
",",
"colb",
")",
"[",
"0",
"]",
"return",
"corrs"
] |
Adds a Golden Image resource from the file that is uploaded from a local drive . Only the . zip format file can be used for the upload . | def upload ( self , file_path , golden_image_info ) : uri = "{0}?name={1}&description={2}" . format ( self . URI , quote ( golden_image_info . get ( 'name' , '' ) ) , quote ( golden_image_info . get ( 'description' , '' ) ) ) return self . _client . upload ( file_path , uri ) | 251,474 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/golden_images.py#L90-L106 | [
"def",
"wait_for_start",
"(",
"self",
")",
":",
"if",
"self",
".",
"wait_matchers",
":",
"matcher",
"=",
"UnorderedMatcher",
"(",
"*",
"self",
".",
"wait_matchers",
")",
"self",
".",
"wait_for_logs_matching",
"(",
"matcher",
",",
"timeout",
"=",
"self",
".",
"wait_timeout",
")"
] |
Download the details of the Golden Image capture logs which has been archived based on the specific attribute ID . | def download_archive ( self , id_or_uri , file_path ) : uri = self . URI + "/archive/" + extract_id_from_uri ( id_or_uri ) return self . _client . download ( uri , file_path ) | 251,475 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/golden_images.py#L108-L121 | [
"def",
"is_registration_possible",
"(",
"self",
",",
"user_info",
")",
":",
"return",
"self",
".",
"get_accessibility",
"(",
")",
".",
"is_open",
"(",
")",
"and",
"self",
".",
"_registration",
".",
"is_open",
"(",
")",
"and",
"self",
".",
"is_user_accepted_by_access_control",
"(",
"user_info",
")"
] |
Updates the specified alert resource . | def update ( self , resource , id_or_uri = None , timeout = - 1 ) : uri = resource . pop ( 'uri' , None ) if not uri : if not id_or_uri : raise ValueError ( "URI was not provided" ) uri = self . _client . build_uri ( id_or_uri ) return self . _client . update ( resource = resource , uri = uri , timeout = timeout ) | 251,476 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/activity/alerts.py#L135-L152 | [
"def",
"cublasZgemm",
"(",
"handle",
",",
"transa",
",",
"transb",
",",
"m",
",",
"n",
",",
"k",
",",
"alpha",
",",
"A",
",",
"lda",
",",
"B",
",",
"ldb",
",",
"beta",
",",
"C",
",",
"ldc",
")",
":",
"status",
"=",
"_libcublas",
".",
"cublasZgemm_v2",
"(",
"handle",
",",
"_CUBLAS_OP",
"[",
"transa",
"]",
",",
"_CUBLAS_OP",
"[",
"transb",
"]",
",",
"m",
",",
"n",
",",
"k",
",",
"ctypes",
".",
"byref",
"(",
"cuda",
".",
"cuDoubleComplex",
"(",
"alpha",
".",
"real",
",",
"alpha",
".",
"imag",
")",
")",
",",
"int",
"(",
"A",
")",
",",
"lda",
",",
"int",
"(",
"B",
")",
",",
"ldb",
",",
"ctypes",
".",
"byref",
"(",
"cuda",
".",
"cuDoubleComplex",
"(",
"beta",
".",
"real",
",",
"beta",
".",
"imag",
")",
")",
",",
"int",
"(",
"C",
")",
",",
"ldc",
")",
"cublasCheckStatus",
"(",
"status",
")"
] |
Deletes alert change log by alert ID or URI . | def delete_alert_change_log ( self , id_or_uri ) : uri = self . URI + "/AlertChangeLog/" + extract_id_from_uri ( id_or_uri ) resource = { "uri" : uri } self . _client . delete ( resource ) | 251,477 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/activity/alerts.py#L154-L165 | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"name",
",",
"path",
",",
"args",
",",
"kwargs",
"=",
"super",
"(",
"AssetsFileField",
",",
"self",
")",
".",
"deconstruct",
"(",
")",
"kwargs",
"[",
"'denormalize'",
"]",
"=",
"False",
"return",
"name",
",",
"path",
",",
"args",
",",
"kwargs"
] |
Adds multiple rack - mount servers for management by the appliance . This API initiates the asynchronous addition of supported server models . | def add_multiple_servers ( self , information , timeout = - 1 ) : uri = "{}/discovery" . format ( self . URI ) return self . create ( information , uri = uri , timeout = timeout ) | 251,478 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_hardware.py#L68-L87 | [
"def",
"all_experiments",
"(",
"self",
")",
":",
"from",
"db",
".",
"models",
".",
"experiments",
"import",
"Experiment",
"return",
"Experiment",
".",
"all",
".",
"filter",
"(",
"experiment_group",
"=",
"self",
")"
] |
Get the firmware inventory of a server . | def get_firmware ( self ) : uri = "{}/firmware" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,479 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_hardware.py#L199-L210 | [
"def",
"load_ragged_time_series",
"(",
"filename",
",",
"dtype",
"=",
"float",
",",
"delimiter",
"=",
"r'\\s+'",
",",
"header",
"=",
"False",
")",
":",
"# Initialize empty lists",
"times",
"=",
"[",
"]",
"values",
"=",
"[",
"]",
"# Create re object for splitting lines",
"splitter",
"=",
"re",
".",
"compile",
"(",
"delimiter",
")",
"if",
"header",
":",
"start_row",
"=",
"1",
"else",
":",
"start_row",
"=",
"0",
"with",
"_open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
")",
"as",
"input_file",
":",
"for",
"row",
",",
"line",
"in",
"enumerate",
"(",
"input_file",
",",
"start_row",
")",
":",
"# Split each line using the supplied delimiter",
"data",
"=",
"splitter",
".",
"split",
"(",
"line",
".",
"strip",
"(",
")",
")",
"try",
":",
"converted_time",
"=",
"float",
"(",
"data",
"[",
"0",
"]",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
"as",
"exe",
":",
"six",
".",
"raise_from",
"(",
"ValueError",
"(",
"\"Couldn't convert value {} using {} \"",
"\"found at {}:{:d}:\\n\\t{}\"",
".",
"format",
"(",
"data",
"[",
"0",
"]",
",",
"float",
".",
"__name__",
",",
"filename",
",",
"row",
",",
"line",
")",
")",
",",
"exe",
")",
"times",
".",
"append",
"(",
"converted_time",
")",
"# cast values to a numpy array. time stamps with no values are cast",
"# to an empty array.",
"try",
":",
"converted_value",
"=",
"np",
".",
"array",
"(",
"data",
"[",
"1",
":",
"]",
",",
"dtype",
"=",
"dtype",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
"as",
"exe",
":",
"six",
".",
"raise_from",
"(",
"ValueError",
"(",
"\"Couldn't convert value {} using {} \"",
"\"found at {}:{:d}:\\n\\t{}\"",
".",
"format",
"(",
"data",
"[",
"1",
":",
"]",
",",
"dtype",
".",
"__name__",
",",
"filename",
",",
"row",
",",
"line",
")",
")",
",",
"exe",
")",
"values",
".",
"append",
"(",
"converted_value",
")",
"return",
"np",
".",
"array",
"(",
"times",
")",
",",
"values"
] |
Updates the iLO firmware on a physical server to a minimum ILO firmware version required by OneView to manage the server . | def update_mp_firware_version ( self , timeout = - 1 ) : uri = "{}/mpFirmwareVersion" . format ( self . data [ "uri" ] ) return self . _helper . do_put ( uri , None , timeout , None ) | 251,480 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_hardware.py#L233-L246 | [
"def",
"wait",
"(",
"timeout",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
")",
"->",
"Iterator",
"[",
"Any",
"]",
":",
"if",
"timeout",
"is",
"not",
"None",
":",
"tcod",
".",
"lib",
".",
"SDL_WaitEventTimeout",
"(",
"tcod",
".",
"ffi",
".",
"NULL",
",",
"int",
"(",
"timeout",
"*",
"1000",
")",
")",
"else",
":",
"tcod",
".",
"lib",
".",
"SDL_WaitEvent",
"(",
"tcod",
".",
"ffi",
".",
"NULL",
")",
"return",
"get",
"(",
")"
] |
Information describing an SDX partition including a list of physical server blades represented by a server hardware . Used with SDX enclosures only . | def get_physical_server_hardware ( self ) : uri = "{}/physicalServerHardware" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,481 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_hardware.py#L302-L311 | [
"def",
"resource_to_url",
"(",
"resource",
",",
"request",
"=",
"None",
",",
"quote",
"=",
"False",
")",
":",
"if",
"request",
"is",
"None",
":",
"request",
"=",
"get_current_request",
"(",
")",
"# cnv = request.registry.getAdapter(request, IResourceUrlConverter)",
"reg",
"=",
"get_current_registry",
"(",
")",
"cnv",
"=",
"reg",
".",
"getAdapter",
"(",
"request",
",",
"IResourceUrlConverter",
")",
"return",
"cnv",
".",
"resource_to_url",
"(",
"resource",
",",
"quote",
"=",
"quote",
")"
] |
Updates a Logical Switch . | def update ( self , resource , timeout = - 1 ) : self . __set_default_values ( resource ) uri = self . _client . build_uri ( resource [ 'logicalSwitch' ] [ 'uri' ] ) return self . _client . update ( resource , uri = uri , timeout = timeout ) | 251,482 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_switches.py#L130-L145 | [
"def",
"extract_declarations",
"(",
"map_el",
",",
"dirs",
",",
"scale",
"=",
"1",
",",
"user_styles",
"=",
"[",
"]",
")",
":",
"styles",
"=",
"[",
"]",
"#",
"# First, look at all the stylesheets defined in the map itself.",
"#",
"for",
"stylesheet",
"in",
"map_el",
".",
"findall",
"(",
"'Stylesheet'",
")",
":",
"map_el",
".",
"remove",
"(",
"stylesheet",
")",
"content",
",",
"mss_href",
"=",
"fetch_embedded_or_remote_src",
"(",
"stylesheet",
",",
"dirs",
")",
"if",
"content",
":",
"styles",
".",
"append",
"(",
"(",
"content",
",",
"mss_href",
")",
")",
"#",
"# Second, look through the user-supplied styles for override rules.",
"#",
"for",
"stylesheet",
"in",
"user_styles",
":",
"mss_href",
"=",
"urljoin",
"(",
"dirs",
".",
"source",
".",
"rstrip",
"(",
"'/'",
")",
"+",
"'/'",
",",
"stylesheet",
")",
"content",
"=",
"urllib",
".",
"urlopen",
"(",
"mss_href",
")",
".",
"read",
"(",
")",
".",
"decode",
"(",
"DEFAULT_ENCODING",
")",
"styles",
".",
"append",
"(",
"(",
"content",
",",
"mss_href",
")",
")",
"declarations",
"=",
"[",
"]",
"for",
"(",
"content",
",",
"mss_href",
")",
"in",
"styles",
":",
"is_merc",
"=",
"is_merc_projection",
"(",
"map_el",
".",
"get",
"(",
"'srs'",
",",
"''",
")",
")",
"for",
"declaration",
"in",
"stylesheet_declarations",
"(",
"content",
",",
"is_merc",
",",
"scale",
")",
":",
"#",
"# Change the value of each URI relative to the location",
"# of the containing stylesheet. We generally just have",
"# the one instance of \"dirs\" around for a full parse cycle,",
"# so it's necessary to perform this normalization here",
"# instead of later, while mss_href is still available.",
"#",
"uri_value",
"=",
"declaration",
".",
"value",
".",
"value",
"if",
"uri_value",
".",
"__class__",
"is",
"uri",
":",
"uri_value",
".",
"address",
"=",
"urljoin",
"(",
"mss_href",
",",
"uri_value",
".",
"address",
")",
"declarations",
".",
"append",
"(",
"declaration",
")",
"return",
"declarations"
] |
The Refresh action reclaims the top - of - rack switches in a logical switch . | def refresh ( self , id_or_uri , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) + "/refresh" return self . _client . update_with_zero_body ( uri , timeout = timeout ) | 251,483 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_switches.py#L162-L177 | [
"def",
"_update_job",
"(",
"job_id",
",",
"job_dict",
")",
":",
"# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"",
"# warnings.",
"if",
"job_id",
":",
"job_id",
"=",
"unicode",
"(",
"job_id",
")",
"if",
"\"error\"",
"in",
"job_dict",
":",
"job_dict",
"[",
"\"error\"",
"]",
"=",
"_validate_error",
"(",
"job_dict",
"[",
"\"error\"",
"]",
")",
"job_dict",
"[",
"\"error\"",
"]",
"=",
"json",
".",
"dumps",
"(",
"job_dict",
"[",
"\"error\"",
"]",
")",
"# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"",
"# warnings.",
"job_dict",
"[",
"\"error\"",
"]",
"=",
"unicode",
"(",
"job_dict",
"[",
"\"error\"",
"]",
")",
"# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"",
"# warnings.",
"if",
"\"data\"",
"in",
"job_dict",
":",
"job_dict",
"[",
"\"data\"",
"]",
"=",
"unicode",
"(",
"job_dict",
"[",
"\"data\"",
"]",
")",
"ENGINE",
".",
"execute",
"(",
"JOBS_TABLE",
".",
"update",
"(",
")",
".",
"where",
"(",
"JOBS_TABLE",
".",
"c",
".",
"job_id",
"==",
"job_id",
")",
".",
"values",
"(",
"*",
"*",
"job_dict",
")",
")"
] |
Uses the PATCH to update a resource for a given logical switch group . | def patch ( self , id_or_uri , operation , path , value , timeout = - 1 ) : return self . _client . patch ( id_or_uri , operation , path , value , timeout = timeout ) | 251,484 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/logical_switches.py#L179-L196 | [
"def",
"parse_registries",
"(",
"filesystem",
",",
"registries",
")",
":",
"results",
"=",
"{",
"}",
"for",
"path",
"in",
"registries",
":",
"with",
"NamedTemporaryFile",
"(",
"buffering",
"=",
"0",
")",
"as",
"tempfile",
":",
"filesystem",
".",
"download",
"(",
"path",
",",
"tempfile",
".",
"name",
")",
"registry",
"=",
"RegistryHive",
"(",
"tempfile",
".",
"name",
")",
"registry",
".",
"rootkey",
"=",
"registry_root",
"(",
"path",
")",
"results",
".",
"update",
"(",
"{",
"k",
".",
"path",
":",
"(",
"k",
".",
"timestamp",
",",
"k",
".",
"values",
")",
"for",
"k",
"in",
"registry",
".",
"keys",
"(",
")",
"}",
")",
"return",
"results"
] |
Initiates a migration of an enclosure specified by the ID or URI of a migration report . | def migrate ( self , id_or_uri , timeout = - 1 ) : # create the special payload to tell the VC Migration Manager to migrate the VC domain migrationInformation = { 'migrationState' : 'Migrated' , 'type' : 'migratable-vc-domains' , 'category' : 'migratable-vc-domains' } # call build_uri manually since .update(...) doesn't do it and the URI is not to be included in the body when # requesting a migration complete_uri = self . _client . build_uri ( id_or_uri ) return self . _client . update ( migrationInformation , uri = complete_uri , timeout = timeout ) | 251,485 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/migratable_vc_domains.py#L95-L118 | [
"def",
"_get_keycodes",
"(",
")",
":",
"try",
":",
"return",
"_key_cache",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"pass",
"result",
"=",
"[",
"]",
"terminators",
"=",
"'ABCDFHPQRS~'",
"with",
"TerminalContext",
"(",
")",
":",
"code",
"=",
"get_ord",
"(",
")",
"result",
".",
"append",
"(",
"code",
")",
"if",
"code",
"==",
"27",
":",
"with",
"TimerContext",
"(",
"0.1",
")",
"as",
"timer",
":",
"code",
"=",
"get_ord",
"(",
")",
"if",
"not",
"timer",
".",
"timed_out",
":",
"result",
".",
"append",
"(",
"code",
")",
"result",
".",
"append",
"(",
"get_ord",
"(",
")",
")",
"if",
"64",
"<",
"result",
"[",
"-",
"1",
"]",
"<",
"69",
":",
"pass",
"elif",
"result",
"[",
"1",
"]",
"==",
"91",
":",
"while",
"True",
":",
"code",
"=",
"get_ord",
"(",
")",
"result",
".",
"append",
"(",
"code",
")",
"if",
"chr",
"(",
"code",
")",
"in",
"terminators",
":",
"break",
"return",
"tuple",
"(",
"result",
")"
] |
Gets all the labels for the specified resource | def get_by_resource ( self , resource_uri ) : uri = self . URI + self . RESOURCES_PATH + '/' + resource_uri return self . _client . get ( id_or_uri = uri ) | 251,486 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/search/labels.py#L87-L98 | [
"def",
"_read_console_output",
"(",
"self",
",",
"ws",
",",
"out",
")",
":",
"while",
"True",
":",
"msg",
"=",
"yield",
"from",
"ws",
".",
"receive",
"(",
")",
"if",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"text",
":",
"out",
".",
"feed_data",
"(",
"msg",
".",
"data",
".",
"encode",
"(",
")",
")",
"elif",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"BINARY",
":",
"out",
".",
"feed_data",
"(",
"msg",
".",
"data",
")",
"elif",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"ERROR",
":",
"log",
".",
"critical",
"(",
"\"Docker WebSocket Error: {}\"",
".",
"format",
"(",
"msg",
".",
"data",
")",
")",
"else",
":",
"out",
".",
"feed_eof",
"(",
")",
"ws",
".",
"close",
"(",
")",
"break",
"yield",
"from",
"self",
".",
"stop",
"(",
")"
] |
Set all the labels for a resource . | def create ( self , resource ) : uri = self . URI + self . RESOURCES_PATH return self . _client . create ( resource = resource , uri = uri ) | 251,487 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/search/labels.py#L100-L111 | [
"def",
"_read_console_output",
"(",
"self",
",",
"ws",
",",
"out",
")",
":",
"while",
"True",
":",
"msg",
"=",
"yield",
"from",
"ws",
".",
"receive",
"(",
")",
"if",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"text",
":",
"out",
".",
"feed_data",
"(",
"msg",
".",
"data",
".",
"encode",
"(",
")",
")",
"elif",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"BINARY",
":",
"out",
".",
"feed_data",
"(",
"msg",
".",
"data",
")",
"elif",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"ERROR",
":",
"log",
".",
"critical",
"(",
"\"Docker WebSocket Error: {}\"",
".",
"format",
"(",
"msg",
".",
"data",
")",
")",
"else",
":",
"out",
".",
"feed_eof",
"(",
")",
"ws",
".",
"close",
"(",
")",
"break",
"yield",
"from",
"self",
".",
"stop",
"(",
")"
] |
Delete all the labels for a resource . | def delete ( self , resource , timeout = - 1 ) : self . _client . delete ( resource = resource , timeout = timeout ) | 251,488 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/search/labels.py#L125-L135 | [
"def",
"_read_console_output",
"(",
"self",
",",
"ws",
",",
"out",
")",
":",
"while",
"True",
":",
"msg",
"=",
"yield",
"from",
"ws",
".",
"receive",
"(",
")",
"if",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"text",
":",
"out",
".",
"feed_data",
"(",
"msg",
".",
"data",
".",
"encode",
"(",
")",
")",
"elif",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"BINARY",
":",
"out",
".",
"feed_data",
"(",
"msg",
".",
"data",
")",
"elif",
"msg",
".",
"tp",
"==",
"aiohttp",
".",
"WSMsgType",
".",
"ERROR",
":",
"log",
".",
"critical",
"(",
"\"Docker WebSocket Error: {}\"",
".",
"format",
"(",
"msg",
".",
"data",
")",
")",
"else",
":",
"out",
".",
"feed_eof",
"(",
")",
"ws",
".",
"close",
"(",
")",
"break",
"yield",
"from",
"self",
".",
"stop",
"(",
")"
] |
Updates a User . | def update ( self , resource , timeout = - 1 ) : return self . _client . update ( resource , timeout = timeout , default_values = self . DEFAULT_VALUES , uri = self . URI ) | 251,489 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/users.py#L116-L130 | [
"def",
"_remove_entry",
"(",
"self",
",",
"source_file",
",",
"key",
")",
":",
"entry",
"=",
"self",
".",
"__index",
".",
"get",
"(",
"key",
")",
"if",
"entry",
"is",
"None",
":",
"return",
"# Release the referenced files...",
"for",
"id_",
",",
"_",
"in",
"entry",
".",
"filesigs",
":",
"self",
".",
"__filename_rep",
".",
"release_filename",
"(",
"id_",
")",
"# Remove the cache entry...",
"del",
"self",
".",
"__index",
"[",
"key",
"]",
"self",
".",
"__modified_flag",
"=",
"True",
"# Delete the corresponding cache file...",
"cachefilename",
"=",
"self",
".",
"_create_cache_filename",
"(",
"source_file",
")",
"try",
":",
"os",
".",
"remove",
"(",
"cachefilename",
")",
"except",
"OSError",
"as",
"e",
":",
"print",
"(",
"\"Could not remove cache file (%s)\"",
"%",
"e",
")"
] |
Gets all Users that match the filter . | def get_by ( self , field , value ) : if field == 'userName' or field == 'name' : return self . _client . get ( self . URI + '/' + value ) elif field == 'role' : value = value . replace ( " " , "%20" ) return self . _client . get ( self . URI + '/roles/users/' + value ) [ 'members' ] else : raise HPOneViewException ( 'Only userName, name and role can be queried for this resource.' ) | 251,490 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/users.py#L132-L151 | [
"def",
"aux",
"(",
"self",
",",
"aux",
")",
":",
"if",
"aux",
"==",
"self",
".",
"_aux",
":",
"return",
"if",
"self",
".",
"_aux",
":",
"self",
".",
"_manager",
".",
"port_manager",
".",
"release_tcp_port",
"(",
"self",
".",
"_aux",
",",
"self",
".",
"_project",
")",
"self",
".",
"_aux",
"=",
"None",
"if",
"aux",
"is",
"not",
"None",
":",
"self",
".",
"_aux",
"=",
"self",
".",
"_manager",
".",
"port_manager",
".",
"reserve_tcp_port",
"(",
"aux",
",",
"self",
".",
"_project",
")",
"log",
".",
"info",
"(",
"\"{module}: '{name}' [{id}]: aux port set to {port}\"",
".",
"format",
"(",
"module",
"=",
"self",
".",
"manager",
".",
"module_name",
",",
"name",
"=",
"self",
".",
"name",
",",
"id",
"=",
"self",
".",
"id",
",",
"port",
"=",
"aux",
")",
")"
] |
Verifies if a userName is already in use . | def validate_user_name ( self , user_name , timeout = - 1 ) : uri = self . URI + '/validateLoginName/' + user_name return self . _client . create_with_zero_body ( uri = uri , timeout = timeout ) | 251,491 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/users.py#L153-L167 | [
"def",
"libvlc_log_set_file",
"(",
"p_instance",
",",
"stream",
")",
":",
"f",
"=",
"_Cfunctions",
".",
"get",
"(",
"'libvlc_log_set_file'",
",",
"None",
")",
"or",
"_Cfunction",
"(",
"'libvlc_log_set_file'",
",",
"(",
"(",
"1",
",",
")",
",",
"(",
"1",
",",
")",
",",
")",
",",
"None",
",",
"None",
",",
"Instance",
",",
"FILE_ptr",
")",
"return",
"f",
"(",
"p_instance",
",",
"stream",
")"
] |
Verifies if a fullName is already in use . | def validate_full_name ( self , full_name , timeout = - 1 ) : uri = self . URI + '/validateUserName/' + full_name return self . _client . create_with_zero_body ( uri = uri , timeout = timeout ) | 251,492 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/security/users.py#L169-L183 | [
"def",
"_setup_ipc",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Setting up the server IPC puller to receive from the listener'",
")",
"self",
".",
"ctx",
"=",
"zmq",
".",
"Context",
"(",
")",
"# subscribe to listener",
"self",
".",
"sub",
"=",
"self",
".",
"ctx",
".",
"socket",
"(",
"zmq",
".",
"PULL",
")",
"self",
".",
"sub",
".",
"bind",
"(",
"LST_IPC_URL",
")",
"try",
":",
"self",
".",
"sub",
".",
"setsockopt",
"(",
"zmq",
".",
"HWM",
",",
"self",
".",
"opts",
"[",
"'hwm'",
"]",
")",
"# zmq 2",
"except",
"AttributeError",
":",
"# zmq 3",
"self",
".",
"sub",
".",
"setsockopt",
"(",
"zmq",
".",
"RCVHWM",
",",
"self",
".",
"opts",
"[",
"'hwm'",
"]",
")",
"# device publishers",
"log",
".",
"debug",
"(",
"'Creating the router ICP on the server'",
")",
"self",
".",
"pub",
"=",
"self",
".",
"ctx",
".",
"socket",
"(",
"zmq",
".",
"ROUTER",
")",
"self",
".",
"pub",
".",
"bind",
"(",
"DEV_IPC_URL",
")",
"try",
":",
"self",
".",
"pub",
".",
"setsockopt",
"(",
"zmq",
".",
"HWM",
",",
"self",
".",
"opts",
"[",
"'hwm'",
"]",
")",
"# zmq 2",
"except",
"AttributeError",
":",
"# zmq 3",
"self",
".",
"pub",
".",
"setsockopt",
"(",
"zmq",
".",
"SNDHWM",
",",
"self",
".",
"opts",
"[",
"'hwm'",
"]",
")",
"# Pipe to the publishers",
"self",
".",
"publisher_pub",
"=",
"self",
".",
"ctx",
".",
"socket",
"(",
"zmq",
".",
"PUB",
")",
"self",
".",
"publisher_pub",
".",
"connect",
"(",
"PUB_PX_IPC_URL",
")",
"try",
":",
"self",
".",
"publisher_pub",
".",
"setsockopt",
"(",
"zmq",
".",
"HWM",
",",
"self",
".",
"opts",
"[",
"'hwm'",
"]",
")",
"# zmq 2",
"except",
"AttributeError",
":",
"# zmq 3",
"self",
".",
"publisher_pub",
".",
"setsockopt",
"(",
"zmq",
".",
"SNDHWM",
",",
"self",
".",
"opts",
"[",
"'hwm'",
"]",
")"
] |
Add an HP iPDU and bring all components under management by discovery of its management module . Bring the management module under exclusive management by the appliance configure any management or data collection settings and create a private set of administrative credentials to enable ongoing communication and management of the iPDU . Use force to claim the device even if claimed by another management appliance | def add_ipdu ( self , information , timeout = - 1 ) : uri = self . URI + "/discover" return self . _client . create ( information , uri = uri , timeout = timeout ) | 251,493 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/facilities/power_devices.py#L126-L142 | [
"def",
"PopEvents",
"(",
"self",
")",
":",
"event",
"=",
"self",
".",
"PopEvent",
"(",
")",
"while",
"event",
":",
"yield",
"event",
"event",
"=",
"self",
".",
"PopEvent",
"(",
")"
] |
Sets the power state of the specified power delivery device . The device must be an HP Intelligent Outlet . | def update_power_state ( self , id_or_uri , power_state ) : uri = self . _client . build_uri ( id_or_uri ) + "/powerState" return self . _client . update ( power_state , uri ) | 251,494 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/facilities/power_devices.py#L176-L190 | [
"def",
"_save",
"(",
"self",
")",
":",
"if",
"self",
".",
"__modified_flag",
":",
"self",
".",
"__filename_rep",
".",
"update_id_counter",
"(",
")",
"indexfilename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__dir",
",",
"\"index.dat\"",
")",
"self",
".",
"_write_file",
"(",
"indexfilename",
",",
"(",
"self",
".",
"__index",
",",
"self",
".",
"__filename_rep",
")",
")",
"self",
".",
"__modified_flag",
"=",
"False"
] |
Refreshes a given intelligent power delivery device . | def update_refresh_state ( self , id_or_uri , refresh_state_data ) : uri = self . _client . build_uri ( id_or_uri ) + "/refreshState" return self . _client . update ( refresh_state_data , uri = uri ) | 251,495 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/facilities/power_devices.py#L192-L206 | [
"def",
"store_contents",
"(",
"self",
")",
":",
"string_buffer",
"=",
"os",
".",
"linesep",
".",
"join",
"(",
"map",
"(",
"lambda",
"x",
":",
"os",
".",
"linesep",
".",
"join",
"(",
"[",
"\"<begin_table>\"",
"]",
"+",
"[",
"x",
".",
"name",
"]",
"+",
"x",
".",
"columns",
"+",
"[",
"\"<end_table>\"",
"]",
")",
",",
"self",
".",
"tables",
")",
")",
"with",
"open",
"(",
"METADATA_FILE",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"string_buffer",
")",
"for",
"i",
"in",
"self",
".",
"tables",
":",
"i",
".",
"store_contents",
"(",
")"
] |
Retrieves historical utilization data for the specified metrics and time span . The device must be a component of an HPE iPDU . | def get_utilization ( self , id_or_uri , fields = None , filter = None , refresh = False , view = None ) : return self . _client . get_utilization ( id_or_uri , fields , filter , refresh , view ) | 251,496 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/facilities/power_devices.py#L261-L333 | [
"def",
"remove",
"(",
"self",
",",
"objs",
")",
":",
"if",
"self",
".",
"readonly",
":",
"raise",
"NotImplementedError",
"(",
"'{} links can\\'t be modified'",
".",
"format",
"(",
"self",
".",
"_slug",
")",
")",
"if",
"not",
"self",
".",
"_parent",
".",
"id",
":",
"raise",
"ObjectNotSavedException",
"(",
"\"Links can not be modified before the object has been saved.\"",
")",
"_objs",
"=",
"[",
"obj",
"for",
"obj",
"in",
"self",
".",
"_build_obj_list",
"(",
"objs",
")",
"if",
"obj",
"in",
"self",
"]",
"if",
"not",
"_objs",
":",
"return",
"_obj_ids",
"=",
"\",\"",
".",
"join",
"(",
"_objs",
")",
"self",
".",
"_parent",
".",
"http_delete",
"(",
"'{}/links/{}/{}'",
".",
"format",
"(",
"self",
".",
"_parent",
".",
"id",
",",
"self",
".",
"_slug",
",",
"_obj_ids",
")",
",",
"retry",
"=",
"True",
",",
")",
"self",
".",
"_linked_object_ids",
"=",
"[",
"obj",
"for",
"obj",
"in",
"self",
".",
"_linked_object_ids",
"if",
"obj",
"not",
"in",
"_objs",
"]"
] |
Retrieves the modified contents of the selected Plan Script according to the provided content object as per the selected attributes . | def retrieve_differences ( self , id_or_uri , content , timeout = - 1 ) : uri = self . URI + "/differences/" + extract_id_from_uri ( id_or_uri ) return self . _client . create ( content , uri = uri , timeout = timeout ) | 251,497 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/plan_scripts.py#L154-L170 | [
"def",
"_set_idx_to_vec_by_embeddings",
"(",
"self",
",",
"token_embeddings",
",",
"vocab_len",
",",
"vocab_idx_to_token",
")",
":",
"new_vec_len",
"=",
"sum",
"(",
"embed",
".",
"vec_len",
"for",
"embed",
"in",
"token_embeddings",
")",
"new_idx_to_vec",
"=",
"nd",
".",
"zeros",
"(",
"shape",
"=",
"(",
"vocab_len",
",",
"new_vec_len",
")",
")",
"col_start",
"=",
"0",
"# Concatenate all the embedding vectors in token_embeddings.",
"for",
"embed",
"in",
"token_embeddings",
":",
"col_end",
"=",
"col_start",
"+",
"embed",
".",
"vec_len",
"# Cancatenate vectors of the unknown token.",
"new_idx_to_vec",
"[",
"0",
",",
"col_start",
":",
"col_end",
"]",
"=",
"embed",
".",
"idx_to_vec",
"[",
"0",
"]",
"new_idx_to_vec",
"[",
"1",
":",
",",
"col_start",
":",
"col_end",
"]",
"=",
"embed",
".",
"get_vecs_by_tokens",
"(",
"vocab_idx_to_token",
"[",
"1",
":",
"]",
")",
"col_start",
"=",
"col_end",
"self",
".",
"_vec_len",
"=",
"new_vec_len",
"self",
".",
"_idx_to_vec",
"=",
"new_idx_to_vec"
] |
Gets the build plans details os teh selected plan script as per the selected attributes . | def get_usedby_and_readonly ( self , id ) : uri = self . URI + "/" + id + "/usedby/readonly" return self . _client . get ( uri ) | 251,498 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/plan_scripts.py#L172-L183 | [
"def",
"set_guest_access",
"(",
"self",
",",
"room_id",
",",
"guest_access",
")",
":",
"content",
"=",
"{",
"\"guest_access\"",
":",
"guest_access",
"}",
"return",
"self",
".",
"send_state_event",
"(",
"room_id",
",",
"\"m.room.guest_access\"",
",",
"content",
")"
] |
Retrieves facts about Server Profiles and Server Profile Templates that are using Deployment Plan based on the ID or URI provided . | def get_osdp ( self , id_or_uri ) : uri = self . _client . build_subresource_uri ( resource_id_or_uri = id_or_uri , subresource_path = "osdp" ) return self . _client . get ( uri ) | 251,499 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/deployment_plans.py#L131-L142 | [
"def",
"flash",
"(",
"self",
",",
"duration",
"=",
"0.0",
")",
":",
"for",
"_",
"in",
"range",
"(",
"2",
")",
":",
"self",
".",
"on",
"=",
"not",
"self",
".",
"on",
"time",
".",
"sleep",
"(",
"duration",
")"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.