diff options
author | Laura Moore <laura.moore@sap.com> | 2015-07-27 17:29:57 -0400 |
---|---|---|
committer | Vladyslav Drok <vdrok@mirantis.com> | 2016-07-13 13:39:56 +0300 |
commit | 0a5549680d491894faad5133db38e1bc2b4c93d6 (patch) | |
tree | afa919b8a748981371037383086ad977f353b0c1 /ironic/common/utils.py | |
parent | 5041703401ded33fc0b54409d60667900a319403 (diff) | |
download | ironic-0a5549680d491894faad5133db38e1bc2b4c93d6.tar.gz |
Add multitenancy-related fields to port API object
This commit adds new fields to port object:
- port.pxe_enabled: indicates whether pxe is enabled or disabled
for this port
- port.local_link_connection: contains the port binding profile.
Partial-bug: #1526403
Co-Authored-By: Jenny Moorehead <jenny.moorehead@sap.com>
Co-Authored-By: Will Stevenson <will.stevenson@sap.com>
Co-Authored-By: Vasyl Saienko <vsaienko@mirantis.com>
Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com>
Co-Authored-By: Zhenguo Niu <Niu.ZGlinux@gmail.com>
Change-Id: Ie655fd59b06de7b84fba3b438d5e4c2ecd8075c3
Diffstat (limited to 'ironic/common/utils.py')
-rw-r--r-- | ironic/common/utils.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ironic/common/utils.py b/ironic/common/utils.py index 65acb5dd4..1f76a9a17 100644 --- a/ironic/common/utils.py +++ b/ironic/common/utils.py @@ -185,6 +185,22 @@ def is_valid_mac(address): re.match(m, address.lower())) +def is_valid_datapath_id(datapath_id): + """Verify the format of an OpenFlow datapath_id. + + Check if a datapath_id is valid and contains 16 hexadecimal digits. + Datapath ID format: the lower 48-bits are for a MAC address, + while the upper 16-bits are implementer-defined. + + :param datapath_id: OpenFlow datapath_id to be validated. + :returns: True if valid. False if not. + + """ + m = "^[0-9a-f]{16}$" + return (isinstance(datapath_id, six.string_types) and + re.match(m, datapath_id.lower())) + + _is_valid_logical_name_re = re.compile(r'^[A-Z0-9-._~]+$', re.I) # old is_hostname_safe() regex, retained for backwards compat @@ -284,6 +300,23 @@ def validate_and_normalize_mac(address): return address.lower() +def validate_and_normalize_datapath_id(datapath_id): + """Validate an OpenFlow datapath_id and return normalized form. + + Checks whether the supplied OpenFlow datapath_id is formally correct and + normalize it to all lower case. + + :param datapath_id: OpenFlow datapath_id to be validated and normalized. + :returns: Normalized and validated OpenFlow datapath_id. + :raises: InvalidDatapathId If an OpenFlow datapath_id is not valid. + + """ + + if not is_valid_datapath_id(datapath_id): + raise exception.InvalidDatapathId(datapath_id=datapath_id) + return datapath_id.lower() + + def is_valid_ipv6_cidr(address): try: str(netaddr.IPNetwork(address, version=6).cidr) |