text
stringlengths
81
112k
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: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :para...
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 :param template_name: str value of template name :retur...
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 name of the specific ssh template :param template_id Internal IMC number which designates the specific ...
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 url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :par...
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 :param url: base url of IMC RS interface #usually 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 of dictionatires containing the device asset deta...
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) ...
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.auth.authclass :param network_address: str IPv4 Network Address :param category:...
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 interface #usually auth.url from pyhpeimc.auth.aut...
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 object #usually auth.creds from auth pyhpeimc.auth.class :param url: ...
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 :param auth: requests auth object #usually auth.creds from auth pyhpeimc....
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 target device :param cmd_list: list of strings :param auth: reque...
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. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.au...
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 address of the target devices :param ifindex: int or str value of the target inte...
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 address of the target devices :param ifindex: int or str value of the target...
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 ...
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_lim...
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 = ...
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' \ ...
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...
Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12 async def info(self, fields: Iterable[str] = None) -> dict: ''' Returns the keypair's information such as resource limits. :param fiel...
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!) {' +...
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 ...
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 o...
Lists all resource presets in the current scaling group with additiona information. async def check_presets(cls): ''' Lists all resource presets in the current scaling group with additiona information. ''' rqst = Request(cls.session, 'POST', '/resource/check-presets') ...
function takes the a python dict containing all necessary fields for a performance tasks, transforms the dict into JSON and issues a RESTFUL call to create the performance task. device. :param task: dictionary containing all required fields for performance tasks :param auth: requests ...
function takes the a str object containing the name of an existing performance tasks and issues a RESTFUL call to the IMC REST service. It will return a list :param task_name: str containing the name of the performance task :param auth: requests auth object #usually auth.creds from auth pyhpei...
function takes hostId as input to RESTFUL call to HP IMC :param hostip: int or string of hostip of Hypervisor host :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: Dict...
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 where each element of the list represents a ...
This function prompts user for IMC server information and credentuials and stores values in url and auth global variables def set_imc_creds(h_url=None, imc_server=None, imc_port=None, imc_user=None,imc_pw=None): """ This function prompts user for IMC server information and credentuials and stores values in...
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): """ Fun...
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_ur...
Load and return the contents of version.json. :param root: The root path that the ``version.json`` file will be opened :type root: str :returns: Content of ``version.json`` or None :rtype: dict or None def get_version(root): """ Load and return the contents of version.json. :param root: T...
Calls this instance's request_client's post method with the specified component endpoint Args: - endpoint_name (str) - The endpoint to call like "property/value". - identifier_input - One or more identifiers to request data for. An identifier can be in one of the...
Calls this instance's request_client's get method with the specified component endpoint def fetch_synchronous(self, endpoint_name, query_params=None): """Calls this instance's request_client's get method with the specified component endpoint""" endpoint_url = constants.URL_PREFIX + "/"...
Convert the various formats of input identifier_data into the proper json format expected by the ApiClient fetch method, which is a list of dicts. def get_identifier_input(self, identifier_data): """Convert the various formats of input identifier_data into the proper json format expecte...
Common method for handling parameters before passing to api_client def fetch_identifier_component(self, endpoint_name, identifier_data, query_params=None): """Common method for handling parameters before passing to api_client""" if query_params is None: query_params = {} identifie...
Convert input address data into json format def _convert_to_identifier_json(self, address_data): """Convert input address data into json format""" if isinstance(address_data, str): # allow just passing a slug string. return {"slug": address_data} if isinstance(address_...
Call the value_report component Value Report only supports a single address. Args: - address - zipcode Kwargs: - report_type - "full" or "summary". Default is "full". - format_type - "json", "pdf", "xlsx" or "all". Default is "json". def value_...
Call the rental_report component Rental Report only supports a single address. Args: - address - zipcode Kwargs: - format_type - "json", "xlsx" or "all". Default is "json". def rental_report(self, address, zipcode, format_type="json"): """Call the ...
Call the zip component_mget endpoint Args: - zip_data - As described in the class docstring. - components - A list of strings for each component to include in the request. Example: ["zip/details", "zip/volatility"] def component_mget(self, zip_data, components): ...
Returns the contents of version.json or a 404. def version(request): """ Returns the contents of version.json or a 404. """ version_json = import_string(version_callback)(settings.BASE_DIR) if version_json is None: return HttpResponseNotFound('version.json not found') else: retu...
Runs all the Django checks and returns a JsonResponse 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(request): """ Runs all the Django checks and returns a JsonRes...
Returns a list of ComponentResult from the json_data def _create_component_results(json_data, result_key): """ Returns a list of ComponentResult from the json_data""" component_results = [] for key, value in list(json_data.items()): if key not in [result_key, "meta"]: component_result =...
Returns whether there was a business logic error when fetching data for any components for this property. Returns: boolean def has_error(self): """Returns whether there was a business logic error when fetching data for any components for this property. Returns: ...
If there were any business errors fetching data for this property, returns the error messages. Returns: string - the error message, or None if there was no error. def get_errors(self): """If there were any business errors fetching data for this property, returns the error m...
Deserialize property json data into a Property object Args: json_data (dict): The json data for this property Returns: Property object def create_from_json(cls, json_data): """Deserialize property json data into a Property object Args: json_data (d...
Deserialize block json data into a Block object Args: json_data (dict): The json data for this block Returns: Block object def create_from_json(cls, json_data): """Deserialize block json data into a Block object Args: json_data (dict): The json dat...
Deserialize zipcode json data into a ZipCode object Args: json_data (dict): The json data for this zipcode Returns: Zip object def create_from_json(cls, json_data): """Deserialize zipcode json data into a ZipCode object Args: json_data (dict): The ...
Deserialize msa json data into a Msa object Args: json_data (dict): The json data for this msa Returns: Msa object def create_from_json(cls, json_data): """Deserialize msa json data into a Msa object Args: json_data (dict): The json data for this m...
Start yielding items when a condition arise. Args: iterable: the iterable to filter. condition: if the callable returns True once, start yielding items. If it's not a callable, it will be converted to one as `lambda condition: condition == item`. Example: ...
Stop yielding items when a condition arise. Args: iterable: the iterable to filter. condition: if the callable returns True once, stop yielding items. If it's not a callable, it will be converted to one as `lambda condition: condition == item`. Example: ...
Returns a generator that will yield all objects from iterable, skipping duplicates. Duplicates are identified using the `key` function to calculate a unique fingerprint. This does not use natural equality, but the result use a set() to remove duplicates, so defining __eq__ on yo...
Yields items from an iterator in iterable chunks. def chunks(iterable, chunksize, cast=tuple): # type: (Iterable, int, Callable) -> Iterable """ Yields items from an iterator in iterable chunks. """ it = iter(iterable) while True: yield cast(itertools.chain([next(it)], ...
Yields iterms by bunch of a given size, but rolling only one item in and out at a time when iterating. >>> list(window([1, 2, 3])) [(1, 2), (2, 3)] By default, this will cast the window to a tuple before yielding it; however, any function that will accept an iterable as its arg...
Return the item at the index of this iterable or raises IndexError. WARNING: this will consume generators. Negative indices are allowed but be aware they will cause n items to be held in memory, where n = abs(index) def at_index(iterable, index): # type: (Iterable[T], int) -> T """" R...
Return the first item of the iterable for which func(item) == True. Or raises IndexError. WARNING: this will consume generators. def first_true(iterable, func): # type: (Iterable[T], Callable) -> T """" Return the first item of the iterable for which func(item) == True. Or raises Ind...
Like itertools.islice, but accept int and callables. If `start` is a callable, start the slice after the first time start(item) == True. If `stop` is a callable, stop the slice after the first time stop(item) == True. def iterslice(iterable, start=0, stop=None, step=1): # type: (I...
Lazily return the first x items from this iterable or default. def firsts(iterable, items=1, default=None): # type: (Iterable[T], int, T) -> Iterable[T] """ Lazily return the first x items from this iterable or default. """ try: items = int(items) except (ValueError, TypeError): raise ...
Lazily return the last x items from this iterable or default. def lasts(iterable, items=1, default=None): # type: (Iterable[T], int, T) -> Iterable[T] """ Lazily return the last x items from this iterable or default. """ last_items = deque(iterable, maxlen=items) for _ in range(items - len(last_items...
Determine execution mode. Legacy mode: <= v4.20181215 def is_legacy_server(): '''Determine execution mode. Legacy mode: <= v4.20181215 ''' with Session() as session: ret = session.Kernel.hello() bai_version = ret['version'] legacy = True if bai_version <= 'v4.20181215' else False ...
Terminates the session. It schedules the ``close()`` coroutine of the underlying aiohttp session and then enqueues a sentinel object to indicate termination. Then it waits until the worker thread to self-terminate by joining. def close(self): ''' Terminates the session. It sc...
A proposed-but-not-implemented asyncio.run_forever() API based on @vxgmichel's idea. See discussions on https://github.com/python/asyncio/pull/465 def asyncio_run_forever(setup_coro, shutdown_coro, *, stop_signals={signal.SIGINT}, debug=False): ''' A proposed-but-not-implemented...
claar all the cache, and release memory def clear(self): ''' claar all the cache, and release memory ''' for node in self.dli(): node.empty = True node.key = None node.value = None self.head = _dlnode() self.head.next = self.head self.head.prev = self.head self.listSize = 1 self.table....
Delete the item def pop(self, key, default = None): """Delete the item""" node = self.get(key, None) if node == None: value = default else: value = node try: del self[key] except: return value return value
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...
Get-or-creates a compute session. If *client_token* is ``None``, it creates a new compute session as long as the server has enough resources and your API key has remaining quota. If *client_token* is a valid string and there is an existing compute session with the same token and the same...
Destroys the compute session. Since the server literally kills the container(s), all ongoing executions are forcibly interrupted. async def destroy(self): ''' Destroys the compute session. Since the server literally kills the container(s), all ongoing executions are forc...
Restarts the compute session. The server force-destroys the current running container(s), but keeps their temporary scratch directories intact. async def restart(self): ''' Restarts the compute session. The server force-destroys the current running container(s), but keeps their ...
Gets the auto-completion candidates from the given code string, as if a user has pressed the tab key just after the code in IDEs. Depending on the language of the compute session, this feature may not be supported. Unsupported sessions returns an empty list. :param code: An (i...
Retrieves a brief information about the compute session. async def get_info(self): ''' Retrieves a brief information about the compute session. ''' params = {} if self.owner_access_key: params['owner_access_key'] = self.owner_access_key rqst = Request(self.se...
Executes a code snippet directly in the compute session or sends a set of build/clean/execute commands to the compute session. For more details about using this API, please refer :doc:`the official API documentation <user-api/intro>`. :param run_id: A unique identifier for a particular...
Uploads the given list of files to the compute session. You may refer them in the batch-mode execution or from the code executed in the server afterwards. :param files: The list of file paths in the client-side. If the paths include directories, the location of them in the compute ...
Downloads the given list of files from the compute session. :param files: The list of file paths in the compute session. If they are relative paths, the path is calculated from ``/home/work`` in the compute session container. :param dest: The destination directory in the client-...
Gets the list of files in the given path inside the compute session container. :param path: The directory path in the compute session. async def list_files(self, path: Union[str, Path] = '.'): ''' Gets the list of files in the given path inside the compute session container. ...
Opens a pseudo-terminal of the kernel (if supported) streamed via websockets. :returns: a :class:`StreamPty` object. def stream_pty(self) -> 'StreamPty': ''' Opens a pseudo-terminal of the kernel (if supported) streamed via websockets. :returns: a :class:`StreamPty` ob...
Executes a code snippet in the streaming mode. Since the returned websocket represents a run loop, there is no need to specify *run_id* explicitly. def stream_execute(self, code: str = '', *, mode: str = 'query', opts: dict = None) -> WebSocketResponse: ...
Grab the ~/.polyglot/.env file for variables If you are running Polyglot v2 on this same machine then it should already exist. If not create it. def init_interface(): sys.stdout = LoggerWriter(LOGGER.debug) sys.stderr = LoggerWriter(LOGGER.error) """ Grab the ~/.polyglot/.env file for variable...
The callback for when the client receives a CONNACK response from the server. Subscribing in on_connect() means that if we lose the connection and reconnect then subscriptions will be renewed. :param mqttc: The client instance for this callback :param userdata: The private userdata for ...
The callback for when a PUBLISH message is received from the server. :param mqttc: The client instance for this callback :param userdata: The private userdata for the mqtt client. Not used in Polyglot :param flags: The flags set on the connection. :param msg: Dictionary of MQTT received...
The callback for when a DISCONNECT occurs. :param mqttc: The client instance for this callback :param userdata: The private userdata for the mqtt client. Not used in Polyglot :param rc: Result code of connection, 0 = Graceful, anything else is unclean def _disconnect(self, mqttc, userdata, rc)...
The client start method. Starts the thread for the MQTT Client and publishes the connected message. def _startMqtt(self): """ The client start method. Starts the thread for the MQTT Client and publishes the connected message. """ LOGGER.info('Connecting to MQTT... {}:{}'...
The client stop method. If the client is currently connected stop the thread and disconnect. Publish the disconnected message if clean shutdown. def stop(self): """ The client stop method. If the client is currently connected stop the thread and disconnect. Publish the disconnec...
Formatted Message to send to Polyglot. Connection messages are sent automatically from this module so this method is used to send commands to/from Polyglot and formats it for consumption def send(self, message): """ Formatted Message to send to Polyglot. Connection messages are sent automatical...
Add a node to the NodeServer :param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required. def addNode(self, node): """ Add a node to the NodeServer :param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, an...
Send custom dictionary to Polyglot to save and be retrieved on startup. :param data: Dictionary of key value pairs to store in Polyglot database. def saveCustomData(self, data): """ Send custom dictionary to Polyglot to save and be retrieved on startup. :param data: Dictionary of key ...
Send custom dictionary to Polyglot to save and be retrieved on startup. :param data: Dictionary of key value pairs to store in Polyglot database. def saveCustomParams(self, data): """ Send custom dictionary to Polyglot to save and be retrieved on startup. :param data: Dictionary of ke...
Add custom notice to front-end for this NodeServers :param data: String of characters to add as a notification in the front-end. def addNotice(self, data): """ Add custom notice to front-end for this NodeServers :param data: String of characters to add as a notification in the front-e...
Add custom notice to front-end for this NodeServers :param data: Index of notices list to remove. def removeNotice(self, data): """ Add custom notice to front-end for this NodeServers :param data: Index of notices list to remove. """ LOGGER.info('Sending removenotice t...
Delete a node from the NodeServer :param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required. def delNode(self, address): """ Delete a node from the NodeServer :param node: Dictionary of node settings. Keys: address, name, node_def_id...
Get Node by Address of existing nodes. def getNode(self, address): """ Get Node by Address of existing nodes. """ try: for node in self.config['nodes']: if node['address'] == address: return node return False except Key...
Save incoming config received from Polyglot to Interface.config and then do any functions that are waiting on the config to be received. def inConfig(self, config): """ Save incoming config received from Polyglot to Interface.config and then do any functions that are waiting on the conf...
Send custom parameters descriptions to Polyglot to be used in front end UI configuration screen Accepts list of objects with the followin properties name - used as a key when data is sent from UI title - displayed in UI defaultValue - optionanl type - opti...
Just send it along if requested, should be able to delete the node even if it isn't in our config anywhere. Usually used for normalization. def delNode(self, address): """ Just send it along if requested, should be able to delete the node even if it isn't in our config anywhere. Usually...
Sends the GraphQL query and returns the response. :param query: The GraphQL query string. :param variables: An optional key-value dictionary to fill the interpolated template variables in the query. :returns: The object parsed from the response JSON string. async def q...
Returns human readable string from number of seconds def get_readable_time_string(seconds): """Returns human readable string from number of seconds""" seconds = int(seconds) minutes = seconds // 60 seconds = seconds % 60 hours = minutes // 60 minutes = minutes % 60 days = hours // 24 ho...
Returns a list of rate limit information from a given response's headers. def get_rate_limits(response): """Returns a list of rate limit information from a given response's headers.""" periods = response.headers['X-RateLimit-Period'] if not periods: return [] rate_limits = [] periods = pe...
Return key, self[key] as generator for key in keys. Raise KeyError if a key does not exist Args: keys: Iterable containing keys Example: >>> from ww import d >>> list(d({1: 1, 2: 2, 3: 3}).isubset(1, 3)) [(1, 1), (3, 3)] def isubset(self, *key...
Swap key and value /!\ Be carreful, if there are duplicate values, only one will survive /!\ Example: >>> from ww import d >>> d({1: 2, 2: 2, 3: 3}).swap() {2: 2, 3: 3} def swap(self): # type: () -> DictWrapper """Swap key and value ...
Create a new d from Args: iterable: Iterable containing keys value: value to associate with each key. If callable, will be value[key] Returns: new DictWrapper Example: >>> from ww import d >>> sorted(d.fromkeys('123', value=4).items...