MCPcopy Create free account
hub / github.com/apache/cloudstack / CsGuestNetwork

Class CsGuestNetwork

systemvm/debian/opt/cloud/bin/cs/CsGuestNetwork.py:20–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class CsGuestNetwork:
21 def __init__(self, device, config):
22 self.data = {}
23 self.guest = True
24 db = DataBag()
25 db.setKey("guestnetwork")
26 db.load()
27 dbag = db.getDataBag()
28 self.config = config
29 if device in list(dbag.keys()) and len(dbag[device]) != 0:
30 self.data = dbag[device][0]
31 else:
32 self.guest = False
33
34 def is_guestnetwork(self):
35 return self.guest
36
37 def is_vr_guest_gateway(self):
38 return self.guest and ('is_vr_guest_gateway' not in self.data or self.data['is_vr_guest_gateway'])
39
40 def get_dns(self):
41 if not self.guest:
42 return self.config.get_dns()
43
44 if self.config.use_router_ip_as_resolver():
45 return [self.data['router_guest_ip']]
46
47 dns = []
48 if not self.config.use_extdns():
49 if 'router_guest_gateway' in self.data and self.is_vr_guest_gateway():
50 dns.append(self.data['router_guest_gateway'])
51 elif 'router_guest_ip' in self.data and not self.is_vr_guest_gateway():
52 dns.append(self.data['router_guest_ip'])
53
54 if 'dns' in self.data:
55 dns.extend(self.data['dns'].split(','))
56
57 return dns or ['']
58
59 def set_dns(self, val):
60 self.data['dns'] = val
61
62 def set_router(self, val):
63 self.data['router_guest_gateway'] = val
64
65 def get_netmask(self):
66 # We need to fix it properly. I just added the if, as Ian did in some other files, to avoid the exception.
67 if 'router_guest_netmask' in self.data:
68 return self.data['router_guest_netmask']
69 return ''
70
71 def get_gateway(self):
72 # We need to fix it properly. I just added the if, as Ian did in some other files, to avoid the exception.
73 if 'router_guest_gateway' in self.data:
74 return self.data['router_guest_gateway']
75 return ''
76
77 def get_domain(self):

Callers 3

configure_serverMethod · 0.90
test_initMethod · 0.90
test_get_dnsMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_initMethod · 0.72
test_get_dnsMethod · 0.72