From ec3cf49799e9cf17dcd23fa3d09209597d1d85ea Mon Sep 17 00:00:00 2001 From: meow Date: Thu, 26 Dec 2019 12:24:19 +0500 Subject: [PATCH] Create radvd configuration and start it <--> VM's which is being started has IPv6 network which is global --- ucloud/host/virtualmachine.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ucloud/host/virtualmachine.py b/ucloud/host/virtualmachine.py index b3a1d2a..dbd13de 100755 --- a/ucloud/host/virtualmachine.py +++ b/ucloud/host/virtualmachine.py @@ -8,6 +8,7 @@ import os import subprocess as sp import tempfile import time +import ipaddress from functools import wraps from string import Template @@ -90,7 +91,9 @@ class VMM: tap_id=tap, ip=network_ipv6) all_networks = self.etcd_client.get_prefix('/v1/network/', value_in_json=True) - update_radvd_conf(all_networks) + + if ipaddress.ip_network(network_ipv6).is_global: + update_radvd_conf(all_networks) command += " -netdev tap,id=vmnet{net_id},ifname={tap},script=no,downscript=no" \ " -device virtio-net-pci,netdev=vmnet{net_id},mac={mac}" \ @@ -361,7 +364,7 @@ def update_radvd_conf(all_networks): networks = { net.value['ipv6']: net.value['id'] for net in all_networks - if net.value.get('ipv6') + if net.value.get('ipv6') and ipaddress.ip_network(net.value.get('ipv6')).is_global } radvd_template = open(os.path.join(network_script_base, 'radvd-template.conf'), 'r').read()