- def info(dom):
- ''' Helper method to get a "nice" output of the info struct for debug'''
- [state, maxmem, mem, ncpu, cputime] = dom.info()
- return '%s is %s, maxmem = %s, mem = %s, ncpu = %s, cputime = %s' % (dom.name(), states.get(state, state), maxmem, mem, ncpu, cputime)
+ def get_interfaces_xml(rec):
+ xml = """
+ <interface type='network'>
+ <source network='default'/>
+ <target dev='{}'/>
+ </interface>
+""".format(Sliver_Libvirt.get_unique_vif())
+ try:
+ tags = rec['rspec']['tags']
+ if 'interface' in tags:
+ interfaces = eval(tags['interface'])
+ if not isinstance(interfaces, (list, tuple)):
+ # if interface is not a list, then make it into a singleton list
+ interfaces = [interfaces]
+ tag_xml = ""
+ for interface in interfaces:
+ if 'vlan' in interface:
+ vlanxml = "<vlan><tag id='{}'/></vlan>".format(interface['vlan'])
+ else:
+ vlanxml = ""
+ if 'bridge' in interface:
+ tag_xml = tag_xml + """
+ <interface type='bridge'>
+ <source bridge='{}'/>
+ {}
+ <virtualport type='openvswitch'/>
+ <target dev='{}'/>
+ </interface>
+ """.format(interface['bridge'], vlanxml, Sliver_Libvirt.get_unique_vif())
+ else:
+ tag_xml = tag_xml + """
+ <interface type='network'>
+ <source network='default'/>
+ <target dev='{}'/>
+ </interface>
+ """.format(Sliver_Libvirt.get_unique_vif())