Ejemplo n.º 1
0
 def replaceNetworkAcl(self, aclId, network):
     self.logger.debug("Replacing Network ACL with ACL ID ==> %s" % aclId)
     replaceNetworkACLListCmd = replaceNetworkACLList.replaceNetworkACLListCmd(
     )
     replaceNetworkACLListCmd.aclid = aclId
     replaceNetworkACLListCmd.networkid = network.id
     self._replaceAcl(replaceNetworkACLListCmd)
Ejemplo n.º 2
0
    def define_custom_acl(self):

        acl1 = NetworkACLList.create(self.api_client,
                                     self.attributes['acls']['acl1'],
                                     vpcid=self.vpc1.id)

        NetworkACL.create(self.api_client,
                          self.attributes['acls']['acl1']['entries']['entry1'],
                          networkid=self.network1.id,
                          aclid=acl1.id)

        try:
            command = replaceNetworkACLList.replaceNetworkACLListCmd()
            command.aclid = acl1.id
            command.gatewayid = self.private_gateway1.id
            response = self.api_client.replaceNetworkACLList(command)

        except Exception as e:
            raise Exception("Exception: %s" % e)

        self.assertTrue(response.success)
        self.logger.debug("Private Gateway '%s' ACL replaced",
                          self.private_gateway1.ipaddress)

        acl2 = NetworkACLList.create(self.api_client,
                                     self.attributes['acls']['acl2'],
                                     vpcid=self.vpc2.id)

        NetworkACL.create(self.api_client,
                          self.attributes['acls']['acl2']['entries']['entry2'],
                          networkid=self.network2.id,
                          aclid=acl2.id)

        try:
            command2 = replaceNetworkACLList.replaceNetworkACLListCmd()
            command2.aclid = acl2.id
            command2.gatewayid = self.private_gateway2.id
            response2 = self.api_client.replaceNetworkACLList(command2)

        except Exception as e:
            raise Exception("Exception: %s" % e)

        self.assertTrue(response2.success)
        self.logger.debug("Private Gateway '%s' ACL replaced",
                          self.private_gateway2.ipaddress)
    def define_custom_acl(self):

        acl1 = NetworkACLList.create(self.api_client,
            self.attributes['acls']['acl1'],
            vpcid=self.vpc1.id)

        NetworkACL.create(self.api_client,
            self.attributes['acls']['acl1']['entries']['entry1'],
            networkid=self.network1.id,
            aclid=acl1.id)

        try:
            command = replaceNetworkACLList.replaceNetworkACLListCmd()
            command.aclid = acl1.id
            command.gatewayid = self.private_gateway1.id
            response = self.api_client.replaceNetworkACLList(command)

        except Exception as e:
            raise Exception("Exception: %s" % e)

        self.assertTrue(response.success)
        self.logger.debug("Private Gateway '%s' ACL replaced", self.private_gateway1.ipaddress)

        acl2 = NetworkACLList.create(self.api_client,
            self.attributes['acls']['acl2'],
            vpcid=self.vpc2.id)

        NetworkACL.create(self.api_client,
            self.attributes['acls']['acl2']['entries']['entry2'],
            networkid=self.network2.id,
            aclid=acl2.id)

        try:
            command2 = replaceNetworkACLList.replaceNetworkACLListCmd()
            command2.aclid = acl2.id
            command2.gatewayid = self.private_gateway2.id
            response2 = self.api_client.replaceNetworkACLList(command2)

        except Exception as e:
            raise Exception("Exception: %s" % e)

        self.assertTrue(response2.success)
        self.logger.debug("Private Gateway '%s' ACL replaced", self.private_gateway2.ipaddress)
    def define_acl(self, acl):

        try:
            command = replaceNetworkACLList.replaceNetworkACLListCmd()
            command.aclid = acl.id
            command.publicipid = self.public_ip1.ipaddress.id
            response = self.api_client.replaceNetworkACLList(command)

        except Exception as e:
            raise Exception("Exception: %s" % e)

        self.assertTrue(response.success)
        self.logger.debug("Public IP '%s' ACL replaced with '%s'", self.public_ip1.ipaddress.ipaddress, acl.name)
