code stringlengths 1 18.2k |
|---|
not support VLAN function') return r.status_code else: print("An Error has occured") |
def set_inteface_down(devid, ifindex): """ 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 sta... |
url is None: # checks to see if the imc credentials are already available set_imc_creds() set_int_down_url = "/imcrs/plat/res/device/" + str(devid) + "/interface/" + str(ifindex) + "/down" f_url = url + set_int_down_url payload = None r = requests.put(f_url, auth=auth, headers=headers) # creates the URL using the paylo... |
def set_inteface_up(devid, ifindex): """ 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 s... |
url is None: # checks to see if the imc credentials are already available set_imc_creds() set_int_up_url = "/imcrs/plat/res/device/" + str(devid) + "/interface/" + str(ifindex) + "/up" f_url = url + set_int_up_url payload = None r = requests.put(f_url, auth=auth, headers=headers) # creates the URL using the payload var... |
def get_vm_host_info(hostId): """ 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 """ global r if auth is None or url is None: # checks to see if the imc credent... |
f_url = url + get_vm_host_info_url payload = None r = requests.get(f_url, auth=auth, headers=headers) # creates the URL using the payload variable as the contents # print(r.status_code) if r.status_code == 200: if len(r.text) > 0: return json.loads(r.text) elif r.status_code == 204: print("Device is not a supported Hyp... |
def get_trap_definitions(): """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 """ # checks to see if the imc credentials are already available if auth is None or url is None: set_imc_creds() global r get_trap... |
# creates the URL using the payload variable as the contents r = requests.get(f_url, auth=auth, headers=headers) # r.status_code if r.status_code == 200: trap_def_list = (json.loads(r.text)) return trap_def_list['trapDefine'] else: print("get_dev_asset_details: An Error has occured") |
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 |
def get_custom_views(auth, url, name=None): """ 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... |
:param name: (optional) str of name of specific custom view :return: list of dictionaties containing attributes of the custom views :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.groups import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> all_views = get_custom_views... |
>>> assert non_existant_view is None """ get_custom_view_url = None if name is None: get_custom_view_url = '/imcrs/plat/res/view/custom?resPrivilegeFilter=false&desc=false' \ '&total=false' elif name is not None: get_custom_view_url = '/imcrs/plat/res/view/custom?resPrivilegeFilter=false&name=' + \ name + '&desc=false&... |
else: return custom_view_list except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + ' get_custom_views: An Error has occured' |
def get_custom_view_details(name, auth, url): """ 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.cre... |
:param name: (optional) str of name of specific custom view :return: list of dictionaties containing attributes of the custom views :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.groups import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> view_details = get_custom_vi... |
if view_id is None: return view_id view_id = get_custom_views(auth, url, name=name)[0]['symbolId'] get_custom_view_details_url = '/imcrs/plat/res/view/custom/' + str(view_id) f_url = url + get_custom_view_details_url response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: current... |
def create_custom_views(auth, url, name=None, upperview=None): """ 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 u... |
desired custom view :param upperview: str contraining the name of the desired parent custom view :return: str of creation results ( "view " + name + "created successfully" :rtype: str >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.groups import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "a... |
=get_custom_views( auth.creds, auth.url, name = 'L1 View') >>> assert type(view_1) is list >>> assert view_1[0]['name'] == 'L1 View' #Create Nested custome view >>> create_custom_views(auth.creds, auth.url, name='L2 View', upperview='L1 View') 'View L2 View created successfully' >>> view_2 = get_custom_views( auth.cred... |
+ create_custom_views_url if upperview is None: payload = '''{ "name": "''' + name + '''", "upLevelSymbolId" : ""}''' else: parentviewid = get_custom_views(auth, url, upperview)[0]['symbolId'] payload = '''{ "name": "''' + name + '''", "upLevelSymbolId" : "''' + str(parentviewid) + '''"}''' response = requests.post(f_u... |
409: print("View " + name + " already exists") return response.status_code else: return response.status_code except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + ' get_custom_views: An Error has occured' |
def add_devs_custom_views(custom_view_name, dev_list, auth, url): """ 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:... |
: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: str of creation results ( "view " + name + "created successfully" :rtype: str >>> from pyhpeimc.auth import * >>> auth = IMCAuth("http://",... |
+ " doesn't exist") return view_id view_id = get_custom_views(auth, url, name=custom_view_name)[0]['symbolId'] add_devs_custom_views_url = '/imcrs/plat/res/view/custom/' + str(view_id) device_list = [] for dev in dev_list: new_dev = {"id": dev} device_list.append(new_dev) payload = '''{"device" : ''' + json.dumps(devic... |
return response.status_code except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + ' get_custom_views: An Error has occured' |
def delete_custom_view(auth, url, name): """ 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 :para... |
creation results ( "view " + name + "created successfully" :rtype: str >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.groups import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> delete_custom_view(auth.creds, auth.url, name = "L1 View") 'View L1 View deleted successfully' >>> vie... |
L2 View deleted successfully' >>> view_2 =get_custom_views( auth.creds, auth.url, name = 'L2 View') >>> assert view_2 is None """ view_id = get_custom_views(auth, url, name) if view_id is None: print("View " + name + " doesn't exists") return view_id view_id = get_custom_views(auth, url, name)[0]['symbolId'] delete_cus... |
' + name + ' deleted successfully') return response.status_code else: return response.status_code except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + ' delete_custom_view: An Error has occured' |
def _get_token(self): """ 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 subsequent requests, such as a sentence translate. Returns o... |
= requests.post(oauth_url, informations).json() return token["access_token"] |
def _set_format_oauth(self): """ Format and encode dict for make authentication on microsoft servers. """ format_oauth = urllib.parse.urlencode({ 'client_id': self._client_id, 'client_secret': self._client_secret, 'scope': self._url_request, 'grant_type': self._grant_type }).encode("utf-8") return format_oauth |
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 = requests.get(translation_url, params=params, headers=headers) resp.encoding = "UTF-8-sig" result = resp.json() return result |
def _get_content(self, params, mode_translate): """ This method gets the token and makes the header variable that will be used in connection authentication. After that, calls the _make_request() method to return the desired data. """ token = self._get_token() headers = {'Authorization': 'Bearer '+ token} parameters = p... |
def detect_language(self, text): """ Params: ::text = Text for identify language. Returns: Returns language present on text. """ infos_translate = TextDetectLanguageModel(text).to_dict() mode_translate = TranslatorMode.Detect.value return self._get_content(infos_translate, mode_translate) |
def detect_languages(self, texts): """ Params: ::texts = Array of texts for detect languages Returns: Returns language present on array of text. """ text_list = TextUtils.format_list_to_send(texts) infos_translate = TextDetectLanguageModel(text_list).to_dict() texts_for_detect = TextUtils.change_key(infos_translate, "t... |
def translate(self, text, to_lang, from_lang=None, content_type="text/plain", category=None): """ This method takes as a parameter the desired text to be translated and the language to which should be translated. To find the code for each language just go to the library home page. The parameter ::from_lang:: is optiona... |
"text/plain". In fact it can be of two types: the very "text/plain" or "text/html". By default the parameter ::category:: is defined as "general", we do not touch it. """ infos_translate = TextModel(text, to_lang, from_lang, content_type, category).to_dict() mode_translate = TranslatorMode.Translate.value return self._... |
def speak_phrase(self, text, language, format_audio=None, option=None): """ This method is very similar to the above, the difference between them is that this method creates an object of class TranslateSpeak(having therefore different attributes) and use another url, as we see the presence of SpeakMode enumerator inste... |
go to the home page of the documentation that library. The parameter ::format_audio:: can be of two types: "audio/mp3" or "audio/wav". If we do not define, Microsoft api will insert by default the "audio/wav". It is important to be aware that, to properly name the file downloaded by AudioSpeaked class(which uses thecla... |
can be of two types: "MaxQuality" or "MinQuality". By default, if not define, it will be "MinQuality". """ infos_speak_translate = SpeakModel( text, language, format_audio, option).to_dict() mode_translate = TranslatorMode.SpeakMode.value return self._get_content(infos_speak_translate, mode_translate) |
def get_vm_host_info(hostip, auth, url): """ 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.aut... |
* >>> from pyhpeimc.plat.vrm import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> host_info = get_vm_host_info('10.101.0.6', auth.creds, auth.url) >>> assert type(host_info) is dict >>> assert len(host_info) == 10 >>> assert 'cpuFeg' in host_info >>> assert 'cpuNum' in host_info >>> asse... |
host_info >>> assert 'porductFlag' in host_info >>> assert 'serverName' in host_info >>> assert 'vendor' in host_info """ hostid = get_dev_details(hostip, auth, url)['id'] f_url = url + "/imcrs/vrm/host?hostId=" + str(hostid) response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200... |
as error: return "Error:\n" + str(error) + " get_vm_host_info: An Error has occured" |
def get_plat_operator(auth, url,headers=HEADERS): ''' Funtion takes no inputs and returns a list of dictionaties of all of the operators currently configured on the HPE IMC system :return: list of dictionaries ''' get_operator_url = '/imcrs/plat/operator?start=0&size=1000&orderBy=id&desc=false&total=false' f_url = url ... |
occured') return "Error:\n" + str(e) + ' get_plat_operator: An Error has occured' |
def delete_plat_operator(operator,auth, url, headers=HEADERS): """ Function to set the password of an existing operator :param operator: str Name of the operator account :param password: str New password :param url: str url of IMC server, see requests library docs for more info :param auth: str see requests library doc... |
= None plat_oper_list = get_plat_operator(auth, url) for i in plat_oper_list: if operator == i['name']: oper_id = i['id'] if oper_id == None: return("\n User does not exist") delete_plat_operator_url = "/imcrs/plat/operator/" f_url = url + delete_plat_operator_url + str(oper_id) r = requests.delete(f_url, auth=auth, he... |
+ str(e) + ' delete_plat_operator: An Error has occured') return "Error:\n" + str(e) + ' delete_plat_operator: An Error has occured' |
def index(self, value): """ Args: value: index Returns: index of the values Raises: ValueError: value is not in list """ for i, x in enumerate(self): if x == value: return i raise ValueError("{} is not in list".format(value)) |
def to_d(self): """ Args: self Returns: a d that stems from self Raises: ValueError: dictionary update sequence element #index has length len(tuple); 2 is required TypeError: cannot convert dictionary update sequence element #index to a sequence """ try: return ww.d(self) except (TypeError, ValueError): for i, element ... |
tested but don't appear in coverage except TypeError: # pragma: no cover # TODO: use raise_from ? raise ValueError(("'{}' (position {}) is not iterable. You" " can only create a dictionary from a " "elements that are iterables, such as " "tuples, lists, etc.") .format(element, i)) try: size = len(element) except TypeEr... |
contains {} " "elements. You can only create a " "dictionary from iterables containing " "2 elements.").format(element, i, size)) raise |
def get_cfg_template(auth, url, folder = None): ''' Function takes no input and returns a list of dictionaries containing the configuration templates in the root folder of the icc configuration template library. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of ... |
ICC library. :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> config_templates = get_cfg_template(auth.creds, auth.url) >>> assert type(config_templates) is list >>> assert 'confFileName' in config_templates[0] >... |
''' if folder == None: get_cfg_template_url = "/imcrs/icc/confFile/list" else: folder_id = get_folder_id(folder, auth, url) get_cfg_template_url = "/imcrs/icc/confFile/list/"+str(folder_id) f_url = url + get_cfg_template_url r = requests.get(f_url,auth=auth, headers=HEADERS) #print (r.status_code) try: if r.status_code... |
def create_cfg_segment(filename, filecontent, description, auth, url): ''' Takes a str into var filecontent which represents the entire content of a configuration segment, or partial configuration file. Takes a str into var description which represents the description of the configuration segment :param filename: str c... |
contrianing the description of the configuration segment :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: If successful, Boolena of type True :rtype: Boolean >>> from pyhpeimc.auth import ... |
= create_cfg_segment('CW7SNMP.cfg', filecontent, 'My New Template', auth.creds, auth.url) >>> template_id = get_template_id('CW7SNMP.cfg', auth.creds, auth.url) >>> assert type(template_id) is str >>> ''' payload = {"confFileName": filename, "confFileType": "2", "cfgFileParent": "-1", "confFileDesc": description, "cont... |
True except requests.exceptions.RequestException as e: return "Error:\n" + str(e) + " create_cfg_segment: An Error has occured" |
def get_template_id(template_name, auth, url): """ Helper function takes str input of folder name and returns str numerical id of the folder. :param folder_name: str name of the folder :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually a... |
>>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> file_id = get_template_id('CW7SNMP.cfg', auth.creds, auth.url) >>> assert type(file_id) is str """ object_list = get_cfg_template(auth=auth, url=url) for object in object_list: if object['confFileName'] == te... |
def delete_cfg_template(template_name, auth, url): '''Uses the get_template_id() funct to gather the template_id to craft a url which is sent to the IMC server using a Delete Method :param template_name: str containing the entire contents of the configuration segment :param auth: requests auth object #usually auth.cred... |
of type True :rtype: Boolean >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> delete_cfg_template('CW7SNMP.cfg', auth.creds, auth.url) True >>> get_template_id('CW7SNMP.cfg', auth.creds, auth.url) 'template not found' ''' fil... |
headers=HEADERS) #print (r.status_code) try: if r.status_code == 204: return True except requests.exceptions.RequestException as e: return "Error:\n" + str(e) + " delete_cfg_template: An Error has occured" |
def get_folder_id(folder_name, auth, url): """ Helper function takes str input of folder name and returns str numerical id of the folder. :param folder_name: str name of the folder :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.... |
>>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> default_folder_id = get_folder_id('Default Folder', auth.creds, auth.url) >>> assert type(default_folder_id) is str """ object_list = get_cfg_template(auth=auth, url=url) for object in object_list: if object[... |
def bold(text: str) -> str: ''' Wraps the given text with bold enable/disable ANSI sequences. ''' return (style(text, bold=True, reset=False) + style('', bold=False, reset=False)) |
async def status(cls): ''' Returns the current status of the configured API server. ''' rqst = Request(cls.session, 'GET', '/manager/status') rqst.set_json({ 'status': 'running', }) async with rqst.fetch() as resp: return await resp.json() |
async def freeze(cls, force_kill: bool = False): ''' Freezes the configured API server. Any API clients will no longer be able to create new compute sessions nor create and modify vfolders/keypairs/etc. This is used to enter the maintenance mode of the server for unobtrusive manager and/or agent upgrades. :param force_... |
clients who have running compute session are still able to interact with them though they cannot create new compute sessions. ''' rqst = Request(cls.session, 'PUT', '/manager/status') rqst.set_json({ 'status': 'frozen', 'force_kill': force_kill, }) async with rqst.fetch() as resp: assert resp.status == 204 |
def get_dev_alarms(devId, auth=auth.creds, url=auth.url): """ 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 """ # checks to se... |
+ "&desc=false" f_url = url + get_dev_alarm_url # creates the URL using the payload variable as the contents r = requests.get(f_url, auth=auth, headers=headers) try: if r.status_code == 200: dev_alarm = (json.loads(r.text)) if 'alarm' in dev_alarm: return dev_alarm['alarm'] else: return "Device has no alarms" except re... |
def upload(sess_id_or_alias, files): """ Upload files to user's home folder. \b SESSID: Session ID or its alias given when creating the session. FILES: Path to upload. """ if len(files) < 1: return with Session() as session: try: print_wait('Uploading files...') kernel = session.Kernel(sess_id_or_alias) kernel.upload(f... |
def download(sess_id_or_alias, files, dest): """ Download files from a running container. \b SESSID: Session ID or its alias given when creating the session. FILES: Paths inside container. """ if len(files) < 1: return with Session() as session: try: print_wait('Downloading file(s) from {}...' .format(sess_id_or_alias)... |
def ls(sess_id_or_alias, path): """ List files in a path of a running container. \b SESSID: Session ID or its alias given when creating the session. PATH: Path inside container. """ with Session() as session: try: print_wait('Retrieving list of files in "{}"...'.format(path)) kernel = session.Kernel(sess_id_or_alias) r... |
name', 'size', 'modified', 'mode'] for file in files: mdt = datetime.fromtimestamp(file['mtime']) mtime = mdt.strftime('%b %d %Y %H:%M:%S') row = [file['filename'], file['size'], mtime, file['mode']] table.append(row) print_done('Retrived.') print('Path in container:', result['abspath'], end='') print(tabulate(table, h... |
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( # `demo` directory's absolute path os.path.dirname( # This file's absolute path os.path.abspath(__file__) ) ) ) # If the `src` direct... |
save user setting PYTHONPATH when running this demo. # sys.path.append(src_path) # Import reloader class from aoiklivereload import LiveReloader # Create reloader reloader = LiveReloader() # Start watcher thread reloader.start_watcher_thread() # Server host server_host = '0.0.0.0' # Server port server_port = 8000 # Get... |
sanic_app = Sanic() # Create request handler @sanic_app.route('/') async def hello_handler(request): # pylint: disable=unused-variable """ Request handler. :return: Response body. """ # Return response body return text('hello') # Run server. # # Notice `KeyboardInterrupt` will be caught inside `sanic_app.run`. # sanic_... |
def get_cfg_template(auth, url, folder=None): """ Function takes no input and returns a list of dictionaries containing the configuration templates in the root folder of the icc configuration template library. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IM... |
target folder name :return: List of Dictionaries containing folders and configuration files in the ICC library. :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> config_templates = get_cfg_template(auth.creds, aut... |
'confFileName' in config_templates_folder[0] >>> config_template_no_folder = get_cfg_template(auth.creds, auth.url, folder='Doesnt_Exist') >>> assert config_template_no_folder is None """ if folder is None: get_cfg_template_url = "/imcrs/icc/confFile/list" else: folder_id = get_folder_id(folder, auth, url) get_cfg_temp... |
error: return "Error:\n" + str(error) + " get_cfg_template: An Error has occured" |
def create_cfg_segment(filename, filecontent, description, auth, url): """ Takes a str into var filecontent which represents the entire content of a configuration segment, or partial configuration file. Takes a str into var description which represents the description of the configuration segment :param filename: str c... |
contrianing the description of the configuration segment :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: If successful, Boolena of type True :rtype: Boolean >>> from pyhpeimc.auth import ... |
= create_cfg_segment('CW7SNMP.cfg', filecontent, 'My New Template', auth.creds, auth.url) >>> template_id = get_template_id('CW7SNMP.cfg', auth.creds, auth.url) >>> assert type(template_id) is str >>> """ payload = {"confFileName": filename, "confFileType": "2", "cfgFileParent": "-1", "confFileDesc": description, "cont... |
error: return "Error:\n" + str(error) + " create_cfg_segment: An Error has occured" |
def get_template_id(template_name, auth, url): """ Helper function takes str input of folder name and returns str numerical id of the folder. :param template_name: str name of the target template :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface... |
* >>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> file_id = get_template_id('CW7SNMP.cfg', auth.creds, auth.url) >>> assert type(file_id) is int """ object_list = get_cfg_template(auth=auth, url=url) for template in object_list: if template['confFileName']... |
def get_folder_id(folder_name, auth, url): """ Helper function takes str input of folder name and returns str numerical id of the folder. :param folder_name: str name of the folder :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.... |
>>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> default_folder_id = get_folder_id('Default Folder', auth.creds, auth.url) >>> assert type(default_folder_id) is int """ object_list = get_cfg_template(auth=auth, url=url) for template in object_list: if templ... |
def delete_cfg_template(template_name, auth, url): """Uses the get_template_id() funct to gather the template_id to craft a url which is sent to the IMC server using a Delete Method :param template_name: str containing the entire contents of the configuration segment :param auth: requests auth object #usually auth.cred... |
int of status.code 204. :rtype: Int >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> delete_cfg_template('CW7SNMP.cfg', auth.creds, auth.url) """ file_id = get_template_id(template_name, auth, url) f_url = url + "/imcrs/icc/c... |
+ " delete_cfg_template: An Error has occured" |
def get_template_details(template_name, auth, url): """Uses the get_template_id() funct to gather the template_id to craft a get_template_details_url which is sent to the IMC server using a get Method :param template_name: str containing the entire contents of the configuration segment :param auth: requests auth object... |
dict containing the template details :rtype: dict >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.icc import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> filecontent = 'sample file content' >>> create_new_file = create_cfg_segment('CW7SNMP.cfg', filecontent, 'My New Template', au... |
= url + "/imcrs/icc/confFile/" + str(file_id) response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: template_details = json.loads(response.text) return template_details except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + " get_template_content... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.