Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tkt-64341: Fix creating additional epairs (by skarekrow) #153

Merged
merged 1 commit into from
Dec 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions iocage_lib/ioc_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def __start_jail__(self):
interface = self.conf["interfaces"].split(",")[0].split(
":")[0]

if interface == "vnet0":
if 'vnet' in interface:
# Jails default is epairNb
interface = f"{interface.replace('vnet', 'epair')}b"

Expand Down Expand Up @@ -638,7 +638,6 @@ def start_network_interface_vnet(self, nic_defs, net_configs, jid):
iface, ip = addr.split("|")
except ValueError:
# They didn't supply an interface, assuming default

iface, ip = "vnet0", addr

if iface not in nics:
Expand Down Expand Up @@ -682,7 +681,7 @@ def start_network_vnet_iface(self, nic, bridge, mtu, jid):
epair_a = epair_a.strip()
epair_b = re.sub(b"a$", b"b", epair_a)

if nic == "vnet0":
if 'vnet' in nic:
# Inside jails they are epairN
jail_nic = f"{nic.replace('vnet', 'epair')}b"
else:
Expand All @@ -702,8 +701,8 @@ def start_network_vnet_iface(self, nic, bridge, mtu, jid):
stderr=su.STDOUT
)
iocage_lib.ioc_common.checkoutput(
["ifconfig", f"{nic}:{jid}", "description",
f"associated with jail: {self.uuid}"],
["ifconfig", f"{nic}.{jid}", "description",
f"associated with jail: {self.uuid} as nic: {jail_nic}"],
stderr=su.STDOUT
)

Expand Down Expand Up @@ -772,31 +771,38 @@ def start_network_vnet_addr(self, iface, ip, defaultgw, ipv6=False):
:param defaultgw: The gateway IP to assign to the nic
:return: If an error occurs it returns the error. Otherwise, it's None
"""
dhcp = self.get("dhcp")
dhcp = self.get('dhcp')

if iface == "vnet0":
if 'vnet' in iface:
# Inside jails they are epairNb

iface = f"{iface.replace('vnet', 'epair')}b"

# Crude check to see if it's a IPv6 address
iface = f'{iface.replace("vnet", "epair")}b'

if ipv6:
ifconfig = [iface, "inet6", ip, "up"]
route = ["add", "-6", "default", defaultgw]
ifconfig = [iface, 'inet6', ip, 'up']
# set route to none if this is not the first interface
if iface.rsplit('epair')[1][0] == '0':
route = ['add', '-6', 'default', defaultgw]
else:
route = 'none'
else:
ifconfig = [iface, ip, "up"]
route = ["add", "default", defaultgw]
ifconfig = [iface, ip, 'up']
# set route to none if this is not the first interface
if iface.rsplit('epair')[1][0] == '0':
route = ['add', 'default', defaultgw]
else:
route = 'none'

try:
if dhcp == "off" and ip != 'accept_rtadv':
if dhcp == 'off' and ip != 'accept_rtadv':
# Jail side
iocage_lib.ioc_common.checkoutput(
["setfib", self.exec_fib, "jexec", f"ioc-{self.uuid}",
"ifconfig"] + ifconfig, stderr=su.STDOUT)
iocage_lib.ioc_common.checkoutput(
["setfib", self.exec_fib, "jexec", f"ioc-{self.uuid}",
"route"] + route, stderr=su.STDOUT)
['setfib', self.exec_fib, 'jexec', f'ioc-{self.uuid}',
'ifconfig'] + ifconfig, stderr=su.STDOUT)
# route has value of none if this is not the first interface
if route != 'none':
iocage_lib.ioc_common.checkoutput(
['setfib', self.exec_fib, 'jexec', f'ioc-{self.uuid}',
'route'] + route, stderr=su.STDOUT)
else:
if ipv6:
if ip == 'accept_rtadv':
Expand All @@ -807,11 +813,11 @@ def start_network_vnet_addr(self, iface, ip, defaultgw, ipv6=False):
'onestart'], stderr=su.STDOUT)
else:
iocage_lib.ioc_common.checkoutput(
["setfib", self.exec_fib, "jexec", f"ioc-{self.uuid}",
"service", "dhclient", "start", iface],
['setfib', self.exec_fib, 'jexec', f'ioc-{self.uuid}',
'service', 'dhclient', 'start', iface],
stderr=su.STDOUT)
except su.CalledProcessError as err:
return f"{err.output.decode('utf-8')}".rstrip()
return f'{err.output.decode("utf-8")}'.rstrip()
else:
return

Expand Down Expand Up @@ -893,7 +899,7 @@ def __check_dhcp__(self):
_rc = open(f"{self.path}/root/etc/rc.conf").readlines()

for nic in nics:
if nic == "vnet0":
if 'vnet' in nic:
# Inside jails they are epairNb
nic = f"{nic.replace('vnet', 'epair')}b"
replaced = False
Expand Down