def checkIpv6NetworkVm(self): self.debug("Listing NICS for VM %s in network: %s" % (self.virtual_machine.name, self.network.name)) nics = NIC.list( self.apiclient, virtualmachineid=self.virtual_machine.id, networkid=self.network.id ) self.assertEqual( len(nics), 1, "Router for the network isn't found" ) nic = nics[0] self.assertNotEqual(nic.ip6address, None, "IPv6 address for VM %s NIC is empty" % nic.traffictype) self.virtual_machine_ipv6_address = nic.ip6address self.assertNotEqual(nic.ip6cidr, None, "IPv6 CIDR for VM %s NIC is empty" % nic.traffictype) self.assertNotEqual(nic.ip6gateway, None, "IPv6 gateway for VM %s NIC is empty" % nic.traffictype)
def test_updating_nics_on_two_shared_networks(self): """ Test updating vm nics on two shared networks Works as follows: - Create two shared networks, with different IP ranges (eg network1, network2). - Create two VMs on each shared network (eg vm1 on network1, vm2 on network2) and stop them. - Add additional IP range to each shared network. The two additional IP ranges have same start IP and end IP, but different gateway and netmask (eg network1-iprange2, network2-iprange2). - Update IP address of the two vms, by specifying new IP address on additional IP ranges. The new gateway and netmask should be updated correctly (eg vm1 on network1-iprange2, vm2 on network2-iprange2). """ # - Create two shared networks, with different IP ranges (eg network1, network2). self.services["shared_network"]["netmask"] = "255.255.255.0" self.services["shared_network"]["gateway"] = "192.168.1.1" self.services["shared_network"]["startip"] = "192.168.1.2" self.services["shared_network"]["endip"] = "192.168.1.20" self.services["shared_network"]["vlan"] = "111" testnet = self.services["shared_network"] self.debug(f"========= network 1 : {testnet}") self.network1 = Network.create( self.apiclient, self.services["shared_network"], networkofferingid=self.shared_network_offering.id, zoneid=self.zone.id, ) self._cleanup.append(self.network1) self.services["shared_network"]["netmask"] = "255.255.255.0" self.services["shared_network"]["gateway"] = "192.168.2.1" self.services["shared_network"]["startip"] = "192.168.2.2" self.services["shared_network"]["endip"] = "192.168.2.20" self.services["shared_network"]["vlan"] = "222" self.network2 = Network.create( self.apiclient, self.services["shared_network"], networkofferingid=self.shared_network_offering.id, zoneid=self.zone.id, ) self._cleanup.append(self.network2) # - Create two VMs on each shared network (eg vm1 on network1, vm2 on network2) and stop them. vm_data = self.services["virtual_machine"] self.debug(f"============virtual machine data : {vm_data}") virtual_machine1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, serviceofferingid=self.service_offering.id, networkids=[self.network1.id], zoneid=self.zone.id) self.cleanup.append(virtual_machine1) virtual_machine1.stop(self.apiclient) virtual_machine2 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, serviceofferingid=self.service_offering.id, networkids=[self.network2.id], zoneid=self.zone.id) self.cleanup.append(virtual_machine2) virtual_machine2.stop(self.apiclient) # - Add additional IP range to each shared network. The two additional IP ranges have same start IP and end IP, # but different gateway and netmask (eg network1-iprange2, network2-iprange2). self.services["vlan_ip_range"]["netmask"] = "255.255.255.224" self.services["vlan_ip_range"]["gateway"] = "192.168.3.1" self.services["vlan_ip_range"]["startip"] = "192.168.3.2" self.services["vlan_ip_range"]["endip"] = "192.168.3.20" self.services["vlan_ip_range"]["vlan"] = "111" range1 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"], networkid=self.network1.id) self.debug(f"============range 1 : {range1}") self.services["vlan_ip_range"]["netmask"] = "255.255.255.192" self.services["vlan_ip_range"]["gateway"] = "192.168.3.21" self.services["vlan_ip_range"]["startip"] = "192.168.3.2" self.services["vlan_ip_range"]["endip"] = "192.168.3.20" self.services["vlan_ip_range"]["vlan"] = "222" range2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"], networkid=self.network2.id) # - Update IP address of the two vms, by specifying new IP address on additional IP ranges. The new gateway and # netmask should be updated correctly (eg vm1 on network1-iprange2, vm2 on network2-iprange2). nic1id = NIC.list(self.apiclient, virtualmachineid=virtual_machine1.id, networkid=self.network1.id)[0].id NIC.updateIp(self.apiclient, id=nic1id, ipaddress="192.168.3.2") nics = NIC.list(self.apiclient, virtualmachineid=virtual_machine1.id, networkid=self.network1.id) self.check_nic(nics, self.network1, range1) nic2id = NIC.list(self.apiclient, virtualmachineid=virtual_machine2.id, networkid=self.network2.id)[0].id NIC.updateIp(self.apiclient, id=nic2id, ipaddress="192.168.3.2") nics = NIC.list(self.apiclient, virtualmachineid=virtual_machine2.id, networkid=self.network2.id) self.check_nic(nics, self.network2, range2) return