query
stringlengths 5
1.23k
| positive
stringlengths 53
15.2k
| id_
int64 0
252k
| task_name
stringlengths 87
242
| negative
sequencelengths 20
553
|
---|---|---|---|---|
Gets the preview of manual and automatic updates required to make the server profile consistent with its template . | def get_compliance_preview ( self ) : uri = '{}/compliance-preview' . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,500 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L138-L147 | [
"def",
"clean_restricted_chars",
"(",
"path",
",",
"restricted_chars",
"=",
"restricted_chars",
")",
":",
"for",
"character",
"in",
"restricted_chars",
":",
"path",
"=",
"path",
".",
"replace",
"(",
"character",
",",
"'_'",
")",
"return",
"path"
] |
Retrieves the port model associated with a server or server hardware type and enclosure group . | def get_profile_ports ( self , * * kwargs ) : uri = self . _helper . build_uri_with_query_string ( kwargs , '/profile-ports' ) return self . _helper . do_get ( uri ) | 251,501 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L149-L165 | [
"async",
"def",
"expand",
"(",
"self",
",",
"request",
":",
"Request",
",",
"layer",
":",
"BaseLayer",
")",
":",
"if",
"isinstance",
"(",
"layer",
",",
"lyr",
".",
"RawText",
")",
":",
"t",
"=",
"self",
".",
"reading_time",
"(",
"layer",
".",
"text",
")",
"yield",
"layer",
"yield",
"lyr",
".",
"Sleep",
"(",
"t",
")",
"elif",
"isinstance",
"(",
"layer",
",",
"lyr",
".",
"MultiText",
")",
":",
"texts",
"=",
"await",
"render",
"(",
"layer",
".",
"text",
",",
"request",
",",
"True",
")",
"for",
"text",
"in",
"texts",
":",
"t",
"=",
"self",
".",
"reading_time",
"(",
"text",
")",
"yield",
"lyr",
".",
"RawText",
"(",
"text",
")",
"yield",
"lyr",
".",
"Sleep",
"(",
"t",
")",
"elif",
"isinstance",
"(",
"layer",
",",
"lyr",
".",
"Text",
")",
":",
"text",
"=",
"await",
"render",
"(",
"layer",
".",
"text",
",",
"request",
")",
"t",
"=",
"self",
".",
"reading_time",
"(",
"text",
")",
"yield",
"lyr",
".",
"RawText",
"(",
"text",
")",
"yield",
"lyr",
".",
"Sleep",
"(",
"t",
")",
"else",
":",
"yield",
"layer"
] |
Retrieves the error or status messages associated with the specified profile . | def get_messages ( self ) : uri = '{}/messages' . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,502 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L168-L176 | [
"def",
"add_cookie_header",
"(",
"self",
",",
"request",
",",
"referrer_host",
"=",
"None",
")",
":",
"new_request",
"=",
"convert_http_request",
"(",
"request",
",",
"referrer_host",
")",
"self",
".",
"_cookie_jar",
".",
"add_cookie_header",
"(",
"new_request",
")",
"request",
".",
"fields",
".",
"clear",
"(",
")",
"for",
"name",
",",
"value",
"in",
"new_request",
".",
"header_items",
"(",
")",
":",
"request",
".",
"fields",
".",
"add",
"(",
"name",
",",
"value",
")"
] |
Retrieves the list of Ethernet networks Fiber Channel networks and network sets that are available to a server profile along with their respective ports . | def get_available_networks ( self , * * kwargs ) : uri = self . _helper . build_uri_with_query_string ( kwargs , '/available-networks' ) return self . _helper . do_get ( uri ) | 251,503 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L205-L233 | [
"def",
"_strip_colors",
"(",
"self",
",",
"message",
":",
"str",
")",
"->",
"str",
":",
"for",
"c",
"in",
"self",
".",
"COLORS",
":",
"message",
"=",
"message",
".",
"replace",
"(",
"c",
",",
"\"\"",
")",
"return",
"message"
] |
Retrieves the list of available servers . | def get_available_servers ( self , * * kwargs ) : uri = self . _helper . build_uri_with_query_string ( kwargs , '/available-servers' ) return self . _helper . do_get ( uri ) | 251,504 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L235-L251 | [
"def",
"matchi",
"(",
"string",
",",
"templ",
",",
"wstr",
",",
"wchr",
")",
":",
"string",
"=",
"stypes",
".",
"stringToCharP",
"(",
"string",
")",
"templ",
"=",
"stypes",
".",
"stringToCharP",
"(",
"templ",
")",
"wstr",
"=",
"ctypes",
".",
"c_char",
"(",
"wstr",
".",
"encode",
"(",
"encoding",
"=",
"'UTF-8'",
")",
")",
"wchr",
"=",
"ctypes",
".",
"c_char",
"(",
"wchr",
".",
"encode",
"(",
"encoding",
"=",
"'UTF-8'",
")",
")",
"return",
"bool",
"(",
"libspice",
".",
"matchi_c",
"(",
"string",
",",
"templ",
",",
"wstr",
",",
"wchr",
")",
")"
] |
Retrieves a specific storage system and its associated volumes available to the server profile based on the given server hardware type and enclosure group . | def get_available_storage_system ( self , * * kwargs ) : uri = self . _helper . build_uri_with_query_string ( kwargs , '/available-storage-system' ) return self . _helper . do_get ( uri ) | 251,505 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L253-L270 | [
"def",
"get_color_cycle",
"(",
"n",
",",
"cmap",
"=",
"\"rainbow\"",
",",
"rotations",
"=",
"3",
")",
":",
"cmap",
"=",
"colormaps",
"[",
"cmap",
"]",
"if",
"np",
".",
"mod",
"(",
"n",
",",
"rotations",
")",
"==",
"0",
":",
"per",
"=",
"np",
".",
"floor_divide",
"(",
"n",
",",
"rotations",
")",
"else",
":",
"per",
"=",
"np",
".",
"floor_divide",
"(",
"n",
",",
"rotations",
")",
"+",
"1",
"vals",
"=",
"list",
"(",
"np",
".",
"linspace",
"(",
"0",
",",
"1",
",",
"per",
")",
")",
"vals",
"=",
"vals",
"*",
"rotations",
"vals",
"=",
"vals",
"[",
":",
"n",
"]",
"out",
"=",
"cmap",
"(",
"vals",
")",
"return",
"out"
] |
Retrieves the list of the storage systems and their associated volumes available to the server profile based on the given server hardware type and enclosure group . | def get_available_storage_systems ( self , start = 0 , count = - 1 , filter = '' , sort = '' , * * kwargs ) : uri = self . _helper . build_uri_with_query_string ( kwargs , '/available-storage-systems' ) return self . _helper . get_all ( start = start , count = count , filter = filter , sort = sort , uri = uri ) | 251,506 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L272-L300 | [
"def",
"save_to_file",
"(",
"self",
",",
"filename",
",",
"remap_dim0",
"=",
"None",
",",
"remap_dim1",
"=",
"None",
")",
":",
"# rows - first index",
"# columns - second index",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fobj",
":",
"columns",
"=",
"list",
"(",
"sorted",
"(",
"self",
".",
"_dim1",
")",
")",
"for",
"col",
"in",
"columns",
":",
"fobj",
".",
"write",
"(",
"','",
")",
"fobj",
".",
"write",
"(",
"str",
"(",
"remap_dim1",
"[",
"col",
"]",
"if",
"remap_dim1",
"else",
"col",
")",
")",
"fobj",
".",
"write",
"(",
"'\\n'",
")",
"for",
"row",
"in",
"sorted",
"(",
"self",
".",
"_dim0",
")",
":",
"fobj",
".",
"write",
"(",
"str",
"(",
"remap_dim0",
"[",
"row",
"]",
"if",
"remap_dim0",
"else",
"row",
")",
")",
"for",
"col",
"in",
"columns",
":",
"fobj",
".",
"write",
"(",
"','",
")",
"fobj",
".",
"write",
"(",
"str",
"(",
"self",
"[",
"row",
",",
"col",
"]",
")",
")",
"fobj",
".",
"write",
"(",
"'\\n'",
")"
] |
Retrieves a list of the target servers and empty device bays that are available for assignment to the server profile . | def get_available_targets ( self , * * kwargs ) : uri = self . _helper . build_uri_with_query_string ( kwargs , '/available-targets' ) return self . _helper . do_get ( uri ) | 251,507 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L302-L320 | [
"def",
"load_files",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"verbose",
"==",
"2",
":",
"print",
"(",
"\"Indexing {}\"",
".",
"format",
"(",
"path",
")",
")",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"file_path",
"=",
"path",
"+",
"\"/\"",
"+",
"filename",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"file_path",
")",
":",
"self",
".",
"load_files",
"(",
"file_path",
")",
"elif",
"filename",
".",
"endswith",
"(",
"\".yaml\"",
")",
"or",
"filename",
".",
"endswith",
"(",
"\".yml\"",
")",
":",
"self",
".",
"unfold_yaml",
"(",
"file_path",
")"
] |
Retrieves the profile template for a given server profile . | def get_new_profile_template ( self ) : uri = '{}/new-profile-template' . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,508 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L323-L331 | [
"def",
"restrict_input_to_index",
"(",
"df_or_dict",
",",
"column_id",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"df_or_dict",
",",
"pd",
".",
"DataFrame",
")",
":",
"df_or_dict_restricted",
"=",
"df_or_dict",
"[",
"df_or_dict",
"[",
"column_id",
"]",
".",
"isin",
"(",
"index",
")",
"]",
"elif",
"isinstance",
"(",
"df_or_dict",
",",
"dict",
")",
":",
"df_or_dict_restricted",
"=",
"{",
"kind",
":",
"df",
"[",
"df",
"[",
"column_id",
"]",
".",
"isin",
"(",
"index",
")",
"]",
"for",
"kind",
",",
"df",
"in",
"df_or_dict",
".",
"items",
"(",
")",
"}",
"else",
":",
"raise",
"TypeError",
"(",
"\"df_or_dict should be of type dict or pandas.DataFrame\"",
")",
"return",
"df_or_dict_restricted"
] |
Updates the configuration script of the enclosure - group with the specified URI . | def update_script ( self , script_body ) : uri = "{}/script" . format ( self . data [ 'uri' ] ) return self . _helper . update ( script_body , uri = uri ) | 251,509 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/enclosure_groups.py#L94-L107 | [
"def",
"SetConsoleTextAttribute",
"(",
"stream_id",
",",
"attrs",
")",
":",
"handle",
"=",
"handles",
"[",
"stream_id",
"]",
"return",
"windll",
".",
"kernel32",
".",
"SetConsoleTextAttribute",
"(",
"handle",
",",
"attrs",
")"
] |
Removes extra presentations from a specified server profile . | def remove_extra_presentations ( self , resource , timeout = - 1 ) : uri = self . URI + "/repair" custom_headers = { 'Accept-Language' : 'en_US' } return self . _client . create ( resource , uri = uri , timeout = timeout , custom_headers = custom_headers ) | 251,510 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/storage_volume_attachments.py#L98-L113 | [
"def",
"img2code",
"(",
"self",
",",
"key",
",",
"img",
")",
":",
"code_template",
"=",
"\"wx.ImageFromData({width}, {height}, \"",
"+",
"\"bz2.decompress(base64.b64decode('{data}'))).ConvertToBitmap()\"",
"code_alpha_template",
"=",
"\"wx.ImageFromDataWithAlpha({width}, {height}, \"",
"+",
"\"bz2.decompress(base64.b64decode('{data}')), \"",
"+",
"\"bz2.decompress(base64.b64decode('{alpha}'))).ConvertToBitmap()\"",
"data",
"=",
"base64",
".",
"b64encode",
"(",
"bz2",
".",
"compress",
"(",
"img",
".",
"GetData",
"(",
")",
",",
"9",
")",
")",
"if",
"img",
".",
"HasAlpha",
"(",
")",
":",
"alpha",
"=",
"base64",
".",
"b64encode",
"(",
"bz2",
".",
"compress",
"(",
"img",
".",
"GetAlphaData",
"(",
")",
",",
"9",
")",
")",
"code_str",
"=",
"code_alpha_template",
".",
"format",
"(",
"width",
"=",
"img",
".",
"GetWidth",
"(",
")",
",",
"height",
"=",
"img",
".",
"GetHeight",
"(",
")",
",",
"data",
"=",
"data",
",",
"alpha",
"=",
"alpha",
")",
"else",
":",
"code_str",
"=",
"code_template",
".",
"format",
"(",
"width",
"=",
"img",
".",
"GetWidth",
"(",
")",
",",
"height",
"=",
"img",
".",
"GetHeight",
"(",
")",
",",
"data",
"=",
"data",
")",
"return",
"code_str"
] |
Gets all paths or a specific attachment path for the specified volume attachment . | def get_paths ( self , id_or_uri , path_id_or_uri = '' ) : if path_id_or_uri : uri = self . _client . build_uri ( path_id_or_uri ) if "/paths" not in uri : uri = self . _client . build_uri ( id_or_uri ) + "/paths" + "/" + path_id_or_uri else : uri = self . _client . build_uri ( id_or_uri ) + "/paths" return self . _client . get ( uri ) | 251,511 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/storage_volume_attachments.py#L115-L135 | [
"def",
"AuthorizingClient",
"(",
"domain",
",",
"auth",
",",
"request_encoder",
",",
"response_decoder",
",",
"user_agent",
"=",
"None",
")",
":",
"http_transport",
"=",
"transport",
".",
"HttpTransport",
"(",
"api_url",
"(",
"domain",
")",
",",
"build_headers",
"(",
"auth",
",",
"user_agent",
")",
")",
"return",
"client",
".",
"Client",
"(",
"request_encoder",
",",
"http_transport",
",",
"response_decoder",
")"
] |
Get the details for the backup from an Artifact Bundle . | def get_backup ( self , id_or_uri ) : uri = self . BACKUPS_PATH + '/' + extract_id_from_uri ( id_or_uri ) return self . _client . get ( id_or_uri = uri ) | 251,512 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L129-L140 | [
"def",
"fill_inbuffer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"connection",
":",
"raise",
"OmapiError",
"(",
"\"not connected\"",
")",
"try",
":",
"data",
"=",
"self",
".",
"connection",
".",
"recv",
"(",
"2048",
")",
"except",
"socket",
".",
"error",
":",
"self",
".",
"close",
"(",
")",
"raise",
"if",
"not",
"data",
":",
"self",
".",
"close",
"(",
")",
"raise",
"OmapiError",
"(",
"\"connection closed\"",
")",
"try",
":",
"self",
".",
"protocol",
".",
"data_received",
"(",
"data",
")",
"except",
"OmapiSizeLimitError",
":",
"self",
".",
"close",
"(",
")",
"raise"
] |
Downloads an archive for the Artifact Bundle . | def download_archive_artifact_bundle ( self , id_or_uri , file_path ) : uri = self . BACKUP_ARCHIVE_PATH + '/' + extract_id_from_uri ( id_or_uri ) return self . _client . download ( uri , file_path ) | 251,513 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L142-L155 | [
"def",
"load_toml_rest_api_config",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Skipping rest api loading from non-existent config file: %s\"",
",",
"filename",
")",
"return",
"RestApiConfig",
"(",
")",
"LOGGER",
".",
"info",
"(",
"\"Loading rest api information from config: %s\"",
",",
"filename",
")",
"try",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fd",
":",
"raw_config",
"=",
"fd",
".",
"read",
"(",
")",
"except",
"IOError",
"as",
"e",
":",
"raise",
"RestApiConfigurationError",
"(",
"\"Unable to load rest api configuration file: {}\"",
".",
"format",
"(",
"str",
"(",
"e",
")",
")",
")",
"toml_config",
"=",
"toml",
".",
"loads",
"(",
"raw_config",
")",
"invalid_keys",
"=",
"set",
"(",
"toml_config",
".",
"keys",
"(",
")",
")",
".",
"difference",
"(",
"[",
"'bind'",
",",
"'connect'",
",",
"'timeout'",
",",
"'opentsdb_db'",
",",
"'opentsdb_url'",
",",
"'opentsdb_username'",
",",
"'opentsdb_password'",
",",
"'client_max_size'",
"]",
")",
"if",
"invalid_keys",
":",
"raise",
"RestApiConfigurationError",
"(",
"\"Invalid keys in rest api config: {}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"sorted",
"(",
"list",
"(",
"invalid_keys",
")",
")",
")",
")",
")",
"config",
"=",
"RestApiConfig",
"(",
"bind",
"=",
"toml_config",
".",
"get",
"(",
"\"bind\"",
",",
"None",
")",
",",
"connect",
"=",
"toml_config",
".",
"get",
"(",
"'connect'",
",",
"None",
")",
",",
"timeout",
"=",
"toml_config",
".",
"get",
"(",
"'timeout'",
",",
"None",
")",
",",
"opentsdb_url",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_url'",
",",
"None",
")",
",",
"opentsdb_db",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_db'",
",",
"None",
")",
",",
"opentsdb_username",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_username'",
",",
"None",
")",
",",
"opentsdb_password",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_password'",
",",
"None",
")",
",",
"client_max_size",
"=",
"toml_config",
".",
"get",
"(",
"'client_max_size'",
",",
"None",
")",
")",
"return",
"config"
] |
Download the Artifact Bundle . | def download_artifact_bundle ( self , id_or_uri , file_path ) : uri = self . DOWNLOAD_PATH + '/' + extract_id_from_uri ( id_or_uri ) return self . _client . download ( uri , file_path ) | 251,514 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L157-L169 | [
"def",
"load_toml_rest_api_config",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Skipping rest api loading from non-existent config file: %s\"",
",",
"filename",
")",
"return",
"RestApiConfig",
"(",
")",
"LOGGER",
".",
"info",
"(",
"\"Loading rest api information from config: %s\"",
",",
"filename",
")",
"try",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fd",
":",
"raw_config",
"=",
"fd",
".",
"read",
"(",
")",
"except",
"IOError",
"as",
"e",
":",
"raise",
"RestApiConfigurationError",
"(",
"\"Unable to load rest api configuration file: {}\"",
".",
"format",
"(",
"str",
"(",
"e",
")",
")",
")",
"toml_config",
"=",
"toml",
".",
"loads",
"(",
"raw_config",
")",
"invalid_keys",
"=",
"set",
"(",
"toml_config",
".",
"keys",
"(",
")",
")",
".",
"difference",
"(",
"[",
"'bind'",
",",
"'connect'",
",",
"'timeout'",
",",
"'opentsdb_db'",
",",
"'opentsdb_url'",
",",
"'opentsdb_username'",
",",
"'opentsdb_password'",
",",
"'client_max_size'",
"]",
")",
"if",
"invalid_keys",
":",
"raise",
"RestApiConfigurationError",
"(",
"\"Invalid keys in rest api config: {}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"sorted",
"(",
"list",
"(",
"invalid_keys",
")",
")",
")",
")",
")",
"config",
"=",
"RestApiConfig",
"(",
"bind",
"=",
"toml_config",
".",
"get",
"(",
"\"bind\"",
",",
"None",
")",
",",
"connect",
"=",
"toml_config",
".",
"get",
"(",
"'connect'",
",",
"None",
")",
",",
"timeout",
"=",
"toml_config",
".",
"get",
"(",
"'timeout'",
",",
"None",
")",
",",
"opentsdb_url",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_url'",
",",
"None",
")",
",",
"opentsdb_db",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_db'",
",",
"None",
")",
",",
"opentsdb_username",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_username'",
",",
"None",
")",
",",
"opentsdb_password",
"=",
"toml_config",
".",
"get",
"(",
"'opentsdb_password'",
",",
"None",
")",
",",
"client_max_size",
"=",
"toml_config",
".",
"get",
"(",
"'client_max_size'",
",",
"None",
")",
")",
"return",
"config"
] |
Creates a backup bundle with all the artifacts present on the appliance . At any given point only one backup bundle will exist on the appliance . | def create_backup ( self , resource , timeout = - 1 ) : return self . _client . create ( resource , uri = self . BACKUPS_PATH , timeout = timeout ) | 251,515 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L171-L185 | [
"def",
"win32_refresh_window",
"(",
"cls",
")",
":",
"# Get console handle",
"handle",
"=",
"windll",
".",
"kernel32",
".",
"GetConsoleWindow",
"(",
")",
"RDW_INVALIDATE",
"=",
"0x0001",
"windll",
".",
"user32",
".",
"RedrawWindow",
"(",
"handle",
",",
"None",
",",
"None",
",",
"c_uint",
"(",
"RDW_INVALIDATE",
")",
")"
] |
Restore an Artifact Bundle from a backup file . | def upload_backup_bundle_from_file ( self , file_path , deployment_groups_id_or_uri ) : deployment_groups_uri = deployment_groups_id_or_uri if self . DEPLOYMENT_GROUPS_URI not in deployment_groups_id_or_uri : deployment_groups_uri = self . DEPLOYMENT_GROUPS_URI + deployment_groups_id_or_uri uri = self . BACKUP_ARCHIVE_PATH + "?deploymentGrpUri=" + deployment_groups_uri return self . _client . upload ( file_path , uri ) | 251,516 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L199-L217 | [
"def",
"communityvisibilitystate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_communityvisibilitystate",
"==",
"None",
":",
"return",
"None",
"elif",
"self",
".",
"_communityvisibilitystate",
"in",
"self",
".",
"VisibilityState",
":",
"return",
"self",
".",
"VisibilityState",
"[",
"self",
".",
"_communityvisibilitystate",
"]",
"else",
":",
"#Invalid State",
"return",
"None"
] |
Updates only name for the Artifact Bundle . | def update ( self , resource , timeout = - 1 ) : return self . _client . update ( resource , timeout = timeout , default_values = self . DEFAULT_VALUES ) | 251,517 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L250-L263 | [
"def",
"random_connection",
"(",
"self",
")",
":",
"# While at the moment there's no need for this to be a context manager",
"# per se, I would like to use that interface since I anticipate",
"# adding some wrapping around it at some point.",
"yield",
"random",
".",
"choice",
"(",
"[",
"conn",
"for",
"conn",
"in",
"self",
".",
"connections",
"(",
")",
"if",
"conn",
".",
"alive",
"(",
")",
"]",
")"
] |
Extracts the existing bundle on the appliance and creates all the artifacts . | def extract_bundle ( self , resource , timeout = - 1 ) : return self . _client . update ( resource , timeout = timeout , custom_headers = { "Content-Type" : "text/plain" } ) | 251,518 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L265-L278 | [
"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"
] |
Extracts the existing backup bundle on the appliance and creates all the artifacts . | def extract_backup_bundle ( self , resource , timeout = - 1 ) : return self . _client . update ( resource , uri = self . BACKUP_ARCHIVE_PATH , timeout = timeout ) | 251,519 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L280-L293 | [
"def",
"ensure_segment_table",
"(",
"connection",
")",
":",
"count",
"=",
"connection",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"\"SELECT count(*) FROM sqlite_master WHERE name='segment'\"",
")",
".",
"fetchone",
"(",
")",
"[",
"0",
"]",
"if",
"count",
"==",
"0",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"\"WARNING: None of the loaded files contain a segment table\"",
"theClass",
"=",
"lsctables",
".",
"TableByName",
"[",
"'segment'",
"]",
"statement",
"=",
"\"CREATE TABLE IF NOT EXISTS segment (\"",
"+",
"\", \"",
".",
"join",
"(",
"map",
"(",
"lambda",
"key",
":",
"\"%s %s\"",
"%",
"(",
"key",
",",
"ligolwtypes",
".",
"ToSQLiteType",
"[",
"theClass",
".",
"validcolumns",
"[",
"key",
"]",
"]",
")",
",",
"theClass",
".",
"validcolumns",
")",
")",
"+",
"\")\"",
"connection",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"statement",
")"
] |
Stops creation of the selected Artifact Bundle . | def stop_artifact_creation ( self , id_or_uri , task_uri ) : data = { "taskUri" : task_uri } uri = self . URI + '/' + extract_id_from_uri ( id_or_uri ) + self . STOP_CREATION_PATH return self . _client . update ( data , uri = uri ) | 251,520 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/image_streamer/resources/artifact_bundles.py#L295-L312 | [
"def",
"access_token",
"(",
"self",
",",
"cookie",
")",
":",
"if",
"(",
"cookie",
")",
":",
"token",
"=",
"self",
".",
"_generate_random_string",
"(",
"self",
".",
"access_tokens",
")",
"self",
".",
"access_tokens",
"[",
"token",
"]",
"=",
"(",
"cookie",
",",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"return",
"token",
"else",
":",
"return",
"None"
] |
Gets the configuration script of the logical enclosure by ID or URI . | def get_script ( self ) : uri = "{}/script" . format ( self . data [ "uri" ] ) return self . _helper . do_get ( uri ) | 251,521 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/logical_enclosures.py#L97-L105 | [
"def",
"get_product_info",
"(",
"self",
",",
"apps",
"=",
"[",
"]",
",",
"packages",
"=",
"[",
"]",
",",
"timeout",
"=",
"15",
")",
":",
"if",
"not",
"apps",
"and",
"not",
"packages",
":",
"return",
"message",
"=",
"MsgProto",
"(",
"EMsg",
".",
"ClientPICSProductInfoRequest",
")",
"for",
"app",
"in",
"apps",
":",
"app_info",
"=",
"message",
".",
"body",
".",
"apps",
".",
"add",
"(",
")",
"app_info",
".",
"only_public",
"=",
"False",
"if",
"isinstance",
"(",
"app",
",",
"tuple",
")",
":",
"app_info",
".",
"appid",
",",
"app_info",
".",
"access_token",
"=",
"app",
"else",
":",
"app_info",
".",
"appid",
"=",
"app",
"for",
"package",
"in",
"packages",
":",
"package_info",
"=",
"message",
".",
"body",
".",
"packages",
".",
"add",
"(",
")",
"if",
"isinstance",
"(",
"package",
",",
"tuple",
")",
":",
"package_info",
".",
"appid",
",",
"package_info",
".",
"access_token",
"=",
"package",
"else",
":",
"package_info",
".",
"packageid",
"=",
"package",
"message",
".",
"body",
".",
"meta_data_only",
"=",
"False",
"job_id",
"=",
"self",
".",
"send_job",
"(",
"message",
")",
"data",
"=",
"dict",
"(",
"apps",
"=",
"{",
"}",
",",
"packages",
"=",
"{",
"}",
")",
"while",
"True",
":",
"chunk",
"=",
"self",
".",
"wait_event",
"(",
"job_id",
",",
"timeout",
"=",
"timeout",
")",
"if",
"chunk",
"is",
"None",
":",
"return",
"chunk",
"=",
"chunk",
"[",
"0",
"]",
".",
"body",
"for",
"app",
"in",
"chunk",
".",
"apps",
":",
"data",
"[",
"'apps'",
"]",
"[",
"app",
".",
"appid",
"]",
"=",
"vdf",
".",
"loads",
"(",
"app",
".",
"buffer",
"[",
":",
"-",
"1",
"]",
".",
"decode",
"(",
"'utf-8'",
",",
"'replace'",
")",
")",
"[",
"'appinfo'",
"]",
"for",
"pkg",
"in",
"chunk",
".",
"packages",
":",
"data",
"[",
"'packages'",
"]",
"[",
"pkg",
".",
"packageid",
"]",
"=",
"vdf",
".",
"binary_loads",
"(",
"pkg",
".",
"buffer",
"[",
"4",
":",
"]",
")",
"[",
"str",
"(",
"pkg",
".",
"packageid",
")",
"]",
"if",
"not",
"chunk",
".",
"response_pending",
":",
"break",
"return",
"data"
] |
Updates the configuration script of the logical enclosure and on all enclosures in the logical enclosure with the specified ID . | def update_script ( self , information , timeout = - 1 ) : uri = "{}/script" . format ( self . data [ "uri" ] ) return self . _helper . update ( information , uri = uri , timeout = timeout ) | 251,522 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/logical_enclosures.py#L108-L122 | [
"def",
"_get_access_from_refresh",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"float",
"]",
":",
"headers",
"=",
"self",
".",
"_get_authorization_headers",
"(",
")",
"data",
"=",
"{",
"'grant_type'",
":",
"'refresh_token'",
",",
"'refresh_token'",
":",
"self",
".",
"refresh_token",
"}",
"r",
"=",
"self",
".",
"session",
".",
"post",
"(",
"self",
".",
"TOKEN_URL",
",",
"headers",
"=",
"headers",
",",
"data",
"=",
"data",
")",
"response_data",
"=",
"r",
".",
"json",
"(",
")",
"return",
"(",
"response_data",
"[",
"'access_token'",
"]",
",",
"response_data",
"[",
"'expires_in'",
"]",
")"
] |
Generates a support dump for the logical enclosure with the specified ID . A logical enclosure support dump includes content for logical interconnects associated with that logical enclosure . By default it also contains appliance support dump content . | def generate_support_dump ( self , information , timeout = - 1 ) : uri = "{}/support-dumps" . format ( self . data [ "uri" ] ) return self . _helper . create ( information , uri = uri , timeout = timeout ) | 251,523 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/logical_enclosures.py#L125-L140 | [
"def",
"_setGroupNames",
"(",
"classes",
",",
"classRename",
")",
":",
"groups",
"=",
"{",
"}",
"for",
"groupName",
",",
"glyphList",
"in",
"classes",
".",
"items",
"(",
")",
":",
"groupName",
"=",
"classRename",
".",
"get",
"(",
"groupName",
",",
"groupName",
")",
"# if the glyph list has only one member,",
"# the glyph name will be used in the pairs.",
"# no group is needed.",
"if",
"len",
"(",
"glyphList",
")",
"==",
"1",
":",
"continue",
"groups",
"[",
"groupName",
"]",
"=",
"glyphList",
"return",
"groups"
] |
Use this action to make a logical enclosure consistent with the enclosure group when the logical enclosure is in the Inconsistent state . | def update_from_group ( self , data = None , timeout = - 1 ) : uri = "{}/updateFromGroup" . format ( self . data [ "uri" ] ) return self . _helper . update ( data , uri , timeout = timeout ) | 251,524 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/logical_enclosures.py#L143-L156 | [
"def",
"fetcher",
"(",
"date",
"=",
"datetime",
".",
"today",
"(",
")",
",",
"url_pattern",
"=",
"URL_PATTERN",
")",
":",
"api_url",
"=",
"url_pattern",
"%",
"date",
".",
"strftime",
"(",
"'%Y-%m-%d'",
")",
"headers",
"=",
"{",
"'Referer'",
":",
"'http://n.pl/program-tv'",
"}",
"raw_result",
"=",
"requests",
".",
"get",
"(",
"api_url",
",",
"headers",
"=",
"headers",
")",
".",
"json",
"(",
")",
"return",
"raw_result"
] |
Creates bulk Ethernet networks . | def create_bulk ( self , resource , timeout = - 1 ) : uri = self . URI + '/bulk' default_values = self . _get_default_values ( self . BULK_DEFAULT_VALUES ) updated_data = self . _helper . update_resource_fields ( resource , default_values ) self . _helper . create ( updated_data , uri = uri , timeout = timeout ) return self . get_range ( resource [ 'namePrefix' ] , resource [ 'vlanIdRange' ] ) | 251,525 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/ethernet_networks.py#L63-L83 | [
"def",
"annotation_wrapper",
"(",
"annotation",
",",
"doc",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"attr",
")",
":",
"__cache__",
".",
"setdefault",
"(",
"attr",
",",
"[",
"]",
")",
".",
"append",
"(",
"annotation",
")",
"# Also mark the annotation on the object itself. This will",
"# fail if the object has a restrictive __slots__, but it's",
"# required for some objects like Column because SQLAlchemy copies",
"# them in subclasses, changing their hash and making them",
"# undiscoverable via the cache.",
"try",
":",
"if",
"not",
"hasattr",
"(",
"attr",
",",
"'_coaster_annotations'",
")",
":",
"setattr",
"(",
"attr",
",",
"'_coaster_annotations'",
",",
"[",
"]",
")",
"attr",
".",
"_coaster_annotations",
".",
"append",
"(",
"annotation",
")",
"except",
"AttributeError",
":",
"pass",
"return",
"attr",
"decorator",
".",
"__name__",
"=",
"decorator",
".",
"name",
"=",
"annotation",
"decorator",
".",
"__doc__",
"=",
"doc",
"return",
"decorator"
] |
Gets a list of Ethernet Networks that match the given name_prefix and the vlan_id_range . | def get_range ( self , name_prefix , vlan_id_range ) : filter = '"\'name\' matches \'{}\_%\'"' . format ( name_prefix ) ethernet_networks = self . get_all ( filter = filter , sort = 'vlanId:ascending' ) vlan_ids = self . dissociate_values_or_ranges ( vlan_id_range ) for net in ethernet_networks [ : ] : if int ( net [ 'vlanId' ] ) not in vlan_ids : ethernet_networks . remove ( net ) return ethernet_networks | 251,526 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/ethernet_networks.py#L85-L114 | [
"def",
"correlator",
"(",
"A",
",",
"B",
")",
":",
"correlators",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"A",
")",
")",
":",
"correlator_row",
"=",
"[",
"]",
"for",
"j",
"in",
"range",
"(",
"len",
"(",
"B",
")",
")",
":",
"corr",
"=",
"0",
"for",
"k",
"in",
"range",
"(",
"len",
"(",
"A",
"[",
"i",
"]",
")",
")",
":",
"for",
"l",
"in",
"range",
"(",
"len",
"(",
"B",
"[",
"j",
"]",
")",
")",
":",
"if",
"k",
"==",
"l",
":",
"corr",
"+=",
"A",
"[",
"i",
"]",
"[",
"k",
"]",
"*",
"B",
"[",
"j",
"]",
"[",
"l",
"]",
"else",
":",
"corr",
"-=",
"A",
"[",
"i",
"]",
"[",
"k",
"]",
"*",
"B",
"[",
"j",
"]",
"[",
"l",
"]",
"correlator_row",
".",
"append",
"(",
"corr",
")",
"correlators",
".",
"append",
"(",
"correlator_row",
")",
"return",
"correlators"
] |
Gets the URIs of profiles which are using an Ethernet network . | def get_associated_profiles ( self ) : uri = "{}/associatedProfiles" . format ( self . data [ 'uri' ] ) return self . _helper . do_get ( uri ) | 251,527 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/ethernet_networks.py#L154-L166 | [
"def",
"get_client_token",
"(",
")",
":",
"if",
"getattr",
"(",
"settings",
",",
"'NOMIS_API_CLIENT_TOKEN'",
",",
"''",
")",
":",
"return",
"settings",
".",
"NOMIS_API_CLIENT_TOKEN",
"global",
"client_token",
"if",
"not",
"client_token",
"or",
"client_token",
"[",
"'expires'",
"]",
"and",
"client_token",
"[",
"'expires'",
"]",
"-",
"now",
"(",
")",
"<",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
":",
"session",
"=",
"None",
"try",
":",
"session",
"=",
"api_client",
".",
"get_authenticated_api_session",
"(",
"settings",
".",
"TOKEN_RETRIEVAL_USERNAME",
",",
"settings",
".",
"TOKEN_RETRIEVAL_PASSWORD",
")",
"client_token",
"=",
"session",
".",
"get",
"(",
"'/tokens/nomis/'",
")",
".",
"json",
"(",
")",
"except",
"(",
"requests",
".",
"RequestException",
",",
"HttpNotFoundError",
",",
"ValueError",
",",
"AttributeError",
")",
":",
"logger",
".",
"exception",
"(",
"'Cannot load NOMIS API client token'",
")",
"return",
"None",
"finally",
":",
"if",
"session",
"and",
"getattr",
"(",
"session",
",",
"'access_token'",
",",
"None",
")",
":",
"api_client",
".",
"revoke_token",
"(",
"session",
".",
"access_token",
")",
"if",
"client_token",
".",
"get",
"(",
"'expires'",
")",
":",
"client_token",
"[",
"'expires'",
"]",
"=",
"parse_datetime",
"(",
"client_token",
"[",
"'expires'",
"]",
")",
"if",
"client_token",
"[",
"'expires'",
"]",
"<",
"now",
"(",
")",
":",
"logger",
".",
"error",
"(",
"'NOMIS API client token from mtp-api had expired'",
")",
"return",
"None",
"return",
"client_token",
"[",
"'token'",
"]"
] |
Gets the uplink sets which are using an Ethernet network . | def get_associated_uplink_groups ( self ) : uri = "{}/associatedUplinkGroups" . format ( self . data [ 'uri' ] ) return self . _helper . do_get ( uri ) | 251,528 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/ethernet_networks.py#L169-L178 | [
"def",
"queries",
"(",
"self",
",",
"request",
")",
":",
"queries",
"=",
"self",
".",
"get_queries",
"(",
"request",
")",
"worlds",
"=",
"[",
"]",
"with",
"self",
".",
"mapper",
".",
"begin",
"(",
")",
"as",
"session",
":",
"for",
"_",
"in",
"range",
"(",
"queries",
")",
":",
"world",
"=",
"session",
".",
"query",
"(",
"World",
")",
".",
"get",
"(",
"randint",
"(",
"1",
",",
"MAXINT",
")",
")",
"worlds",
".",
"append",
"(",
"self",
".",
"get_json",
"(",
"world",
")",
")",
"return",
"Json",
"(",
"worlds",
")",
".",
"http_response",
"(",
"request",
")"
] |
Updates a copy of resource1 with resource2 values and returns the merged dictionary . | def merge_resources ( resource1 , resource2 ) : merged = resource1 . copy ( ) merged . update ( resource2 ) return merged | 251,529 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L1737-L1750 | [
"def",
"search",
"(",
"query",
",",
"team",
"=",
"None",
")",
":",
"if",
"team",
"is",
"None",
":",
"team",
"=",
"_find_logged_in_team",
"(",
")",
"if",
"team",
"is",
"not",
"None",
":",
"session",
"=",
"_get_session",
"(",
"team",
")",
"response",
"=",
"session",
".",
"get",
"(",
"\"%s/api/search/\"",
"%",
"get_registry_url",
"(",
"team",
")",
",",
"params",
"=",
"dict",
"(",
"q",
"=",
"query",
")",
")",
"print",
"(",
"\"* Packages in team %s\"",
"%",
"team",
")",
"packages",
"=",
"response",
".",
"json",
"(",
")",
"[",
"'packages'",
"]",
"for",
"pkg",
"in",
"packages",
":",
"print",
"(",
"(",
"\"%s:\"",
"%",
"team",
")",
"+",
"(",
"\"%(owner)s/%(name)s\"",
"%",
"pkg",
")",
")",
"if",
"len",
"(",
"packages",
")",
"==",
"0",
":",
"print",
"(",
"\"(No results)\"",
")",
"print",
"(",
"\"* Packages in public cloud\"",
")",
"public_session",
"=",
"_get_session",
"(",
"None",
")",
"response",
"=",
"public_session",
".",
"get",
"(",
"\"%s/api/search/\"",
"%",
"get_registry_url",
"(",
"None",
")",
",",
"params",
"=",
"dict",
"(",
"q",
"=",
"query",
")",
")",
"packages",
"=",
"response",
".",
"json",
"(",
")",
"[",
"'packages'",
"]",
"for",
"pkg",
"in",
"packages",
":",
"print",
"(",
"\"%(owner)s/%(name)s\"",
"%",
"pkg",
")",
"if",
"len",
"(",
"packages",
")",
"==",
"0",
":",
"print",
"(",
"\"(No results)\"",
")"
] |
Generate a new list where each item of original resource_list will be merged with the default_values . | def merge_default_values ( resource_list , default_values ) : def merge_item ( resource ) : return merge_resources ( default_values , resource ) return lmap ( merge_item , resource_list ) | 251,530 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L1753-L1769 | [
"def",
"Uptime",
"(",
")",
":",
"uptime",
"=",
"''",
"try",
":",
"uptime",
"=",
"check_output",
"(",
"[",
"'uptime'",
"]",
",",
"close_fds",
"=",
"True",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"[",
"1",
":",
"]",
"except",
"Exception",
"as",
"e",
":",
"# pragma: no cover",
"logger",
".",
"error",
"(",
"'Could not get current uptime '",
"+",
"str",
"(",
"e",
")",
")",
"return",
"uptime"
] |
Retrieves data from OneView and updates resource object . | def ensure_resource_data ( self , update_data = False ) : # Check for unique identifier in the resource data if not any ( key in self . data for key in self . UNIQUE_IDENTIFIERS ) : raise exceptions . HPOneViewMissingUniqueIdentifiers ( MISSING_UNIQUE_IDENTIFIERS ) # Returns if data update is not required if not update_data : return resource_data = None if 'uri' in self . UNIQUE_IDENTIFIERS and self . data . get ( 'uri' ) : resource_data = self . _helper . do_get ( self . data [ 'uri' ] ) else : for identifier in self . UNIQUE_IDENTIFIERS : identifier_value = self . data . get ( identifier ) if identifier_value : result = self . get_by ( identifier , identifier_value ) if result and isinstance ( result , list ) : resource_data = result [ 0 ] break if resource_data : self . data . update ( resource_data ) else : raise exceptions . HPOneViewResourceNotFound ( RESOURCE_DOES_NOT_EXIST ) | 251,531 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L110-L141 | [
"def",
"stop_experiment",
"(",
"args",
")",
":",
"experiment_id_list",
"=",
"parse_ids",
"(",
"args",
")",
"if",
"experiment_id_list",
":",
"experiment_config",
"=",
"Experiments",
"(",
")",
"experiment_dict",
"=",
"experiment_config",
".",
"get_all_experiments",
"(",
")",
"for",
"experiment_id",
"in",
"experiment_id_list",
":",
"print_normal",
"(",
"'Stoping experiment %s'",
"%",
"experiment_id",
")",
"nni_config",
"=",
"Config",
"(",
"experiment_dict",
"[",
"experiment_id",
"]",
"[",
"'fileName'",
"]",
")",
"rest_port",
"=",
"nni_config",
".",
"get_config",
"(",
"'restServerPort'",
")",
"rest_pid",
"=",
"nni_config",
".",
"get_config",
"(",
"'restServerPid'",
")",
"if",
"rest_pid",
":",
"kill_command",
"(",
"rest_pid",
")",
"tensorboard_pid_list",
"=",
"nni_config",
".",
"get_config",
"(",
"'tensorboardPidList'",
")",
"if",
"tensorboard_pid_list",
":",
"for",
"tensorboard_pid",
"in",
"tensorboard_pid_list",
":",
"try",
":",
"kill_command",
"(",
"tensorboard_pid",
")",
"except",
"Exception",
"as",
"exception",
":",
"print_error",
"(",
"exception",
")",
"nni_config",
".",
"set_config",
"(",
"'tensorboardPidList'",
",",
"[",
"]",
")",
"print_normal",
"(",
"'Stop experiment success!'",
")",
"experiment_config",
".",
"update_experiment",
"(",
"experiment_id",
",",
"'status'",
",",
"'STOPPED'",
")",
"time_now",
"=",
"time",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
",",
"time",
".",
"localtime",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"experiment_config",
".",
"update_experiment",
"(",
"experiment_id",
",",
"'endTime'",
",",
"str",
"(",
"time_now",
")",
")"
] |
Get the resource by passing a field and its value . | def get_by ( self , field , value ) : if not field : logger . exception ( RESOURCE_CLIENT_INVALID_FIELD ) raise ValueError ( RESOURCE_CLIENT_INVALID_FIELD ) filter = "\"{0}='{1}'\"" . format ( field , value ) results = self . get_all ( filter = filter ) # Workaround when the OneView filter does not work, it will filter again if "." not in field : # This filter only work for the first level results = [ item for item in results if str ( item . get ( field , "" ) ) . lower ( ) == value . lower ( ) ] return results | 251,532 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L234-L259 | [
"def",
"principal_axis",
"(",
"inertia",
")",
":",
"inertia",
"=",
"np",
".",
"asanyarray",
"(",
"inertia",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"if",
"inertia",
".",
"shape",
"!=",
"(",
"3",
",",
"3",
")",
":",
"raise",
"ValueError",
"(",
"'inertia tensor must be (3,3)!'",
")",
"# you could any of the following to calculate this:",
"# np.linalg.svd, np.linalg.eig, np.linalg.eigh",
"# moment of inertia is square symmetric matrix",
"# eigh has the best numeric precision in tests",
"components",
",",
"vectors",
"=",
"np",
".",
"linalg",
".",
"eigh",
"(",
"inertia",
"*",
"negate_nondiagonal",
")",
"# eigh returns them as column vectors, change them to row vectors",
"vectors",
"=",
"vectors",
".",
"T",
"return",
"components",
",",
"vectors"
] |
Retrieves a resource by its name . | def get_by_name ( self , name ) : result = self . get_by ( "name" , name ) if result : data = result [ 0 ] new_resource = self . new ( self . _connection , data ) else : new_resource = None return new_resource | 251,533 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L261-L278 | [
"def",
"dnd_endDnd",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"SlackResponse",
":",
"self",
".",
"_validate_xoxp_token",
"(",
")",
"return",
"self",
".",
"api_call",
"(",
"\"dnd.endDnd\"",
",",
"json",
"=",
"kwargs",
")"
] |
Retrieves a resource by its URI | def get_by_uri ( self , uri ) : self . _helper . validate_resource_uri ( uri ) data = self . _helper . do_get ( uri ) if data : new_resource = self . new ( self . _connection , data ) else : new_resource = None return new_resource | 251,534 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L280-L297 | [
"def",
"_index_audio_cmu",
"(",
"self",
",",
"basename",
"=",
"None",
",",
"replace_already_indexed",
"=",
"False",
")",
":",
"self",
".",
"_prepare_audio",
"(",
"basename",
"=",
"basename",
",",
"replace_already_indexed",
"=",
"replace_already_indexed",
")",
"for",
"staging_audio_basename",
"in",
"self",
".",
"_list_audio_files",
"(",
"sub_dir",
"=",
"\"staging\"",
")",
":",
"original_audio_name",
"=",
"''",
".",
"join",
"(",
"staging_audio_basename",
".",
"split",
"(",
"'.'",
")",
"[",
":",
"-",
"1",
"]",
")",
"[",
":",
"-",
"3",
"]",
"pocketsphinx_command",
"=",
"''",
".",
"join",
"(",
"[",
"\"pocketsphinx_continuous\"",
",",
"\"-infile\"",
",",
"str",
"(",
"\"{}/staging/{}\"",
".",
"format",
"(",
"self",
".",
"src_dir",
",",
"staging_audio_basename",
")",
")",
",",
"\"-time\"",
",",
"\"yes\"",
",",
"\"-logfn\"",
",",
"\"/dev/null\"",
"]",
")",
"try",
":",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Now indexing {}\"",
".",
"format",
"(",
"staging_audio_basename",
")",
")",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pocketsphinx_continuous\"",
",",
"\"-infile\"",
",",
"str",
"(",
"\"{}/staging/{}\"",
".",
"format",
"(",
"self",
".",
"src_dir",
",",
"staging_audio_basename",
")",
")",
",",
"\"-time\"",
",",
"\"yes\"",
",",
"\"-logfn\"",
",",
"\"/dev/null\"",
"]",
",",
"universal_newlines",
"=",
"True",
")",
".",
"split",
"(",
"'\\n'",
")",
"str_timestamps_with_sil_conf",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"split",
"(",
"\" \"",
")",
",",
"filter",
"(",
"None",
",",
"output",
"[",
"1",
":",
"]",
")",
")",
")",
"# Timestamps are putted in a list of a single element. To match",
"# Watson's output.",
"self",
".",
"__timestamps_unregulated",
"[",
"original_audio_name",
"+",
"\".wav\"",
"]",
"=",
"[",
"(",
"self",
".",
"_timestamp_extractor_cmu",
"(",
"staging_audio_basename",
",",
"str_timestamps_with_sil_conf",
")",
")",
"]",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Done indexing {}\"",
".",
"format",
"(",
"staging_audio_basename",
")",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"e",
",",
"\"The command was: {}\"",
".",
"format",
"(",
"pocketsphinx_command",
")",
")",
"self",
".",
"__errors",
"[",
"(",
"time",
"(",
")",
",",
"staging_audio_basename",
")",
"]",
"=",
"e",
"self",
".",
"_timestamp_regulator",
"(",
")",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Finished indexing procedure\"",
")"
] |
Gets the default values set for a resource | def _get_default_values ( self , default_values = None ) : if not default_values : default_values = self . DEFAULT_VALUES if default_values : api_version = str ( self . _connection . _apiVersion ) values = default_values . get ( api_version , { } ) . copy ( ) else : values = { } return values | 251,535 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L299-L311 | [
"def",
"_index_audio_cmu",
"(",
"self",
",",
"basename",
"=",
"None",
",",
"replace_already_indexed",
"=",
"False",
")",
":",
"self",
".",
"_prepare_audio",
"(",
"basename",
"=",
"basename",
",",
"replace_already_indexed",
"=",
"replace_already_indexed",
")",
"for",
"staging_audio_basename",
"in",
"self",
".",
"_list_audio_files",
"(",
"sub_dir",
"=",
"\"staging\"",
")",
":",
"original_audio_name",
"=",
"''",
".",
"join",
"(",
"staging_audio_basename",
".",
"split",
"(",
"'.'",
")",
"[",
":",
"-",
"1",
"]",
")",
"[",
":",
"-",
"3",
"]",
"pocketsphinx_command",
"=",
"''",
".",
"join",
"(",
"[",
"\"pocketsphinx_continuous\"",
",",
"\"-infile\"",
",",
"str",
"(",
"\"{}/staging/{}\"",
".",
"format",
"(",
"self",
".",
"src_dir",
",",
"staging_audio_basename",
")",
")",
",",
"\"-time\"",
",",
"\"yes\"",
",",
"\"-logfn\"",
",",
"\"/dev/null\"",
"]",
")",
"try",
":",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Now indexing {}\"",
".",
"format",
"(",
"staging_audio_basename",
")",
")",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pocketsphinx_continuous\"",
",",
"\"-infile\"",
",",
"str",
"(",
"\"{}/staging/{}\"",
".",
"format",
"(",
"self",
".",
"src_dir",
",",
"staging_audio_basename",
")",
")",
",",
"\"-time\"",
",",
"\"yes\"",
",",
"\"-logfn\"",
",",
"\"/dev/null\"",
"]",
",",
"universal_newlines",
"=",
"True",
")",
".",
"split",
"(",
"'\\n'",
")",
"str_timestamps_with_sil_conf",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"split",
"(",
"\" \"",
")",
",",
"filter",
"(",
"None",
",",
"output",
"[",
"1",
":",
"]",
")",
")",
")",
"# Timestamps are putted in a list of a single element. To match",
"# Watson's output.",
"self",
".",
"__timestamps_unregulated",
"[",
"original_audio_name",
"+",
"\".wav\"",
"]",
"=",
"[",
"(",
"self",
".",
"_timestamp_extractor_cmu",
"(",
"staging_audio_basename",
",",
"str_timestamps_with_sil_conf",
")",
")",
"]",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Done indexing {}\"",
".",
"format",
"(",
"staging_audio_basename",
")",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"e",
",",
"\"The command was: {}\"",
".",
"format",
"(",
"pocketsphinx_command",
")",
")",
"self",
".",
"__errors",
"[",
"(",
"time",
"(",
")",
",",
"staging_audio_basename",
")",
"]",
"=",
"e",
"self",
".",
"_timestamp_regulator",
"(",
")",
"if",
"self",
".",
"get_verbosity",
"(",
")",
":",
"print",
"(",
"\"Finished indexing procedure\"",
")"
] |
Merge default values with resource data . | def _merge_default_values ( self ) : values = self . _get_default_values ( ) for key , value in values . items ( ) : if not self . data . get ( key ) : self . data [ key ] = value | 251,536 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L313-L318 | [
"def",
"upload_cbn_dir",
"(",
"dir_path",
",",
"manager",
")",
":",
"t",
"=",
"time",
".",
"time",
"(",
")",
"for",
"jfg_path",
"in",
"os",
".",
"listdir",
"(",
"dir_path",
")",
":",
"if",
"not",
"jfg_path",
".",
"endswith",
"(",
"'.jgf'",
")",
":",
"continue",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_path",
",",
"jfg_path",
")",
"log",
".",
"info",
"(",
"'opening %s'",
",",
"path",
")",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"cbn_jgif_dict",
"=",
"json",
".",
"load",
"(",
"f",
")",
"graph",
"=",
"pybel",
".",
"from_cbn_jgif",
"(",
"cbn_jgif_dict",
")",
"out_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_path",
",",
"jfg_path",
".",
"replace",
"(",
"'.jgf'",
",",
"'.bel'",
")",
")",
"with",
"open",
"(",
"out_path",
",",
"'w'",
")",
"as",
"o",
":",
"pybel",
".",
"to_bel",
"(",
"graph",
",",
"o",
")",
"strip_annotations",
"(",
"graph",
")",
"enrich_pubmed_citations",
"(",
"manager",
"=",
"manager",
",",
"graph",
"=",
"graph",
")",
"pybel",
".",
"to_database",
"(",
"graph",
",",
"manager",
"=",
"manager",
")",
"log",
".",
"info",
"(",
"''",
")",
"log",
".",
"info",
"(",
"'done in %.2f'",
",",
"time",
".",
"time",
"(",
")",
"-",
"t",
")"
] |
Creates a report and returns the output . | def create_report ( self , uri , timeout = - 1 ) : logger . debug ( 'Creating Report (uri = %s)' . format ( uri ) ) task , _ = self . _connection . post ( uri , { } ) if not task : raise exceptions . HPOneViewException ( RESOURCE_CLIENT_TASK_EXPECTED ) task = self . _task_monitor . get_completed_task ( task , timeout ) return task [ 'taskOutput' ] | 251,537 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L471-L492 | [
"def",
"insert",
"(",
"self",
",",
"storagemodel",
")",
"->",
"StorageTableModel",
":",
"modeldefinition",
"=",
"self",
".",
"getmodeldefinition",
"(",
"storagemodel",
",",
"True",
")",
"try",
":",
"modeldefinition",
"[",
"'tableservice'",
"]",
".",
"insert_or_replace_entity",
"(",
"modeldefinition",
"[",
"'tablename'",
"]",
",",
"storagemodel",
".",
"entity",
"(",
")",
")",
"storagemodel",
".",
"_exists",
"=",
"True",
"except",
"AzureMissingResourceHttpError",
"as",
"e",
":",
"storagemodel",
".",
"_exists",
"=",
"False",
"log",
".",
"debug",
"(",
"'can not insert or replace table entity: Table {}, PartitionKey {}, RowKey {} because {!s}'",
".",
"format",
"(",
"modeldefinition",
"[",
"'tablename'",
"]",
",",
"storagemodel",
".",
"getPartitionKey",
"(",
")",
",",
"storagemodel",
".",
"getRowKey",
"(",
")",
",",
"e",
")",
")",
"except",
"Exception",
"as",
"e",
":",
"storagemodel",
".",
"_exists",
"=",
"False",
"msg",
"=",
"'can not insert or replace table entity: Table {}, PartitionKey {}, RowKey {} because {!s}'",
".",
"format",
"(",
"modeldefinition",
"[",
"'tablename'",
"]",
",",
"storagemodel",
".",
"PartitionKey",
",",
"storagemodel",
".",
"RowKey",
",",
"e",
")",
"raise",
"AzureStorageWrapException",
"(",
"msg",
"=",
"msg",
")",
"finally",
":",
"return",
"storagemodel"
] |
Builds the URI from given parameters . | def build_query_uri ( self , uri = None , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , view = '' , fields = '' , scope_uris = '' ) : if filter : filter = self . make_query_filter ( filter ) if query : query = "&query=" + quote ( query ) if sort : sort = "&sort=" + quote ( sort ) if view : view = "&view=" + quote ( view ) if fields : fields = "&fields=" + quote ( fields ) if scope_uris : scope_uris = "&scopeUris=" + quote ( scope_uris ) path = uri if uri else self . _base_uri self . validate_resource_uri ( path ) symbol = '?' if '?' not in path else '&' uri = "{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}" . format ( path , symbol , start , count , filter , query , sort , view , fields , scope_uris ) return uri | 251,538 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L523-L585 | [
"def",
"read",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"trace_file",
".",
"readline",
"(",
")",
"if",
"line",
"==",
"''",
":",
"if",
"self",
".",
"loop",
":",
"self",
".",
"_reopen_file",
"(",
")",
"else",
":",
"self",
".",
"trace_file",
".",
"close",
"(",
")",
"self",
".",
"trace_file",
"=",
"None",
"raise",
"DataSourceError",
"(",
")",
"message",
"=",
"JsonFormatter",
".",
"deserialize",
"(",
"line",
")",
"timestamp",
"=",
"message",
".",
"get",
"(",
"'timestamp'",
",",
"None",
")",
"if",
"self",
".",
"realtime",
"and",
"timestamp",
"is",
"not",
"None",
":",
"self",
".",
"_store_timestamp",
"(",
"timestamp",
")",
"self",
".",
"_wait",
"(",
"self",
".",
"starting_time",
",",
"self",
".",
"first_timestamp",
",",
"timestamp",
")",
"return",
"line",
"+",
"\"\\x00\""
] |
Helps to build the URI from resource id and validate the URI . | def build_uri ( self , id_or_uri ) : if not id_or_uri : logger . exception ( RESOURCE_CLIENT_INVALID_ID ) raise ValueError ( RESOURCE_CLIENT_INVALID_ID ) if "/" in id_or_uri : self . validate_resource_uri ( id_or_uri ) return id_or_uri else : return self . _base_uri + "/" + id_or_uri | 251,539 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L594-L611 | [
"def",
"benchmark_backward",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_benchmark_backward",
"(",
")",
"except",
"RuntimeError",
"as",
"e",
":",
"# Seems like not implemented.",
"print",
"(",
"e",
")",
"self",
".",
"mod_ext",
".",
"synchronize",
"(",
"*",
"*",
"self",
".",
"ext_kwargs",
")",
"self",
".",
"backward_stat",
"=",
"None"
] |
Helps to build a URI with resource path and its sub resource path . | def build_subresource_uri ( self , resource_id_or_uri = None , subresource_id_or_uri = None , subresource_path = '' ) : if subresource_id_or_uri and "/" in subresource_id_or_uri : return subresource_id_or_uri else : if not resource_id_or_uri : raise exceptions . HPOneViewValueError ( RESOURCE_ID_OR_URI_REQUIRED ) resource_uri = self . build_uri ( resource_id_or_uri ) uri = "{}/{}/{}" . format ( resource_uri , subresource_path , str ( subresource_id_or_uri or '' ) ) uri = uri . replace ( "//" , "/" ) if uri . endswith ( "/" ) : uri = uri [ : - 1 ] return uri | 251,540 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L613-L638 | [
"def",
"login_with_token",
"(",
"refresh_token",
",",
"team",
"=",
"None",
")",
":",
"# Get an access token and a new refresh token.",
"_check_team_id",
"(",
"team",
")",
"auth",
"=",
"_update_auth",
"(",
"team",
",",
"refresh_token",
")",
"url",
"=",
"get_registry_url",
"(",
"team",
")",
"contents",
"=",
"_load_auth",
"(",
")",
"contents",
"[",
"url",
"]",
"=",
"auth",
"_save_auth",
"(",
"contents",
")",
"_clear_session",
"(",
"team",
")"
] |
Helper method to validate URI of the resource . | def validate_resource_uri ( self , path ) : if self . _base_uri not in path : logger . exception ( 'Get by uri : unrecognized uri: (%s)' % path ) raise exceptions . HPOneViewUnknownType ( UNRECOGNIZED_URI ) | 251,541 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L640-L644 | [
"def",
"insert_seperator_results",
"(",
"results",
")",
":",
"sepbench",
"=",
"BenchmarkResult",
"(",
"*",
"[",
"' '",
"*",
"w",
"for",
"w",
"in",
"COLUMN_WIDTHS",
"]",
")",
"last_bm",
"=",
"None",
"for",
"r",
"in",
"results",
":",
"if",
"last_bm",
"is",
"None",
":",
"last_bm",
"=",
"r",
".",
"benchmark",
"elif",
"last_bm",
"!=",
"r",
".",
"benchmark",
":",
"yield",
"sepbench",
"last_bm",
"=",
"r",
".",
"benchmark",
"yield",
"r"
] |
Helps to make http request for get_all method . | def do_requests_to_getall ( self , uri , requested_count ) : items = [ ] while uri : logger . debug ( 'Making HTTP request to get all resources. Uri: {0}' . format ( uri ) ) response = self . _connection . get ( uri ) members = self . get_members ( response ) items += members logger . debug ( "Response getAll: nextPageUri = {0}, members list length: {1}" . format ( uri , str ( len ( members ) ) ) ) uri = self . get_next_page ( response , items , requested_count ) logger . debug ( 'Total # of members found = {0}' . format ( str ( len ( items ) ) ) ) return items | 251,542 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L678-L697 | [
"def",
"create_meta_main",
"(",
"create_path",
",",
"config",
",",
"role",
",",
"categories",
")",
":",
"meta_file",
"=",
"c",
".",
"DEFAULT_META_FILE",
".",
"replace",
"(",
"\"%author_name\"",
",",
"config",
"[",
"\"author_name\"",
"]",
")",
"meta_file",
"=",
"meta_file",
".",
"replace",
"(",
"\"%author_company\"",
",",
"config",
"[",
"\"author_company\"",
"]",
")",
"meta_file",
"=",
"meta_file",
".",
"replace",
"(",
"\"%license_type\"",
",",
"config",
"[",
"\"license_type\"",
"]",
")",
"meta_file",
"=",
"meta_file",
".",
"replace",
"(",
"\"%role_name\"",
",",
"role",
")",
"# Normalize the category so %categories always gets replaced.",
"if",
"not",
"categories",
":",
"categories",
"=",
"\"\"",
"meta_file",
"=",
"meta_file",
".",
"replace",
"(",
"\"%categories\"",
",",
"categories",
")",
"string_to_file",
"(",
"create_path",
",",
"meta_file",
")"
] |
Helps to make get requests | def do_get ( self , uri ) : self . validate_resource_uri ( uri ) return self . _connection . get ( uri ) | 251,543 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L710-L720 | [
"def",
"get_listing",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'listing'",
")",
":",
"allEvents",
"=",
"self",
".",
"get_allEvents",
"(",
")",
"openEvents",
"=",
"allEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
"closedEvents",
"=",
"allEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
"publicEvents",
"=",
"allEvents",
".",
"instance_of",
"(",
"PublicEvent",
")",
"allSeries",
"=",
"allEvents",
".",
"instance_of",
"(",
"Series",
")",
"self",
".",
"listing",
"=",
"{",
"'allEvents'",
":",
"allEvents",
",",
"'openEvents'",
":",
"openEvents",
",",
"'closedEvents'",
":",
"closedEvents",
",",
"'publicEvents'",
":",
"publicEvents",
",",
"'allSeries'",
":",
"allSeries",
",",
"'regOpenEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
".",
"filter",
"(",
"Q",
"(",
"publicevent__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'regClosedEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
".",
"filter",
"(",
"Q",
"(",
"publicevent__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'categorySeparateEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"True",
")",
".",
"order_by",
"(",
"'publicevent__category'",
")",
",",
"'regOpenSeries'",
":",
"allSeries",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
".",
"filter",
"(",
"Q",
"(",
"series__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"series__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'regClosedSeries'",
":",
"allSeries",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
".",
"filter",
"(",
"Q",
"(",
"series__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"series__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'categorySeparateSeries'",
":",
"allSeries",
".",
"filter",
"(",
"series__category__separateOnRegistrationPage",
"=",
"True",
")",
".",
"order_by",
"(",
"'series__category'",
")",
",",
"}",
"return",
"self",
".",
"listing"
] |
Helps to make post requests . | def do_post ( self , uri , resource , timeout , custom_headers ) : self . validate_resource_uri ( uri ) task , entity = self . _connection . post ( uri , resource , custom_headers = custom_headers ) if not task : return entity return self . _task_monitor . wait_for_task ( task , timeout ) | 251,544 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L722-L741 | [
"def",
"partition_by_vid",
"(",
"self",
",",
"ref",
")",
":",
"from",
"ambry",
".",
"orm",
"import",
"Partition",
"p",
"=",
"self",
".",
"session",
".",
"query",
"(",
"Partition",
")",
".",
"filter",
"(",
"Partition",
".",
"vid",
"==",
"str",
"(",
"ref",
")",
")",
".",
"first",
"(",
")",
"if",
"p",
":",
"return",
"self",
".",
"wrap_partition",
"(",
"p",
")",
"else",
":",
"return",
"None"
] |
Helps to make put requests . | def do_put ( self , uri , resource , timeout , custom_headers ) : self . validate_resource_uri ( uri ) task , body = self . _connection . put ( uri , resource , custom_headers = custom_headers ) if not task : return body return self . _task_monitor . wait_for_task ( task , timeout ) | 251,545 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L743-L761 | [
"def",
"get_listing",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'listing'",
")",
":",
"allEvents",
"=",
"self",
".",
"get_allEvents",
"(",
")",
"openEvents",
"=",
"allEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
"closedEvents",
"=",
"allEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
"publicEvents",
"=",
"allEvents",
".",
"instance_of",
"(",
"PublicEvent",
")",
"allSeries",
"=",
"allEvents",
".",
"instance_of",
"(",
"Series",
")",
"self",
".",
"listing",
"=",
"{",
"'allEvents'",
":",
"allEvents",
",",
"'openEvents'",
":",
"openEvents",
",",
"'closedEvents'",
":",
"closedEvents",
",",
"'publicEvents'",
":",
"publicEvents",
",",
"'allSeries'",
":",
"allSeries",
",",
"'regOpenEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
".",
"filter",
"(",
"Q",
"(",
"publicevent__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'regClosedEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
".",
"filter",
"(",
"Q",
"(",
"publicevent__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'categorySeparateEvents'",
":",
"publicEvents",
".",
"filter",
"(",
"publicevent__category__separateOnRegistrationPage",
"=",
"True",
")",
".",
"order_by",
"(",
"'publicevent__category'",
")",
",",
"'regOpenSeries'",
":",
"allSeries",
".",
"filter",
"(",
"registrationOpen",
"=",
"True",
")",
".",
"filter",
"(",
"Q",
"(",
"series__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"series__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'regClosedSeries'",
":",
"allSeries",
".",
"filter",
"(",
"registrationOpen",
"=",
"False",
")",
".",
"filter",
"(",
"Q",
"(",
"series__category__isnull",
"=",
"True",
")",
"|",
"Q",
"(",
"series__category__separateOnRegistrationPage",
"=",
"False",
")",
")",
",",
"'categorySeparateSeries'",
":",
"allSeries",
".",
"filter",
"(",
"series__category__separateOnRegistrationPage",
"=",
"True",
")",
".",
"order_by",
"(",
"'series__category'",
")",
",",
"}",
"return",
"self",
".",
"listing"
] |
Downloads the contents of the requested URI to a stream . | def download ( self , uri , file_path ) : with open ( file_path , 'wb' ) as file : return self . _connection . download_to_stream ( file , uri ) | 251,546 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L863-L874 | [
"def",
"parsedate_tz",
"(",
"data",
")",
":",
"res",
"=",
"_parsedate_tz",
"(",
"data",
")",
"if",
"not",
"res",
":",
"return",
"if",
"res",
"[",
"9",
"]",
"is",
"None",
":",
"res",
"[",
"9",
"]",
"=",
"0",
"return",
"tuple",
"(",
"res",
")"
] |
Builds the URI given the parameters . | def build_query_uri ( self , start = 0 , count = - 1 , filter = '' , query = '' , sort = '' , view = '' , fields = '' , uri = None , scope_uris = '' ) : if filter : filter = self . __make_query_filter ( filter ) if query : query = "&query=" + quote ( query ) if sort : sort = "&sort=" + quote ( sort ) if view : view = "&view=" + quote ( view ) if fields : fields = "&fields=" + quote ( fields ) if scope_uris : scope_uris = "&scopeUris=" + quote ( scope_uris ) path = uri if uri else self . _uri self . __validate_resource_uri ( path ) symbol = '?' if '?' not in path else '&' uri = "{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}" . format ( path , symbol , start , count , filter , query , sort , view , fields , scope_uris ) return uri | 251,547 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L1023-L1095 | [
"def",
"join_time_series",
"(",
"serieses",
",",
"ignore_year",
"=",
"False",
",",
"T_s",
"=",
"None",
",",
"aggregator",
"=",
"'mean'",
")",
":",
"if",
"ignore_year",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"for",
"name",
",",
"ts",
"in",
"serieses",
".",
"iteritems",
"(",
")",
":",
"# FIXME: deal with leap years",
"sod",
"=",
"np",
".",
"array",
"(",
"map",
"(",
"lambda",
"x",
":",
"(",
"x",
".",
"hour",
"*",
"3600",
"+",
"x",
".",
"minute",
"*",
"60",
"+",
"x",
".",
"second",
")",
",",
"ts",
".",
"index",
".",
"time",
")",
")",
"# Coerce soy to an integer so that merge/join operations identify same values",
"# (floats don't equal!?)",
"soy",
"=",
"(",
"ts",
".",
"index",
".",
"dayofyear",
"+",
"366",
"*",
"(",
"ts",
".",
"index",
".",
"year",
"-",
"ts",
".",
"index",
".",
"year",
"[",
"0",
"]",
")",
")",
"*",
"3600",
"*",
"24",
"+",
"sod",
"ts2",
"=",
"pd",
".",
"Series",
"(",
"ts",
".",
"values",
",",
"index",
"=",
"soy",
")",
"ts2",
"=",
"ts2",
".",
"dropna",
"(",
")",
"ts2",
"=",
"ts2",
".",
"sort_index",
"(",
")",
"df2",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"name",
":",
"ts2",
".",
"values",
"}",
",",
"index",
"=",
"soy",
")",
"df",
"=",
"df",
".",
"join",
"(",
"df2",
",",
"how",
"=",
"'outer'",
")",
"if",
"T_s",
"and",
"aggregator",
":",
"df",
"=",
"df",
".",
"groupby",
"(",
"lambda",
"x",
":",
"int",
"(",
"x",
"/",
"float",
"(",
"T_s",
")",
")",
")",
".",
"aggregate",
"(",
"dict",
"(",
"(",
"name",
",",
"aggregator",
")",
"for",
"name",
"in",
"df",
".",
"columns",
")",
")",
"else",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"serieses",
")",
"if",
"T_s",
"and",
"aggregator",
":",
"x0",
"=",
"df",
".",
"index",
"[",
"0",
"]",
"df",
"=",
"df",
".",
"groupby",
"(",
"lambda",
"x",
":",
"int",
"(",
"(",
"x",
"-",
"x0",
")",
".",
"total_seconds",
"(",
")",
"/",
"float",
"(",
"T_s",
")",
")",
")",
".",
"aggregate",
"(",
"dict",
"(",
"(",
"name",
",",
"aggregator",
")",
"for",
"name",
"in",
"df",
".",
"columns",
")",
")",
"# FIXME: convert seconds since begninning of first year back into Timestamp instances",
"return",
"df"
] |
Makes a multipart request . | def upload ( self , file_path , uri = None , timeout = - 1 ) : if not uri : uri = self . _uri upload_file_name = os . path . basename ( file_path ) task , entity = self . _connection . post_multipart_with_response_handling ( uri , file_path , upload_file_name ) if not task : return entity return self . _task_monitor . wait_for_task ( task , timeout ) | 251,548 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L1376-L1401 | [
"def",
"audit_customer_subscription",
"(",
"customer",
",",
"unknown",
"=",
"True",
")",
":",
"if",
"(",
"hasattr",
"(",
"customer",
",",
"'suspended'",
")",
"and",
"customer",
".",
"suspended",
")",
":",
"result",
"=",
"AUDIT_RESULTS",
"[",
"'suspended'",
"]",
"else",
":",
"if",
"hasattr",
"(",
"customer",
",",
"'subscription'",
")",
":",
"try",
":",
"result",
"=",
"AUDIT_RESULTS",
"[",
"customer",
".",
"subscription",
".",
"status",
"]",
"except",
"KeyError",
",",
"err",
":",
"# TODO should this be a more specific exception class?",
"raise",
"Exception",
"(",
"\"Unable to locate a result set for \\\nsubscription status %s in ZEBRA_AUDIT_RESULTS\"",
")",
"%",
"str",
"(",
"err",
")",
"else",
":",
"result",
"=",
"AUDIT_RESULTS",
"[",
"'no_subscription'",
"]",
"return",
"result"
] |
This function uses get_all passing a filter . | def get_by ( self , field , value , uri = None ) : if not field : logger . exception ( RESOURCE_CLIENT_INVALID_FIELD ) raise ValueError ( RESOURCE_CLIENT_INVALID_FIELD ) if not uri : uri = self . _uri self . __validate_resource_uri ( uri ) logger . debug ( 'Get by (uri = %s, field = %s, value = %s)' % ( uri , field , str ( value ) ) ) filter = "\"{0}='{1}'\"" . format ( field , value ) results = self . get_all ( filter = filter , uri = uri ) # Workaround when the OneView filter does not work, it will filter again if "." not in field : # This filter only work for the first level results = [ item for item in results if str ( item . get ( field , '' ) ) . lower ( ) == value . lower ( ) ] return results | 251,549 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L1457-L1490 | [
"def",
"create_api_call",
"(",
"func",
",",
"settings",
")",
":",
"def",
"base_caller",
"(",
"api_call",
",",
"_",
",",
"*",
"args",
")",
":",
"\"\"\"Simply call api_call and ignore settings.\"\"\"",
"return",
"api_call",
"(",
"*",
"args",
")",
"def",
"inner",
"(",
"request",
",",
"options",
"=",
"None",
")",
":",
"\"\"\"Invoke with the actual settings.\"\"\"",
"this_options",
"=",
"_merge_options_metadata",
"(",
"options",
",",
"settings",
")",
"this_settings",
"=",
"settings",
".",
"merge",
"(",
"this_options",
")",
"if",
"this_settings",
".",
"retry",
"and",
"this_settings",
".",
"retry",
".",
"retry_codes",
":",
"api_call",
"=",
"gax",
".",
"retry",
".",
"retryable",
"(",
"func",
",",
"this_settings",
".",
"retry",
",",
"*",
"*",
"this_settings",
".",
"kwargs",
")",
"else",
":",
"api_call",
"=",
"gax",
".",
"retry",
".",
"add_timeout_arg",
"(",
"func",
",",
"this_settings",
".",
"timeout",
",",
"*",
"*",
"this_settings",
".",
"kwargs",
")",
"api_call",
"=",
"_catch_errors",
"(",
"api_call",
",",
"gax",
".",
"config",
".",
"API_ERRORS",
")",
"return",
"api_caller",
"(",
"api_call",
",",
"this_settings",
",",
"request",
")",
"if",
"settings",
".",
"page_descriptor",
":",
"if",
"settings",
".",
"bundler",
"and",
"settings",
".",
"bundle_descriptor",
":",
"raise",
"ValueError",
"(",
"'The API call has incompatible settings: '",
"'bundling and page streaming'",
")",
"api_caller",
"=",
"_page_streamable",
"(",
"settings",
".",
"page_descriptor",
")",
"elif",
"settings",
".",
"bundler",
"and",
"settings",
".",
"bundle_descriptor",
":",
"api_caller",
"=",
"_bundleable",
"(",
"settings",
".",
"bundle_descriptor",
")",
"else",
":",
"api_caller",
"=",
"base_caller",
"return",
"inner"
] |
Gets the list of firmware baseline resources managed by the appliance . Optional parameters can be used to filter the list of resources returned . | def get_by ( self , field , value ) : firmwares = self . get_all ( ) matches = [ ] for item in firmwares : if item . get ( field ) == value : matches . append ( item ) return matches | 251,550 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/firmware_drivers.py#L73-L92 | [
"def",
"_sign",
"(",
"translator",
",",
"expr",
")",
":",
"op",
"=",
"expr",
".",
"op",
"(",
")",
"arg",
",",
"=",
"op",
".",
"args",
"arg_",
"=",
"translator",
".",
"translate",
"(",
"arg",
")",
"return",
"'intDivOrZero({0}, abs({0}))'",
".",
"format",
"(",
"arg_",
")"
] |
Gets the statistics from an interconnect . | def get_statistics ( self , id_or_uri , port_name = '' ) : uri = self . _client . build_uri ( id_or_uri ) + "/statistics" if port_name : uri = uri + "/" + port_name return self . _client . get ( uri ) | 251,551 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L75-L91 | [
"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",
"]"
] |
Gets the subport statistics on an interconnect . | def get_subport_statistics ( self , id_or_uri , port_name , subport_number ) : uri = self . _client . build_uri ( id_or_uri ) + "/statistics/{0}/subport/{1}" . format ( port_name , subport_number ) return self . _client . get ( uri ) | 251,552 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L93-L106 | [
"def",
"markdown",
"(",
"source",
":",
"str",
"=",
"None",
",",
"source_path",
":",
"str",
"=",
"None",
",",
"preserve_lines",
":",
"bool",
"=",
"False",
",",
"font_size",
":",
"float",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"environ",
".",
"abort_thread",
"(",
")",
"library_includes",
"=",
"[",
"]",
"rendered",
"=",
"textwrap",
".",
"dedent",
"(",
"templating",
".",
"render_file",
"(",
"source_path",
",",
"*",
"*",
"kwargs",
")",
"if",
"source_path",
"else",
"templating",
".",
"render",
"(",
"source",
"or",
"''",
",",
"*",
"*",
"kwargs",
")",
")",
"if",
"md",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"'Unable to import the markdown package'",
")",
"offset",
"=",
"0",
"while",
"offset",
"<",
"len",
"(",
"rendered",
")",
":",
"bound_chars",
"=",
"'$$'",
"start_index",
"=",
"rendered",
".",
"find",
"(",
"bound_chars",
",",
"offset",
")",
"if",
"start_index",
"<",
"0",
":",
"break",
"inline",
"=",
"rendered",
"[",
"start_index",
"+",
"2",
"]",
"!=",
"'$'",
"bound_chars",
"=",
"'$$'",
"if",
"inline",
"else",
"'$$$'",
"end_index",
"=",
"rendered",
".",
"find",
"(",
"bound_chars",
",",
"start_index",
"+",
"len",
"(",
"bound_chars",
")",
")",
"if",
"end_index",
"<",
"0",
":",
"break",
"end_index",
"+=",
"len",
"(",
"bound_chars",
")",
"chunk",
"=",
"rendered",
"[",
"start_index",
":",
"end_index",
"]",
".",
"strip",
"(",
"'$'",
")",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"'@'",
",",
"'\\\\'",
")",
"if",
"inline",
":",
"chunk",
"=",
"chunk",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
"chunk",
"=",
"latex",
"(",
"chunk",
",",
"inline",
")",
"rendered",
"=",
"'{pre}{gap}{latex}{gap}{post}'",
".",
"format",
"(",
"pre",
"=",
"rendered",
"[",
":",
"start_index",
"]",
",",
"latex",
"=",
"chunk",
",",
"post",
"=",
"rendered",
"[",
"end_index",
":",
"]",
",",
"gap",
"=",
"''",
"if",
"inline",
"else",
"'\\n\\n'",
")",
"if",
"'katex'",
"not",
"in",
"library_includes",
":",
"library_includes",
".",
"append",
"(",
"'katex'",
")",
"offset",
"=",
"end_index",
"extensions",
"=",
"[",
"'markdown.extensions.extra'",
",",
"'markdown.extensions.admonition'",
",",
"'markdown.extensions.sane_lists'",
",",
"'markdown.extensions.nl2br'",
"if",
"preserve_lines",
"else",
"None",
"]",
"body",
"=",
"templating",
".",
"render_template",
"(",
"'markdown-block.html'",
",",
"text",
"=",
"md",
".",
"markdown",
"(",
"rendered",
",",
"extensions",
"=",
"[",
"e",
"for",
"e",
"in",
"extensions",
"if",
"e",
"is",
"not",
"None",
"]",
")",
",",
"font_size",
"=",
"font_size",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'src=\"(?P<url>[^\"]+)\"'",
")",
"body",
"=",
"pattern",
".",
"sub",
"(",
"r'data-src=\"\\g<url>\"'",
",",
"body",
")",
"return",
"dict",
"(",
"body",
"=",
"body",
",",
"library_includes",
"=",
"library_includes",
",",
"rendered",
"=",
"rendered",
")"
] |
Gets the named servers for an interconnect . | def get_name_servers ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/nameServers" return self . _client . get ( uri ) | 251,553 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L108-L120 | [
"def",
"call_moses_detokenizer",
"(",
"workspace_dir",
":",
"str",
",",
"input_fname",
":",
"str",
",",
"output_fname",
":",
"str",
",",
"lang_code",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
":",
"detokenizer_fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"workspace_dir",
",",
"DIR_THIRD_PARTY",
",",
"MOSES_DEST",
",",
"\"scripts\"",
",",
"\"tokenizer\"",
",",
"\"detokenizer.perl\"",
")",
"with",
"bin_open",
"(",
"input_fname",
")",
"as",
"inp",
",",
"open",
"(",
"output_fname",
",",
"\"wb\"",
")",
"as",
"out",
",",
"open",
"(",
"os",
".",
"devnull",
",",
"\"wb\"",
")",
"as",
"devnull",
":",
"command",
"=",
"[",
"\"perl\"",
",",
"detokenizer_fname",
"]",
"if",
"lang_code",
":",
"command",
".",
"append",
"(",
"\"-l\"",
")",
"command",
".",
"append",
"(",
"lang_code",
")",
"detokenizer",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"stdin",
"=",
"subprocess",
".",
"PIPE",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"devnull",
")",
"detokenizer_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"copy_out",
",",
"args",
"=",
"(",
"detokenizer",
".",
"stdout",
",",
"out",
")",
")",
"detokenizer_thread",
".",
"start",
"(",
")",
"for",
"line",
"in",
"inp",
":",
"detokenizer",
".",
"stdin",
".",
"write",
"(",
"line",
")",
"detokenizer",
".",
"stdin",
".",
"close",
"(",
")",
"detokenizer_thread",
".",
"join",
"(",
")",
"detokenizer",
".",
"wait",
"(",
")"
] |
Updates an interconnect port . | def update_port ( self , port_information , id_or_uri , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) + "/ports" return self . _client . update ( port_information , uri , timeout ) | 251,554 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L186-L201 | [
"def",
"denormalize_volume",
"(",
"volume",
")",
":",
"id",
"=",
"volume",
".",
"get",
"(",
"'id'",
",",
"None",
")",
"res",
"=",
"dict",
"(",
")",
"res",
".",
"update",
"(",
"volume",
"[",
"'metadata'",
"]",
")",
"denorm_attachments",
"=",
"list",
"(",
")",
"for",
"a",
"in",
"volume",
"[",
"'attachments'",
"]",
":",
"denorm_attachments",
".",
"append",
"(",
"Archivant",
".",
"denormalize_attachment",
"(",
"a",
")",
")",
"res",
"[",
"'_attachments'",
"]",
"=",
"denorm_attachments",
"return",
"id",
",",
"res"
] |
Updates the interconnect ports . | def update_ports ( self , ports , id_or_uri , timeout = - 1 ) : resources = merge_default_values ( ports , { 'type' : 'port' } ) uri = self . _client . build_uri ( id_or_uri ) + "/update-ports" return self . _client . update ( resources , uri , timeout ) | 251,555 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L203-L220 | [
"def",
"markdown",
"(",
"source",
":",
"str",
"=",
"None",
",",
"source_path",
":",
"str",
"=",
"None",
",",
"preserve_lines",
":",
"bool",
"=",
"False",
",",
"font_size",
":",
"float",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"environ",
".",
"abort_thread",
"(",
")",
"library_includes",
"=",
"[",
"]",
"rendered",
"=",
"textwrap",
".",
"dedent",
"(",
"templating",
".",
"render_file",
"(",
"source_path",
",",
"*",
"*",
"kwargs",
")",
"if",
"source_path",
"else",
"templating",
".",
"render",
"(",
"source",
"or",
"''",
",",
"*",
"*",
"kwargs",
")",
")",
"if",
"md",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"'Unable to import the markdown package'",
")",
"offset",
"=",
"0",
"while",
"offset",
"<",
"len",
"(",
"rendered",
")",
":",
"bound_chars",
"=",
"'$$'",
"start_index",
"=",
"rendered",
".",
"find",
"(",
"bound_chars",
",",
"offset",
")",
"if",
"start_index",
"<",
"0",
":",
"break",
"inline",
"=",
"rendered",
"[",
"start_index",
"+",
"2",
"]",
"!=",
"'$'",
"bound_chars",
"=",
"'$$'",
"if",
"inline",
"else",
"'$$$'",
"end_index",
"=",
"rendered",
".",
"find",
"(",
"bound_chars",
",",
"start_index",
"+",
"len",
"(",
"bound_chars",
")",
")",
"if",
"end_index",
"<",
"0",
":",
"break",
"end_index",
"+=",
"len",
"(",
"bound_chars",
")",
"chunk",
"=",
"rendered",
"[",
"start_index",
":",
"end_index",
"]",
".",
"strip",
"(",
"'$'",
")",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"'@'",
",",
"'\\\\'",
")",
"if",
"inline",
":",
"chunk",
"=",
"chunk",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
"chunk",
"=",
"latex",
"(",
"chunk",
",",
"inline",
")",
"rendered",
"=",
"'{pre}{gap}{latex}{gap}{post}'",
".",
"format",
"(",
"pre",
"=",
"rendered",
"[",
":",
"start_index",
"]",
",",
"latex",
"=",
"chunk",
",",
"post",
"=",
"rendered",
"[",
"end_index",
":",
"]",
",",
"gap",
"=",
"''",
"if",
"inline",
"else",
"'\\n\\n'",
")",
"if",
"'katex'",
"not",
"in",
"library_includes",
":",
"library_includes",
".",
"append",
"(",
"'katex'",
")",
"offset",
"=",
"end_index",
"extensions",
"=",
"[",
"'markdown.extensions.extra'",
",",
"'markdown.extensions.admonition'",
",",
"'markdown.extensions.sane_lists'",
",",
"'markdown.extensions.nl2br'",
"if",
"preserve_lines",
"else",
"None",
"]",
"body",
"=",
"templating",
".",
"render_template",
"(",
"'markdown-block.html'",
",",
"text",
"=",
"md",
".",
"markdown",
"(",
"rendered",
",",
"extensions",
"=",
"[",
"e",
"for",
"e",
"in",
"extensions",
"if",
"e",
"is",
"not",
"None",
"]",
")",
",",
"font_size",
"=",
"font_size",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'src=\"(?P<url>[^\"]+)\"'",
")",
"body",
"=",
"pattern",
".",
"sub",
"(",
"r'data-src=\"\\g<url>\"'",
",",
"body",
")",
"return",
"dict",
"(",
"body",
"=",
"body",
",",
"library_includes",
"=",
"library_includes",
",",
"rendered",
"=",
"rendered",
")"
] |
Triggers a reset of port protection . | def reset_port_protection ( self , id_or_uri , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) + "/resetportprotection" return self . _client . update_with_zero_body ( uri , timeout ) | 251,556 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L222-L238 | [
"def",
"column",
"(",
"self",
",",
"column",
",",
"option",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"config",
"=",
"False",
"if",
"option",
"==",
"'type'",
":",
"return",
"self",
".",
"_column_types",
"[",
"column",
"]",
"elif",
"'type'",
"in",
"kw",
":",
"config",
"=",
"True",
"self",
".",
"_column_types",
"[",
"column",
"]",
"=",
"kw",
".",
"pop",
"(",
"'type'",
")",
"if",
"kw",
":",
"self",
".",
"_visual_drag",
".",
"column",
"(",
"ttk",
".",
"Treeview",
".",
"column",
"(",
"self",
",",
"column",
",",
"'id'",
")",
",",
"option",
",",
"*",
"*",
"kw",
")",
"if",
"kw",
"or",
"option",
":",
"return",
"ttk",
".",
"Treeview",
".",
"column",
"(",
"self",
",",
"column",
",",
"option",
",",
"*",
"*",
"kw",
")",
"elif",
"not",
"config",
":",
"res",
"=",
"ttk",
".",
"Treeview",
".",
"column",
"(",
"self",
",",
"column",
",",
"option",
",",
"*",
"*",
"kw",
")",
"res",
"[",
"'type'",
"]",
"=",
"self",
".",
"_column_types",
"[",
"column",
"]",
"return",
"res"
] |
Gets all interconnect ports . | def get_ports ( self , id_or_uri , start = 0 , count = - 1 ) : uri = self . _client . build_subresource_uri ( resource_id_or_uri = id_or_uri , subresource_path = "ports" ) return self . _client . get_all ( start , count , uri = uri ) | 251,557 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L240-L258 | [
"def",
"markdown",
"(",
"source",
":",
"str",
"=",
"None",
",",
"source_path",
":",
"str",
"=",
"None",
",",
"preserve_lines",
":",
"bool",
"=",
"False",
",",
"font_size",
":",
"float",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"dict",
":",
"environ",
".",
"abort_thread",
"(",
")",
"library_includes",
"=",
"[",
"]",
"rendered",
"=",
"textwrap",
".",
"dedent",
"(",
"templating",
".",
"render_file",
"(",
"source_path",
",",
"*",
"*",
"kwargs",
")",
"if",
"source_path",
"else",
"templating",
".",
"render",
"(",
"source",
"or",
"''",
",",
"*",
"*",
"kwargs",
")",
")",
"if",
"md",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"'Unable to import the markdown package'",
")",
"offset",
"=",
"0",
"while",
"offset",
"<",
"len",
"(",
"rendered",
")",
":",
"bound_chars",
"=",
"'$$'",
"start_index",
"=",
"rendered",
".",
"find",
"(",
"bound_chars",
",",
"offset",
")",
"if",
"start_index",
"<",
"0",
":",
"break",
"inline",
"=",
"rendered",
"[",
"start_index",
"+",
"2",
"]",
"!=",
"'$'",
"bound_chars",
"=",
"'$$'",
"if",
"inline",
"else",
"'$$$'",
"end_index",
"=",
"rendered",
".",
"find",
"(",
"bound_chars",
",",
"start_index",
"+",
"len",
"(",
"bound_chars",
")",
")",
"if",
"end_index",
"<",
"0",
":",
"break",
"end_index",
"+=",
"len",
"(",
"bound_chars",
")",
"chunk",
"=",
"rendered",
"[",
"start_index",
":",
"end_index",
"]",
".",
"strip",
"(",
"'$'",
")",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"'@'",
",",
"'\\\\'",
")",
"if",
"inline",
":",
"chunk",
"=",
"chunk",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
"chunk",
"=",
"latex",
"(",
"chunk",
",",
"inline",
")",
"rendered",
"=",
"'{pre}{gap}{latex}{gap}{post}'",
".",
"format",
"(",
"pre",
"=",
"rendered",
"[",
":",
"start_index",
"]",
",",
"latex",
"=",
"chunk",
",",
"post",
"=",
"rendered",
"[",
"end_index",
":",
"]",
",",
"gap",
"=",
"''",
"if",
"inline",
"else",
"'\\n\\n'",
")",
"if",
"'katex'",
"not",
"in",
"library_includes",
":",
"library_includes",
".",
"append",
"(",
"'katex'",
")",
"offset",
"=",
"end_index",
"extensions",
"=",
"[",
"'markdown.extensions.extra'",
",",
"'markdown.extensions.admonition'",
",",
"'markdown.extensions.sane_lists'",
",",
"'markdown.extensions.nl2br'",
"if",
"preserve_lines",
"else",
"None",
"]",
"body",
"=",
"templating",
".",
"render_template",
"(",
"'markdown-block.html'",
",",
"text",
"=",
"md",
".",
"markdown",
"(",
"rendered",
",",
"extensions",
"=",
"[",
"e",
"for",
"e",
"in",
"extensions",
"if",
"e",
"is",
"not",
"None",
"]",
")",
",",
"font_size",
"=",
"font_size",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'src=\"(?P<url>[^\"]+)\"'",
")",
"body",
"=",
"pattern",
".",
"sub",
"(",
"r'data-src=\"\\g<url>\"'",
",",
"body",
")",
"return",
"dict",
"(",
"body",
"=",
"body",
",",
"library_includes",
"=",
"library_includes",
",",
"rendered",
"=",
"rendered",
")"
] |
Gets an interconnect port . | def get_port ( self , id_or_uri , port_id_or_uri ) : uri = self . _client . build_subresource_uri ( id_or_uri , port_id_or_uri , "ports" ) return self . _client . get ( uri ) | 251,558 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L260-L272 | [
"def",
"denormalize_volume",
"(",
"volume",
")",
":",
"id",
"=",
"volume",
".",
"get",
"(",
"'id'",
",",
"None",
")",
"res",
"=",
"dict",
"(",
")",
"res",
".",
"update",
"(",
"volume",
"[",
"'metadata'",
"]",
")",
"denorm_attachments",
"=",
"list",
"(",
")",
"for",
"a",
"in",
"volume",
"[",
"'attachments'",
"]",
":",
"denorm_attachments",
".",
"append",
"(",
"Archivant",
".",
"denormalize_attachment",
"(",
"a",
")",
")",
"res",
"[",
"'_attachments'",
"]",
"=",
"denorm_attachments",
"return",
"id",
",",
"res"
] |
Gets all the pluggable module information . | def get_pluggable_module_information ( self , id_or_uri ) : uri = self . _client . build_uri ( id_or_uri ) + "/pluggableModuleInformation" return self . _client . get ( uri ) | 251,559 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L274-L285 | [
"def",
"arcball_constrain_to_axis",
"(",
"point",
",",
"axis",
")",
":",
"v",
"=",
"np",
".",
"array",
"(",
"point",
",",
"dtype",
"=",
"np",
".",
"float64",
",",
"copy",
"=",
"True",
")",
"a",
"=",
"np",
".",
"array",
"(",
"axis",
",",
"dtype",
"=",
"np",
".",
"float64",
",",
"copy",
"=",
"True",
")",
"v",
"-=",
"a",
"*",
"np",
".",
"dot",
"(",
"a",
",",
"v",
")",
"# on plane",
"n",
"=",
"vector_norm",
"(",
"v",
")",
"if",
"n",
">",
"_EPS",
":",
"if",
"v",
"[",
"2",
"]",
"<",
"0.0",
":",
"np",
".",
"negative",
"(",
"v",
",",
"v",
")",
"v",
"/=",
"n",
"return",
"v",
"if",
"a",
"[",
"2",
"]",
"==",
"1.0",
":",
"return",
"np",
".",
"array",
"(",
"[",
"1.0",
",",
"0.0",
",",
"0.0",
"]",
")",
"return",
"unit_vector",
"(",
"[",
"-",
"a",
"[",
"1",
"]",
",",
"a",
"[",
"0",
"]",
",",
"0.0",
"]",
")"
] |
Reapplies the appliance s configuration on the interconnect . This includes running the same configure steps that were performed as part of the interconnect add by the enclosure . | def update_configuration ( self , id_or_uri , timeout = - 1 ) : uri = self . _client . build_uri ( id_or_uri ) + "/configuration" return self . _client . update_with_zero_body ( uri , timeout = timeout ) | 251,560 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/interconnects.py#L287-L301 | [
"def",
"make_entity_name",
"(",
"name",
")",
":",
"invalid_chars",
"=",
"\"-=!#$%^&*[](){}/~'`<>:;\"",
"for",
"char",
"in",
"invalid_chars",
":",
"name",
"=",
"name",
".",
"replace",
"(",
"char",
",",
"\"_\"",
")",
"return",
"name"
] |
Updates a registered Device Manager . | def update ( self , resource , id_or_uri ) : return self . _client . update ( resource = resource , uri = id_or_uri ) | 251,561 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/san_managers.py#L87-L98 | [
"def",
"fetch_and_create_image",
"(",
"self",
",",
"url",
",",
"image_title",
")",
":",
"context",
"=",
"{",
"\"file_url\"",
":",
"url",
",",
"\"foreign_title\"",
":",
"image_title",
",",
"}",
"try",
":",
"image_file",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"local_image",
"=",
"Image",
"(",
"title",
"=",
"image_title",
",",
"file",
"=",
"ImageFile",
"(",
"BytesIO",
"(",
"image_file",
".",
"content",
")",
",",
"name",
"=",
"image_title",
")",
")",
"local_image",
".",
"save",
"(",
")",
"return",
"(",
"local_image",
",",
"context",
")",
"except",
"Exception",
"as",
"e",
":",
"context",
".",
"update",
"(",
"{",
"\"exception\"",
":",
"e",
",",
"}",
")",
"raise",
"ImageCreationFailed",
"(",
"context",
",",
"None",
")"
] |
Adds a Device Manager under the specified provider . | def add ( self , resource , provider_uri_or_id , timeout = - 1 ) : uri = self . _provider_client . build_uri ( provider_uri_or_id ) + "/device-managers" return self . _client . create ( resource = resource , uri = uri , timeout = timeout ) | 251,562 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/san_managers.py#L100-L115 | [
"def",
"parse_plotCorrelation",
"(",
"self",
")",
":",
"self",
".",
"deeptools_plotCorrelationData",
"=",
"dict",
"(",
")",
"for",
"f",
"in",
"self",
".",
"find_log_files",
"(",
"'deeptools/plotCorrelationData'",
",",
"filehandles",
"=",
"False",
")",
":",
"parsed_data",
",",
"samples",
"=",
"self",
".",
"parsePlotCorrelationData",
"(",
"f",
")",
"for",
"k",
",",
"v",
"in",
"parsed_data",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"self",
".",
"deeptools_plotCorrelationData",
":",
"log",
".",
"warning",
"(",
"\"Replacing duplicate sample {}.\"",
".",
"format",
"(",
"k",
")",
")",
"self",
".",
"deeptools_plotCorrelationData",
"[",
"k",
"]",
"=",
"v",
"if",
"len",
"(",
"parsed_data",
")",
">",
"0",
":",
"self",
".",
"add_data_source",
"(",
"f",
",",
"section",
"=",
"'plotCorrelation'",
")",
"if",
"len",
"(",
"self",
".",
"deeptools_plotCorrelationData",
")",
">",
"0",
":",
"config",
"=",
"{",
"'id'",
":",
"'deeptools_correlation_plot'",
",",
"'title'",
":",
"'deeptools: Correlation Plot'",
",",
"}",
"data",
"=",
"[",
"]",
"for",
"s_name",
"in",
"samples",
":",
"try",
":",
"data",
".",
"append",
"(",
"self",
".",
"deeptools_plotCorrelationData",
"[",
"s_name",
"]",
")",
"except",
"KeyError",
":",
"pass",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
"log",
".",
"debug",
"(",
"'No valid data for correlation plot'",
")",
"return",
"None",
"self",
".",
"add_section",
"(",
"name",
"=",
"\"Correlation heatmap\"",
",",
"anchor",
"=",
"\"deeptools_correlation\"",
",",
"description",
"=",
"\"Pairwise correlations of samples based on distribution of sequence reads\"",
",",
"plot",
"=",
"heatmap",
".",
"plot",
"(",
"data",
",",
"samples",
",",
"samples",
",",
"config",
")",
")",
"return",
"len",
"(",
"self",
".",
"deeptools_plotCorrelationData",
")"
] |
Gets uri for a specific provider . | def get_provider_uri ( self , provider_display_name ) : providers = self . _provider_client . get_by ( 'displayName' , provider_display_name ) return providers [ 0 ] [ 'uri' ] if providers else None | 251,563 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/san_managers.py#L117-L128 | [
"def",
"unpackmar",
"(",
"marfile",
",",
"destdir",
")",
":",
"marfile",
"=",
"cygpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"marfile",
")",
")",
"nullfd",
"=",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"try",
":",
"check_call",
"(",
"[",
"MAR",
",",
"'-x'",
",",
"marfile",
"]",
",",
"cwd",
"=",
"destdir",
",",
"stdout",
"=",
"nullfd",
",",
"preexec_fn",
"=",
"_noumask",
")",
"except",
"Exception",
":",
"log",
".",
"exception",
"(",
"\"Error unpacking mar file %s to %s\"",
",",
"marfile",
",",
"destdir",
")",
"raise",
"nullfd",
".",
"close",
"(",
")"
] |
Gets default connection info for a specific provider . | def get_default_connection_info ( self , provider_name ) : provider = self . _provider_client . get_by_name ( provider_name ) if provider : return provider [ 'defaultConnectionInfo' ] else : return { } | 251,564 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/san_managers.py#L130-L144 | [
"def",
"remove_unused_resources",
"(",
"issues",
",",
"app_dir",
",",
"ignore_layouts",
")",
":",
"for",
"issue",
"in",
"issues",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_dir",
",",
"issue",
".",
"filepath",
")",
"if",
"issue",
".",
"remove_file",
":",
"remove_resource_file",
"(",
"issue",
",",
"filepath",
",",
"ignore_layouts",
")",
"else",
":",
"remove_resource_value",
"(",
"issue",
",",
"filepath",
")"
] |
Gets a SAN Manager by name . | def get_by_name ( self , name ) : san_managers = self . _client . get_all ( ) result = [ x for x in san_managers if x [ 'name' ] == name ] return result [ 0 ] if result else None | 251,565 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/san_managers.py#L161-L173 | [
"def",
"_merge_meta_data",
"(",
"cls",
",",
"first",
":",
"\"HistogramBase\"",
",",
"second",
":",
"\"HistogramBase\"",
")",
"->",
"dict",
":",
"keys",
"=",
"set",
"(",
"first",
".",
"_meta_data",
".",
"keys",
"(",
")",
")",
"keys",
"=",
"keys",
".",
"union",
"(",
"set",
"(",
"second",
".",
"_meta_data",
".",
"keys",
"(",
")",
")",
")",
"return",
"{",
"key",
":",
"(",
"first",
".",
"_meta_data",
".",
"get",
"(",
"key",
",",
"None",
")",
"if",
"first",
".",
"_meta_data",
".",
"get",
"(",
"key",
",",
"None",
")",
"==",
"second",
".",
"_meta_data",
".",
"get",
"(",
"key",
",",
"None",
")",
"else",
"None",
")",
"for",
"key",
"in",
"keys",
"}"
] |
Gets a SAN Manager by provider display name . | def get_by_provider_display_name ( self , provider_display_name ) : san_managers = self . _client . get_all ( ) result = [ x for x in san_managers if x [ 'providerDisplayName' ] == provider_display_name ] return result [ 0 ] if result else None | 251,566 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/fc_sans/san_managers.py#L175-L187 | [
"def",
"cli",
"(",
"file1",
",",
"file2",
",",
"comments",
")",
"->",
"int",
":",
"sys",
".",
"exit",
"(",
"compare_files",
"(",
"file1",
",",
"file2",
",",
"comments",
")",
")"
] |
Updates the metrics configuration with the new values . Overwrites the existing configuration . | def update_configuration ( self , configuration ) : return self . _client . update ( configuration , uri = self . URI + "/configuration" ) | 251,567 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/data_services/metric_streaming.py#L99-L112 | [
"def",
"container_unfreeze",
"(",
"name",
",",
"remote_addr",
"=",
"None",
",",
"cert",
"=",
"None",
",",
"key",
"=",
"None",
",",
"verify_cert",
"=",
"True",
")",
":",
"container",
"=",
"container_get",
"(",
"name",
",",
"remote_addr",
",",
"cert",
",",
"key",
",",
"verify_cert",
",",
"_raw",
"=",
"True",
")",
"container",
".",
"unfreeze",
"(",
"wait",
"=",
"True",
")",
"return",
"_pylxd_model_to_dict",
"(",
"container",
")"
] |
Delete an SNMPv3 User based on User name specified in filter . The user will be deleted only if it has no associated destinations . | def delete_all ( self , filter = None , timeout = - 1 ) : return self . _client . delete_all ( filter = filter , timeout = timeout ) | 251,568 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/appliance_device_snmp_v3_users.py#L122-L134 | [
"def",
"lock",
"(",
"self",
",",
"seconds",
"=",
"5",
")",
":",
"self",
".",
"_current_application",
"(",
")",
".",
"lock",
"(",
"robot",
".",
"utils",
".",
"timestr_to_secs",
"(",
"seconds",
")",
")"
] |
Updates the switch ports . Only the ports under the management of OneView and those that are unlinked are supported for update . | def update_ports ( self , ports , id_or_uri ) : ports = merge_default_values ( ports , { 'type' : 'port' } ) uri = self . _client . build_uri ( id_or_uri ) + "/update-ports" return self . _client . update ( uri = uri , resource = ports ) | 251,569 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/networking/switches.py#L152-L170 | [
"def",
"_cached_results",
"(",
"self",
",",
"start_time",
",",
"end_time",
")",
":",
"cached_buckets",
"=",
"self",
".",
"_bucket_events",
"(",
"self",
".",
"_client",
".",
"get",
"(",
"self",
".",
"_scratch_stream",
",",
"start_time",
",",
"end_time",
",",
"namespace",
"=",
"self",
".",
"_scratch_namespace",
")",
")",
"for",
"bucket_events",
"in",
"cached_buckets",
":",
"# If we have multiple cache entries for the same bucket, pretend",
"# we have no results for that bucket.",
"if",
"len",
"(",
"bucket_events",
")",
"==",
"1",
":",
"first_result",
"=",
"bucket_events",
"[",
"0",
"]",
"yield",
"(",
"kronos_time_to_epoch_time",
"(",
"first_result",
"[",
"TIMESTAMP_FIELD",
"]",
")",
",",
"first_result",
"[",
"QueryCache",
".",
"CACHE_KEY",
"]",
")"
] |
Construct OneViewClient using a json file . | def from_json_file ( cls , file_name ) : with open ( file_name ) as json_data : config = json . load ( json_data ) return cls ( config ) | 251,570 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L209-L222 | [
"def",
"strand",
"(",
"s1",
",",
"s2",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"x",
",",
"y",
":",
"chr",
"(",
"ord",
"(",
"x",
")",
"&",
"ord",
"(",
"y",
")",
")",
",",
"s1",
",",
"s2",
")",
")"
] |
Construct OneViewClient using environment variables . | def from_environment_variables ( cls ) : ip = os . environ . get ( 'ONEVIEWSDK_IP' , '' ) image_streamer_ip = os . environ . get ( 'ONEVIEWSDK_IMAGE_STREAMER_IP' , '' ) api_version = int ( os . environ . get ( 'ONEVIEWSDK_API_VERSION' , OneViewClient . DEFAULT_API_VERSION ) ) ssl_certificate = os . environ . get ( 'ONEVIEWSDK_SSL_CERTIFICATE' , '' ) username = os . environ . get ( 'ONEVIEWSDK_USERNAME' , '' ) auth_login_domain = os . environ . get ( 'ONEVIEWSDK_AUTH_LOGIN_DOMAIN' , '' ) password = os . environ . get ( 'ONEVIEWSDK_PASSWORD' , '' ) proxy = os . environ . get ( 'ONEVIEWSDK_PROXY' , '' ) sessionID = os . environ . get ( 'ONEVIEWSDK_SESSIONID' , '' ) timeout = os . environ . get ( 'ONEVIEWSDK_CONNECTION_TIMEOUT' ) config = dict ( ip = ip , image_streamer_ip = image_streamer_ip , api_version = api_version , ssl_certificate = ssl_certificate , credentials = dict ( userName = username , authLoginDomain = auth_login_domain , password = password , sessionID = sessionID ) , proxy = proxy , timeout = timeout ) return cls ( config ) | 251,571 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L225-L254 | [
"def",
"render_field_error",
"(",
"self",
",",
"obj_id",
",",
"obj",
",",
"exception",
",",
"request",
")",
":",
"if",
"obj",
"is",
"None",
":",
"msg",
"=",
"'No match for ID={0}'",
".",
"format",
"(",
"obj_id",
")",
"else",
":",
"msg",
"=",
"unicode",
"(",
"exception",
")",
"return",
"u'<p class=\"error\">{0}</p>'",
".",
"format",
"(",
"msg",
")"
] |
Create the Image Streamer API Client . | def create_image_streamer_client ( self ) : image_streamer = ImageStreamerClient ( self . __image_streamer_ip , self . __connection . get_session_id ( ) , self . __connection . _apiVersion , self . __connection . _sslBundle ) return image_streamer | 251,572 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L292-L304 | [
"def",
"unmount",
"(",
"self",
")",
":",
"self",
".",
"unmount_bindmounts",
"(",
")",
"self",
".",
"unmount_mounts",
"(",
")",
"self",
".",
"unmount_volume_groups",
"(",
")",
"self",
".",
"unmount_loopbacks",
"(",
")",
"self",
".",
"unmount_base_images",
"(",
")",
"self",
".",
"clean_dirs",
"(",
")"
] |
Gets the Certificate Authority API client . | def certificate_authority ( self ) : if not self . __certificate_authority : self . __certificate_authority = CertificateAuthority ( self . __connection ) return self . __certificate_authority | 251,573 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L307-L316 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"BaseEntryChannel",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"context",
".",
"update",
"(",
"{",
"'query'",
":",
"self",
".",
"query",
"}",
")",
"return",
"context"
] |
Gets the Connections API client . | def connections ( self ) : if not self . __connections : self . __connections = Connections ( self . __connection ) return self . __connections | 251,574 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L319-L329 | [
"def",
"get_metadata",
"(",
"self",
",",
"digest",
",",
"content",
",",
"mime_type",
")",
":",
"# XXX: ad-hoc for now, refactor later",
"if",
"mime_type",
".",
"startswith",
"(",
"\"image/\"",
")",
":",
"img",
"=",
"Image",
".",
"open",
"(",
"BytesIO",
"(",
"content",
")",
")",
"ret",
"=",
"{",
"}",
"if",
"not",
"hasattr",
"(",
"img",
",",
"\"_getexif\"",
")",
":",
"return",
"{",
"}",
"info",
"=",
"img",
".",
"_getexif",
"(",
")",
"if",
"not",
"info",
":",
"return",
"{",
"}",
"for",
"tag",
",",
"value",
"in",
"info",
".",
"items",
"(",
")",
":",
"decoded",
"=",
"TAGS",
".",
"get",
"(",
"tag",
",",
"tag",
")",
"ret",
"[",
"\"EXIF:\"",
"+",
"str",
"(",
"decoded",
")",
"]",
"=",
"value",
"return",
"ret",
"else",
":",
"if",
"mime_type",
"!=",
"\"application/pdf\"",
":",
"content",
"=",
"self",
".",
"to_pdf",
"(",
"digest",
",",
"content",
",",
"mime_type",
")",
"with",
"make_temp_file",
"(",
"content",
")",
"as",
"in_fn",
":",
"try",
":",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pdfinfo\"",
",",
"in_fn",
"]",
")",
"except",
"OSError",
":",
"logger",
".",
"error",
"(",
"\"Conversion failed, probably pdfinfo is not installed\"",
")",
"raise",
"ret",
"=",
"{",
"}",
"for",
"line",
"in",
"output",
".",
"split",
"(",
"b\"\\n\"",
")",
":",
"if",
"b\":\"",
"in",
"line",
":",
"key",
",",
"value",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"b\":\"",
",",
"1",
")",
"key",
"=",
"str",
"(",
"key",
")",
"ret",
"[",
"\"PDF:\"",
"+",
"key",
"]",
"=",
"str",
"(",
"value",
".",
"strip",
"(",
")",
",",
"errors",
"=",
"\"replace\"",
")",
"return",
"ret"
] |
Gets the FcoeNetworks API client . | def fcoe_networks ( self ) : if not self . __fcoe_networks : self . __fcoe_networks = FcoeNetworks ( self . __connection ) return self . __fcoe_networks | 251,575 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L352-L361 | [
"def",
"to_td",
"(",
"frame",
",",
"name",
",",
"con",
",",
"if_exists",
"=",
"'fail'",
",",
"time_col",
"=",
"None",
",",
"time_index",
"=",
"None",
",",
"index",
"=",
"True",
",",
"index_label",
"=",
"None",
",",
"chunksize",
"=",
"10000",
",",
"date_format",
"=",
"None",
")",
":",
"database",
",",
"table",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"uploader",
"=",
"StreamingUploader",
"(",
"con",
".",
"client",
",",
"database",
",",
"table",
",",
"show_progress",
"=",
"True",
",",
"clear_progress",
"=",
"True",
")",
"uploader",
".",
"message",
"(",
"'Streaming import into: {0}.{1}'",
".",
"format",
"(",
"database",
",",
"table",
")",
")",
"# check existence",
"if",
"if_exists",
"==",
"'fail'",
":",
"try",
":",
"con",
".",
"client",
".",
"table",
"(",
"database",
",",
"table",
")",
"except",
"tdclient",
".",
"api",
".",
"NotFoundError",
":",
"uploader",
".",
"message",
"(",
"'creating new table...'",
")",
"con",
".",
"client",
".",
"create_log_table",
"(",
"database",
",",
"table",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"'table \"%s\" already exists'",
"%",
"name",
")",
"elif",
"if_exists",
"==",
"'replace'",
":",
"try",
":",
"con",
".",
"client",
".",
"table",
"(",
"database",
",",
"table",
")",
"except",
"tdclient",
".",
"api",
".",
"NotFoundError",
":",
"pass",
"else",
":",
"uploader",
".",
"message",
"(",
"'deleting old table...'",
")",
"con",
".",
"client",
".",
"delete_table",
"(",
"database",
",",
"table",
")",
"uploader",
".",
"message",
"(",
"'creating new table...'",
")",
"con",
".",
"client",
".",
"create_log_table",
"(",
"database",
",",
"table",
")",
"elif",
"if_exists",
"==",
"'append'",
":",
"try",
":",
"con",
".",
"client",
".",
"table",
"(",
"database",
",",
"table",
")",
"except",
"tdclient",
".",
"api",
".",
"NotFoundError",
":",
"uploader",
".",
"message",
"(",
"'creating new table...'",
")",
"con",
".",
"client",
".",
"create_log_table",
"(",
"database",
",",
"table",
")",
"else",
":",
"raise",
"ValueError",
"(",
"'invalid value for if_exists: %s'",
"%",
"if_exists",
")",
"# \"time_index\" implies \"index=False\"",
"if",
"time_index",
":",
"index",
"=",
"None",
"# convert",
"frame",
"=",
"frame",
".",
"copy",
"(",
")",
"frame",
"=",
"_convert_time_column",
"(",
"frame",
",",
"time_col",
",",
"time_index",
")",
"frame",
"=",
"_convert_index_column",
"(",
"frame",
",",
"index",
",",
"index_label",
")",
"frame",
"=",
"_convert_date_format",
"(",
"frame",
",",
"date_format",
")",
"# upload",
"uploader",
".",
"upload_frame",
"(",
"frame",
",",
"chunksize",
")",
"uploader",
".",
"wait_for_import",
"(",
"len",
"(",
"frame",
")",
")"
] |
Gets the Fabrics API client . | def fabrics ( self ) : if not self . __fabrics : self . __fabrics = Fabrics ( self . __connection ) return self . __fabrics | 251,576 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L374-L383 | [
"def",
"run",
"(",
"self",
")",
":",
"states",
"=",
"open",
"(",
"self",
".",
"states",
",",
"'r'",
")",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"for",
"state",
"in",
"states",
":",
"url",
"=",
"self",
".",
"build_url",
"(",
"state",
")",
"log",
"=",
"\"Downloading State < {0} > from < {1} >\"",
"logging",
".",
"info",
"(",
"log",
".",
"format",
"(",
"state",
",",
"url",
")",
")",
"tmp",
"=",
"self",
".",
"download",
"(",
"self",
".",
"output",
",",
"url",
",",
"self",
".",
"overwrite",
")",
"self",
".",
"s3",
".",
"store",
"(",
"self",
".",
"extract",
"(",
"tmp",
",",
"self",
".",
"tmp2poi",
"(",
"tmp",
")",
")",
")"
] |
Gets the Restores API client . | def restores ( self ) : if not self . __restores : self . __restores = Restores ( self . __connection ) return self . __restores | 251,577 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L386-L395 | [
"def",
"_custom_fields",
"(",
")",
":",
"# Import some commonly needed modules",
"import",
"os",
"from",
"pyrocore",
".",
"torrent",
"import",
"engine",
",",
"matching",
"from",
"pyrocore",
".",
"util",
"import",
"fmt",
"# PUT CUSTOM FIELD CODE HERE",
"# Disk space check (as an example)",
"# see https://pyrocore.readthedocs.io/en/latest/custom.html#has-room",
"def",
"has_room",
"(",
"obj",
")",
":",
"\"Check disk space.\"",
"pathname",
"=",
"obj",
".",
"path",
"if",
"pathname",
"and",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"pathname",
")",
":",
"pathname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"pathname",
")",
"if",
"pathname",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"pathname",
")",
":",
"stats",
"=",
"os",
".",
"statvfs",
"(",
"pathname",
")",
"return",
"(",
"stats",
".",
"f_bavail",
"*",
"stats",
".",
"f_frsize",
"-",
"int",
"(",
"diskspace_threshold_mb",
")",
"*",
"1024",
"**",
"2",
">",
"obj",
".",
"size",
"*",
"(",
"1.0",
"-",
"obj",
".",
"done",
"/",
"100.0",
")",
")",
"else",
":",
"return",
"None",
"yield",
"engine",
".",
"DynamicField",
"(",
"engine",
".",
"untyped",
",",
"\"has_room\"",
",",
"\"check whether the download will fit on its target device\"",
",",
"matcher",
"=",
"matching",
".",
"BoolFilter",
",",
"accessor",
"=",
"has_room",
",",
"formatter",
"=",
"lambda",
"val",
":",
"\"OK\"",
"if",
"val",
"else",
"\"??\"",
"if",
"val",
"is",
"None",
"else",
"\"NO\"",
")",
"globals",
"(",
")",
".",
"setdefault",
"(",
"\"diskspace_threshold_mb\"",
",",
"\"500\"",
")"
] |
Gets the Scopes API client . | def scopes ( self ) : if not self . __scopes : self . __scopes = Scopes ( self . __connection ) return self . __scopes | 251,578 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L398-L407 | [
"def",
"_read_vmx_file",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_vmx_pairs",
"=",
"self",
".",
"manager",
".",
"parse_vmware_file",
"(",
"self",
".",
"_vmx_path",
")",
"except",
"OSError",
"as",
"e",
":",
"raise",
"VMwareError",
"(",
"'Could not read VMware VMX file \"{}\": {}'",
".",
"format",
"(",
"self",
".",
"_vmx_path",
",",
"e",
")",
")"
] |
Gets the Datacenters API client . | def datacenters ( self ) : if not self . __datacenters : self . __datacenters = Datacenters ( self . __connection ) return self . __datacenters | 251,579 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L410-L419 | [
"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"
] |
Gets the NetworkSets API client . | def network_sets ( self ) : if not self . __network_sets : self . __network_sets = NetworkSets ( self . __connection ) return self . __network_sets | 251,580 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L422-L431 | [
"def",
"revoke_session",
"(",
"self",
",",
"sid",
"=",
"''",
",",
"token",
"=",
"''",
")",
":",
"if",
"not",
"sid",
":",
"if",
"token",
":",
"sid",
"=",
"self",
".",
"handler",
".",
"sid",
"(",
"token",
")",
"else",
":",
"raise",
"ValueError",
"(",
"'Need one of \"sid\" or \"token\"'",
")",
"for",
"typ",
"in",
"[",
"'access_token'",
",",
"'refresh_token'",
",",
"'code'",
"]",
":",
"try",
":",
"self",
".",
"revoke_token",
"(",
"self",
"[",
"sid",
"]",
"[",
"typ",
"]",
",",
"typ",
")",
"except",
"KeyError",
":",
"# If no such token has been issued",
"pass",
"self",
".",
"update",
"(",
"sid",
",",
"revoked",
"=",
"True",
")"
] |
Gets the ServerHardware API client . | def server_hardware ( self ) : if not self . __server_hardware : self . __server_hardware = ServerHardware ( self . __connection ) return self . __server_hardware | 251,581 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L434-L443 | [
"def",
"json",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"self",
".",
"_decompress",
"(",
"self",
".",
"encoding",
")",
"return",
"_json",
".",
"loads",
"(",
"body",
",",
"*",
"*",
"kwargs",
")"
] |
Gets the ServerHardwareTypes API client . | def server_hardware_types ( self ) : if not self . __server_hardware_types : self . __server_hardware_types = ServerHardwareTypes ( self . __connection ) return self . __server_hardware_types | 251,582 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L446-L456 | [
"def",
"json",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"self",
".",
"_decompress",
"(",
"self",
".",
"encoding",
")",
"return",
"_json",
".",
"loads",
"(",
"body",
",",
"*",
"*",
"kwargs",
")"
] |
Gets the IdPoolsRanges API Client for VSN Ranges . | def id_pools_vsn_ranges ( self ) : if not self . __id_pools_vsn_ranges : self . __id_pools_vsn_ranges = IdPoolsRanges ( 'vsn' , self . __connection ) return self . __id_pools_vsn_ranges | 251,583 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L459-L468 | [
"def",
"parse_message",
"(",
"message",
",",
"nodata",
"=",
"False",
")",
":",
"header",
"=",
"read_machine_header",
"(",
"message",
")",
"h_len",
"=",
"__get_machine_header_length",
"(",
"header",
")",
"meta_raw",
"=",
"message",
"[",
"h_len",
":",
"h_len",
"+",
"header",
"[",
"'meta_len'",
"]",
"]",
"meta",
"=",
"__parse_meta",
"(",
"meta_raw",
",",
"header",
")",
"data_start",
"=",
"h_len",
"+",
"header",
"[",
"'meta_len'",
"]",
"data",
"=",
"b''",
"if",
"not",
"nodata",
":",
"data",
"=",
"__decompress",
"(",
"meta",
",",
"message",
"[",
"data_start",
":",
"data_start",
"+",
"header",
"[",
"'data_len'",
"]",
"]",
")",
"return",
"header",
",",
"meta",
",",
"data"
] |
Gets the IdPoolsRanges API Client for VMAC Ranges . | def id_pools_vmac_ranges ( self ) : if not self . __id_pools_vmac_ranges : self . __id_pools_vmac_ranges = IdPoolsRanges ( 'vmac' , self . __connection ) return self . __id_pools_vmac_ranges | 251,584 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L471-L480 | [
"def",
"send",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"collection",
".",
"insert",
"(",
"event",
",",
"manipulate",
"=",
"False",
")",
"except",
"(",
"PyMongoError",
",",
"BSONError",
")",
":",
"# The event will be lost in case of a connection error or any error",
"# that occurs when trying to insert the event into Mongo.",
"# pymongo will re-connect/re-authenticate automatically",
"# during the next event.",
"msg",
"=",
"'Error inserting to MongoDB event tracker backend'",
"log",
".",
"exception",
"(",
"msg",
")"
] |
Gets the IdPoolsRanges API Client for VWWN Ranges . | def id_pools_vwwn_ranges ( self ) : if not self . __id_pools_vwwn_ranges : self . __id_pools_vwwn_ranges = IdPoolsRanges ( 'vwwn' , self . __connection ) return self . __id_pools_vwwn_ranges | 251,585 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L483-L492 | [
"def",
"send",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"collection",
".",
"insert",
"(",
"event",
",",
"manipulate",
"=",
"False",
")",
"except",
"(",
"PyMongoError",
",",
"BSONError",
")",
":",
"# The event will be lost in case of a connection error or any error",
"# that occurs when trying to insert the event into Mongo.",
"# pymongo will re-connect/re-authenticate automatically",
"# during the next event.",
"msg",
"=",
"'Error inserting to MongoDB event tracker backend'",
"log",
".",
"exception",
"(",
"msg",
")"
] |
Gets the IdPoolsIpv4Ranges API client . | def id_pools_ipv4_ranges ( self ) : if not self . __id_pools_ipv4_ranges : self . __id_pools_ipv4_ranges = IdPoolsIpv4Ranges ( self . __connection ) return self . __id_pools_ipv4_ranges | 251,586 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L495-L504 | [
"def",
"_recurmatch",
"(",
"path",
",",
"aug",
")",
":",
"if",
"path",
":",
"clean_path",
"=",
"path",
".",
"rstrip",
"(",
"'/*'",
")",
"yield",
"(",
"clean_path",
",",
"aug",
".",
"get",
"(",
"path",
")",
")",
"for",
"i",
"in",
"aug",
".",
"match",
"(",
"clean_path",
"+",
"'/*'",
")",
":",
"i",
"=",
"i",
".",
"replace",
"(",
"'!'",
",",
"'\\\\!'",
")",
"# escape some dirs",
"for",
"_match",
"in",
"_recurmatch",
"(",
"i",
",",
"aug",
")",
":",
"yield",
"_match"
] |
Gets the IdPoolsIpv4Subnets API client . | def id_pools_ipv4_subnets ( self ) : if not self . __id_pools_ipv4_subnets : self . __id_pools_ipv4_subnets = IdPoolsIpv4Subnets ( self . __connection ) return self . __id_pools_ipv4_subnets | 251,587 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L507-L516 | [
"def",
"transform",
"(",
"self",
",",
"y",
",",
"sr",
")",
":",
"if",
"sr",
"!=",
"self",
".",
"sr",
":",
"y",
"=",
"resample",
"(",
"y",
",",
"sr",
",",
"self",
".",
"sr",
")",
"return",
"self",
".",
"merge",
"(",
"[",
"self",
".",
"transform_audio",
"(",
"y",
")",
"]",
")"
] |
Gets the IdPools API client . | def id_pools ( self ) : if not self . __id_pools : self . __id_pools = IdPools ( self . __connection ) return self . __id_pools | 251,588 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L519-L528 | [
"def",
"segment",
"(",
"f",
",",
"output",
",",
"target_duration",
",",
"mpegts",
")",
":",
"try",
":",
"target_duration",
"=",
"int",
"(",
"target_duration",
")",
"except",
"ValueError",
":",
"exit",
"(",
"'Error: Invalid target duration.'",
")",
"try",
":",
"mpegts",
"=",
"int",
"(",
"mpegts",
")",
"except",
"ValueError",
":",
"exit",
"(",
"'Error: Invalid MPEGTS value.'",
")",
"WebVTTSegmenter",
"(",
")",
".",
"segment",
"(",
"f",
",",
"output",
",",
"target_duration",
",",
"mpegts",
")"
] |
Gets the Switches API client . | def switches ( self ) : if not self . __switches : self . __switches = Switches ( self . __connection ) return self . __switches | 251,589 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L531-L540 | [
"def",
"getCell",
"(",
"self",
",",
"row",
",",
"width",
"=",
"None",
")",
":",
"cellval",
"=",
"wrapply",
"(",
"self",
".",
"getValue",
",",
"row",
")",
"typedval",
"=",
"wrapply",
"(",
"self",
".",
"type",
",",
"cellval",
")",
"if",
"isinstance",
"(",
"typedval",
",",
"TypedWrapper",
")",
":",
"if",
"isinstance",
"(",
"cellval",
",",
"TypedExceptionWrapper",
")",
":",
"# calc failed",
"exc",
"=",
"cellval",
".",
"exception",
"if",
"cellval",
".",
"forwarded",
":",
"dispval",
"=",
"str",
"(",
"cellval",
")",
"# traceback.format_exception_only(type(exc), exc)[-1].strip()",
"else",
":",
"dispval",
"=",
"options",
".",
"disp_error_val",
"return",
"DisplayWrapper",
"(",
"cellval",
".",
"val",
",",
"error",
"=",
"exc",
".",
"stacktrace",
",",
"display",
"=",
"dispval",
",",
"note",
"=",
"options",
".",
"note_getter_exc",
",",
"notecolor",
"=",
"'color_error'",
")",
"elif",
"typedval",
".",
"val",
"is",
"None",
":",
"# early out for strict None",
"return",
"DisplayWrapper",
"(",
"None",
",",
"display",
"=",
"''",
",",
"# force empty display for None",
"note",
"=",
"options",
".",
"disp_note_none",
",",
"notecolor",
"=",
"'color_note_type'",
")",
"elif",
"isinstance",
"(",
"typedval",
",",
"TypedExceptionWrapper",
")",
":",
"# calc succeeded, type failed",
"return",
"DisplayWrapper",
"(",
"typedval",
".",
"val",
",",
"display",
"=",
"str",
"(",
"cellval",
")",
",",
"error",
"=",
"typedval",
".",
"exception",
".",
"stacktrace",
",",
"note",
"=",
"options",
".",
"note_type_exc",
",",
"notecolor",
"=",
"'color_warning'",
")",
"else",
":",
"return",
"DisplayWrapper",
"(",
"typedval",
".",
"val",
",",
"display",
"=",
"str",
"(",
"typedval",
".",
"val",
")",
",",
"note",
"=",
"options",
".",
"note_type_exc",
",",
"notecolor",
"=",
"'color_warning'",
")",
"elif",
"isinstance",
"(",
"typedval",
",",
"threading",
".",
"Thread",
")",
":",
"return",
"DisplayWrapper",
"(",
"None",
",",
"display",
"=",
"options",
".",
"disp_pending",
",",
"note",
"=",
"options",
".",
"note_pending",
",",
"notecolor",
"=",
"'color_note_pending'",
")",
"dw",
"=",
"DisplayWrapper",
"(",
"cellval",
")",
"try",
":",
"dw",
".",
"display",
"=",
"self",
".",
"format",
"(",
"typedval",
")",
"or",
"''",
"if",
"width",
"and",
"isNumeric",
"(",
"self",
")",
":",
"dw",
".",
"display",
"=",
"dw",
".",
"display",
".",
"rjust",
"(",
"width",
"-",
"1",
")",
"# annotate cells with raw value type in anytype columns, except for strings",
"if",
"self",
".",
"type",
"is",
"anytype",
"and",
"type",
"(",
"cellval",
")",
"is",
"not",
"str",
":",
"typedesc",
"=",
"typemap",
".",
"get",
"(",
"type",
"(",
"cellval",
")",
",",
"None",
")",
"dw",
".",
"note",
"=",
"typedesc",
".",
"icon",
"if",
"typedesc",
"else",
"options",
".",
"note_unknown_type",
"dw",
".",
"notecolor",
"=",
"'color_note_type'",
"except",
"Exception",
"as",
"e",
":",
"# formatting failure",
"e",
".",
"stacktrace",
"=",
"stacktrace",
"(",
")",
"dw",
".",
"error",
"=",
"e",
"try",
":",
"dw",
".",
"display",
"=",
"str",
"(",
"cellval",
")",
"except",
"Exception",
"as",
"e",
":",
"dw",
".",
"display",
"=",
"str",
"(",
"e",
")",
"dw",
".",
"note",
"=",
"options",
".",
"note_format_exc",
"dw",
".",
"notecolor",
"=",
"'color_warning'",
"return",
"dw"
] |
Gets the Roles API client . | def roles ( self ) : if not self . __roles : self . __roles = Roles ( self . __connection ) return self . __roles | 251,590 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L543-L552 | [
"def",
"add_match",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"args",
".",
"extend",
"(",
"_make_line",
"(",
"key",
",",
"val",
")",
"for",
"key",
",",
"val",
"in",
"kwargs",
".",
"items",
"(",
")",
")",
"for",
"arg",
"in",
"args",
":",
"super",
"(",
"Reader",
",",
"self",
")",
".",
"add_match",
"(",
"arg",
")"
] |
Gets the SwitchTypes API client . | def switch_types ( self ) : if not self . __switch_types : self . __switch_types = SwitchTypes ( self . __connection ) return self . __switch_types | 251,591 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L555-L564 | [
"def",
"grep_log",
"(",
"self",
",",
"expr",
",",
"filename",
"=",
"'system.log'",
",",
"from_mark",
"=",
"None",
")",
":",
"matchings",
"=",
"[",
"]",
"pattern",
"=",
"re",
".",
"compile",
"(",
"expr",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"get_path",
"(",
")",
",",
"'logs'",
",",
"filename",
")",
")",
"as",
"f",
":",
"if",
"from_mark",
":",
"f",
".",
"seek",
"(",
"from_mark",
")",
"for",
"line",
"in",
"f",
":",
"m",
"=",
"pattern",
".",
"search",
"(",
"line",
")",
"if",
"m",
":",
"matchings",
".",
"append",
"(",
"(",
"line",
",",
"m",
")",
")",
"return",
"matchings"
] |
Gets the LogicalSwitches API client . | def logical_switches ( self ) : if not self . __logical_switches : self . __logical_switches = LogicalSwitches ( self . __connection ) return self . __logical_switches | 251,592 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L577-L586 | [
"def",
"inject_extra_args",
"(",
"callback",
",",
"request",
",",
"kwargs",
")",
":",
"# TODO: this is a temporary pach, should be managed via honouring the",
"# mimetype in the request header....",
"annots",
"=",
"dict",
"(",
"callback",
".",
"__annotations__",
")",
"del",
"annots",
"[",
"'return'",
"]",
"for",
"param_name",
",",
"(",
"param_type",
",",
"_",
")",
"in",
"annots",
".",
"items",
"(",
")",
":",
"if",
"param_type",
"==",
"Ptypes",
".",
"path",
":",
"continue",
"# Already parsed by werkzeug",
"elif",
"param_type",
"==",
"Ptypes",
".",
"body",
":",
"value",
"=",
"getattr",
"(",
"request",
",",
"PTYPE_TO_REQUEST_PROPERTY",
"[",
"param_type",
"]",
")",
"# TODO: The JSON conversion should be dependant from request",
"# header type, really...",
"value",
"=",
"json",
".",
"loads",
"(",
"value",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"else",
":",
"get",
"=",
"lambda",
"attr",
":",
"getattr",
"(",
"request",
",",
"attr",
")",
".",
"get",
"(",
"param_name",
",",
"None",
")",
"value",
"=",
"get",
"(",
"PTYPE_TO_REQUEST_PROPERTY",
"[",
"param_type",
"]",
")",
"if",
"value",
"is",
"not",
"None",
":",
"kwargs",
"[",
"param_name",
"]",
"=",
"value"
] |
Gets the Tasks API client . | def tasks ( self ) : if not self . __tasks : self . __tasks = Tasks ( self . __connection ) return self . __tasks | 251,593 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L589-L598 | [
"def",
"_clearQuantity",
"(",
"self",
",",
"offbids",
",",
"gen",
")",
":",
"# Filter out offers/bids not applicable to the generator in question.",
"gOffbids",
"=",
"[",
"offer",
"for",
"offer",
"in",
"offbids",
"if",
"offer",
".",
"generator",
"==",
"gen",
"]",
"# Offers/bids within valid price limits (not withheld).",
"valid",
"=",
"[",
"ob",
"for",
"ob",
"in",
"gOffbids",
"if",
"not",
"ob",
".",
"withheld",
"]",
"# Sort offers by price in ascending order and bids in decending order.",
"valid",
".",
"sort",
"(",
"key",
"=",
"lambda",
"ob",
":",
"ob",
".",
"price",
",",
"reverse",
"=",
"[",
"False",
",",
"True",
"]",
"[",
"gen",
".",
"is_load",
"]",
")",
"acceptedQty",
"=",
"0.0",
"for",
"ob",
"in",
"valid",
":",
"# Compute the fraction of the block accepted.",
"accepted",
"=",
"(",
"ob",
".",
"totalQuantity",
"-",
"acceptedQty",
")",
"/",
"ob",
".",
"quantity",
"# Clip to the range 0-1.",
"if",
"accepted",
">",
"1.0",
":",
"accepted",
"=",
"1.0",
"elif",
"accepted",
"<",
"1.0e-05",
":",
"accepted",
"=",
"0.0",
"ob",
".",
"clearedQuantity",
"=",
"accepted",
"*",
"ob",
".",
"quantity",
"ob",
".",
"accepted",
"=",
"(",
"accepted",
">",
"0.0",
")",
"# Log the event.",
"# if ob.accepted:",
"# logger.info(\"%s [%s, %.3f, %.3f] accepted at %.2f MW.\" %",
"# (ob.__class__.__name__, ob.generator.name, ob.quantity,",
"# ob.price, ob.clearedQuantity))",
"# else:",
"# logger.info(\"%s [%s, %.3f, %.3f] rejected.\" %",
"# (ob.__class__.__name__, ob.generator.name, ob.quantity,",
"# ob.price))",
"# Increment the accepted quantity.",
"acceptedQty",
"+=",
"ob",
".",
"quantity"
] |
Gets the EnclosureGroups API client . | def enclosure_groups ( self ) : if not self . __enclosure_groups : self . __enclosure_groups = EnclosureGroups ( self . __connection ) return self . __enclosure_groups | 251,594 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L601-L610 | [
"def",
"grant_revoke",
"(",
"grant",
",",
"database",
",",
"user",
",",
"host",
"=",
"'localhost'",
",",
"grant_option",
"=",
"False",
",",
"escape",
"=",
"True",
",",
"*",
"*",
"connection_args",
")",
":",
"dbc",
"=",
"_connect",
"(",
"*",
"*",
"connection_args",
")",
"if",
"dbc",
"is",
"None",
":",
"return",
"False",
"cur",
"=",
"dbc",
".",
"cursor",
"(",
")",
"grant",
"=",
"__grant_normalize",
"(",
"grant",
")",
"if",
"salt",
".",
"utils",
".",
"data",
".",
"is_true",
"(",
"grant_option",
")",
":",
"grant",
"+=",
"', GRANT OPTION'",
"db_part",
"=",
"database",
".",
"rpartition",
"(",
"'.'",
")",
"dbc",
"=",
"db_part",
"[",
"0",
"]",
"table",
"=",
"db_part",
"[",
"2",
"]",
"if",
"dbc",
"!=",
"'*'",
":",
"# _ and % are authorized on GRANT queries and should get escaped",
"# on the db name, but only if not requesting a table level grant",
"s_database",
"=",
"quote_identifier",
"(",
"dbc",
",",
"for_grants",
"=",
"(",
"table",
"==",
"'*'",
")",
")",
"if",
"dbc",
"==",
"'*'",
":",
"# add revoke for *.*",
"# before the modification query send to mysql will looks like",
"# REVOKE SELECT ON `*`.* FROM %(user)s@%(host)s",
"s_database",
"=",
"dbc",
"if",
"table",
"!=",
"'*'",
":",
"table",
"=",
"quote_identifier",
"(",
"table",
")",
"# identifiers cannot be used as values, same thing for grants",
"qry",
"=",
"'REVOKE {0} ON {1}.{2} FROM %(user)s@%(host)s;'",
".",
"format",
"(",
"grant",
",",
"s_database",
",",
"table",
")",
"args",
"=",
"{",
"}",
"args",
"[",
"'user'",
"]",
"=",
"user",
"args",
"[",
"'host'",
"]",
"=",
"host",
"try",
":",
"_execute",
"(",
"cur",
",",
"qry",
",",
"args",
")",
"except",
"MySQLdb",
".",
"OperationalError",
"as",
"exc",
":",
"err",
"=",
"'MySQL Error {0}: {1}'",
".",
"format",
"(",
"*",
"exc",
".",
"args",
")",
"__context__",
"[",
"'mysql.error'",
"]",
"=",
"err",
"log",
".",
"error",
"(",
"err",
")",
"return",
"False",
"if",
"not",
"grant_exists",
"(",
"grant",
",",
"database",
",",
"user",
",",
"host",
",",
"grant_option",
",",
"escape",
",",
"*",
"*",
"connection_args",
")",
":",
"log",
".",
"info",
"(",
"'Grant \\'%s\\' on \\'%s\\' for user \\'%s\\' has been '",
"'revoked'",
",",
"grant",
",",
"database",
",",
"user",
")",
"return",
"True",
"log",
".",
"info",
"(",
"'Grant \\'%s\\' on \\'%s\\' for user \\'%s\\' has NOT been '",
"'revoked'",
",",
"grant",
",",
"database",
",",
"user",
")",
"return",
"False"
] |
Gets the LogicalEnclosures API client . | def logical_enclosures ( self ) : if not self . __logical_enclosures : self . __logical_enclosures = LogicalEnclosures ( self . __connection ) return self . __logical_enclosures | 251,595 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L623-L632 | [
"def",
"retract",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"msg",
":",
"return",
"\"Syntax: !vote retract <pollnum>\"",
"if",
"not",
"args",
".",
"msg",
".",
"isdigit",
"(",
")",
":",
"return",
"\"Not A Valid Positive Integer.\"",
"response",
"=",
"get_response",
"(",
"args",
".",
"session",
",",
"args",
".",
"msg",
",",
"args",
".",
"nick",
")",
"if",
"response",
"is",
"None",
":",
"return",
"\"You haven't voted on that poll yet!\"",
"args",
".",
"session",
".",
"delete",
"(",
"response",
")",
"return",
"\"Vote retracted\""
] |
Gets the MetricStreaming API client . | def metric_streaming ( self ) : if not self . __metric_streaming : self . __metric_streaming = MetricStreaming ( self . __connection ) return self . __metric_streaming | 251,596 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L635-L644 | [
"def",
"diff_args",
"(",
"subparsers",
")",
":",
"diff_parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"'diff'",
")",
"secretfile_args",
"(",
"diff_parser",
")",
"vars_args",
"(",
"diff_parser",
")",
"base_args",
"(",
"diff_parser",
")",
"thaw_from_args",
"(",
"diff_parser",
")"
] |
Gets the Interconnects API client . | def interconnects ( self ) : if not self . __interconnects : self . __interconnects = Interconnects ( self . __connection ) return self . __interconnects | 251,597 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L647-L656 | [
"def",
"removeApplicationManifest",
"(",
"self",
",",
"pchApplicationManifestFullPath",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"removeApplicationManifest",
"result",
"=",
"fn",
"(",
"pchApplicationManifestFullPath",
")",
"return",
"result"
] |
Gets the InterconnectLinkTopologies API client . | def interconnect_link_topologies ( self ) : if not self . __interconnect_link_topologies : self . __interconnect_link_topologies = InterconnectLinkTopologies ( self . __connection ) return self . __interconnect_link_topologies | 251,598 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L669-L678 | [
"def",
"extract_string_pairs_in_directory",
"(",
"directory_path",
",",
"extract_func",
",",
"filter_func",
")",
":",
"result",
"=",
"{",
"}",
"for",
"root",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"directory_path",
")",
":",
"for",
"file_name",
"in",
"filenames",
":",
"if",
"filter_func",
"(",
"file_name",
")",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"file_name",
")",
"try",
":",
"extract_func",
"(",
"result",
",",
"file_path",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"\"Error in file \"",
"+",
"file_name",
"print",
"e",
"return",
"result"
] |
Gets the SasInterconnectTypes API client . | def sas_interconnect_types ( self ) : if not self . __sas_interconnect_types : self . __sas_interconnect_types = SasInterconnectTypes ( self . __connection ) return self . __sas_interconnect_types | 251,599 | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L681-L690 | [
"def",
"replace_emoticons",
"(",
"content",
",",
"excluded_markups",
")",
":",
"if",
"not",
"excluded_markups",
":",
"return",
"regexp_replace_emoticons",
"(",
"content",
")",
"excluded_markups",
"=",
"excluded_markups",
".",
"split",
"(",
"','",
")",
"+",
"[",
"'[document]'",
"]",
"soup",
"=",
"BeautifulSoup",
"(",
"content",
",",
"'html.parser'",
")",
"for",
"content_string",
"in",
"list",
"(",
"soup",
".",
"strings",
")",
":",
"if",
"content_string",
".",
"parent",
".",
"name",
"not",
"in",
"excluded_markups",
":",
"replaced_content_string",
"=",
"regexp_replace_emoticons",
"(",
"content_string",
")",
"if",
"content_string",
"!=",
"replaced_content_string",
":",
"content_string",
".",
"replace_with",
"(",
"BeautifulSoup",
"(",
"replaced_content_string",
",",
"'html.parser'",
")",
")",
"return",
"str",
"(",
"soup",
")"
] |