Skip to content

Commit ca9a009

Browse files
committed
prefer IPv6 but fall back to IPv4
1 parent e52b098 commit ca9a009

5 files changed

Lines changed: 13 additions & 8 deletions

File tree

igvm/drbd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_host_config(self):
185185
' }}'
186186
.format(
187187
host=self.hv.dataset_obj['hostname'],
188-
addr=self.hv.dataset_obj['ipv6'],
188+
addr=self.hv.ip_address,
189189
port=self.get_device_port(),
190190
dm_minor=self.get_device_minor(),
191191
lv_name=self.lv_name,

igvm/host.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,10 @@ def set_block_size(self, device, bs_kib):
184184
.format(bs_kib, device)
185185
)
186186
self.run('sync')
187+
188+
@property
189+
def ip_address(self):
190+
ipaddr = self.dataset_obj.get('ipv6') or self.dataset_obj.get('ipv4')
191+
if not ipaddr:
192+
raise ValueError('This host has no IP address!')
193+
return ipaddr

igvm/hypervisor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def check_vm(self, vm, offline):
212212
)
213213

214214
# Proper VLAN?
215-
if not self.get_vlan_network(vm.dataset_obj['ipv6']):
215+
if not self.get_vlan_network(vm.ip_address):
216216
raise HypervisorError(
217217
'Hypervisor "{}" does not support route_network "{}".'
218218
.format(self.fqdn, vm.route_network)

igvm/kvm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,7 @@ def generate_domain_xml(hypervisor, vm):
388388
# VM, instead the VM is updated to the latest settings.
389389
# Every KVM setting should be configurable via Serveradmin anyway.
390390
props = DomainProperties(hypervisor, vm)
391-
vlan_network = hypervisor.get_vlan_network(
392-
vm.dataset_obj.get('ipv6') or vm.dataset_obj.get('ipv4')
393-
)
391+
vlan_network = hypervisor.get_vlan_network(vm.ip_address)
394392

395393
config = {
396394
'name': vm.uid_name,

igvm/vm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def start(self, force_stop_failed=True, transaction=None):
363363
raise VMError('VM did not come online in time')
364364

365365
host_up = wait_until(
366-
str(self.dataset_obj['ipv6']),
366+
str(self.ip_address),
367367
waitmsg='Waiting for SSH to respond',
368368
)
369369
if not host_up and force_stop_failed:
@@ -408,7 +408,7 @@ def aws_start(self):
408408
raise VMError(e)
409409

410410
host_up = wait_until(
411-
str(self.dataset_obj['ipv6']),
411+
str(self.ip_address),
412412
waitmsg='Waiting for SSH to respond',
413413
)
414414

@@ -431,7 +431,7 @@ def aws_restart(self):
431431
raise VMError(e)
432432

433433
host_up = wait_until(
434-
str(self.dataset_obj['ipv6']),
434+
str(self.ip_address),
435435
waitmsg='Waiting for SSH to respond',
436436
timeout=180
437437
)

0 commit comments

Comments
 (0)