Skip to content

Commit

Permalink
Merge "SM-VLAN: fix vlan configuration"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 20, 2017
2 parents 6a636c4 + e038458 commit e9a0099
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
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
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
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
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
Expand Up @@ -3672,8 +3672,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 @@ -3682,32 +3690,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 e9a0099

Please sign in to comment.