os.path.join(BASE_DIR, subsystem, 'libvirt', 'lxc'),
# as observed on f20
os.path.join(BASE_DIR, subsystem ),
+ # as observed on f16 libvirt 1.2.1
+ os.path.join(BASE_DIR, subsystem, 'machine'),
]
# try several locations and return all the results
# get_cgroup_path will sort it out
def get_cgroup_path(name, subsystem="cpuset"):
""" Returns the base path for the cgroup with a specific name or None."""
- return reduce(lambda a, b: b if os.path.basename(b) == name else a,
+ result = reduce(lambda a, b: b if os.path.basename(b) == name else a,
get_cgroup_paths(subsystem), None)
+ if result is None:
+ name = name + ".libvirt-lxc"
+ result = reduce(lambda a, b: b if os.path.basename(b) == name else a,
+ get_cgroup_paths(subsystem), None)
+
+ return result
+
def get_base_path():
return BASE_DIR
import os, os.path
import subprocess
import pprint
+import random
import libvirt
# Call the upper configure method (ssh keys...)
Account.configure(self, rec)
+ @staticmethod
+ def get_unique_vif():
+ return 'veth%s' % random.getrandbits(32)
+
# A placeholder until we get true VirtualInterface objects
@staticmethod
def get_interfaces_xml(rec):
xml = """
<interface type='network'>
<source network='default'/>
+ <target dev='%s'/>
</interface>
-"""
+""" % (Sliver_Libvirt.get_unique_vif())
try:
tags = rec['rspec']['tags']
if 'interface' in tags:
<source bridge='%s'/>
%s
<virtualport type='openvswitch'/>
+ <target dev='%s'/>
</interface>
- """ % (interface['bridge'], vlanxml)
+ """ % (interface['bridge'], vlanxml, Sliver_Libvirt.get_unique_vif())
else:
tag_xml = tag_xml + """
<interface type='network'>
<source network='default'/>
+ <target dev='%s'/>
</interface>
- """
+ """ % (Sliver_Libvirt.get_unique_vif())
+
xml = tag_xml
logger.log('sliver_libvirty.py: interface XML is: %s' % xml)