Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions igvm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ def change_address(
)

new_address = ip_address(new_address)
new_address_attr = 'ipv6'
if new_address.version == 4:
new_address_attr = 'ipv4'

if vm.dataset_obj['intern_ip'] == new_address:
if vm.dataset_obj[new_address_attr] == new_address:
raise ConfigError('New IP address is the same as the old one!')

if not vm.hypervisor.get_vlan_network(new_address) and not migrate:
Expand Down Expand Up @@ -825,7 +828,8 @@ def host_info(vm_hostname):
'status',
)),
('Network', (
'intern_ip',
'ipv4',
'ipv6',
'mac_address',
)),
('Resources', (
Expand Down
2 changes: 1 addition & 1 deletion igvm/drbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def get_host_config(self):
' }}'
.format(
host=self.hv.dataset_obj['hostname'],
addr=self.hv.dataset_obj['intern_ip'],
addr=self.hv.dataset_obj['ipv6'],
port=self.get_device_port(),
dm_minor=self.get_device_minor(),
lv_name=self.lv_name,
Expand Down
4 changes: 2 additions & 2 deletions igvm/hypervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def get_vlan_network(self, ip_addr):
its IP address changed.
"""
for vlan_network in self.dataset_obj['vlan_networks']:
if ip_addr in vlan_network['ipv4'] or ip_addr in vlan_network['ipv6']:
if ip_addr in vlan_network['ipv6']:
return vlan_network
return None

Expand Down Expand Up @@ -206,7 +206,7 @@ def check_vm(self, vm, offline):
)

# Proper VLAN?
if not self.get_vlan_network(vm.dataset_obj['intern_ip']):
if not self.get_vlan_network(vm.dataset_obj['ipv6']):
raise HypervisorError(
'Hypervisor "{}" does not support route_network "{}".'
.format(self.fqdn, vm.route_network)
Expand Down
4 changes: 3 additions & 1 deletion igvm/kvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ def generate_domain_xml(hypervisor, vm):
# VM, instead the VM is updated to the latest settings.
# Every KVM setting should be configurable via Serveradmin anyway.
props = DomainProperties(hypervisor, vm)
vlan_network = hypervisor.get_vlan_network(vm.dataset_obj['intern_ip'])
vlan_network = hypervisor.get_vlan_network(
vm.dataset_obj.get('ipv4',{}).get('ipv6')
)

config = {
'name': vm.uid_name,
Expand Down
6 changes: 2 additions & 4 deletions igvm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
'hostname',
'igvm_locked',
'igvm_migration_log',
'intern_ip',
'iops_avg',
'igvm_migration_log',
'ipv4',
'ipv6',
'libvirt_memory_total_gib',
'libvirt_memory_used_gib',
'libvirt_pool_total_gib',
Expand Down Expand Up @@ -178,15 +178,13 @@
'game_world',
'hostname',
'igvm_locked',
'intern_ip',
'io_weight',
'libvirt_pool_override',
'load_99',
'mac',
'memory',
'num_cpu',
'os',
'primary_ip6',
'project',
{'project_network': NETWORK_ATTRIBUTES},
'puppet_ca',
Expand Down
22 changes: 13 additions & 9 deletions igvm/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def start(self, force_stop_failed=True, transaction=None):
raise VMError('VM did not come online in time')

host_up = wait_until(
str(self.dataset_obj['intern_ip']),
str(self.dataset_obj['ipv6']),
waitmsg='Waiting for SSH to respond',
)
if not host_up and force_stop_failed:
Expand Down Expand Up @@ -407,7 +407,7 @@ def aws_start(self):
raise VMError(e)

host_up = wait_until(
str(self.dataset_obj['intern_ip']),
str(self.dataset_obj['ipv6']),
waitmsg='Waiting for SSH to respond',
)

Expand Down Expand Up @@ -622,7 +622,8 @@ def disk_free(self):
def info(self):
result = {
'hypervisor': self.hypervisor.fqdn,
'intern_ip': self.dataset_obj['intern_ip'],
'ipv4': self.dataset_obj['ipv4'],
'ipv6': self.dataset_obj['ipv6'],
'num_cpu': self.dataset_obj['num_cpu'],
'memory': self.dataset_obj['memory'],
'disk_size_gib': self.dataset_obj['disk_size_gib'],
Expand Down Expand Up @@ -782,8 +783,8 @@ def aws_build(self,
self.dataset_obj['aws_placement']
)
},
PrivateIpAddress=str(self.dataset_obj['intern_ip']),
Ipv6Addresses=[{'Ipv6Address':str(self.dataset_obj['primary_ip6'])}],
PrivateIpAddress=str(self.dataset_obj['ipv4']),
Ipv6Addresses=[{'Ipv6Address':str(self.dataset_obj['ipv6'])}],
UserData='' if postboot is None else postboot,
TagSpecifications=[
{
Expand Down Expand Up @@ -1021,16 +1022,19 @@ def copy_postboot_script(self, script):
self.put('/buildvm-postboot', script, '0755')

def restore_address(self):
self.dataset_obj['intern_ip'] = self.old_address
self.dataset_obj['ipv4'] = self.old_address_ipv4
self.dataset_obj['ipv6'] = self.old_address_ipv6
self.dataset_obj.commit()
self.route_network = self.old_network

def change_address(self, new_address, new_network, transaction=None):
def change_address(self, new_address_ipv4, new_address_ipv6, new_network, transaction=None):
# All queries to Serveradmin are kept in commands.py.
# That's why this metod receives both new address and new network.
self.old_address = self.dataset_obj['intern_ip']
self.old_address_ipv4 = self.dataset_obj['ipv4']
self.old_address_ipv6 = self.dataset_obj['ipv6']
self.old_network = self.route_network
self.dataset_obj['intern_ip'] = new_address
self.dataset_obj['ipv4'] = new_address_ipv4
self.dataset_obj['ipv6'] = new_address_ipv6
self.dataset_obj.commit()
self.route_network = new_network

Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def setUp(self):
self.vm_obj['environment'] = 'testing'
self.vm_obj['hostname'] = VM_HOSTNAME
self.vm_obj['hypervisor'] = None
self.vm_obj['intern_ip'] = get_next_address(VM_NET, 1, self.ip_attr)
self.vm_obj['memory'] = 2048
self.vm_obj['no_monitoring'] = True
self.vm_obj['num_cpu'] = 2
self.vm_obj['os'] = 'bullseye'
self.vm_obj['project'] = 'test'
self.vm_obj['project_network'] = VM_NET
self.vm_obj['puppet_environment'] = None
self.vm_obj['puppet_ca'] = 'testing-puppetca.innogames.de'
self.vm_obj['puppet_master'] = 'puppet-lb.test.innogames.net'
Expand Down