code stringlengths 1 18.2k |
|---|
# Output items list outputs=[ # Use the touch node as output target for dirty checking touch_node, # Given output items list outputs, ], # Whether always run always=always, # Task cache key cache_key=cache_key or (python, 'virtualenv'), ) # Return the created task return task |
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 object. :param python: Python program path. :param venv_... |
add to created task. See :paramref:`create_cmd_task.outputs` for allowed item types. :param pip_setup_file: `get-pip.py` file path for `pip_setup` task. :param pip_setup_touch: Touch file path for `pip_setup` task. :param virtualenv_setup_touch: Touch file path for `virtualenv_setup` task. :param task_name: Task name f... |
# Create task that sets up `virtualenv` package virtualenv_setup_task = virtualenv_setup( # Context ctx=ctx, # Python program path python=python, # Touch file path touch=virtualenv_setup_touch, # `get-pip.py` file path for `pip_setup` task. pip_setup_file=pip_setup_file, # Touch file path for `pip_setup` task. pip_setu... |
task that sets up virtual environment. task = create_cmd_task( # Context ctx=ctx, # Command parts parts=[ # Python program path python, # Run module '-m', # Module name 'virtualenv', # Virtual environment directory absolute path venv_path_node.abspath(), ], # Input items list inputs=[ # Run after the task that sets up ... |
outputs=[ # Add the virtual environment's `python` program path as output # target for dirty checking get_python_path(venv_path), # Add the virtual environment's `pip` program path as output target # for dirty checking get_pip_path(venv_path), # Given output items list outputs, ], # Whether always run always=always, # ... |
task |
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 given virtual environment's `pip` to sets up \ packages listed i... |
environment directory relative path relative to top directory. If given, will create the virtual environment and set up packages listed in given requirements file in the virtual environment. If not given, will set up packages listed in given requirements file in given Python program's environment. :param inputs: Input ... |
items list to add to created task. See :paramref:`create_cmd_task.outputs` for allowed item types. :param touch: Touch file path for dirty checking. :param check_import: Whether import module for dirty checking. :param check_import_module: Module name to import for dirty checking. :param pip_setup_file: `get-pip.py` fi... |
Whether always run. :return: Created task. """ # Ensure given context object is BuildContext object _ensure_build_context(ctx) # If virtual environment directory path is not given if venv_path is None: # Use given Python program path venv_python = python # If virtual environment directory path is given else: # Get Pyth... |
input target venv_python = mark_input(venv_python) # If virtual environment directory path is not given, # it means not create virtual environment. if venv_path is None: # Create task that sets up `pip` pip_setup_task = pip_setup( # Context ctx=ctx, # Python program path python=python, # `get-pip.py` file path setup_fi... |
create virtual environment venv_task = None # If virtual environment directory path is given else: # Not create task that sets up `pip` here because `create_venv` # function below will do pip_setup_task = None # Create task that sets up virtual environment venv_task = create_venv( # Context ctx=ctx, # Python program pa... |
# Add the virtual environment's `python` program path as output # target for dirty checking get_python_path(venv_path), # Add the virtual environment's `pip` program path as output # target for dirty checking get_pip_path(venv_path), ], # Whether always run always=always, # Task name task_name='Create venv `{}`'.format... |
for `virtualenv_setup` task virtualenv_setup_touch=virtualenv_setup_touch, ) # If touch file path is not given if not touch: # Not update touch file touch_node = None # If touch file path is given else: # Update touch file touch_node, always = update_touch_file( # Context ctx=ctx, # Touch file path path=touch, # Whethe... |
check_import_module=check_import_module, # Python program path for dirty checking check_import_python=venv_python, # Whether always run always=always, ) # Create task that sets up packages task = create_cmd_task( # Context ctx=ctx, # Command parts parts=[ # Python program path venv_python, # Run module '-m', # Module n... |
target. mark_input(req_path), ], # Input items list inputs=inputs, # Output items list outputs=[ # Use the touch node as output target for dirty checking touch_node, # Given output items list outputs, ], # Whether always run always=always, ) # Chain these tasks to run one after another chain_tasks([ pip_setup_task, ven... |
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', # Remove untracked directories too '-d', # Force to remove '-f', # Give two `-f` flags to... |
# Print the command in multi-line format print_text(_format_multi_line_command(cmd_part_s)) # Create subprocess to run the command in top directory proc = subprocess.Popen(cmd_part_s, cwd=ctx.top_dir) # Wait the subprocess to finish proc.wait() # Print end title print_title('git_clean', is_end=True) |
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_title('Find program') # Get program path from command parts program_path = cmd_part_s[0] # If the pr... |
the file extension. # This is because `Waf`'s `find_binary` function adds each of the # file extensions when finding the program. program_path = program_path[:-4] # Print info print_text('Find program: {0}'.format(program_path)) # try: # Find program found_program_path_s = ctx.find_program(program_path, quiet=True) # I... |
Raise error raise ValueError(msg) # If program paths are found. # If program paths are found. # Use the first program path found. # If program paths are not found. (Should not happen.) # Use given program path. found_program_path = found_program_path_s[0] \ if found_program_path_s else program_path # Use the program pa... |
program: {0}'.format(found_program_path)) # Print end title print_title('Find program', is_end=True) # Print title print_title('PATH') # Print environment variable PATH's value, one part per line print_text('\n'.join(os.environ.get('PATH', '').split(os.pathsep))) # Print end title print_title('PATH', is_end=True) # Pri... |
# Print end title print_title('DIR', is_end=True) # Print title print_title('CMD') # Print the command in multi-line format print_text(_format_multi_line_command(cmd_part_s)) # Print end title print_title('CMD', is_end=True) # Print title print_title('RUN') # Run the command in the working directory exit_code = self.ex... |
the exit code return exit_code |
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 where each element of t... |
list >>> from pyhpeimc.auth import * >>> from pyhpeimc.wsm.acinfo import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> ac_info_all = get_ac_info_all(auth.creds, auth.url) >>> assert type(ac_info_all) is list >>> assert len(ac_info_all[0]) == 12 >>> assert 'hardwareVersion' in ac_info_all... |
>>> assert 'pingStatus' in ac_info_all[0] >>> assert 'serialId' in ac_info_all[0] >>> assert 'softwareVersion' in ac_info_all[0] >>> assert 'status' in ac_info_all[0] >>> assert 'sysName' in ac_info_all[0] >>> assert 'type' in ac_info_all[0] """ get_ac_info_all_url = "/imcrs/wlan/acInfo/queryAcBasicInfo" f_url = url + ... |
200: if len(r.text) > 0: return json.loads(r.text)['acBasicInfo'] except requests.exceptions.RequestException as e: return "Error:\n" + str(e) + " get_ac_info_all: An Error has occured" |
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. :param vlanid: str of VLANId ( valid 1-4094 )... |
devid = self.devid) |
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 ( valid 1-4094 ) :return: """ delete_dev_vla... |
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) |
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.adminstatus = get_interface_details(self.ifIndex, self.auth,... |
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=self.ip) self.adminstatus = get_interface_details(self.ifIndex, self.auth, self.... |
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 of the target host ip record :param desc... |
""" add_scope_ip(hostipaddress, name, description, self.auth, self.url, scopeid=self.id) |
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, self.url) |
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) |
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('.')[-1] == '0': continue if ip not in allocated_ips: return ip |
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 the child scope :param endip: str ... |
child scope :param name: of the owner of the child scope :param description: description of the child scope :return: """ add_child_ip_scope(self.auth, self.url, startip, endip, name, description, self.id) |
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.authclass :param template... |
list """ f_url = url + "/imcrs/plat/res/telnet?start=0&size=10000&desc=false&total=false" response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: telnet_templates = (json.loads(response.text)) template = None if type(telnet_templates['telnetParamTemplate']) is dict: my_templates ... |
return template except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + " get_telnet_templates: An Error has occured" |
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 is the name of the specif... |
201 for proper creation or 404 for failed creation :rtype int Sample of proper KV pairs. Please see documentation for valid values for different fields. telnet_template = {"type": "0", "name": "User_with_Enable", "authType": "4", "userName": "newadmin", "userPassword": "newpassword", "superPassword": "newpassword", "au... |
None: template_name = telnet_template['name'] if template_id is None: telnet_templates = get_telnet_template(auth, url) template_id = None for template in telnet_templates: if template['name'] == template_name: template_id = template['id'] f_url = url + "/imcrs/plat/res/telnet/"+str(template_id)+"/update" response = re... |
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 :param url: base url of IM... |
template_id value :return: int HTTP response code :rtype int """ try: if template_id is None: telnet_templates = get_telnet_template(auth, url) if template_name is None: template_name = telnet_template['name'] template_id = None for template in telnet_templates: if template['name'] == template_name: template_id = templ... |
delete_telnet_template: An Error has occured" |
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 response code 201 for proper creati... |
documentation for valid values for different fields. ssh_template = { "type": "0", "name": "ssh_admin_template", "authType": "3", "authTypeStr": "Password + Super Password", "userName": "admin", "password": "password", "superPassword": "password", "port": "22", "timeout": "10", "retries": "3", "keyFileName": "", "keyPh... |
" create_ssh_template: An Error has occured" |
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 :param template_na... |
list """ f_url = url + "/imcrs/plat/res/ssh?start=0&size=10000&desc=false&total=false" response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: ssh_templates = (json.loads(response.text)) template = None if type(ssh_templates['sshParamTemplate']) is dict: my_templates = [ssh_templ... |
return template except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + " get_ssh_templates: An Error has occured" |
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 of the specific ssh templ... |
201 for proper creation or 404 for failed creation :rtype int Sample of proper KV pairs. Please see documentation for valid values for different fields. ssh_template = { "type": "0", "name": "ssh_admin_template", "authType": "3", "authTypeStr": "Password + Super Password", "userName": "newadmin", "password": "password"... |
if template_id is None: ssh_templates = get_ssh_template(auth, url) template_id = None for template in ssh_templates: if template['name'] == template_name: template_id = template['id'] f_url = url + "/imcrs/plat/res/ssh/"+str(template_id)+"/update" response = requests.put(f_url, data = json.dumps(ssh_template), auth=au... |
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: base url of IMC RS i... |
template_id value :return: int HTTP response code :rtype int """ try: if template_id is None: ssh_templates = get_ssh_template(auth, url) if template_name is None: template_name = ssh_template['name'] template_id = None for template in ssh_templates: if template['name'] == template_name: template_id = template['id'] f_... |
delete_ssh_template: An Error has occured" |
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.authclass :param template_... |
list """ f_url = url + "/imcrs/plat/res/snmp?start=0&size=10000&desc=false&total=false" response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: snmp_templates = (json.loads(response.text)) template = None if type(snmp_templates['snmpParamTemplate']) is dict: my_templates = [snmp_... |
except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + " get_snmp_templates: An Error has occured" |
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 name of the specific ssh te... |
201 for proper creation or 404 for failed creation :rtype int Sample of proper KV pairs. Please see documentation for valid values for different fields. snmp_template = { "version": "2", "name": "new_snmp_template", "type": "0", "paraType": "SNMPv2c", "roCommunity": "newpublic", "rwCommunity": "newprivate", "timeout": ... |
"admin", "accessType": "1", "operatorGroupStr": "" } """ if template_name is None: template_name = snmp_template['name'] if template_id is None: snmp_templates = get_snmp_templates(auth, url) template_id = None for template in snmp_templates: if template['name'] == template_name: template_id = template['id'] f_url = ur... |
Error has occured" |
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 url: base url of IMC RS... |
template_id value :return: int HTTP response code :rtype int """ try: if template_id is None: snmp_templates = get_snmp_templates(auth, url) if template_name is None: template_name = snmp_template['name'] template_id = None for template in snmp_templates: if template['name'] == template_name: template_id = template['id... |
delete_snmp_template: An Error has occured" |
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 :param url: base url ... |
details, with each asset contained in a dictionary :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.netassets import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> single_asset = get_dev_asset_details('10.101.0.1', auth.creds, auth.url) >>> assert type(single_asset) is ... |
url + "/imcrs/netasset/asset?assetDevice.ip=" + str(ipaddress) response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: dev_asset_info = (json.loads(response.text)) if len(dev_asset_info) > 0: dev_asset_info = dev_asset_info['netAsset'] if isinstance(dev_asset_info, dict): dev_ass... |
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 of dictionatires co... |
"8080", "admin", "admin") >>> all_assets = get_dev_asset_details_all( auth.creds, auth.url) >>> assert type(all_assets) is list >>> assert 'asset' in all_assets[0] """ f_url = url + "/imcrs/netasset/asset?start=0&size=15000" response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200:... |
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:.*$}', websocket_handler) app.router.add_route... |
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.auth.authclass :... |
:return: dictionary of device details :rtype: dict >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.device import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> dev_list = get_all_devs( auth.creds, auth.url, network_address= '10.11.') >>> assert type(dev_list) is list >>> assert 'sy... |
= "&label=" + str(label) else: label = '' if category: category = "&category" + category else: category = '' f_url = url + base_url + str(network_address) + str(label) + str(category) + end_url print(f_url) response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: dev_details = (js... |
return dev_details['device'] except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + " get_dev_details: An Error has occured" |
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 interface #usually... |
pyhpeimc.plat.device import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> dev_1 = get_dev_details('10.101.0.221', auth.creds, auth.url) >>> assert type(dev_1) is dict >>> assert 'sysName' in dev_1 >>> dev_2 = get_dev_details('8.8.8.8', auth.creds, auth.url) Device not found >>> assert ty... |
200: dev_details = (json.loads(response.text)) if len(dev_details) == 0: print("Device not found") return "Device not found" elif isinstance(dev_details['device'], list): for i in dev_details['device']: if i['ip'] == ip_address: dev_details = i return dev_details elif isinstance(dev_details['device'], dict): return dev... |
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 object #usually auth.creds from... |
list object which contains a dictionary per interface :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.device import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> dev_interfaces = get_dev_interface(auth.creds, auth.url, devid='15') >>> dev_interfaces = get_dev_interfac... |
+ str(devid) + \ "/interface?start=0&size=1000&desc=false&total=false" f_url = url + get_dev_interface_url response = requests.get(f_url, auth=auth, headers=HEADERS) try: if response.status_code == 200: int_list = json.loads(response.text) if 'interface' in int_list: return int_list['interface'] else: return [] except ... |
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 :param auth: requests auth obje... |
from pyhpeimc.auth.authclass :return: list of dict objects which contain the mac learn table of target device id :rtype: list >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.device import * >>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin") >>> dev_mac_learn = get_dev_mac_learn( auth.creds, ... |
is not None: devid = get_dev_details(devip, auth, url)['id'] f_url = url + '/imcrs/res/access/ipMacLearn/' + str(devid) try: response = requests.get(f_url, auth=auth, headers=HEADERS) if response.status_code == 200: if len(json.loads(response.text)) < 1: mac_learn_query = [] return mac_learn_query else: mac_learn_query... |
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 target device :param c... |
pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :param devip: str of ipv4 address of the target device :return: str containing the response of the commands >>> from pyhpeimc.auth import * >>> from pyhpeimc.plat.device import * >>> auth = IMCAuth("http://", "10... |
cmd_output = run_dev_cmd( cmd_list, auth.creds, auth.url, devip='10.101.0.221') >>> assert type(cmd_output) is dict >>> assert 'cmdlist' in cmd_output >>> assert 'success' in cmd_output """ if devip is not None: devid = get_dev_details(devip, auth, url)['id'] run_dev_cmd_url = '/imcrs/icc/confFile/executeCmd' f_url = u... |
} }''' try: response = requests.post(f_url, data=payload, auth=auth, headers=HEADERS) if response.status_code == 200: if len(response.text) < 1: return '' else: return json.loads(response.text) except requests.exceptions.RequestException as error: return "Error:\n" + str(error) + " run_dev_cmd: An Error has occured" |
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. :param auth: reque... |
RS interface #usually auth.url from pyhpeimc.auth.authclass :param devid: int or str value of the devId of the target device :param devip: ipv4 address of the target device :return: list of dict objects which contains the details of all interfaces on the target device :retype: list >>> from pyhpeimc.auth import * >>> f... |
all_interface_details = get_all_interface_details( auth.creds, auth.url, devId='10') >>> all_interface_details = get_all_interface_details( auth.creds, auth.url, devip='10.101.0.221') >>> assert type(all_interface_details) is list >>> assert 'ifAlias' in all_interface_details[0] """ if devip is not None: devid = get_de... |
as error: return "Error:\n" + str(error) + " get_all_interface_details: An Error has occured" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.