328 |
328 |
329 def external_gateway_added(self, ri, ex_gw_port, external_dlname): |
329 def external_gateway_added(self, ri, ex_gw_port, external_dlname): |
330 |
330 |
331 if not net_lib.Datalink.datalink_exists(external_dlname): |
331 if not net_lib.Datalink.datalink_exists(external_dlname): |
332 dl = net_lib.Datalink(external_dlname) |
332 dl = net_lib.Datalink(external_dlname) |
333 # need to determine the VLAN ID for the VNIC |
333 # determine the network type of the external network |
334 evsname = ex_gw_port['network_id'] |
334 evsname = ex_gw_port['network_id'] |
335 cmd = ['/usr/sbin/evsadm', 'show-evs', '-co', 'vid', |
335 cmd = ['/usr/sbin/evsadm', 'show-evs', '-co', 'l2type,vid', |
336 '-f', 'evs=%s' % evsname] |
336 '-f', 'evs=%s' % evsname] |
337 try: |
337 try: |
338 stdout = utils.execute(cmd) |
338 stdout = utils.execute(cmd) |
339 except Exception as err: |
339 except Exception as err: |
340 LOG.error(_("Failed to retrieve the VLAN ID associated " |
340 LOG.error(_("Failed to retrieve the network type for " |
341 "with the external network, and it is required " |
341 "the external network, and it is required " |
342 "to create an external gateway port: %s") % err) |
342 "to create an external gateway port: %s") % err) |
343 return |
343 return |
344 vid = stdout.splitlines()[0].strip() |
344 output = stdout.splitlines()[0].strip() |
345 if vid == "": |
345 l2type, vid = output.split(':') |
346 LOG.error(_("External network does not have a VLAN ID " |
346 if l2type != 'flat' and l2type != 'vlan': |
347 "associated with it, and it is required to " |
347 LOG.error(_("External network should be either Flat or " |
|
348 "VLAN based, and it is required to " |
348 "create an external gateway port")) |
349 "create an external gateway port")) |
349 return |
350 return |
350 mac_address = ex_gw_port['mac_address'] |
351 elif (l2type == 'vlan' and |
351 dl.create_vnic(self.conf.external_network_datalink, |
352 self.conf.get("external_network_datalink", None)): |
352 mac_address=mac_address, vid=vid) |
353 LOG.warning(_("external_network_datalink is deprecated in " |
|
354 "Juno and will be removed in the next release of " |
|
355 "Solaris OpenStack. Please use the evsadm " |
|
356 "set-controlprop subcommand to setup the " |
|
357 "uplink-port for an external network")) |
|
358 # proceed with the old-style of doing things |
|
359 mac_address = ex_gw_port['mac_address'] |
|
360 dl.create_vnic(self.conf.external_network_datalink, |
|
361 mac_address=mac_address, vid=vid) |
|
362 else: |
|
363 # This is to handle HA by Solaris Cluster and is similar to |
|
364 # the code we already have for the DHCP Agent. So, when |
|
365 # the 1st L3 agent is down and the second L3 agent tries to |
|
366 # connect its VNIC to EVS, we will end up in "vport in use" |
|
367 # error. So, we need to reset the vport before we connect |
|
368 # the VNIC to EVS. |
|
369 cmd = ['/usr/sbin/evsadm', 'show-vport', '-f', |
|
370 'vport=%s' % ex_gw_port['id'], '-co', |
|
371 'evs,vport,status'] |
|
372 stdout = utils.execute(cmd) |
|
373 evsname, vportname, status = stdout.strip().split(':') |
|
374 tenant_id = ex_gw_port['tenant_id'] |
|
375 if status == 'used': |
|
376 cmd = ['/usr/sbin/evsadm', 'reset-vport', '-T', tenant_id, |
|
377 '%s/%s' % (evsname, vportname)] |
|
378 utils.execute(cmd) |
|
379 |
|
380 # next remove protection setting on the VPort to allow |
|
381 # multiple floating IPs to be configured on the l3e* |
|
382 # interface |
|
383 evsvport = "%s/%s" % (ex_gw_port['network_id'], |
|
384 ex_gw_port['id']) |
|
385 cmd = ['/usr/sbin/evsadm', 'set-vportprop', '-T', |
|
386 tenant_id, '-p', 'protection=none', evsvport] |
|
387 utils.execute(cmd) |
|
388 dl.connect_vnic(evsvport, tenant_id) |
|
389 |
353 self.driver.init_l3(external_dlname, [ex_gw_port['ip_cidr']]) |
390 self.driver.init_l3(external_dlname, [ex_gw_port['ip_cidr']]) |
354 |
391 |
355 # TODO(gmoodalb): wrap route(1m) command within a class in net_lib.py |
392 # TODO(gmoodalb): wrap route(1m) command within a class in net_lib.py |
356 gw_ip = ex_gw_port['subnet']['gateway_ip'] |
393 gw_ip = ex_gw_port['subnet']['gateway_ip'] |
357 if gw_ip: |
394 if gw_ip: |