Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def decode_eventdata(sensor_type, offset, eventdata, sdr): if sensor_type == 5 and offset == 4: # link loss, indicates which port return 'Port {0}'.format(eventdata[1]) elif sensor_type == 8 and offset == 6: # PSU cfg error errtype = eventdata[...
[ "Decode extra event data from an alert or log\n\n Provide a textual summary of eventdata per descriptions in\n Table 42-3 of the specification. This is for sensor specific\n offset events only.\n\n :param sensor_type: The sensor type number from the event\n :param offset: Sensor specific offset\n ...
Please provide a description of the function:def fetch_sel(self, ipmicmd, clear=False): records = [] # First we do a fetch all without reservation, reducing the risk # of having a long lived reservation that gets canceled in the middle endat = self._fetch_entries(ipmicmd, 0, rec...
[ "Fetch SEL entries\n\n Return an iterable of SEL entries. If clearing is requested,\n the fetch and clear will be done as an atomic operation, assuring\n no entries are dropped.\n\n :param ipmicmd: The Command object to use to interrogate\n :param clear: Whether to clear the entries upon retriev...
Please provide a description of the function:def oem_init(self): if self._oemknown: return self._oem, self._oemknown = get_oem_handler(self._get_device_id(), self)
[ "Initialize the command object for OEM capabilities\n\n A number of capabilities are either totally OEM defined or\n else augmented somehow by knowledge of the OEM. This\n method does an interrogation to identify the OEM.\n\n " ]
Please provide a description of the function:def get_bootdev(self): response = self.raw_command(netfn=0, command=9, data=(5, 0, 0)) # interpret response per 'get system boot options' if 'error' in response: raise exc.IpmiException(response['error']) # this should onl...
[ "Get current boot device override information.\n\n Provides the current requested boot device. Be aware that not all IPMI\n devices support this. Even in BMCs that claim to, occasionally the\n BIOS or UEFI fail to honor it. This is usually only applicable to the\n next reboot.\n\n ...
Please provide a description of the function:def set_power(self, powerstate, wait=False): if powerstate not in power_states: raise exc.InvalidParameterValue( "Unknown power state %s requested" % powerstate) newpowerstate = powerstate response = self.raw_comma...
[ "Request power state change (helper)\n\n :param powerstate:\n * on -- Request system turn on\n * off -- Request system turn off without waiting\n for OS to shutdown\n * shutdown -- Have system...
Please provide a description of the function:def reset_bmc(self): response = self.raw_command(netfn=6, command=2) if 'error' in response: raise exc.IpmiException(response['error'])
[ "Do a cold reset in BMC\n " ]
Please provide a description of the function:def set_bootdev(self, bootdev, persist=False, uefiboot=False): if bootdev not in boot_devices: return {'error': "Unknown bootdevice %s requested" % bootdev} bootdevnum = boot_dev...
[ "Set boot device to use on next reboot (helper)\n\n :param bootdev:\n *network -- Request network boot\n *hd -- Boot from hard drive\n *safe -- Boot from hard drive, requesting 'safe mode'\n *optical -- boot from CD/D...
Please provide a description of the function:def xraw_command(self, netfn, command, bridge_request=(), data=(), delay_xmit=None, retry=True, timeout=None): rsp = self.ipmi_session.raw_command(netfn=netfn, command=command, bridge_request=b...
[ "Send raw ipmi command to BMC, raising exception on error\n\n This is identical to raw_command, except it raises exceptions\n on IPMI errors and returns data as a buffer. This is the recommend\n function to use. The response['data'] being a buffer allows\n traditional indexed access as...
Please provide a description of the function:def raw_command(self, netfn, command, bridge_request=(), data=(), delay_xmit=None, retry=True, timeout=None): rsp = self.ipmi_session.raw_command(netfn=netfn, command=command, bridge_request=bri...
[ "Send raw ipmi command to BMC\n\n This allows arbitrary IPMI bytes to be issued. This is commonly used\n for certain vendor specific commands.\n\n Example: ipmicmd.raw_command(netfn=0,command=4,data=(5))\n\n :param netfn: Net function number\n :param command: Command value\n ...
Please provide a description of the function:def get_power(self): response = self.raw_command(netfn=0, command=1) if 'error' in response: raise exc.IpmiException(response['error']) assert (response['command'] == 1 and response['netfn'] == 1) powerstate = 'on' if (res...
[ "Get current power state of the managed system\n\n The response, if successful, should contain 'powerstate' key and\n either 'on' or 'off' to indicate current state.\n\n :returns: dict -- {'powerstate': value}\n " ]
Please provide a description of the function:def set_identify(self, on=True, duration=None): self.oem_init() try: self._oem.set_identify(on, duration) return except exc.UnsupportedFunctionality: pass if duration is not None: durati...
[ "Request identify light\n\n Request the identify light to turn off, on for a duration,\n or on indefinitely. Other than error exceptions,\n\n :param on: Set to True to force on or False to force off\n :param duration: Set if wanting to request turn on for a duration\n ...
Please provide a description of the function:def init_sdr(self): # For now, return current sdr if it exists and still connected # future, check SDR timestamp for continued relevance # further future, optionally support a cache directory/file # to store cached copies for given de...
[ "Initialize SDR\n\n Do the appropriate action to have a relevant sensor description\n repository for the current management controller\n " ]
Please provide a description of the function:def get_event_log(self, clear=False): self.oem_init() return sel.EventHandler(self.init_sdr(), self).fetch_sel(self, clear)
[ "Retrieve the log of events, optionally clearing\n\n The contents of the SEL are returned as an iterable. Timestamps\n are given as local time, ISO 8601 (whether the target has an accurate\n clock or not). Timestamps may be omitted for events that cannot be\n given a timestamp, leaving...
Please provide a description of the function:def decode_pet(self, specifictrap, petdata): self.oem_init() return sel.EventHandler(self.init_sdr(), self).decode_pet(specifictrap, petdata)
[ "Decode PET to an event\n\n In IPMI, the alert format are PET alerts. It is a particular set of\n data put into an SNMPv1 trap and sent. It bears no small resemblence\n to the SEL entries. This function takes data that would have been\n received by an SNMP trap handler, and provides an...
Please provide a description of the function:def get_inventory_descriptions(self): yield "System" self.init_sdr() for fruid in sorted(self._sdr.fru): yield self._sdr.fru[fruid].fru_name self.oem_init() for compname in self._oem.get_oem_inventory_descriptions(...
[ "Retrieve list of things that could be inventoried\n\n This permits a caller to examine the available items\n without actually causing the inventory data to be gathered. It\n returns an iterable of string descriptions\n " ]
Please provide a description of the function:def get_inventory_of_component(self, component): self.oem_init() if component == 'System': return self._get_zero_fru() self.init_sdr() for fruid in self._sdr.fru: if self._sdr.fru[fruid].fru_name == component: ...
[ "Retrieve inventory of a component\n\n Retrieve detailed inventory information for only the requested\n component.\n " ]
Please provide a description of the function:def get_inventory(self): self.oem_init() yield ("System", self._get_zero_fru()) self.init_sdr() for fruid in sorted(self._sdr.fru): fruinf = fru.FRU( ipmicmd=self, fruid=fruid, sdr=self._sdr.fru[fruid]).inf...
[ "Retrieve inventory of system\n\n Retrieve inventory of the targeted system. This frequently includes\n serial numbers, sometimes hardware addresses, sometimes memory modules\n This function will retrieve whatever the underlying platform provides\n and apply some structure. Iterating o...
Please provide a description of the function:def get_health(self): summary = {'badreadings': [], 'health': const.Health.Ok} fallbackreadings = [] try: self.oem_init() fallbackreadings = self._oem.get_health(summary) for reading in self.get_sensor_data...
[ "Summarize health of managed system\n\n This provides a summary of the health of the managed system.\n It additionally provides an iterable list of reasons for\n warning, critical, or failed assessments.\n " ]
Please provide a description of the function:def get_sensor_reading(self, sensorname): self.init_sdr() for sensor in self._sdr.get_sensor_numbers(): if self._sdr.sensors[sensor].name == sensorname: rsp = self.raw_command(command=0x2d, netfn=4, data=(sensor,)) ...
[ "Get a sensor reading by name\n\n Returns a single decoded sensor reading per the name\n passed in\n\n :param sensorname: Name of the desired sensor\n :returns: sdr.SensorReading object\n " ]
Please provide a description of the function:def _fetch_lancfg_param(self, channel, param, prefixlen=False): fetchcmd = bytearray((channel, param, 0, 0)) fetched = self.xraw_command(0xc, 2, data=fetchcmd) fetchdata = fetched['data'] if ord(fetchdata[0]) != 17: return...
[ "Internal helper for fetching lan cfg parameters\n\n If the parameter revison != 0x11, bail. Further, if 4 bytes, return\n string with ipv4. If 6 bytes, colon delimited hex (mac address). If\n one byte, return the int value\n " ]
Please provide a description of the function:def set_net_configuration(self, ipv4_address=None, ipv4_configuration=None, ipv4_gateway=None, channel=None): if channel is None: channel = self.get_network_channel() if ipv4_configuration is not None: ...
[ "Set network configuration data.\n\n Apply desired network configuration data, leaving unspecified\n parameters alone.\n\n :param ipv4_address: CIDR notation for IP address and netmask\n Example: '192.168.0.10/16'\n :param ipv4_configuration: Method to use to co...
Please provide a description of the function:def get_net_configuration(self, channel=None, gateway_macs=True): if channel is None: channel = self.get_network_channel() retdata = {} v4addr = self._fetch_lancfg_param(channel, 3) if v4addr is None: retdata['...
[ "Get network configuration data\n\n Retrieve network configuration from the target\n\n :param channel: Channel to configure, defaults to None for 'autodetect'\n :param gateway_macs: Whether to retrieve mac addresses for gateways\n :returns: A dictionary of network configuration data\n ...
Please provide a description of the function:def get_sensor_data(self): self.init_sdr() for sensor in self._sdr.get_sensor_numbers(): rsp = self.raw_command(command=0x2d, netfn=4, data=(sensor,)) if 'error' in rsp: if rsp['code'] == 203: # Sensor does no...
[ "Get sensor reading objects\n\n Iterates sensor reading objects pertaining to the currently\n managed BMC.\n\n :returns: Iterator of sdr.SensorReading objects\n " ]
Please provide a description of the function:def get_sensor_descriptions(self): self.init_sdr() for sensor in self._sdr.get_sensor_numbers(): yield {'name': self._sdr.sensors[sensor].name, 'type': self._sdr.sensors[sensor].sensor_type} self.oem_init() ...
[ "Get available sensor names\n\n Iterates over the available sensor descriptions\n\n :returns: Iterator of dicts describing each sensor\n " ]
Please provide a description of the function:def get_network_channel(self): if self._netchannel is None: for channel in chain((0xe,), range(1, 0xc)): try: rsp = self.xraw_command( netfn=6, command=0x42, data=(channel,)) ...
[ "Get a reasonable 'default' network channel.\n\n When configuring/examining network configuration, it's desirable to\n find the correct channel. Here we run with the 'real' number of the\n current channel if it is a LAN channel, otherwise it evaluates\n all of the channels to find the f...
Please provide a description of the function:def get_alert_destination_count(self, channel=None): if channel is None: channel = self.get_network_channel() rqdata = (channel, 0x11, 0, 0) rsp = self.xraw_command(netfn=0xc, command=2, data=rqdata) return ord(rsp['data']...
[ "Get the number of supported alert destinations\n\n :param channel: Channel for alerts to be examined, defaults to current\n " ]
Please provide a description of the function:def get_alert_destination(self, destination=0, channel=None): destinfo = {} if channel is None: channel = self.get_network_channel() rqdata = (channel, 18, destination, 0) rsp = self.xraw_command(netfn=0xc, command=2, data...
[ "Get alert destination\n\n Get a specified alert destination. Returns a dictionary of relevant\n configuration. The following keys may be present:\n acknowledge_required - Indicates whether the target expects an\n acknowledgement\n acknowledge_timeout - Ho...
Please provide a description of the function:def clear_alert_destination(self, destination=0, channel=None): if channel is None: channel = self.get_network_channel() self.set_alert_destination( '0.0.0.0', False, 0, 0, destination, channel)
[ "Clear an alert destination\n\n Remove the specified alert destination configuration.\n\n :param destination: The destination to clear (defaults to 0)\n " ]
Please provide a description of the function:def set_alert_community(self, community, channel=None): if channel is None: channel = self.get_network_channel() community = community.encode('utf-8') community += b'\x00' * (18 - len(community)) cmddata = bytearray((chann...
[ "Set the community string for alerts\n\n This configures the string the BMC will use as the community string\n for PET alerts/traps.\n\n :param community: The community string\n :param channel: The LAN channel (defaults to auto detect)\n " ]
Please provide a description of the function:def _assure_alert_policy(self, channel, destination): # First we do a get PEF configuration parameters to get the count # of entries. We have no guarantee that the meaningful data will # be contiguous rsp = self.xraw_command(netfn=4,...
[ "Make sure an alert policy exists\n\n Each policy will be a dict with the following keys:\n -'index' - The policy index number\n :returns: An iterable of currently configured alert policies\n " ]
Please provide a description of the function:def get_alert_community(self, channel=None): if channel is None: channel = self.get_network_channel() rsp = self.xraw_command(netfn=0xc, command=2, data=(channel, 16, 0, 0)) return rsp['data'][1:].partition('\x00')[0]
[ "Get the current community string for alerts\n\n Returns the community string that will be in SNMP traps from this\n BMC\n\n :param channel: The channel to get configuration for, autodetect by\n default\n :returns: The community string\n " ]
Please provide a description of the function:def set_alert_destination(self, ip=None, acknowledge_required=None, acknowledge_timeout=None, retries=None, destination=0, channel=None): if channel is None: channel = self.get_network_c...
[ "Configure one or more parameters of an alert destination\n\n If any parameter is 'None' (default), that parameter is left unchanged.\n Otherwise, all given parameters are set by this command.\n\n :param ip: IP address of the destination. It is currently expected\n that the c...
Please provide a description of the function:def get_hostname(self): self.oem_init() try: return self._oem.get_hostname() except exc.UnsupportedFunctionality: # Use the DCMI MCI field as a fallback, since it's the closest # thing in the IPMI Spec for ...
[ "Get the hostname used by the BMC in various contexts\n\n This can vary somewhat in interpretation, but generally speaking\n this should be the name that shows up on UIs and in DHCP requests and\n DNS registration requests, as applicable.\n\n :return: current hostname\n " ]
Please provide a description of the function:def set_hostname(self, hostname): self.oem_init() try: return self._oem.set_hostname(hostname) except exc.UnsupportedFunctionality: return self.set_mci(hostname)
[ "Set the hostname to be used by the BMC in various contexts.\n\n See get_hostname for details\n\n :param hostname: The hostname to set\n :return: Nothing\n " ]
Please provide a description of the function:def set_channel_access(self, channel=None, access_update_mode='non_volatile', alerting=False, per_msg_auth=False, user_level_auth=False, access_mode='always', privileg...
[ "Set channel access\n\n :param channel: number [1:7]\n\n :param access_update_mode:\n dont_change = don't set or change Channel Access\n non_volatile = set non-volatile Channel Access\n volatile = set volatile (active) setting of Channel Access\n\n :param a...
Please provide a description of the function:def get_channel_access(self, channel=None, read_mode='volatile'): if channel is None: channel = self.get_network_channel() data = [] data.append(channel & 0b00001111) b = 0 read_modes = { 'non_volatile'...
[ "Get channel access\n\n :param channel: number [1:7]\n :param read_mode:\n non_volatile = get non-volatile Channel Access\n volatile = get present volatile (active) setting of Channel Access\n\n :return: A Python dict with the following keys/values:\n {\n ...
Please provide a description of the function:def get_channel_info(self, channel=None): if channel is None: channel = self.get_network_channel() data = [] data.append(channel & 0b00001111) response = self.raw_command(netfn=0x06, command=0x42, data=data) if 'er...
[ "Get channel info\n\n :param channel: number [1:7]\n\n :return:\n session_support:\n no_session: channel is session-less\n single: channel is single-session\n multi: channel is multi-session\n auto: channel is session-based (channel could alternate be...
Please provide a description of the function:def set_user_access(self, uid, channel=None, callback=False, link_auth=True, ipmi_msg=True, privilege_level='user'): if channel is None: channel = self.get_network_channel() b = 0b10000000 if callback: ...
[ "Set user access\n\n :param uid: user number [1:16]\n\n :param channel: number [1:7]\n\n :parm callback: User Restricted to Callback\n False = User Privilege Limit is determined by the User Privilege Limit\n parameter, below, for both callback and non-callback connections.\n ...
Please provide a description of the function:def get_user_access(self, uid, channel=None): # user access available during call-in or callback direct connection if channel is None: channel = self.get_network_channel() data = [channel, uid] response = self.raw_command(...
[ "Get user access\n\n :param uid: user number [1:16]\n :param channel: number [1:7]\n\n :return:\n channel_info:\n max_user_count = maximum number of user IDs on this channel\n enabled_users = count of User ID slots presently in use\n users_with_fixed_name...
Please provide a description of the function:def set_user_name(self, uid, name): data = [uid] if len(name) > 16: raise Exception('name must be less than or = 16 chars') name = name.ljust(16, "\x00") data.extend([ord(x) for x in name]) self.xraw_command(netfn=...
[ "Set user name\n\n :param uid: user number [1:16]\n :param name: username (limit of 16bytes)\n " ]
Please provide a description of the function:def get_user_name(self, uid, return_none_on_error=True): response = self.raw_command(netfn=0x06, command=0x46, data=(uid,)) if 'error' in response: if return_none_on_error: return None raise Exception(response[...
[ "Get user name\n\n :param uid: user number [1:16]\n :param return_none_on_error: return None on error\n TODO: investigate return code on error\n " ]
Please provide a description of the function:def set_user_password(self, uid, mode='set_password', password=None): mode_mask = { 'disable': 0, 'enable': 1, 'set_password': 2, 'test_password': 3 } data = [uid, mode_mask[mode]] if pa...
[ "Set user password and (modes)\n\n :param uid: id number of user. see: get_names_uid()['name']\n\n :param mode:\n disable = disable user connections\n enable = enable user connections\n set_password = set or ensure password\n test_password = t...
Please provide a description of the function:def get_channel_max_user_count(self, channel=None): if channel is None: channel = self.get_network_channel() access = self.get_user_access(channel=channel, uid=1) return access['channel_info']['max_user_count']
[ "Get max users in channel (helper)\n\n :param channel: number [1:7]\n :return: int -- often 16\n " ]
Please provide a description of the function:def get_user(self, uid, channel=None): if channel is None: channel = self.get_network_channel() name = self.get_user_name(uid) access = self.get_user_access(uid, channel) data = {'name': name, 'uid': uid, 'channel': channe...
[ "Get user (helper)\n\n :param uid: user number [1:16]\n :param channel: number [1:7]\n\n :return:\n name: (str)\n uid: (int)\n channel: (int)\n access:\n callback (bool)\n link_auth (bool)\n ipmi_msg (bool)...
Please provide a description of the function:def get_name_uids(self, name, channel=None): if channel is None: channel = self.get_network_channel() uid_list = [] max_ids = self.get_channel_max_user_count(channel) for uid in range(1, max_ids): if name == se...
[ "get list of users (helper)\n\n :param channel: number [1:7]\n\n :return: list of users\n " ]
Please provide a description of the function:def get_users(self, channel=None): if channel is None: channel = self.get_network_channel() names = {} max_ids = self.get_channel_max_user_count(channel) for uid in range(1, max_ids + 1): name = self.get_user_n...
[ "get list of users and channel access information (helper)\n\n :param channel: number [1:7]\n\n :return:\n name: (str)\n uid: (int)\n channel: (int)\n access:\n callback (bool)\n link_auth (bool)\n ipmi_msg (bool)...
Please provide a description of the function:def create_user(self, uid, name, password, channel=None, callback=False, link_auth=True, ipmi_msg=True, privilege_level='user'): # current user might be trying to update.. dont disable # set_user_password(uid, ...
[ "create/ensure a user is created with provided settings (helper)\n\n :param privilege_level:\n User Privilege Limit. (Determines the maximum privilege level that\n the user is allowed to switch to on the specified channel.)\n * callback\n * user\n * oper...
Please provide a description of the function:def user_delete(self, uid, channel=None): # TODO(jjohnson2): Provide OEM extensibility to cover user deletion if channel is None: channel = self.get_network_channel() self.set_user_password(uid, mode='disable', password=None) ...
[ "Delete user (helper)\n\n Note that in IPMI, user 'deletion' isn't a concept. This function\n will make a best effort to provide the expected result (e.g.\n web interfaces skipping names and ipmitool skipping as well.\n\n :param uid: user number [1:16]\n :param channel: number [1...
Please provide a description of the function:def get_firmware(self, components=()): self.oem_init() mcinfo = self.xraw_command(netfn=6, command=1) bmcver = '{0}.{1}'.format( ord(mcinfo['data'][2]), hex(ord(mcinfo['data'][3]))[2:]) return self._oem.get_oem_firmware(bm...
[ "Retrieve OEM Firmware information\n " ]
Please provide a description of the function:def update_firmware(self, file, data=None, progress=None, bank=None): self.oem_init() if progress is None: progress = lambda x: True return self._oem.update_firmware(file, data, progress, bank)
[ "Send file to BMC to perform firmware update\n\n :param filename: The filename to upload to the target BMC\n :param data: The payload of the firmware. Default is to read from\n specified filename.\n :param progress: A callback that will be given a dict describing\n ...
Please provide a description of the function:def attach_remote_media(self, url, username=None, password=None): self.oem_init() return self._oem.attach_remote_media(url, username, password)
[ "Attach remote media by url\n\n Given a url, attach remote media (cd/usb image) to the target system.\n\n :param url: URL to indicate where to find image (protocol support\n varies by BMC)\n :param username: Username for endpoint to use when accessing the URL.\n ...
Please provide a description of the function:def upload_media(self, filename, progress=None): self.oem_init() return self._oem.upload_media(filename, progress)
[ "Upload a file to be hosted on the target BMC\n\n This will upload the specified data to\n the BMC so that it will make it available to the system as an emulated\n USB device.\n\n :param filename: The filename to use, the basename of the parameter\n will be given ...
Please provide a description of the function:def process_event(self, event, ipmicmd, seldata): event['oem_handler'] = None evdata = event['event_data_bytes'] if evdata[0] & 0b11000000 == 0b10000000: event['oem_byte2'] = evdata[1] if evdata[0] & 0b110000 == 0b100000: ...
[ "Modify an event according with OEM understanding.\n\n Given an event, allow an OEM module to augment it. For example,\n event data fields can have OEM bytes. Other times an OEM may wish\n to apply some transform to some field to suit their conventions.\n " ]
Please provide a description of the function:def _got_session(self, response): if 'error' in response: self._print_error(response['error']) return if not self.ipmi_session: self.callgotsession = response return # Send activate sol payload ...
[ "Private function to navigate SOL payload activation\n " ]
Please provide a description of the function:def _got_cons_input(self, handle): self._addpendingdata(handle.read()) if not self.awaitingack: self._sendpendingoutput()
[ "Callback for handle events detected by ipmi session\n " ]
Please provide a description of the function:def close(self): if self.ipmi_session: self.ipmi_session.unregister_keepalive(self.keepaliveid) if self.activated: try: self.ipmi_session.raw_command(netfn=6, command=0x49, ...
[ "Shut down an SOL session,\n " ]
Please provide a description of the function:def _got_sol_payload(self, payload): # TODO(jbjohnso) test cases to throw some likely scenarios at functions # for example, retry with new data, retry with no new data # retry with unexpected sequence number if type(payload) == dict: ...
[ "SOL payload callback\n " ]
Please provide a description of the function:def is_fpc(self): if self.has_imm or self.has_xcc: return None if self._fpc_variant is not None: return self._fpc_variant fpc_ids = ((19046, 32, 1063), (20301, 32, 462)) smm_id = (19046, 32, 1180) curri...
[ "True if the target is a Lenovo nextscale fan power controller\n " ]
Please provide a description of the function:def has_tsm(self): if (self.oemid['manufacturer_id'] == 19046 and self.oemid['device_id'] == 32): try: self.ipmicmd.xraw_command(netfn=0x3a, command=0xf) except pygexc.IpmiException as ie: ...
[ "True if this particular server have a TSM based service processor\n " ]
Please provide a description of the function:def set_oem_capping_enabled(self, enable): # 1 - Enable power capping(default) if enable: statecode = 1 # 0 - Disable power capping else: statecode = 0 if self.has_tsm: self.ipmicmd.xraw_com...
[ "Set PSU based power capping\n\n :param enable: True for enable and False for disable\n " ]
Please provide a description of the function:def decode_wireformat_uuid(rawguid): if isinstance(rawguid, list): rawguid = bytearray(rawguid) lebytes = struct.unpack_from('<IHH', buffer(rawguid[:8])) bebytes = struct.unpack_from('>HHI', buffer(rawguid[8:])) return '{0:08X}-{1:04X}-{2:04X}-{3...
[ "Decode a wire format UUID\n\n It handles the rather particular scheme where half is little endian\n and half is big endian. It returns a string like dmidecode would output.\n " ]
Please provide a description of the function:def urlsplit(url): proto, rest = url.split(':', 1) host = '' if rest[:2] == '//': host, rest = rest[2:].split('/', 1) rest = '/' + rest return proto, host, rest
[ "Split an arbitrary url into protocol, host, rest\n\n The standard urlsplit does not want to provide 'netloc' for arbitrary\n protocols, this works around that.\n\n :param url: The url to split into component parts\n " ]
Please provide a description of the function:def get_ipv4(hostname): addrinfo = socket.getaddrinfo(hostname, None, socket.AF_INET, socket.SOCK_STREAM) return [addrinfo[x][4][0] for x in range(len(addrinfo))]
[ "Get list of ipv4 addresses for hostname\n\n " ]
Please provide a description of the function:def _aespad(data): currlen = len(data) + 1 # need to count the pad length field as well neededpad = currlen % 16 if neededpad: # if it happens to be zero, hurray, but otherwise invert the # sense of the padding neededpad = 16 - neededpad ...
[ "ipmi demands a certain pad scheme,\n per table 13-20 AES-CBC encrypted payload fields.\n " ]
Please provide a description of the function:def _make_bridge_request_msg(self, channel, netfn, command): head = bytearray((constants.IPMI_BMC_ADDRESS, constants.netfn_codes['application'] << 2)) check_sum = _checksum(*head) # NOTE(fengqian): according IPMI Fig...
[ "This function generate message for bridge request. It is a\n part of ipmi payload.\n " ]
Please provide a description of the function:def _add_request_entry(self, entry=()): if not self._lookup_request_entry(entry): self.request_entry.append(entry)
[ "This function record the request with netfn, sequence number and\n command, which will be used in parse_ipmi_payload.\n :param entry: a set of netfn, sequence number and command.\n " ]
Please provide a description of the function:def _make_ipmi_payload(self, netfn, command, bridge_request=None, data=()): bridge_msg = [] self.expectedcmd = command # in ipmi, the response netfn is always one self.expectednetfn = netfn + 1 # higher than the request payloa...
[ "This function generates the core ipmi payload that would be\n applicable for any channel (including KCS)\n " ]
Please provide a description of the function:def send_payload(self, payload=(), payload_type=None, retry=True, delay_xmit=None, needskeepalive=False, timeout=None): if payload and self.lastpayload: # we already have a packet outgoing, make this # a pending p...
[ "Send payload over the IPMI Session\n\n :param needskeepalive: If the payload is expected not to count as\n 'active' by the BMC, set this to True\n to avoid Session considering the\n job done because of this payload.\n ...
Please provide a description of the function:def wait_for_rsp(cls, timeout=None, callout=True): global iosockets # Assume: # Instance A sends request to packet B # Then Instance C sends request to BMC D # BMC D was faster, so data comes back before BMC B # Instan...
[ "IPMI Session Event loop iteration\n\n This watches for any activity on IPMI handles and handles registered\n by register_handle_callback. Callers are satisfied in the order that\n packets return from network, not in the order of calling.\n\n :param timeout: Maximum time to wait for dat...
Please provide a description of the function:def register_keepalive(self, cmd, callback): regid = random.random() if self._customkeepalives is None: self._customkeepalives = {regid: (cmd, callback)} else: while regid in self._customkeepalives: reg...
[ "Register custom keepalive IPMI command\n\n This is mostly intended for use by the console code.\n calling code would have an easier time just scheduling in their\n own threading scheme. Such a behavior would naturally cause\n the default keepalive to not occur anyway if the calling co...
Please provide a description of the function:def _keepalive(self): try: keptalive = False if self._customkeepalives: kaids = list(self._customkeepalives.keys()) for keepalive in kaids: try: cmd, callback...
[ "Performs a keepalive to avoid idle disconnect\n " ]
Please provide a description of the function:def download(self, url, file): if isinstance(file, str) or isinstance(file, unicode): file = open(file, 'wb') webclient = self.dupe() webclient.request('GET', url) rsp = webclient.getresponse() self._currdl = rsp ...
[ "Download a file to filename or file object\n\n " ]
Please provide a description of the function:def upload(self, url, filename, data=None, formname=None, otherfields=()): if data is None: data = open(filename, 'rb') self._upbuffer = StringIO.StringIO(get_upload_form(filename, data, ...
[ "Upload a file to the url\n\n :param url:\n :param filename: The name of the file\n :param data: A file object or data to use rather than reading from\n the file.\n :return:\n " ]
Please provide a description of the function:def simplestring(self): repr = self.name + ": " if self.value is not None: repr += str(self.value) repr += " ± " + str(self.imprecision) repr += self.units for state in self.states: repr += stat...
[ "Return a summary string of the reading.\n\n This is intended as a sampling of how the data could be presented by\n a UI. It's intended to help a developer understand the relation\n between the attributes of a sensor reading if it is not quite clear\n " ]
Please provide a description of the function:def parse_inventory_category(name, info, countable=True): raw = info["data"][1:] cur = 0 if countable: count = struct.unpack("B", raw[cur])[0] cur += 1 else: count = 0 discarded = 0 entries = [] while cur < len(raw):...
[ "Parses every entry in an inventory category (CPU, memory, PCI, drives,\n etc).\n\n Expects the first byte to be a count of the number of entries, followed\n by a list of elements to be parsed by a dedicated parser (below).\n\n :param name: the name of the parameter (e.g.: \"cpu\")\n :param info: a l...
Please provide a description of the function:def parse_inventory_category_entry(raw, fields): r = raw obj = {} bytes_read = 0 discard = False for field in fields: value = struct.unpack_from(field.fmt, r)[0] read = struct.calcsize(field.fmt) bytes_read += read r ...
[ "Parses one entry in an inventory category.\n\n :param raw: the raw data to the entry. May contain more than one entry,\n only one entry will be read in that case.\n :param fields: an iterable of EntryField objects to be used for parsing the\n entry.\n\n :returns: dict -- a...
Please provide a description of the function:def sessionless_data(self, data, sockaddr): if len(data) < 22: return data = bytearray(data) if not (data[0] == 6 and data[2:4] == b'\xff\x07'): # not ipmi return if data[4] == 6: # ipmi 2 payload... ...
[ "Examines unsolocited packet and decides appropriate action.\n\n For a listening IpmiServer, a packet without an active session\n comes here for examination. If it is something that is utterly\n sessionless (e.g. get channel authentication), send the appropriate\n response. If it is a ...
Please provide a description of the function:def set_kg(self, kg): try: self.kg = kg.encode('utf-8') except AttributeError: self.kg = kg
[ "Sets the Kg for the BMC to use\n\n In RAKP, Kg is a BMC-specific integrity key that can be set. If not\n set, Kuid is used for the integrity key\n " ]
Please provide a description of the function:def source_debianize_name(name): "make name acceptable as a Debian source package name" name = name.replace('_','-') name = name.replace('.','-') name = name.lower() return name
[]
Please provide a description of the function:def get_date_822(): cmd = '/bin/date' if not os.path.exists(cmd): raise ValueError('%s command does not exist.'%cmd) args = [cmd,'-R'] result = get_cmd_stdout(args).strip() result = normstr(result) return result
[ "return output of 822-date command" ]
Please provide a description of the function:def get_deb_depends_from_setuptools_requires(requirements, on_failure="warn"): assert on_failure in ("raise", "warn", "guess"), on_failure import pkg_resources depends = [] # This will be the return value from this function. parsed_reqs=[] for ex...
[ "\n Suppose you can't confidently figure out a .deb which satisfies a given\n requirement. If on_failure == 'warn', then log a warning. If on_failure\n == 'raise' then raise CantSatisfyRequirement exception. If on_failure ==\n 'guess' then guess that python-$FOO will satisfy the dependency and that\n...
Please provide a description of the function:def make_tarball(tarball_fname,directory,cwd=None): "create a tarball from a directory" if tarball_fname.endswith('.gz'): opts = 'czf' else: opts = 'cf' args = ['/bin/tar',opts,tarball_fname,directory] process_command(args, cwd=cwd)
[]
Please provide a description of the function:def expand_tarball(tarball_fname,cwd=None): "expand a tarball" if tarball_fname.endswith('.gz'): opts = 'xzf' elif tarball_fname.endswith('.bz2'): opts = 'xjf' else: opts = 'xf' args = ['/bin/tar',opts,tarball_fname] process_command(args, cwd=cwd)
[]
Please provide a description of the function:def expand_zip(zip_fname,cwd=None): "expand a zip" unzip_path = '/usr/bin/unzip' if not os.path.exists(unzip_path): log.error('ERROR: {} does not exist'.format(unzip_path)) sys.exit(1) args = [unzip_path, zip_fname] # Does it have a top di...
[]
Please provide a description of the function:def dpkg_buildpackage(*args,**kwargs): cwd=kwargs.pop('cwd',None) if len(kwargs)!=0: raise ValueError('only kwarg can be "cwd"') "call dpkg-buildpackage [arg1] [...] [argN]" args = ['/usr/bin/dpkg-buildpackage']+list(args) process_command(args, cw...
[]
Please provide a description of the function:def dpkg_source(b_or_x,arg1,cwd=None): "call dpkg-source -b|x arg1 [arg2]" assert b_or_x in ['-b','-x'] args = ['/usr/bin/dpkg-source',b_or_x,arg1] process_command(args, cwd=cwd)
[]
Please provide a description of the function:def apply_patch(patchfile,cwd=None,posix=False,level=0): if not os.path.exists(patchfile): raise RuntimeError('patchfile "%s" does not exist'%patchfile) fd = open(patchfile,mode='r') level_str = '-p%d'%level args = ['/usr/bin/patch',level_str] ...
[ "call 'patch -p[level] [--posix] < arg1'\n\n posix mode is sometimes necessary. It keeps empty files so that\n dpkg-source removes their contents.\n\n " ]
Please provide a description of the function:def parse_vals(cfg,section,option): try: vals = cfg.get(section,option) except ConfigParser.NoSectionError as err: if section != 'DEFAULT': vals = cfg.get('DEFAULT',option) else: raise err vals = vals.split('#'...
[ "parse comma separated values in debian control file style from .cfg" ]
Please provide a description of the function:def parse_val(cfg,section,option): vals = parse_vals(cfg,section,option) if len(vals)==0: return '' else: assert len(vals)==1, (section, option, vals, type(vals)) return vals[0]
[ "extract a single value from .cfg" ]
Please provide a description of the function:def check_cfg_files(cfg_files,module_name): cfg = ConfigParser.SafeConfigParser() cfg.read(cfg_files) if cfg.has_section(module_name): section_items = cfg.items(module_name) else: section_items = [] default_items = cfg.items('DEFAULT...
[ "check if the configuration files actually specify something\n\n If config files are given, give warning if they don't contain\n information. This may indicate a wrong module name name, for\n example.\n " ]
Please provide a description of the function:def build_dsc(debinfo, dist_dir, repackaged_dirname, orig_sdist=None, patch_posix=0, remove_expanded_source_dir=0, debian_dir_only=False, sign_dsc=False, ): ...
[ "make debian source package" ]
Please provide a description of the function:def request(self, host, handler, request_body, verbose): headers = {'User-Agent': self.user_agent, 'Content-Type': 'text/xml', } url = self._build_url(host, handler) kwargs = {} if StrictVersion(r...
[ "\n Make an xmlrpc request.\n " ]
Please provide a description of the function:def parse_response(self, resp): p, u = self.getparser() if hasattr(resp,'text'): # modern requests will do this for us text = resp.text # this is unicode(py2)/str(py3) else: encoding = requests.utils.get_...
[ "\n Parse the xmlrpc response.\n " ]
Please provide a description of the function:def _build_url(self, host, handler): scheme = 'https' if self.use_https else 'http' return '%s://%s/%s' % (scheme, host, handler)
[ "\n Build a url for our request based on the host, handler and use_http\n property\n " ]
Please provide a description of the function:def setting(self, opt, val): opt = opt.encode() if isinstance(val, basestring): fluid_settings_setstr(self.settings, opt, val) elif isinstance(val, int): fluid_settings_setint(self.settings, opt, val) elif isin...
[ "change an arbitrary synth setting, type-smart" ]
Please provide a description of the function:def start(self, driver=None, device=None, midi_driver=None): if driver is not None: assert (driver in ['alsa', 'oss', 'jack', 'portaudio', 'sndmgr', 'coreaudio', 'Direct Sound', 'pulseaudio']) fluid_settings_setstr(self.settings, b'a...
[ "Start audio output driver in separate background thread\n\n Call this function any time after creating the Synth object.\n If you don't call this function, use get_samples() to generate\n samples.\n\n Optional keyword argument:\n driver : which audio driver to use for output\n ...
Please provide a description of the function:def sfload(self, filename, update_midi_preset=0): return fluid_synth_sfload(self.synth, filename.encode(), update_midi_preset)
[ "Load SoundFont and return its ID" ]
Please provide a description of the function:def channel_info(self, chan): info=fluid_synth_channel_info_t() fluid_synth_get_channel_info(self.synth, chan, byref(info)) return (info.sfont_id, info.bank, info.program, info.name)
[ "get soundfont, bank, prog, preset name of channel" ]
Please provide a description of the function:def router_begin(self, type): if self.router is not None: if type=='note': self.router.cmd_rule_type=0 elif type=='cc': self.router.cmd_rule_type=1 elif type=='prog': self.ro...
[ "types are [note|cc|prog|pbend|cpress|kpress]" ]
Please provide a description of the function:def set_reverb(self, roomsize=-1.0, damping=-1.0, width=-1.0, level=-1.0): set=0 if roomsize>=0: set+=0b0001 if damping>=0: set+=0b0010 if width>=0: set+=0b0100 if level>=0: set+...
[ " \n roomsize Reverb room size value (0.0-1.2)\n damping Reverb damping value (0.0-1.0)\n width Reverb width value (0.0-100.0)\n level Reverb level value (0.0-1.0)\n " ]