Skip to content

Commit

Permalink
Closes-Bug: #1640064
Browse files Browse the repository at this point in the history
Set the default gateway only for the management interface
gateway is no longer a mandatory reimage parameter

Change-Id: I67fb2469a8b3f7ed80bc5bbec4ba06dc442242e5
  • Loading branch information
sgurumurthy committed Nov 11, 2016
1 parent bbf8a7a commit 2719e4a
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/server_mgr_main.py
Expand Up @@ -1879,7 +1879,9 @@ def plug_mgmt_intf_details(self, server):
server_parameters = {}
server_parameters['interface_name'] = mgmt_intf_name
server['parameters'] = server_parameters

dhcp = mgmt_intf_obj.get('dhcp', False)
if not dhcp and mgmt_intf_obj['d_gw'] is None:
raise ServerMgrException("For managment interface configured as static default gateway has to be specified", ERR_OPR_ERROR)
else:
print 'check'
# check if old details are there else throw error
Expand Down Expand Up @@ -3352,8 +3354,7 @@ def reimage_server(self):
(self._args.listen_ip_addr, host_name)

_mandatory_reimage_params = {"server_password": "password",
"server_gateway": "gateway","server_domain":"domain",
"server_ifname" :"interface_name"}
"server_domain":"domain", "server_ifname" :"interface_name"}

msg = ''
for k,v in _mandatory_reimage_params.items():
Expand Down Expand Up @@ -3457,7 +3458,12 @@ def build_server_cfg(self, server):
bond_opts = intf.get('bond_options', {})
member_intfs = self.get_member_interfaces(network_dict,
intf.get('member_interfaces', []))
if d_gw:
if dhcp:
device_str+= ("python /root/interface_setup.py \
--device %s --members %s --bond-opts \"%s\" --dhcp\n") % \
(name, " ".join(member_intfs), json.dumps(bond_opts))
#If bond interface is the management interface you need to set the gateway
elif ((mgmt_intf == name) and d_gw):
device_str+= ("python /root/interface_setup.py \
--device %s --members %s --bond-opts \"%s\" --ip %s --gw %s\n") % \
(name, " ".join(member_intfs), json.dumps(bond_opts), ip_addr, d_gw)
Expand All @@ -3467,17 +3473,14 @@ def build_server_cfg(self, server):
(name, " ".join(member_intfs), json.dumps(bond_opts), ip_addr)
execute_script = True
else:
if 'mac_address' in intf:
#Take mac_address as the name only if the interface name is not specified
if 'name' not in intf and 'mac_address' in intf:
name = intf['mac_address'].lower()
if dhcp:
if d_gw:
device_str+= ("python /root/interface_setup.py --device %s --gw %s --dhcp\n") % \
(name, d_gw)
else:
device_str+= ("python /root/interface_setup.py --device %s --dhcp\n") % \
(name)
device_str+= ("python /root/interface_setup.py --device %s --dhcp\n") %(name)
else:
if d_gw:
#For static managment interface pass the default gateway
if (mgmt_intf == name) and d_gw:
device_str+= ("python /root/interface_setup.py --device %s --ip %s --gw %s\n") % \
(name, ip_addr, d_gw)
else:
Expand Down Expand Up @@ -3737,7 +3740,7 @@ def get_control_ip(self, server):
def get_control_gateway(self, server):
control_intf = eval(self.get_control_interface(server))
for key, value in control_intf.iteritems():
if 'gateway' in value and len(value['gateway']):
if 'gateway' in value and value['gateway'] != 'None':
return str(IPNetwork(value['gateway']).ip)
if 'gateway' in server and len(server['gateway']):
return str(IPNetwork(server['gateway']).ip)
Expand Down

0 comments on commit 2719e4a

Please sign in to comment.