text
stringlengths
81
112k
Main function. :return: None. def main(): """ Main function. :return: None. """ try: # Get the `src` directory's absolute path src_path = os.path.dirname( # `aoiklivereload` directory's absolute path os.path.dirname( # `d...
Generates an Excel workbook object given api_data returned by the Analytics API Args: api_data: Analytics API data as a list of dicts (one per identifier) result_info_key: the key in api_data dicts that contains the data results identifier_keys: the list of keys used as requested identifier...
Writes rest of the worksheets to workbook. Args: workbook: workbook to write into data_list: Analytics API data as a list of dicts result_info_key: the key in api_data dicts that contains the data results identifier_keys: the list of keys used as requested identifiers ...
Creates two worksheets out of the property/nod data because the data doesn't come flat enough to make sense on one sheet. Args: workbook: the main workbook to add the sheets to data_list: the main list of data result_info_key: the key in api_data dicts that contains th...
Gets sorted keys from the dict, ignoring result_info_key and 'meta' key Args: data_dict: dict to pull keys from Returns: list of keys in the dict other than the result_info_key def get_worksheet_keys(data_dict, result_info_key): """Gets sorted keys from the dict, ignoring result_info_key a...
Gets all possible keys from a list of dicts, sorting by leading_columns first Args: data_list: list of dicts to pull keys from leading_columns: list of keys to put first in the result Returns: list of keys to be included as columns in excel worksheet def get_keys(data_list, leading_co...
Writes data into worksheet. Args: worksheet: worksheet to write into data: data to be written def write_data(worksheet, data): """Writes data into worksheet. Args: worksheet: worksheet to write into data: data to be written """ if not data: return if i...
Given a key as the endpoint name, pulls the data for that endpoint out of the data_list for each address, processes the data into a more excel-friendly format and returns that data. Args: key: the endpoint name of the data to process data_list: the main data list to take...
Helper method to flatten a nested dict of dicts (one level) Example: {'a': {'b': 'bbb'}} becomes {'a_-_b': 'bbb'} The separator '_-_' gets formatted later for the column headers Args: data: the dict to flatten top_level_keys: a list of the top level key...
A Django check to see if connecting to the configured default database backend succeeds. def check_database_connected(app_configs, **kwargs): """ A Django check to see if connecting to the configured default database backend succeeds. """ errors = [] try: connection.ensure_connecti...
A Django check to see if all migrations have been applied correctly. def check_migrations_applied(app_configs, **kwargs): """ A Django check to see if all migrations have been applied correctly. """ from django.db.migrations.loader import MigrationLoader errors = [] # Load migrations from disk...
A Django check to connect to the default redis connection using ``django_redis.get_redis_connection`` and see if Redis responds to a ``PING`` command. def check_redis_connected(app_configs, **kwargs): """ A Django check to connect to the default redis connection using ``django_redis.get_redis_conne...
Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API :param username OpeatorName, String type. Required. Default Value "admin". Checks the operator has the privileges to view the Real-Time Alarms. :param devId: int or str value of the target device :param auth: requests auth o...
Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API :param username OpeatorName, String type. Required. Default Value "admin". Checks the operator has the privileges to view the Real-Time Alarms. :param devId: int or str value of the target device :param auth: requests auth o...
function takes the devId of a specific device and issues a RESTFUL call to get the current alarms for the target device. :param devid: int or str value of the target device :param devip: str of ipv4 address of the target device :param auth: requests auth object #usually auth.creds from auth pyhpeimc....
Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API :param username OpeatorName, String type. Required. Default Value "admin". Checks the operator has the privileges to view the Real-Time Alarms. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class ...
Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API :param username OpeatorName, String type. Required. Default Value "admin". Checks the operator has the privileges to view the Real-Time Alarms. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class ...
function to take str input of alarm_id, issues a REST call to the IMC REST interface and returns a dictionary object which contains the details of a specific alarm. :param alarm_id: str number which represents the internal ID of a specific alarm :param auth: :param url: :return: def get_alarm_deta...
Function tasks input of str of alarm ID and sends to REST API. Function will acknowledge designated alarm in the IMC alarm database. :param alarm_id: str of alarm ID param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth...
Function takes input of dictionary operator with the following keys operator = { "fullName" : "" , "sessionTimeout" : "", "password" : "", "operatorGroupId" : "", "name" : "", "desc" : "", "defaultAcl" : "", "authType" : ...
List virtual folders that belongs to the current user. def list(): '''List virtual folders that belongs to the current user.''' fields = [ ('Name', 'name'), ('ID', 'id'), ('Owner', 'is_owner'), ('Permission', 'permission'), ] with Session() as session: try: ...
List the hosts of virtual folders that is accessible to the current user. def list_hosts(): '''List the hosts of virtual folders that is accessible to the current user.''' with Session() as session: try: resp = session.VFolder.list_hosts() print(f"Default vfolder host: {resp['de...
Create a new virtual folder. \b NAME: Name of a virtual folder. HOST: Name of a virtual folder host in which the virtual folder will be created. def create(name, host): '''Create a new virtual folder. \b NAME: Name of a virtual folder. HOST: Name of a virtual folder host in which the virt...
Delete the given virtual folder. This operation is irreversible! NAME: Name of a virtual folder. def delete(name): '''Delete the given virtual folder. This operation is irreversible! NAME: Name of a virtual folder. ''' with Session() as session: try: session.VFolder(name).dele...
Rename the given virtual folder. This operation is irreversible! You cannot change the vfolders that are shared by other users, and the new name must be unique among all your accessible vfolders including the shared ones. OLD_NAME: The current name of a virtual folder. NEW_NAME: The new name of a v...
Show the information of the given virtual folder. NAME: Name of a virtual folder. def info(name): '''Show the information of the given virtual folder. NAME: Name of a virtual folder. ''' with Session() as session: try: result = session.VFolder(name).info() print('V...
Download a file from the virtual folder to the current working directory. The files with the same names will be overwirtten. \b NAME: Name of a virtual folder. FILENAMES: Paths of the files to be uploaded. def download(name, filenames): ''' Download a file from the virtual folder to the curren...
Create an empty directory in the virtual folder. \b NAME: Name of a virtual folder. PATH: The name or path of directory. Parent directories are created automatically if they do not exist. def mkdir(name, path): '''Create an empty directory in the virtual folder. \b NAME: Name of a v...
Delete files in a virtual folder. If one of the given paths is a directory and the recursive option is enabled, all its content and the directory itself are recursively deleted. This operation is irreversible! \b NAME: Name of a virtual folder. FILENAMES: Paths of the files to delete. def rm(...
List files in a path of a virtual folder. \b NAME: Name of a virtual folder. PATH: Path inside vfolder. def ls(name, path): """ List files in a path of a virtual folder. \b NAME: Name of a virtual folder. PATH: Path inside vfolder. """ with Session() as session: try: ...
Invite other users to access the virtual folder. \b NAME: Name of a virtual folder. EMAIL: Emails to invite. def invite(name, emails, perm): """Invite other users to access the virtual folder. \b NAME: Name of a virtual folder. EMAIL: Emails to invite. """ with Session() as sessio...
List and manage received invitations. def invitations(): """List and manage received invitations. """ with Session() as session: try: result = session.VFolder.invitations() invitations = result.get('invitations', []) if len(invitations) < 1: print...
Adds a given check callback with the provided object to the list of checks. Useful for built-ins but also advanced custom checks. def init_check(self, check, obj): """ Adds a given check callback with the provided object to the list of checks. Useful for built-ins but also advanced cust...
Initializes the extension with the given app, registers the built-in views with an own blueprint and hooks up our signal callbacks. def init_app(self, app): """ Initializes the extension with the given app, registers the built-in views with an own blueprint and hooks up our sign...
The before_request callback. def _before_request(self): """ The before_request callback. """ g._request_id = str(uuid.uuid4()) g._start_timestamp = time.time()
The signal handler for the request_finished signal. def _after_request(self, response): """ The signal handler for the request_finished signal. """ if not getattr(g, '_has_exception', False): extra = self.summary_extra() self.summary_logger.info('', extra=extra) ...
The signal handler for the got_request_exception signal. def _got_request_exception(self, sender, exception, **extra): """ The signal handler for the got_request_exception signal. """ extra = self.summary_extra() extra['errno'] = 500 self.summary_logger.error(str(excepti...
Return the ID of the current request's user def user_id(self): """ Return the ID of the current request's user """ # This needs flask-login to be installed if not has_flask_login: return # and the actual login manager installed if not hasattr(current...
Build the extra data for the summary logger. def summary_extra(self): """ Build the extra data for the summary logger. """ out = { 'errno': 0, 'agent': request.headers.get('User-Agent', ''), 'lang': request.headers.get('Accept-Language', ''), ...
View that returns the contents of version.json or a 404. def _version_view(self): """ View that returns the contents of version.json or a 404. """ version_json = self._version_callback(self.version_path) if version_json is None: return 'version.json not found', 404 ...
Runs all the registered checks and returns a JSON response with either a status code of 200 or 500 depending on the results of the checks. Any check that returns a warning or worse (error, critical) will return a 500 response. def _heartbeat_view(self): """ Runs all the registe...
A decorator to register a new Dockerflow check to be run when the /__heartbeat__ endpoint is called., e.g.:: from dockerflow.flask import checks @dockerflow.check def storage_reachable(): try: acme.storage.ping() except Sl...
A simplified version of numpy.linspace with default options def drange(start: Decimal, stop: Decimal, num: int): ''' A simplified version of numpy.linspace with default options ''' delta = stop - start step = delta / (num - 1) yield from (start + step * Decimal(tick) for tick in range(0, num))
Accepts a range expression which generates a range of values for a variable. Linear space range: "linspace:1,2,10" (start, stop, num) as in numpy.linspace Pythonic range: "range:1,10,2" (start, stop[, step]) as in Python's range Case range: "case:a,b,c" (comma-separated strings) def range_expr(arg): '...
Fully streamed asynchronous version of the execute loop. async def exec_loop(stdout, stderr, kernel, mode, code, *, opts=None, vprint_done=print_done, is_multi=False): ''' Fully streamed asynchronous version of the execute loop. ''' async with kernel.stream_execute(code, mode=mode, ...
Old synchronous polling version of the execute loop. def exec_loop_sync(stdout, stderr, kernel, mode, code, *, opts=None, vprint_done=print_done): ''' Old synchronous polling version of the execute loop. ''' opts = opts if opts else {} run_id = None # use server-assigned run ID ...
Run the given code snippet or files in a session. Depending on the session ID you give (default is random), it may reuse an existing session or create a new one. \b LANG: The name (and version/platform tags appended after a colon) of session runtime or programming language.') FILES: The c...
Prepare and start a single compute session without executing codes. You may use the created session to execute codes using the "run" command or connect to an application service provided by the session using the "app" command. \b LANG: The name (and version/platform tags appended after a colon) of...
Terminate the given session. SESSID: session ID or its alias given when creating the session. def terminate(sess_id_or_alias, owner, stats): ''' Terminate the given session. SESSID: session ID or its alias given when creating the session. ''' print_wait('Terminating the session(s)...') wi...
function requires no input and returns a list of dictionaries of custom views from an HPE IMC. Optional name argument will return only the specified view. :param name: str containing the name of the desired custom view :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class ...
function takes a list of devIDs from devices discovered in the HPE IMC platform and and issues a RESTFUL call to add the list of devices to a specific custom views from HPE IMC. :param dev_list: list containing the devID of all devices to be contained in this custom view. :param auth: requests auth objec...
function takes input of auth, url, and name and issues a RESTFUL call to delete a specific of custom views from HPE IMC. :param name: string containg the name of the desired custom view :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS i...
Like unicode.split, but accept several separators and regexes Args: string: the string to split. separators: strings you can split on. Each string can be a regex. maxsplit: max number of time you wish to split. default is 0, whic...
Like unicode.replace() but accept several substitutions and regexes Args: string: the string to split on. patterns: a string, or an iterable of strings to be replaced. substitutions: a string or an iterable of string to use as a replacement. You ca...
Show the manager's current status. def status(): '''Show the manager's current status.''' with Session() as session: resp = session.Manager.status() print(tabulate([('Status', 'Active Sessions'), (resp['status'], resp['active_sessions'])], headers=...
Freeze manager. def freeze(wait, force_kill): '''Freeze manager.''' if wait and force_kill: print('You cannot use both --wait and --force-kill options ' 'at the same time.', file=sys.stderr) return with Session() as session: if wait: while True: ...
Function takes input of devID 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 :param devid: str requires devId as the only input parameter :param...
Function takes devId as input to RESTFULL call to HP IMC platform :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 :param devid: str requires devid of the target device :param d...
Function takes devid pr devip as input to RESTFUL call to HP IMC platform :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 :param devid: str requires devid of the target device ...
Function takes devId as input to RESTFUL call to HP IMC platform :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 :param devid: str requires devid of the target device :param de...
Function takes ifindex, pvid, tagged vlans untagged vlans as input values to add a hybrid port to a HPE Comware based switch. These functions only apply to HPE Comware based devices. :param ifindex: str ifIndex value of target interface :param pvid: str 802.1q value (1-4094) of target VLAN :param tagged...
Function takes devip ( ipv4 address ), ifIndex and pvid (vlanid) of specific device and 802.1q VLAN tag and issues a RESTFUL call to remove the specified VLAN from the target device. :param ifindex: str value of ifIndex for a specific interface on the device :param auth: requests auth object #usually aut...
Function takes devip ( ipv4 address ), ifIndex and pvid (vlanid) of specific device and 802.1q VLAN tag and issues a RESTFUL call to remove the specified VLAN from the target device. :param ifindex: str value of ifIndex for a specific interface on the device :param pvid: str value of dot1q VLAN desired t...
function takes devid and vlanid vlan_name of specific device and 802.1q VLAN tag and issues a RESTFUL call to add the specified VLAN from the target device. VLAN Name MUST be valid on target device. :param vlanid:int or str value of target 802.1q VLAN :param vlan_name: str value of the target 802.1q V...
function takes devid and vlanid of specific device and 802.1q VLAN tag and issues a RESTFUL call to remove the specified VLAN from the target device. :param vlanid:int or str value of target 802.1q VLAN :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: bas...
Use the HouseCanary API Python Client to access the API def _get_results_from_api(identifiers, endpoints, api_key, api_secret): """Use the HouseCanary API Python Client to access the API""" if api_key is not None and api_secret is not None: client = housecanary.ApiClient(api_key, api_secret) else:...
Show the list of registered images in this cluster. def images(): ''' Show the list of registered images in this cluster. ''' fields = [ ('Name', 'name'), ('Registry', 'registry'), ('Tag', 'tag'), ('Digest', 'digest'), ('Size', 'size_bytes'), ('Aliases', ...
Update the kernel image metadata from all configured docker registries. def rescan_images(registry): '''Update the kernel image metadata from all configured docker registries.''' with Session() as session: try: result = session.Image.rescanImages(registry) except Exception as e: ...
Add an image alias. def alias_image(alias, target): '''Add an image alias.''' with Session() as session: try: result = session.Image.aliasImage(alias, target) except Exception as e: print_error(e) sys.exit(1) if result['ok']: print("alias ...
Remove an image alias. def dealias_image(alias): '''Remove an image alias.''' with Session() as session: try: result = session.Image.dealiasImage(alias) except Exception as e: print_error(e) sys.exit(1) if result['ok']: print("alias {0} re...
Quick aliases for run command. def run_alias(): """ Quick aliases for run command. """ mode = Path(sys.argv[0]).stem help = True if len(sys.argv) <= 1 else False if mode == 'lcc': sys.argv.insert(1, 'c') elif mode == 'lpython': sys.argv.insert(1, 'python') sys.argv.inser...
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 :return: object of type list containing the device asset details def get_dev_asset_details(ipaddress): """Takes in ipaddress as input to fetch d...
Helper function: Uses return of get_dev_asset_details function to evaluate to evaluate for multipe serial objects. :param assetList: output of get_dev_asset_details function :return: the serial_list object of list type which contains one or more dictionaries of the asset details def get_serial_numbers(assetLis...
Function takes devId as input to RESTFULL call to HP IMC platform :param devId: output of get_dev_details :return: list of dictionaries containing of interfaces configured as an 802.1q trunk def get_trunk_interfaces(devId): """Function takes devId as input to RESTFULL call to HP IMC platform :param dev...
Function takes devId as input to RESTFUL call to HP IMC platform :param devId: requires deviceID as the only input parameter :return: list of dictionaries containing interfaces configured as access ports def get_device_access_interfaces(devId): """Function takes devId as input to RESTFUL call to HP IMC pla...
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 :return: dictionary of device details >>> get_dev_details('10.101.0.1') {'symbolLevel': '2', 'typeName': 'Cisco 2811', 'location': 'changed this too', 'status': '1...
Function takes input of devID to issue RESTUL call to HP IMC :param devId: requires devId as the only input parameter :return: list dictionaries of existing vlans on the devices. Device must be supported in HP IMC platform VLAN manager module def get_dev_vlans(devId): """Function takes input of devID to is...
Function takes devid as input to RESTFUL call to HP IMC platform :param devid: requires devid as the only input :return: list object which contains a dictionary per interface def get_dev_interface(devid): """ Function takes devid as input to RESTFUL call to HP IMC platform :param devid: requires de...
function takes the devId of a specific device and issues a RESTFUL call to get the most current running config file as known by the HP IMC Base Platform ICC module for the target device. :param devId: int or str value of the target device :return: str which contains the entire content of the target device ...
function takes the devId of a specific device and issues a RESTFUL call to get the most current startup config file as known by the HP IMC Base Platform ICC module for the target device. :param devId: int or str value of the target device :return: str which contains the entire content of the target device ...
function takes the devId of a specific device and issues a RESTFUL call to get the current alarms for the target device. :param devId: int or str value of the target device :return:list of dictionaries containing the alarms for this device def get_dev_alarms(devId): """ function takes the devId of ...
function takes the ipAddress of a specific host and issues a RESTFUL call to get the device and interface that the target host is currently connected to. :param ipAddress: str value valid IPv4 IP address :return: dictionary containing hostIp, devId, deviceIP, ifDesc, ifIndex def get_real_time_locate(ipAddr...
function takes devid of specific device and issues a RESTFUL call to get the IP/MAC/ARP list from the target device. :param devId: int or str value of the target device. :return: list of dictionaries containing the IP/MAC/ARP list of the target device. def get_ip_mac_arp_list(devId): """ function takes...
function takes no input and issues a RESTFUL call to get a list of custom views from HPE IMC. Optioanl Name input will return only the specified view. :param name: string containg the name of the desired custom view :return: list of dictionaries containing attributes of the custom views. def get_custom_vie...
function takes no input and issues a RESTFUL call to get a list of custom views from HPE IMC. Optioanl Name input will return only the specified view. :param name: string containg the name of the desired custom view :return: list of dictionaries containing attributes of the custom views. def create_custom_...
function takes devid and vlanid vlan_name of specific device and 802.1q VLAN tag and issues a RESTFUL call to add the specified VLAN from the target device. VLAN Name MUST be valid on target device. :param devid: int or str value of the target device :param vlanid:int or str value of target 802.1q VLAN ...
function takes devid and vlanid of specific device and 802.1q VLAN tag and issues a RESTFUL call to remove the specified VLAN from the target device. :param devid: int or str value of the target device :param vlanid: :return:HTTP Status code of 204 with no values. def delete_dev_vlans(devid, vlanid): ...
function takest devid and ifindex of specific device and interface and issues a RESTFUL call to " shut" the specifie d interface on the target device. :param devid: int or str value of the target device :param ifindex: int or str value of the target interface :return: HTTP status code 204 with no values...
function takest devid and ifindex of specific device and interface and issues a RESTFUL call to "undo shut" the spec ified interface on the target device. :param devid: int or str value of the target device :param ifindex: int or str value of the target interface :return: HTTP status code 204 with no va...
function takes hostId as input to RESTFUL call to HP IMC :param hostId: int or string of HostId of Hypervisor host :return:list of dictionatires contraining the VM Host information for the target hypervisor def get_vm_host_info(hostId): """ function takes hostId as input to RESTFUL call to HP IMC :...
Takes in no param as input to fetch SNMP TRAP definitions from HP IMC RESTFUL API :param None :return: object of type list containing the device asset details def get_trap_definitions(): """Takes in no param as input to fetch SNMP TRAP definitions from HP IMC RESTFUL API :param None :return: object...
Returns list of rate limit information from the response def rate_limits(self): """Returns list of rate limit information from the response""" if not self._rate_limits: self._rate_limits = utilities.get_rate_limits(self._response) return self._rate_limits
function requires no input and returns a list of dictionaries of custom views from an HPE IMC. Optional name argument will return only the specified view. :param name: str containing the name of the desired custom view :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class ...
function requires no input and returns a list of dictionaries of custom views from an HPE IMC. Optional name argument will return only the specified view. :param name: str containing the name of the desired custom view :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class ...
function takes no input and issues a RESTFUL call to get a list of custom views from HPE IMC. Optional Name input will return only the specified view. :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 pyhpeim...
function takes a list of devIDs from devices discovered in the HPE IMC platform and issues a RESTFUL call to add the list of devices to a specific custom views from HPE IMC. :param custom_view_name: str of the target custom view name :param dev_list: list containing the devID of all devices to be containe...
function takes input of auth, url, and name and issues a RESTFUL call to delete a specific of custom views from HPE IMC. :param name: string containg the name of the desired custom view :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC ...
Get token for make request. The The data obtained herein are used in the variable header. Returns: To perform the request, receive in return a dictionary with several keys. With this method only return the token as it will use it for subseq...
Format and encode dict for make authentication on microsoft servers. def _set_format_oauth(self): """ Format and encode dict for make authentication on microsoft servers. """ format_oauth = urllib.parse.urlencode({ 'client_id': self._clie...
This is the final step, where the request is made, the data is retrieved and returned. def _make_request(self, params, translation_url, headers): """ This is the final step, where the request is made, the data is retrieved and returned. """ resp = req...