Skip to content

Commit

Permalink
SM-VLAN: fix vlan configuration
Browse files Browse the repository at this point in the history
Closes-Bug: #1656461

1. call interface_setup.py with " --vlan <vlan-id>".
2. install vlan package via contrail kickstart.
3. fix interface_setup.py to have vlan with dhcp.

Change-Id: I84707e17d98c59e1c16036d7001646031ec73a5e
  • Loading branch information
Dheeraj Gautam committed Jan 19, 2017
1 parent f8f7c2f commit e038458
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/kickstarts/contrail-ubuntu.ks
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ apt-get update
apt-get -y install puppet
apt-get -y install python-netaddr
apt-get -y install ifenslave-2.6=1.1.0-19ubuntu5
apt-get -y install vlan
# Packages needed to get Inventory and Monitoring Info
apt-get -y install sysstat
Expand Down
1 change: 1 addition & 0 deletions src/kickstarts/contrail-ubuntu_trusty.ks
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ apt-get update
apt-get -y install biosdevname
apt-get -y install python-netaddr
apt-get -y install ifenslave=2.4ubuntu1
apt-get -y install vlan
# Packages needed to get Inventory and Monitoring Info
apt-get -y install sysstat
Expand Down
1 change: 1 addition & 0 deletions src/kickstarts/contrail-ubuntu_xenial.ks
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ apt-get update
apt-get -y install biosdevname
apt-get -y install python-netaddr
apt-get -y install ifenslave=2.4ubuntu1
apt-get -y install vlan
# Packages needed to get Inventory and Monitoring Info
apt-get -y install sysstat
Expand Down
15 changes: 10 additions & 5 deletions src/kickstarts/interface_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,16 @@ def create_bond_members(self):
def create_vlan_interface(self):
'''Create interface config for vlan sub interface'''
interface = 'vlan'+self.vlan
cfg = ['auto %s' %interface,
'iface %s inet static' %interface,
'address %s' %self.ipaddr,
'netmask %s' %self.netmask,
'vlan-raw-device %s' %self.device]
if self.dhcp:
cfg = ['auto %s' %interface,
'iface %s inet dhcp' %interface,
'vlan-raw-device %s' %self.device]
else:
cfg = ['auto %s' %interface,
'iface %s inet static' %interface,
'address %s' %self.ipaddr,
'netmask %s' %self.netmask,
'vlan-raw-device %s' %self.device]
if self.gw:
cfg.append('gateway %s' %self.gw)
if self.mtu:
Expand Down
30 changes: 19 additions & 11 deletions src/server_mgr_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3665,8 +3665,16 @@ def build_server_cfg(self, server):
d_gw = intf.get('default_gateway', None)
dhcp = intf.get('dhcp', None)
mtu = intf.get('mtu', '')
vlan = intf.get('vlan','')

if mtu:
mtu = '--mtu %s' %mtu

if vlan:
vlan = '--vlan %s' %vlan
else:
vlan = ''

type = intf.get('type', None)
#form string
if type and type.lower() == 'bond':
Expand All @@ -3675,32 +3683,32 @@ def build_server_cfg(self, server):
intf.get('member_interfaces', []))
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))
--device %s --members %s --bond-opts \"%s\" --dhcp %s\n") % \
(name, " ".join(member_intfs), json.dumps(bond_opts), vlan)
#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)
--device %s --members %s --bond-opts \"%s\" --ip %s --gw %s %s\n") % \
(name, " ".join(member_intfs), json.dumps(bond_opts), ip_addr, d_gw, vlan)
else:
device_str+= ("python /root/interface_setup.py \
--device %s --members %s --bond-opts \"%s\" --ip %s\n") % \
(name, " ".join(member_intfs), json.dumps(bond_opts), ip_addr)
--device %s --members %s --bond-opts \"%s\" --ip %s %s\n") % \
(name, " ".join(member_intfs), json.dumps(bond_opts), ip_addr, vlan)
execute_script = True
else:
#Take the mac_address as the name as the interface may be renamed after reboot
if 'mac_address' in intf:
name = intf['mac_address'].lower()
if dhcp:
device_str+= ("python /root/interface_setup.py --device %s --dhcp\n") %(name)
device_str+= ("python /root/interface_setup.py --device %s --dhcp %s\n") %(name, vlan)
else:
#For static managment interface pass the default gateway
if (mgmt_intf == intf_name) and d_gw:
device_str+= ("python /root/interface_setup.py --device %s --ip %s --gw %s\n") % \
(name, ip_addr, d_gw)
device_str+= ("python /root/interface_setup.py --device %s --ip %s --gw %s %s\n") % \
(name, ip_addr, d_gw, vlan)
else:
device_str+= ("python /root/interface_setup.py --device %s --ip %s\n") % \
(name, ip_addr)
device_str+= ("python /root/interface_setup.py --device %s --ip %s %s\n") % \
(name, ip_addr, vlan)
execute_script = True
# Build route configuration and add it
route_str = self.build_route_cfg(server)
Expand Down

0 comments on commit e038458

Please sign in to comment.