コード例 #1
0
    def createNewVlanRange(cls):
        """ Increment current cidr of vlan range present in network
            and create new range
        """
        publicIpRange = PublicIpRange.list(cls.api_client)
        cls.startIp = publicIpRange[0].startip
        cls.endIp = publicIpRange[0].endip
        cls.gateway = publicIpRange[0].gateway
        cls.netmask = publicIpRange[0].netmask
        # Pass ip address and mask length to IPNetwork to findout the CIDR
        ip = IPNetwork(cls.startIp + "/" + cls.netmask)
        # Take random increment factor to avoid adding the same vlan ip range
        # in each test case
        networkIncrementFactor = random.randint(1, 255)
        new_cidr = ip.__iadd__(networkIncrementFactor)
        ip2 = IPNetwork(new_cidr)
        test_nw = ip2.network
        ip = IPAddress(test_nw)
        # Add IP range(5 IPs) in the new CIDR
        test_gateway = ip.__add__(1)
        test_startIp = ip.__add__(3)
        test_endIp = ip.__add__(10)
        # Populating services with new IP range
        cls.testdata["vlan_ip_range"]["startip"] = test_startIp
        cls.testdata["vlan_ip_range"]["endip"] = test_endIp
        cls.testdata["vlan_ip_range"]["gateway"] = test_gateway
        cls.testdata["vlan_ip_range"]["netmask"] = cls.netmask
        cls.testdata["vlan_ip_range"]["zoneid"] = cls.zone.id
        cls.testdata["vlan_ip_range"]["podid"] = cls.pod.id

        return PublicIpRange.create(cls.api_client,
                                    cls.testdata["vlan_ip_range"])
コード例 #2
0
    def createNewVlanRange(cls):
        """ Increment current cidr of vlan range present in network
            and create new range
        """
        publicIpRange = PublicIpRange.list(cls.api_client)
        cls.startIp = publicIpRange[0].startip
        cls.endIp = publicIpRange[0].endip
        cls.gateway = publicIpRange[0].gateway
        cls.netmask = publicIpRange[0].netmask
        # Pass ip address and mask length to IPNetwork to findout the CIDR
        ip = IPNetwork(cls.startIp + "/" + cls.netmask)
        # Take random increment factor to avoid adding the same vlan ip range
        # in each test case
        networkIncrementFactor = random.randint(1,255)
        new_cidr = ip.__iadd__(networkIncrementFactor)
        ip2 = IPNetwork(new_cidr)
        test_nw = ip2.network
        ip = IPAddress(test_nw)
        # Add IP range(5 IPs) in the new CIDR
        test_gateway = ip.__add__(1)
        test_startIp = ip.__add__(3)
        test_endIp = ip.__add__(10)
        # Populating services with new IP range
        cls.testdata["vlan_ip_range"]["startip"] = test_startIp
        cls.testdata["vlan_ip_range"]["endip"] = test_endIp
        cls.testdata["vlan_ip_range"]["gateway"] = test_gateway
        cls.testdata["vlan_ip_range"]["netmask"] = cls.netmask
        cls.testdata["vlan_ip_range"]["zoneid"] = cls.zone.id
        cls.testdata["vlan_ip_range"]["podid"] = cls.pod.id

        return PublicIpRange.create(
                cls.api_client,
                cls.testdata["vlan_ip_range"])
コード例 #3
0
 def increment_cidr(self):
     """Takes CIDR as input and will increment by one and returns the new CIDR
     """
     publicIpRange = PublicIpRange.list(self.apiclient)
     self.startIp = publicIpRange[0].startip
     self.endIp = publicIpRange[0].endip
     self.gateway = publicIpRange[0].gateway
     self.netmask = publicIpRange[0].netmask
     # Pass ip address and mask length to IPNetwork to findout the CIDR
     ip = IPNetwork(self.startIp + "/" + self.netmask)
     # Take random increment factor to avoid adding the same vlan ip range
     # in each test case
     networkIncrementFactor = random.randint(1, 255)
     new_cidr = ip.__iadd__(networkIncrementFactor)
     ip2 = IPNetwork(new_cidr)
     return ip2
コード例 #4
0
 def increment_cidr(self):
     """Takes CIDR as input and will increment by one and returns the new CIDR
     """
     publicIpRange = PublicIpRange.list(self.apiclient)
     self.startIp = publicIpRange[0].startip
     self.endIp = publicIpRange[0].endip
     self.gateway = publicIpRange[0].gateway
     self.netmask = publicIpRange[0].netmask
     # Pass ip address and mask length to IPNetwork to findout the CIDR
     ip = IPNetwork(self.startIp + "/" + self.netmask)
     # Take random increment factor to avoid adding the same vlan ip range
     # in each test case
     networkIncrementFactor = random.randint(1,255)
     new_cidr = ip.__iadd__(networkIncrementFactor)
     ip2 = IPNetwork(new_cidr)
     return ip2