import re
import tools
-import libvirt
import uuid
-from sliver_libvirt import Sliver_Libvirt
from xml.dom.minidom import parseString
+# TODO: is there anything better to do if the "libvirt", "sliver_libvirt",
+# and are not in place in the VS distro?
+try:
+ import libvirt
+ from sliver_libvirt import Sliver_Libvirt
+except:
+ logger.log("Could not import 'sliver_lxc' or 'libvirt'.")
+
priority=150
ipv6addrtag = 'ipv6_address'
def SetSliverTag(plc, data, tagname):
+ virt=tools.get_node_virt()
+ if virt!='lxc':
+ return
+
for slice in data['slivers']:
- logger.log("update_ipv6addr_slivertag: starting with slice=%s" % (slice['name']) )
+# logger.log("update_ipv6addr_slivertag: starting with slice=%s" % (slice['name']) )
# TODO: what about the prefixlen? should we add on it as well?
# here, I'm just taking the ipv6addr (value)
except:
logger.log("update_ipv6addr_slivertag: slice tag not deleted for slice=%s" % \
(slice['name']) )
- # if there's no ipv6 address anymore, then remove everything from the /etc/hosts
- tools.remove_all_ipv6addr_hosts(slice['name'], data['hostname'])
+ result = tools.search_ipv6addr_hosts(slice['name'], value)
+ if result:
+ # if there's any ipv6 address, then remove everything from the /etc/hosts
+ tools.remove_all_ipv6addr_hosts(slice['name'], data['hostname'])
else:
# if the ipv6 addr set on the slice does not exist yet, so, let's add it
if (ipv6addr is None) and len(value)>0:
if not result:
tools.remove_all_ipv6addr_hosts(slice['name'], data['hostname'])
tools.add_ipv6addr_hosts_line(slice['name'], data['hostname'], value)
- logger.log("update_ipv6addr_slivertag: finishing the update process for " +
- "slice=%s" % (slice['name']) )
+# logger.log("update_ipv6addr_slivertag: finishing the update process for " +
+# "slice=%s" % (slice['name']) )
def GetSlivers(data, config, plc):
SetSliverTag(plc, data, ipv6addrtag)