Ejemplo n.º 5
0
    def define_acl(self, acl):

        try:
            command = replaceNetworkACLList.replaceNetworkACLListCmd()
            command.aclid = acl.id
            command.publicipid = self.public_ip1.ipaddress.id
            response = self.api_client.replaceNetworkACLList(command)

        except Exception as e:
            raise Exception("Exception: %s" % e)

        self.assertTrue(response.success)
        self.logger.debug("Public IP '%s' ACL replaced with '%s'", self.public_ip1.ipaddress.ipaddress, acl.name)
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()
        testClient = super(TestLoadBalance, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.template = get_template(
            cls.apiclient,
            cls.zone.id
        )
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        # Create an account, network, VM and IP addresses
        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            admin=True,
            domainid=cls.domain.id
        )
        cls.service_offering = get_default_virtual_machine_offering(cls.apiclient)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name)

        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.vpc1 = VPC.create(cls.apiclient,
                               cls.services['vpcs']['vpc1'],
                               vpcofferingid=cls.vpc_offering.id,
                               zoneid=cls.zone.id,
                               domainid=cls.domain.id,
                               account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name, cls.vpc1.cidr)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.network1 = Network.create(cls.apiclient,
                                       cls.services['networks']['network1'],
                                       networkofferingid=cls.network_offering.id,
                                       aclid=cls.default_allow_acl.id,
                                       vpcid=cls.vpc1.id,
                                       zoneid=cls.zone.id,
                                       domainid=cls.domain.id,
                                       accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", cls.network1.name, cls.network1.cidr, cls.network1.gateway)

        cls.vm_1 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id]
        )
        cls.vm_2 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id]
        )
        cls.vm_3 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id]
        )

        cls.non_src_nat_ip = PublicIPAddress.create(cls.apiclient,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            accountid=cls.account.name,
            vpcid=cls.vpc1.id,
            networkid=cls.network1.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s", cls.non_src_nat_ip.ipaddress.ipaddress, cls.vpc1.name, cls.network1.name)

        command = replaceNetworkACLList.replaceNetworkACLListCmd()
        command.aclid = cls.default_allow_acl.id
        command.publicipid = cls.non_src_nat_ip.ipaddress.id
        cls.apiclient.replaceNetworkACLList(command)

        cls._cleanup = [
            cls.account
        ]
 def replaceNetworkAcl(self, aclId, network):
     self.logger.debug("Replacing Network ACL with ACL ID ==> %s" % aclId)
     replaceNetworkACLListCmd = replaceNetworkACLList.replaceNetworkACLListCmd()
     replaceNetworkACLListCmd.aclid = aclId
     replaceNetworkACLListCmd.networkid = network.id
     self._replaceAcl(replaceNetworkACLListCmd)
Ejemplo n.º 8
0
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()
        testClient = super(TestLoadBalance, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.template = get_template(cls.apiclient, cls.zone.id)
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services[
                "ostype"]

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        # Create an account, network, VM and IP addresses
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     admin=True,
                                     domainid=cls.domain.id)
        cls.service_offering = get_default_virtual_machine_offering(
            cls.apiclient)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected",
                         cls.network_offering.name)

        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.vpc1 = VPC.create(cls.apiclient,
                              cls.services['vpcs']['vpc1'],
                              vpcofferingid=cls.vpc_offering.id,
                              zoneid=cls.zone.id,
                              domainid=cls.domain.id,
                              account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name,
                         cls.vpc1.cidr)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.network1 = Network.create(
            cls.apiclient,
            cls.services['networks']['network1'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s",
                         cls.network1.name, cls.network1.cidr,
                         cls.network1.gateway)

        cls.vm_1 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id])
        cls.vm_2 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id])
        cls.vm_3 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id])

        cls.non_src_nat_ip = PublicIPAddress.create(
            cls.apiclient,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            accountid=cls.account.name,
            vpcid=cls.vpc1.id,
            networkid=cls.network1.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s",
                         cls.non_src_nat_ip.ipaddress.ipaddress, cls.vpc1.name,
                         cls.network1.name)

        command = replaceNetworkACLList.replaceNetworkACLListCmd()
        command.aclid = cls.default_allow_acl.id
        command.publicipid = cls.non_src_nat_ip.ipaddress.id
        cls.apiclient.replaceNetworkACLList(command)

        cls._cleanup = [cls.account]