INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
For a json response check if there was any error and throw exception. Otherwise create a housecanary. response. Response.
def process_json_response(self, response): """For a json response, check if there was any error and throw exception. Otherwise, create a housecanary.response.Response.""" response_json = response.json() # handle errors code_key = "code" if code_key in response_json and ...
Start watcher thread.
def start_watcher_thread(self): """ Start watcher thread. :return: Watcher thread object. """ # Create watcher thread watcher_thread = threading.Thread(target=self.run_watcher) # If the reload mode is `spawn_wait` if self._reload_mode == self...
Watcher thread s function.
def run_watcher(self): """ Watcher thread's function. :return: None. """ # Create observer observer = Observer() # Start observer observer.start() # Dict that maps file path to `watch object` watche_obj_map = {} # Ru...
Find paths to watch.
def _find_watch_paths(self): """ Find paths to watch. :return: Paths to watch. """ # Add directory paths in `sys.path` to watch paths watch_path_s = set(os.path.abspath(x) for x in sys.path) # For each extra path for extra_path in self._extra...
Find short paths of given paths.
def _find_short_paths(self, paths): """ Find short paths of given paths. E.g. if both `/home` and `/home/aoik` exist, only keep `/home`. :param paths: Paths. :return: Set of short paths. """ # Split each path to parts. # E.g. '/h...
Collect paths of leaf nodes.
def _collect_leaf_paths(self, node, path_parts, leaf_paths): """ Collect paths of leaf nodes. :param node: Starting node. Type is dict. Key is child node's path part. Value is child node. :param path_parts: The starting node's path parts. Type is tu...
Dispatch file system event.
def dispatch(self, event): """ Dispatch file system event. Callback called when there is a file system event. Hooked at 2KGRW. This function overrides `FileSystemEventHandler.dispatch`. :param event: File system event object. :return: None. ...
Reload the program.
def reload(self): """ Reload the program. :return: None. """ # Get reload mode reload_mode = self._reload_mode # If reload mode is `exec` if self._reload_mode == self.RELOAD_MODE_V_EXEC: # Call `reload_using_exec` self...
Reload the program process.
def reload_using_exec(self): """ Reload the program process. :return: None. """ # Create command parts cmd_parts = [sys.executable] + sys.argv # Get env dict copy env_copy = os.environ.copy() # Reload the program process os.e...
Spawn a subprocess and exit the current process.
def reload_using_spawn_exit(self): """ Spawn a subprocess and exit the current process. :return: None. """ # Create command parts cmd_parts = [sys.executable] + sys.argv # Get env dict copy env_copy = os.environ.copy() # Spawn subpro...
Spawn a subprocess and wait until it finishes.
def reload_using_spawn_wait(self): """ Spawn a subprocess and wait until it finishes. :return: None. """ # Create command parts cmd_parts = [sys.executable] + sys.argv # Get env dict copy env_copy = os.environ.copy() # Send interrupt...
Show the information about the given agent.
def agent(agent_id): ''' Show the information about the given agent. ''' fields = [ ('ID', 'id'), ('Status', 'status'), ('Region', 'region'), ('First Contact', 'first_contact'), ('CPU Usage (%)', 'cpu_cur_pct'), ('Used Memory (MiB)', 'mem_cur_bytes'), ...
List and manage agents. ( admin privilege required )
def agents(status, all): ''' List and manage agents. (admin privilege required) ''' fields = [ ('ID', 'id'), ('Status', 'status'), ('Region', 'region'), ('First Contact', 'first_contact'), ('CPU Usage (%)', 'cpu_cur_pct'), ('Used Memory (MiB)', 'mem_cu...
Show details about a keypair resource policy. When name option is omitted the resource policy for the current access_key will be returned.
def resource_policy(name): """ Show details about a keypair resource policy. When `name` option is omitted, the resource policy for the current access_key will be returned. """ fields = [ ('Name', 'name'), ('Created At', 'created_at'), ('Default for Unspecified', 'default_for...
List and manage resource policies. ( admin privilege required )
def resource_policies(ctx): ''' List and manage resource policies. (admin privilege required) ''' if ctx.invoked_subcommand is not None: return fields = [ ('Name', 'name'), ('Created At', 'created_at'), ('Default for Unspecified', 'default_for_unspecified'), ...
Add a new keypair resource policy.
def add(name, default_for_unspecified, total_resource_slots, max_concurrent_sessions, max_containers_per_session, max_vfolder_count, max_vfolder_size, idle_timeout, allowed_vfolder_hosts): ''' Add a new keypair resource policy. NAME: NAME of a new keypair resource policy. ''' with S...
Delete a keypair resource policy.
def delete(name): """ Delete a keypair resource policy. NAME: NAME of a keypair resource policy to delete. """ with Session() as session: if input('Are you sure? (y/n): ').lower().strip()[:1] != 'y': print('Canceled.') sys.exit(1) try: data = sess...
Run a local proxy to a service provided by Backend. AI compute sessions.
def app(session_id, app, bind, port): """ Run a local proxy to a service provided by Backend.AI compute sessions. The type of proxy depends on the app definition: plain TCP or HTTP. \b SESSID: The compute session ID. APP: The name of service provided by the given session. """ api_sessi...
Retrieves a configuration value from the environment variables. The given * key * is uppercased and prefixed by BACKEND_ and then SORNA_ if the former does not exist.
def get_env(key: str, default: Any = None, clean: Callable[[str], Any] = lambda v: v): ''' Retrieves a configuration value from the environment variables. The given *key* is uppercased and prefixed by ``"BACKEND_"`` and then ``"SORNA_"`` if the former does not exist. :param ...
Shows the output logs of a running container.
def logs(sess_id_or_alias): ''' Shows the output logs of a running container. \b SESSID: Session ID or its alias given when creating the session. ''' with Session() as session: try: print_wait('Retrieving container logs...') kernel = session.Kernel(sess_id_or_ali...
get the key from the function input.
def _wrap_key(function, args, kws): ''' get the key from the function input. ''' return hashlib.md5(pickle.dumps((_from_file(function) + function.__name__, args, kws))).hexdigest()
get the cache value
def get(key, adapter = MemoryAdapter): ''' get the cache value ''' try: return pickle.loads(adapter().get(key)) except CacheExpiredException: return None
set cache by code must set timeout length
def set(key, value, timeout = -1, adapter = MemoryAdapter): ''' set cache by code, must set timeout length ''' if adapter(timeout = timeout).set(key, pickle.dumps(value)): return value else: return None
the Decorator to cache Function.
def wrapcache(timeout = -1, adapter = MemoryAdapter): ''' the Decorator to cache Function. ''' def _wrapcache(function): @wraps(function) def __wrapcache(*args, **kws): hash_key = _wrap_key(function, args, kws) try: adapter_instance = adapter() return pickle.loads(adapter_instance.get(hash_key)) ...
Creates an Excel file containing data returned by the Analytics API
def export_analytics_data_to_excel(data, output_file_name, result_info_key, identifier_keys): """Creates an Excel file containing data returned by the Analytics API Args: data: Analytics API data as a list of dicts output_file_name: File name for output Excel file (use .xlsx extension). ""...
Creates CSV files containing data returned by the Analytics API. Creates one file per requested endpoint and saves it into the specified output_folder
def export_analytics_data_to_csv(data, output_folder, result_info_key, identifier_keys): """Creates CSV files containing data returned by the Analytics API. Creates one file per requested endpoint and saves it into the specified output_folder Args: data: Analytics API data as a list of di...
Creates an Excel file made up of combining the Value Report or Rental Report Excel output for the provided addresses.
def concat_excel_reports(addresses, output_file_name, endpoint, report_type, retry, api_key, api_secret, files_path): """Creates an Excel file made up of combining the Value Report or Rental Report Excel output for the provided addresses. Args: addresses: A list of (addr...
Calls the analytics_data_excel module to create the Workbook
def create_excel_workbook(data, result_info_key, identifier_keys): """Calls the analytics_data_excel module to create the Workbook""" workbook = analytics_data_excel.get_excel_workbook(data, result_info_key, identifier_keys) adjust_column_width_workbook(workbook) return workbook
Adjust column width in worksheet.
def adjust_column_width(worksheet): """Adjust column width in worksheet. Args: worksheet: worksheet to be adjusted """ dims = {} padding = 1 for row in worksheet.rows: for cell in row: if not cell.value: continue dims[cell.column] = max( ...
function takes input of ipaddress to RESTFUL call to HP IMC
def get_ap_info(ipaddress, auth, url): """ function takes input of ipaddress to RESTFUL call to HP IMC :param ipaddress: The current IP address of the Access Point at time of query. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS ...
List and manage compute sessions.
def sessions(status, access_key, id_only, all): ''' List and manage compute sessions. ''' fields = [ ('Session ID', 'sess_id'), ] with Session() as session: if is_admin(session): fields.append(('Owner', 'access_key')) if not id_only: fields.extend([ ...
Show detailed information for a running compute session.
def session(sess_id_or_alias): ''' Show detailed information for a running compute session. SESSID: Session id or its alias. ''' fields = [ ('Session ID', 'sess_id'), ('Role', 'role'), ('Image', 'image'), ('Tag', 'tag'), ('Created At', 'created_at'), ...
Factory for creating the correct type of Response based on the data. Args: endpoint_name ( str ) - The endpoint of the request such as property/ value json_body - The response body in json format. original_response ( response object ) - server response returned from an http request.
def create(cls, endpoint_name, json_body, original_response): """Factory for creating the correct type of Response based on the data. Args: endpoint_name (str) - The endpoint of the request, such as "property/value" json_body - The response body in json format. origin...
Gets a list of business error message strings for each of the requested objects that had a business error. If there was no error returns an empty list
def get_object_errors(self): """Gets a list of business error message strings for each of the requested objects that had a business error. If there was no error, returns an empty list Returns: List of strings """ if self._object_errors is None: se...
Returns true if any requested object had a business logic error otherwise returns false
def has_object_error(self): """Returns true if any requested object had a business logic error, otherwise returns false Returns: boolean """ if self._has_object_error is None: # scan the objects for any business error codes self._has_object_er...
Returns a list of rate limit details.
def rate_limits(self): """Returns a list of rate limit details.""" if not self._rate_limits: self._rate_limits = utilities.get_rate_limits(self.response) return self._rate_limits
Function takes input of auth class object auth object and URL and returns a BOOL of TRUE if the authentication was successful.
def check_imc_creds(auth, url): """Function takes input of auth class object auth object and URL and returns a BOOL of TRUE if the authentication was successful. >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> check_imc_creds(auth.creds, auth.url) True """ tes...
Function takes in object of type str list or dict and prints out to current working directory as pyoutput. txt: param: Object: object of type str list or dict: return: No return. Just prints out to file handler and save to current working directory as pyoutput. txt
def print_to_file(object_name): """ Function takes in object of type str, list, or dict and prints out to current working directory as pyoutput.txt :param: Object: object of type str, list, or dict :return: No return. Just prints out to file handler and save to current working directory as pyou...
This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object: return:
def get_auth(self): """ This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object :return: """ url = self.h_url + self.server + ":" + self.port auth = requests.auth.HTTPDigestAuth(self.username, self.password) ...
Print title like ----- { title } ----- or ===== { title } =====.
def print_title(title, is_end=False): """ Print title like ``----- {title} -----`` or ``===== {title} =====``. :param title: Title. :param is_end: Whether is end title. End title use ``=`` instead of ``-``. :return: None. """ # If is end title if is_end: # Use `=` sep ...
Get full Python version.
def get_full_python_version(): """ Get full Python version. E.g. - `2.7.11.final.0.32bit` - `3.5.1.final.0.64bit` :return: Full Python version. """ # Get version part, e.g. `3.5.1.final.0` version_part = '.'.join(str(x) for x in sys.version_info) # Get integer width, e...
Get given virtual environment s python program path.
def get_python_path(venv_path): """ Get given virtual environment's `python` program path. :param venv_path: Virtual environment directory path. :return: `python` program path. """ # Get `bin` directory path bin_path = get_bin_path(venv_path) # Get `python` program path program_pa...
Add command line options.
def add_options(ctx): """ Add command line options. :return: None. """ # Add option ctx.add_option( '--always', action='store_true', default=False, dest='always', help='whether always run tasks.', ) # Add option ctx.add_option( '--che...
Prepend given path to environment variable PYTHONPATH.
def add_pythonpath(path): """ Prepend given path to environment variable PYTHONPATH. :param path: Path to add to PYTHONPATH. :return: New PYTHONPATH value. """ # Get PYTHONPATH value. Default is empty string. pythonpath = os.environ.setdefault('PYTHONPATH', '') # If given path is not ...
Wrap given path as relative path relative to top directory.
def mark_path(path): """ Wrap given path as relative path relative to top directory. Wrapper object will be handled specially in \ :paramref:`create_cmd_task.parts`. :param path: Relative path relative to top directory. :return: Wrapper object. """ # If given path is not string, #...
Wrap given item as input or output target that should be added to task.
def _mark_target(type, item): """ Wrap given item as input or output target that should be added to task. Wrapper object will be handled specially in \ :paramref:`create_cmd_task.parts`. :param type: Target type. Allowed values: - 'input' - 'output' :param ite...
Create node for given relative path.
def create_node(ctx, path): """ Create node for given relative path. :param ctx: BuildContext object. :param path: Relative path relative to top directory. :return: Created Node. """ # Ensure given context object is BuildContext object _ensure_build_context(ctx) # Get top directo...
Normalize given items.
def _normalize_items( ctx, items, str_to_node=False, node_to_str=False, allow_task=False, ): """ Normalize given items. Do several things: - Ignore None. - Flatten list. - Unwrap wrapped item in `_ItemWrapper`. :param ctx: BuildContext object. :param it...
Update touch file at given path.
def update_touch_file( ctx, path, check_import=False, check_import_module=None, check_import_python=None, always=False, ): """ Update touch file at given path. Do two things: - Create touch file if it not exists. - Update touch file if import checking fails. The...
Chain given tasks. Set each task to run after its previous task.
def chain_tasks(tasks): """ Chain given tasks. Set each task to run after its previous task. :param tasks: Tasks list. :return: Given tasks list. """ # If given tasks list is not empty if tasks: # Previous task previous_task = None # For given tasks list's each tas...
Create task that runs given command.
def create_cmd_task( ctx, parts, inputs=None, outputs=None, env=None, cwd=None, task_name=None, cache_key=None, always=False, add_to_group=True, ): """ Create task that runs given command. :param ctx: BuildContext object. :param parts: Command parts list. ...
Decorator that makes decorated function use BuildContext instead of \ Context instance. BuildContext instance has more methods.
def build_ctx(pythonpath=None): """ Decorator that makes decorated function use BuildContext instead of \ Context instance. BuildContext instance has more methods. :param pythonpath: Path or list of paths to add to environment variable PYTHONPATH. Each path can be absolute path, or relative pat...
Decorator that makes decorated function use ConfigurationContext instead \ of Context instance.
def config_ctx(func): """ Decorator that makes decorated function use ConfigurationContext instead \ of Context instance. :param func: Decorated function. :return: Decorated function. """ # Create ConfigurationContext subclass class _ConfigurationContext(ConfigurationContext): ...
Print given context s info.
def print_ctx(ctx): """ Print given context's info. :param ctx: Context object. :return: None. """ # Print title print_title('ctx attributes') # Print context object's attributes print_text(dir(ctx)) # Print end title print_title('ctx attributes', is_end=True) # Prin...
Create task that sets up virtualenv package.
def virtualenv_setup( ctx, python, inputs=None, outputs=None, touch=None, check_import=False, pip_setup_file=None, pip_setup_touch=None, cache_key=None, always=False, ): """ Create task that sets up `virtualenv` package. :param ctx: BuildContext object. :param p...
Create task that sets up virtual environment.
def create_venv( ctx, python, venv_path, inputs=None, outputs=None, pip_setup_file=None, pip_setup_touch=None, virtualenv_setup_touch=None, task_name=None, cache_key=None, always=False, ): """ Create task that sets up virtual environment. :param ctx: BuildContext...
Create task that uses given virtual environment s pip to sets up \ packages listed in given requirements file.
def pip_ins_req( ctx, python, req_path, venv_path=None, inputs=None, outputs=None, touch=None, check_import=False, check_import_module=None, pip_setup_file=None, pip_setup_touch=None, virtualenv_setup_touch=None, always=False, ): """ Create task that uses give...
Delete all files untracked by git.
def git_clean(ctx): """ Delete all files untracked by git. :param ctx: Context object. :return: None. """ # Get command parts cmd_part_s = [ # Program path 'git', # Clean untracked files 'clean', # Remove all untracked files '-x', ...
Run command.
def run(self): """ Run command. :return: Command exit code. """ # Print task title print_title(self._task_name_title) # Get context object ctx = self._ctx # Get command parts cmd_part_s = self._parts # Print title print_...
function takes no input as input to RESTFUL call to HP IMC
def get_ac_info_all(auth, url): """ function takes no input as input to RESTFUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :return: list of dictionaries ...
Function operates on the IMCDev object. Takes input of vlanid ( 1 - 4094 ) str of vlan_name auth and url to execute the create_dev_vlan method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module.: param vlanid: str of VLANId ( valid 1 - 4094 ): param vlan_name: str of vlan_name: r...
def addvlan(self, vlanid, vlan_name): """ Function operates on the IMCDev object. Takes input of vlanid (1-4094), str of vlan_name, auth and url to execute the create_dev_vlan method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module. :para...
Function operates on the IMCDev object. Takes input of vlanid ( 1 - 4094 ) auth and url to execute the delete_dev_vlans method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module.: param vlanid: str of VLANId ( valid 1 - 4094 ): return:
def delvlan(self, vlanid): """ Function operates on the IMCDev object. Takes input of vlanid (1-4094), auth and url to execute the delete_dev_vlans method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module. :param vlanid: str of VLANId ( va...
Function operates on the IMCDev object and updates the ipmacarp attribute: return:
def getipmacarp(self): """ Function operates on the IMCDev object and updates the ipmacarp attribute :return: """ self.ipmacarp = get_ip_mac_arp_list(self.auth, self.url, devid = self.devid)
Function operates on the IMCInterface object and configures the interface into an administratively down state and refreshes contents of self. adminstatus: return:
def down(self): """ Function operates on the IMCInterface object and configures the interface into an administratively down state and refreshes contents of self.adminstatus :return: """ set_interface_down(self.ifIndex, self.auth, self.url, devip=self.ip) self.admi...
Function operates on the IMCInterface object and configures the interface into an administratively up state and refreshes contents of self. adminstatus: return:
def up(self): """ Function operates on the IMCInterface object and configures the interface into an administratively up state and refreshes contents of self.adminstatus :return: """ set_interface_up(self.ifIndex, self.auth, self.url, devip=...
Object method takes in input of hostipaddress name and description and adds them to the parent ip scope.: param hostipaddress: str of ipv4 address of the target host ip record: param name: str of the name of the owner of the target host ip record: param description: str of a description of the target host ip record: re...
def allocate_ip(self, hostipaddress, name, description): """ Object method takes in input of hostipaddress, name and description and adds them to the parent ip scope. :param hostipaddress: str of ipv4 address of the target host ip record :param name: str of the name of the owner ...
Object method takes in input of hostip address removes them from the parent ip scope.: param hostid: str of the hostid of the target host ip record
def deallocate_ip(self, hostipaddress): """ Object method takes in input of hostip address,removes them from the parent ip scope. :param hostid: str of the hostid of the target host ip record :return: """ delete_host_from_segment(hostipaddress, self.netaddr, self.auth, ...
Method gets all hosts currently allocated to the target scope and refreashes the self. hosts attributes of the object: return:
def gethosts(self): """ Method gets all hosts currently allocated to the target scope and refreashes the self.hosts attributes of the object :return: """ self.hosts = get_ip_scope_hosts(self.auth, self.url, self.id)
Method searches for the next free ip address in the scope object and returns it as a str value.: return:
def nextfreeip(self): """ Method searches for the next free ip address in the scope object and returns it as a str value. :return: """ allocated_ips = [ipaddress.ip_address(host['ip']) for host in self.hosts] for ip in self.netaddr: if str(ip).split('....
Method takes inpur of str startip str endip name and description and adds a child scope. The startip and endip MUST be in the IP address range of the parent scope.: param startip: str of ipv4 address of the first address in the child scope: param endip: str of ipv4 address of the last address in the child scope: param ...
def addchild(self, startip, endip, name, description): """ Method takes inpur of str startip, str endip, name, and description and adds a child scope. The startip and endip MUST be in the IP address range of the parent scope. :param startip: str of ipv4 address of the first address in th...
Takes no input or template_name as input to issue RESTUL call to HP IMC
def get_telnet_template(auth, url, template_name=None): """ Takes no input, or template_name as input to issue RESTUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authcla...
Function takes input of a dictionry containing the required key/ value pair for the modification of a telnet template.
def modify_telnet_template(auth, url, telnet_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a telnet template. :param auth: :param url: :param telnet_template: Human readable label which ...
Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific telnet template from the IMC system
def delete_telnet_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific telnet template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :par...
Function takes input of a dictionry containing the required key/ value pair for the creation of a ssh template.
def create_ssh_template(auth, url, ssh_template ): """ Function takes input of a dictionry containing the required key/value pair for the creation of a ssh template. :param auth: :param url: :param ssh: dictionary of valid JSON which complains to API schema :return: int value of HTTP respon...
Takes no input or template_name as input to issue RESTUL call to HP IMC
def get_ssh_template(auth, url, template_name=None): """ Takes no input, or template_name as input to issue RESTUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass ...
Function takes input of a dictionry containing the required key/ value pair for the modification of a ssh template.
def modify_ssh_template(auth, url, ssh_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a ssh template. :param auth: :param url: :param ssh_template: Human readable label which is the name ...
Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific ssh template from the IMC system
def delete_ssh_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific ssh template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url...
Takes no input or template_name as input to issue RESTUL call to HP IMC
def get_snmp_templates(auth, url, template_name=None): """ Takes no input, or template_name as input to issue RESTUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclas...
Function takes input of a dictionry containing the required key/ value pair for the modification of a snmp template.
def modify_snmp_template(auth, url, snmp_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a snmp template. :param auth: :param url: :param ssh_template: Human readable label which is the na...
Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific snmp template from the IMC system
def delete_snmp_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific snmp template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param u...
Takes in ipaddress as input to fetch device assett details from HP IMC RESTFUL API
def get_dev_asset_details(ipaddress, auth, url): """Takes in ipaddress as input to fetch device assett details from HP IMC RESTFUL API :param ipaddress: IP address of the device you wish to gather the asset details :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :p...
Takes no input to fetch device assett details from HP IMC RESTFUL API
def get_dev_asset_details_all(auth, url): """Takes no input to fetch device assett details from HP IMC RESTFUL API :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :return: list ...
Run a non - encrypted non - authorized API proxy server. Use this only for development and testing!
def proxy(ctx, bind, port): """ Run a non-encrypted non-authorized API proxy server. Use this only for development and testing! """ app = web.Application() app.on_startup.append(startup_proxy) app.on_cleanup.append(cleanup_proxy) app.router.add_route("GET", r'/stream/{path:.*$}', websoc...
Takes string input of IP address to issue RESTUL call to HP IMC \ n
def get_all_devs(auth, url, network_address=None, category=None, label=None): """Takes string input of IP address to issue RESTUL call to HP IMC\n :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.aut...
Takes string input of IP address to issue RESTUL call to HP IMC
def get_dev_details(ip_address, auth, url): """Takes string input of IP address to issue RESTUL call to HP IMC :param ip_address: string object of dotted decimal notation of IPv4 address :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS...
Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces
def get_dev_interface(auth, url, devid=None, devip=None): """ Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces :param devid: optional devid as the input :param devip: str of ipv4 address of the target device :param auth: requests auth obje...
function takes devid of specific device and issues a RESTFUL call to gather the current IP - MAC learning entries on the target device.
def get_dev_mac_learn(auth, url, devid=None, devip=None): """ function takes devid of specific device and issues a RESTFUL call to gather the current IP-MAC learning entries on the target device. :param devid: int value of the target device :param devip: ipv4 address of the target device :pa...
Function takes devid of target device and a sequential list of strings which define the specific commands to be run on the target device and returns a str object containing the output of the commands.
def run_dev_cmd(cmd_list, auth, url, devid=None, devip=None): """ Function takes devid of target device and a sequential list of strings which define the specific commands to be run on the target device and returns a str object containing the output of the commands. :param devid: int devid of the t...
function takes the devId of a specific device and the ifindex value assigned to a specific interface and issues a RESTFUL call to get the interface details file as known by the HP IMC Base Platform ICC module for the target device.
def get_all_interface_details(auth, url, devid=None, devip=None): """ function takes the devId of a specific device and the ifindex value assigned to a specific interface and issues a RESTFUL call to get the interface details file as known by the HP IMC Base Platform ICC module for the target device. ...
function takest devid and ifindex of specific device and interface and issues a RESTFUL call to shut the specified interface on the target device.: param devid: int or str value of the target device
def set_interface_down(ifindex, auth, url, devid=None, devip=None): """ function takest devid and ifindex of specific device and interface and issues a RESTFUL call to " shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 addres...
function takest devid and ifindex of specific device and interface and issues a RESTFUL call to undo shut the specified interface on the target device.
def set_inteface_up(ifindex, auth, url, devid=None, devip=None): """ function takest devid and ifindex of specific device and interface and issues a RESTFUL call to "undo shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 addr...
Helper function to easily create the proper json formated string from a list of strs: param cmd_list: list of strings: return: str json formatted
def _make_cmd_list(cmd_list): """ Helper function to easily create the proper json formated string from a list of strs :param cmd_list: list of strings :return: str json formatted """ cmd = '' for i in cmd_list: cmd = cmd + '"' + i + '",' cmd = cmd[:-1] return cmd
Creates a new keypair with the given options. You need an admin privilege for this operation.
async def create(cls, user_id: Union[int, str], is_active: bool = True, is_admin: bool = False, resource_policy: str = None, rate_limit: int = None, fields: Iterable[str] = None) -> dict: ''' Creates...
Creates a new keypair with the given options. You need an admin privilege for this operation.
async def update(cls, access_key: str, is_active: bool = None, is_admin: bool = None, resource_policy: str = None, rate_limit: int = None) -> dict: """ Creates a new keypair with the given options. You need an ad...
Deletes an existing keypair with given ACCESSKEY.
async def delete(cls, access_key: str): """ Deletes an existing keypair with given ACCESSKEY. """ q = 'mutation($access_key: String!) {' \ ' delete_keypair(access_key: $access_key) {' \ ' ok msg' \ ' }' \ '}' variables = { ...
Lists the keypairs. You need an admin privilege for this operation.
async def list(cls, user_id: Union[int, str] = None, is_active: bool = None, fields: Iterable[str] = None) -> Sequence[dict]: ''' Lists the keypairs. You need an admin privilege for this operation. ''' if fields is None: fields = ...
Returns the keypair s information such as resource limits.
async def info(self, fields: Iterable[str] = None) -> dict: ''' Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12 ''' if fields is None: fields = ( 'a...
Activates this keypair. You need an admin privilege for this operation.
async def activate(cls, access_key: str) -> dict: ''' Activates this keypair. You need an admin privilege for this operation. ''' q = 'mutation($access_key: String!, $input: ModifyKeyPairInput!) {' + \ ' modify_keypair(access_key: $access_key, props: $input) {' \ ...
Deactivates this keypair. Deactivated keypairs cannot make any API requests unless activated again by an administrator. You need an admin privilege for this operation.
async def deactivate(cls, access_key: str) -> dict: ''' Deactivates this keypair. Deactivated keypairs cannot make any API requests unless activated again by an administrator. You need an admin privilege for this operation. ''' q = 'mutation($access_key: String!, ...
Function takes input of four strings Start Ip endIp name and description to add new Ip Scope to terminal access in the HPE IMC base platform: param startIp: str Start of IP address scope ex. 10. 101. 0. 1: param endIp: str End of IP address scope ex. 10. 101. 0. 254: param name: str Name of the owner of this IP scope e...
def add_ip_scope(auth, url,startIp, endIp, name, description): """ Function takes input of four strings Start Ip, endIp, name, and description to add new Ip Scope to terminal access in the HPE IMC base platform :param startIp: str Start of IP address scope ex. '10.101.0.1' :param endIp: str End of I...