Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CEC25200AE4 for ; Wed, 11 May 2016 04:52:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CD7C6160A11; Wed, 11 May 2016 02:52:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C82B216098A for ; Wed, 11 May 2016 04:52:22 +0200 (CEST) Received: (qmail 796 invoked by uid 500); 11 May 2016 02:52:21 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 785 invoked by uid 99); 11 May 2016 02:52:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2016 02:52:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 64ED2DFD43; Wed, 11 May 2016 02:52:21 +0000 (UTC) From: jburwell To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: OSPF: adding dynamically routing capabili... Content-Type: text/plain Message-Id: <20160511025221.64ED2DFD43@git1-us-west.apache.org> Date: Wed, 11 May 2016 02:52:21 +0000 (UTC) archived-at: Wed, 11 May 2016 02:52:24 -0000 Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1371#discussion_r62785662 --- Diff: test/integration/component/test_ospf.py --- @@ -0,0 +1,477 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, 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. +""" BVT tests for Service offerings""" + +# Import Local Modules +from marvin.codes import FAILED +from marvin.cloudstackTestCase import * +from marvin.cloudstackAPI import * +from marvin.lib.utils import * +from marvin.lib.base import * +from marvin.lib.common import * +from nose.plugins.attrib import attr +from marvin.sshClient import SshClient + + +_multiprocess_shared_ = True + + +class TestCreateDynmaicServiceOffering(cloudstackTestCase): + + def setUp(self): + + self.logger = logging.getLogger('TestOSPF') + self.stream_handler = logging.StreamHandler() + self.logger.setLevel(logging.DEBUG) + self.logger.addHandler(self.stream_handler) + + self.apiclient = self.testClient.getApiClient() + self.hypervisor = self.testClient.getHypervisorInfo() + print str(self) + self.dbclient = self.testClient.getDbConnection() + self.services = self.testClient.getParsedTestDataConfig() + self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) + self.pod = get_pod(self.apiclient, self.zone.id) + self.cleanup = [] + self.services = { + "batman_vpc": { + "name": "Batman VPC", + "displaytext": "Marvin Batman VPC", + "netmask": "255.255.252.0" + }, + "superman_vpc": { + "name": "Superman VPC", + "displaytext": "Marvin Superman VPC", + "netmask": "255.255.252.0" + }, + "vpc_offering": { + "name": 'Cosmic VPC off', + "displaytext": 'Cosmic VPC off', + "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,VPCDynamicRouting', + }, + "network_offering": { + "name": 'Milkyway VPC Network offering', + "displaytext": 'Milkyway VPC Network off', + "guestiptype": 'Isolated', + "supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Lb,UserData,StaticNat,NetworkACL,VPCDynamicRouting', + "traffictype": 'GUEST', + "availability": 'Optional', + "useVpc": 'on', + "serviceProviderList": { + "Vpn": 'VpcVirtualRouter', + "Dhcp": 'VpcVirtualRouter', + "Dns": 'VpcVirtualRouter', + "SourceNat": 'VpcVirtualRouter', + "PortForwarding": 'VpcVirtualRouter', + "Lb": 'VpcVirtualRouter', + "UserData": 'VpcVirtualRouter', + "StaticNat": 'VpcVirtualRouter', + "VPCDynamicRouting": 'VpcVirtualRouter', + "NetworkACL": 'VpcVirtualRouter' + }, + }, + "batman_network_tier1": { + "name": "Batman Network Tier 1", + "displaytext": "Batman Network Tier 1", + "netmask": '255.255.255.0' + }, + "superman_network_tier1": { + "name": "Superman Network Tier 1", + "displaytext": "Superman Network Tier 1", + "netmask": '255.255.255.0' + }, + "service_offering": { + "name": "Ultra Tiny Instance", + "displaytext": "Ultra Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, + "memory": 128, + }, + "batman_vm_1": { + "displayname": "Batman-VPC-VM-001", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + # Hypervisor type should be same as + # hypervisor type of cluster + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + }, + "superman_vm_1": { + "displayname": "Superman-VPC-VM-001", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + # Hypervisor type should be same as + # hypervisor type of cluster + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + }, + "natrule": { + "privateport": 22, + "publicport": 22, + "startport": 22, + "endport": 22, + "protocol": "TCP", + "cidrlist": '0.0.0.0/0', + }, + "template_name" : "macchinina-xen", + "ostype": 'Other Linux (64-bit)', + "sleep": 60, + "timeout": 10, + } + + + def tearDown(self): + try: + # Clean up, terminate the created templates + cleanup_resources(self.apiclient, self.cleanup) + + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + + return + + + def validate_vpc_offering(self, vpc_offering): + """Validates the VPC offering""" + + self.logger.debug("Check if the VPC offering is created successfully?") + vpc_offs = VpcOffering.list( + self.apiclient, + id=vpc_offering.id + ) + self.assertEqual( + isinstance(vpc_offs, list), + True, + "List VPC offerings should return a valid list" + ) + self.assertEqual( + vpc_offering.name, + vpc_offs[0].name, + "Name of the VPC offering should match with listVPCOff data" + ) + self.logger.debug( + "VPC offering is created successfully - %s" % + vpc_offering.name) + return + + + def validate_network(self, network, vpcid): + """Validates the VPC offering""" + + self.logger.debug( + "Verifying list network response to check if network created?") + networks = Network.list( + self.apiclient, + id=network.id, + listall=True + ) + self.assertEqual( + isinstance(networks, list), + True, + "List networks should return a valid response" + ) + nw = networks[0] + + self.assertEqual( + nw.networkofferingid, + self.network_offering.id, + "Network should be created from network offering - %s" % + self.network_offering.id + ) + self.assertEqual( + nw.vpcid, + vpcid, + "Network should be created in VPC: %s" % vpcid + ) + + return + + def validate_vpc_network(self, network): + """Validates the VPC network""" + + self.logger.debug("Check if the VPC network is created successfully?") + vpc_networks = VPC.list( + self.apiclient, + id=network.id + ) + self.assertEqual( + isinstance(vpc_networks, list), + True, + "List VPC network should return a valid list" + ) + self.assertEqual( + network.name, + vpc_networks[0].name, + "Name of the VPC network should match with listVPC data" + ) + self.logger.debug("VPC network created successfully - %s" % network.name) + return + + @attr( + tags=[ + "advanced", + "advancedns", + "smoke", + "basic", + "eip", + "sg"], + required_hardware="false") + def test_01_dynamic_routing_using_ospf(self): + cmd = vpcOSPFConfigUpdate.vpcOSPFConfigUpdateCmd() + cmd.zoneid = self.zone.id + cmd.superCIDR = "200.100.0.0/16" + cmd.enabled = "true" + response = self.apiclient.vpcOSPFConfigUpdate(cmd) + self.logger.debug("Response ospfEnabled: %s" % response.enabled) + self.logger.debug("Response ospfSuperCIDR: %s" % response.superCIDR) + + cmd = vpcOSPFConfig.vpcOSPFConfigCmd() + cmd.zoneid = self.zone.id + response = self.apiclient.vpcOSPFConfig(cmd) + self.logger.debug("Response ospf Enabled: %s" % response.enabled) + self.logger.debug("Response ospfSuperCIDR: %s" % response.superCIDR) + + cmd.zoneid = self.zone.id + + + self.assertEqual( + response.enabled, True + ) + + + self.assertEqual( + response.superCIDR, "200.100.0.0/16" + ) + + self.vpc_off = VpcOffering.create( + self.apiclient, + self.services["vpc_offering"] + ) + self.vpc_off.update(self.apiclient, state='Enabled') + + self.validate_vpc_offering(self.vpc_off) + self.logger.debug("VPC Offering id = %s" % self.vpc_off.id) + + """ vpc_super_netmask=255.255.252.0 """ + self.batman_vpc = VPC.create( + self.apiclient, + self.services["batman_vpc"], + netmask="255.255.252.0", + vpcofferingid=self.vpc_off.id, + zoneid=self.zone.id + ) + + self.validate_vpc_network(self.batman_vpc) + self.logger.debug("VPC batman_vpc id = %s" % self.batman_vpc.id) + + self.superman_vpc = VPC.create( + self.apiclient, + self.services["superman_vpc"], + netmask="255.255.252.0", + vpcofferingid=self.vpc_off.id, + zoneid=self.zone.id + ) + + self.validate_vpc_network(self.superman_vpc) + self.logger.debug("VPC superman_vpc id = %s" % self.superman_vpc.id) + + """ -----------------------------------------------""" + + self.network_offering = NetworkOffering.create( + self.apiclient, + self.services["network_offering"], + conservemode=False + ) + # Enable Network offering + self.network_offering.update(self.apiclient, state='Enabled') + self.logger.debug("Dynamic Network offering id = %s" % self.network_offering.id) + + """ --------------------BATMAN---------------------------""" + # 2) Create ACL + self.batman_aclgroup = NetworkACLList.create(apiclient=self.apiclient, services={}, name="acl", description="acl", vpcid=self.batman_vpc.id) + self.assertIsNotNone(self.batman_aclgroup, "Failed to create NetworkACL list") + self.logger.debug("Created a network ACL list %s" % self.batman_aclgroup.name) + + # 3) Create ACL Items + self.batman_aclitem1 = NetworkACL.create(apiclient=self.apiclient, services={}, + protocol="ICMP", action="Allow", aclid=self.batman_aclgroup.id, cidrlist=["0.0.0.0/0"]) + self.assertIsNotNone(self.batman_aclitem1, "Network failed to aclItem") + self.logger.debug("Added a network ACL %s to ACL list %s" % (self.batman_aclitem1.id, self.batman_aclgroup.name)) + + self.batman_aclitem2 = NetworkACL.create( self.apiclient, aclid=self.batman_aclgroup.id, services=self.services["natrule"], + traffictype='Ingress' ) + + self.assertIsNotNone(self.batman_aclitem2, "Network failed to aclItem") + self.logger.debug("Added a network ACL %s to ACL list %s" % (self.batman_aclitem2.id, self.batman_aclgroup.name)) --- End diff -- Consider extracting lines 315-325 to a private method to reduce the complexity of this test method. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---