ironic_inspector.common.context.
RequestContext
(is_public_api=False, **kwargs)[source]¶Bases: oslo_context.context.RequestContext
Extends security contexts from the oslo.context library.
from_dict
(values, **kwargs)[source]¶Construct a context object from a provided dictionary.
from_environ
(environ, **kwargs)[source]¶Load a context object from a request environment.
If keyword arguments are provided then they override the values in the request environment.
Parameters: | environ (dict) – The environment dictionary associated with a request. |
---|
to_policy_values
()[source]¶A dictionary of context attributes to enforce policy with.
oslo.policy enforcement requires a dictionary of attributes representing the current logged in user on which it applies policy enforcement. This dictionary defines a standard list of attributes that should be available for enforcement across services.
It is expected that services will often have to override this method with either deprecated values or additional attributes used by that service specific policy.
ironic_inspector.common.coordination.
Coordinator
(prefix=None)[source]¶Bases: object
Tooz coordination wrapper.
group_name
= b'ironic_inspector.service_group'¶lock_prefix
= 'ironic_inspector.'¶ironic_inspector.common.ironic.
NotFound
(node_ident, code=404, *args, **kwargs)[source]¶Bases: ironic_inspector.utils.Error
Node not found in Ironic.
ironic_inspector.common.ironic.
capabilities_to_dict
(caps)[source]¶Convert the Node’s capabilities into a dictionary.
ironic_inspector.common.ironic.
check_provision_state
(node)[source]¶Sanity checks the provision state of the node.
Parameters: | node – An API client returned node object describing the baremetal node according to ironic’s node data model. |
---|---|
Returns: | None if no action is to be taken, True if the power node state should not be modified. |
Raises: | Error on an invalid state being detected. |
ironic_inspector.common.ironic.
dict_to_capabilities
(caps_dict)[source]¶Convert a dictionary into a string with the capabilities syntax.
ironic_inspector.common.ironic.
get_ipmi_address
(node)[source]¶Get the BMC address defined in node.driver_info dictionary
Possible names of BMC address value examined in order of list [‘ipmi_address’] + CONF.ipmi_address_fields. The value could be an IP address or a hostname. DNS lookup performed for the first non empty value.
The first valid BMC address value returned along with it’s v4 and v6 IP addresses.
Parameters: | node – Node object with defined driver_info dictionary |
---|---|
Returns: | tuple (ipmi_address, ipv4_address, ipv6_address) |
ironic_inspector.common.ironic.
get_node
(node_id, ironic=None, **kwargs)[source]¶Get a node from Ironic.
Parameters: |
|
---|---|
Raises: | Error on failure |
ironic_inspector.common.ironic.
lookup_node
(macs=None, bmc_addresses=None, introspection_data=None, ironic=None)[source]¶Lookup a node in the ironic database.
ironic_inspector.common.ironic.
lookup_node_by_bmc_addresses
(addresses, introspection_data=None, ironic=None, fail=False)[source]¶Find a node by its BMC address.
Names and mapping functions used to map LLDP TLVs to name/value pairs
ironic_inspector.common.lldp_parsers.
LLDPBasicMgmtParser
(nv=None)[source]¶Bases: ironic_inspector.common.lldp_parsers.LLDPParser
Class to handle parsing of 802.1AB Basic Management set
This class will also handle 802.1Q and 802.3 OUI TLVs.
add_mgmt_address
(struct, name, data)[source]¶Handle LLDP_TLV_MGMT_ADDRESS
There can be multiple Mgmt Address TLVs, store in list.
handle_org_specific_tlv
(struct, name, data)[source]¶Handle Organizationally Unique ID TLVs
This class supports 802.1Q and 802.3 OUI TLVs.
See http://www.ieee802.org/1/pages/802.1Q-2014.html, Annex D and http://standards.ieee.org/about/get/802/802.3.html
ironic_inspector.common.lldp_parsers.
LLDPParser
(node_info, nv=None)[source]¶Bases: object
Base class to handle parsing of LLDP TLVs
Each class that inherits from this base class must provide a parser map. Parser maps are used to associate a LLDP TLV with a function handler and arguments necessary to parse the TLV and generate one or more name/value pairs. Each LLDP TLV maps to a tuple with the following fields:
function - handler function to generate name/value pairs
construct - name of construct definition for TLV
name - user-friendly name of TLV. For TLVs that generate only one name/value pair this is the name used
len_check - boolean indicating if length check should be done on construct
It’s valid to have a function handler of None, this is for TLVs that are not mapped to a name/value pair(e.g.LLDP_TLV_TTL).
add_dot1_link_aggregation
(struct, name, data)[source]¶Add name/value pairs for TLV Dot1_LinkAggregationId
This is in base class since it can be used by both dot1 and dot3.
parse_tlv
(tlv_type, data)[source]¶Parse TLVs from mapping table
This functions takes the TLV type and the raw data for this TLV and gets a tuple from the parser_map. The construct field in the tuple contains the construct lib definition of the TLV which can be parsed to access individual fields. Once the TLV is parsed, the handler function for each TLV will store the individual fields as name/value pairs in nv_dict.
If the handler function does not exist, then no name/value pairs will be added to nv_dict, but since the TLV was handled, True will be returned.
Param: | tlv_type - type identifier for TLV |
---|---|
Param: | data - raw TLV value |
Returns: | True if TLV in parser_map and data is valid, otherwise False. |
ironic_inspector.common.lldp_parsers.
LLDPdot1Parser
(node_info, nv=None)[source]¶Bases: ironic_inspector.common.lldp_parsers.LLDPParser
Class to handle parsing of 802.1Q TLVs
ironic_inspector.common.lldp_parsers.
LLDPdot3Parser
(node_info, nv=None)[source]¶Bases: ironic_inspector.common.lldp_parsers.LLDPParser
Class to handle parsing of 802.3 TLVs
Link Layer Discovery Protocol TLVs
ironic_inspector.common.lldp_tlvs.
bytes_to_int
(obj)[source]¶Convert bytes to an integer
Param: | obj - array of bytes |
---|
ironic_inspector.common.lldp_tlvs.
get_autoneg_cap
(pmd)[source]¶Get autonegotiated capability strings
This returns a list of capability strings from the Physical Media Dependent (PMD) capability bits.
Parameters: | pmd – PMD bits |
---|---|
Returns: | Sorted ist containing capability strings |
ironic_inspector.common.locking.
InternalLock
(uuid)[source]¶Bases: ironic_inspector.common.locking.BaseLock
Locking mechanism based on threading.Semaphore.
ironic_inspector.common.locking.
ToozLock
(lock)[source]¶Bases: ironic_inspector.common.locking.BaseLock
Wrapper on tooz locks.
ironic_inspector.common.swift.
SwiftAPI
[source]¶Bases: object
API for communicating with Swift.
create_object
(object, data, container=None, headers=None)[source]¶Uploads a given string to Swift.
Parameters: |
|
---|---|
Returns: | The Swift UUID of the object |
Raises: | utils.Error, if any operation with Swift fails. |
get_object
(object, container=None)[source]¶Downloads a given object from Swift.
Parameters: |
|
---|---|
Returns: | Swift object |
Raises: | utils.Error, if the Swift operation fails. |
ironic_inspector.common.swift.
get_introspection_data
(uuid, suffix=None)[source]¶Downloads introspection data from Swift.
Parameters: |
|
---|---|
Returns: | Swift object with the introspection data |
ironic_inspector.common.swift.
reset_swift_session
()[source]¶Reset the global session variable.
Mostly useful for unit tests.
ironic_inspector.common.swift.
store_introspection_data
(data, uuid, suffix=None)[source]¶Uploads introspection data to Swift.
Parameters: |
|
---|---|
Returns: | name of the Swift object that the data is stored in |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.