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

Function is_guestnet_configured

systemvm/debian/opt/cloud/bin/update_config.py:60–113  ·  view source on GitHub ↗
(guestnet_dict, keys)

Source from the content-addressed store, hash-verified

58
59
60def is_guestnet_configured(guestnet_dict, keys):
61
62 existing_keys = []
63 new_eth_key = None
64
65 for k1, v1 in guestnet_dict.items():
66 if k1 in keys and len(v1) > 0:
67 existing_keys.append(k1)
68
69 if not existing_keys:
70 '''
71 It seems all the interfaces have been removed. Let's allow a new configuration to come in.
72 '''
73 logging.warn("update_config.py :: Reconfiguring guest network...")
74 return False
75
76 file = open(jsonConfigFile)
77 new_guestnet_dict = json.load(file)
78
79 if not new_guestnet_dict['add']:
80 '''
81 Guest network has to be removed.
82 '''
83 logging.info("update_config.py :: Removing guest network...")
84 return False
85
86 '''
87 Check if we have a new guest network ready to be setup
88 '''
89 device = new_guestnet_dict['device']
90
91 if device in existing_keys:
92 '''
93 Device already configured, ignore.
94 '''
95 return True
96
97 exists = False
98
99 for key in existing_keys:
100 for interface in guestnet_dict[key]:
101 new_mac = new_guestnet_dict["mac_address"].encode('utf-8')
102 old_mac = interface["mac_address"].encode('utf-8')
103 new_ip = new_guestnet_dict["router_guest_ip"].encode('utf-8')
104 old_ip = interface["router_guest_ip"].encode('utf-8')
105
106 if (new_mac == old_mac) and (new_ip == old_ip):
107 exists = True
108 break
109
110 if exists:
111 break
112
113 return exists
114
115
116# If the command line json file is unprocessed process it

Callers 1

update_config.pyFile · 0.85

Calls 4

encodeMethod · 0.65
appendMethod · 0.45
loadMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected