From 0e7b478d4e9e576a56513da1acdc7aefdd028568 Mon Sep 17 00:00:00 2001 From: Leonardo Maycotte Date: Thu, 6 Nov 2014 16:29:15 -0600 Subject: [PATCH] Adding port methods - Adding port config values - Adding port constants - Adding a port behavior method Change-Id: Ibcb26557823eaf3ac625676da4d35f0492808c3a --- .../networking/networks/common/constants.py | 1 + .../networks/ports_api/behaviors.py | 17 ++++++++++++++-- .../networking/networks/ports_api/config.py | 20 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/cloudcafe/networking/networks/common/constants.py b/cloudcafe/networking/networks/common/constants.py index b1f7f717..b8a146df 100644 --- a/cloudcafe/networking/networks/common/constants.py +++ b/cloudcafe/networking/networks/common/constants.py @@ -55,4 +55,5 @@ class NeutronErrorTypes(object): OVERLAPPING_ALLOCATION_POOLS = 'OverlappingAllocationPools' OVER_QUOTA = 'OverQuota' POLICY_NOT_AUTHORIZED = 'PolicyNotAuthorized' + PORT_NOT_FOUND = 'PortNotFound' SECURITY_GROUPS_NOT_IMPLEMENTED = 'SecurityGroupsNotImplemented' diff --git a/cloudcafe/networking/networks/ports_api/behaviors.py b/cloudcafe/networking/networks/ports_api/behaviors.py index 1d5e21ea..bc351d75 100644 --- a/cloudcafe/networking/networks/ports_api/behaviors.py +++ b/cloudcafe/networking/networks/ports_api/behaviors.py @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import time - +import netaddr import time from cloudcafe.common.tools.datagen import rand_name @@ -38,6 +37,20 @@ class PortsBehaviors(NetworkingBaseBehaviors): self.config = ports_config self.client = ports_client + def format_fixed_ips(self, fixed_ips): + """ + @summary: formats fixed ips for assertions removing zeros on + IPv6 addresses + @param fixed_ips: list of fixed_ips + @type fixed_ips: list(dict) + @return: formated fixed_ips + @rtype: list(dict) + """ + result = [dict(subnet_id=fixed_ip['subnet_id'], ip_address=str( + netaddr.IPAddress(fixed_ip['ip_address']))) + for fixed_ip in fixed_ips] + return result + def create_port(self, network_id, name=None, admin_state_up=None, mac_address=None, fixed_ips=None, device_id=None, device_owner=None, tenant_id=None, security_groups=None, diff --git a/cloudcafe/networking/networks/ports_api/config.py b/cloudcafe/networking/networks/ports_api/config.py index 8b3aed7b..435e8be4 100644 --- a/cloudcafe/networking/networks/ports_api/config.py +++ b/cloudcafe/networking/networks/ports_api/config.py @@ -26,3 +26,23 @@ class PortsConfig(NetworkingBaseConfig): def starts_with_name(self): """Port start name label for test runs""" return self.get("starts_with_name", "test_port") + + @property + def multiple_ports(self): + """Test multiple ports smoke test ports number""" + return int(self.get("multiple_ports", 10)) + + @property + def ports_per_network(self): + """Ports per network quota""" + return int(self.get("ports_per_network", 250)) + + @property + def test_quotas(self): + """Flag for running the ports quotas tests""" + return self.get_boolean("test_quotas", False) + + @property + def fixed_ips_per_port(self): + """Ports fixed IPs quota""" + return int(self.get("fixed_ips_per_port", 4))