MCPcopy
hub / github.com/retspen/webvirtcloud / wvmInterfaces

Class wvmInterfaces

vrtManager/interface.py:6–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class wvmInterfaces(wvmConnect):
7 def get_iface_info(self, name):
8 iface = self.get_iface(name)
9 xml = iface.XMLDesc(0)
10 mac = iface.MACString()
11 itype = util.get_xml_path(xml, "/interface/@type")
12 state = iface.isActive()
13 return {'name': name, 'type': itype, 'state': state, 'mac': mac}
14
15 def define_iface(self, xml, flag=0):
16 self.wvm.interfaceDefineXML(xml, flag)
17
18 def create_iface(self, name, itype, mode, netdev, ipv4_type, ipv4_addr, ipv4_gw,
19 ipv6_type, ipv6_addr, ipv6_gw, stp, delay):
20 xml = """<interface type='%s' name='%s'>
21 <start mode='%s'/>""" % (itype, name, mode)
22 if ipv4_type == 'dhcp':
23 xml += """<protocol family='ipv4'>
24 <dhcp/>
25 </protocol>"""
26 if ipv4_type == 'static':
27 address, prefix = ipv4_addr.split('/')
28 xml += """<protocol family='ipv4'>
29 <ip address='%s' prefix='%s'/>
30 <route gateway='%s'/>
31 </protocol>""" % (address, prefix, ipv4_gw)
32 if ipv6_type == 'dhcp':
33 xml += """<protocol family='ipv6'>
34 <dhcp/>
35 </protocol>"""
36 if ipv6_type == 'static':
37 address, prefix = ipv6_addr.split('/')
38 xml += """<protocol family='ipv6'>
39 <ip address='%s' prefix='%s'/>
40 <route gateway='%s'/>
41 </protocol>""" % (address, prefix, ipv6_gw)
42 if itype == 'bridge':
43 xml += """<bridge stp='%s' delay='%s'>
44 <interface name='%s' type='ethernet'/>
45 </bridge>""" % (stp, delay, netdev)
46 xml += """</interface>"""
47 self.define_iface(xml)
48 iface = self.get_iface(name)
49 iface.create()
50
51
52class wvmInterface(wvmConnect):

Callers 1

interfacesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected