--- a/components/openstack/neutron/files/agent/solaris/net_lib.py Mon May 16 14:46:20 2016 +0200
+++ b/components/openstack/neutron/files/agent/solaris/net_lib.py Fri May 20 17:42:29 2016 -0400
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -42,12 +42,13 @@
@classmethod
def ifname_exists(cls, ifname):
-
- cmd = ['/usr/sbin/ipadm', 'show-if', '-po', 'ifname']
- stdout = cls.execute(cmd)
-
- return ifname in stdout
-
+ try:
+ cmd = ['/usr/sbin/ipadm', 'show-if', '-po', 'ifname', ifname]
+ cls.execute(cmd, log_fail_as_error=False)
+ except Exception:
+ return False
+ return True
+
@classmethod
def ipaddr_exists(cls, ifname, ipaddr):
@@ -82,8 +83,7 @@
if temp:
cmd.append('-t')
self.execute_with_pfexec(cmd)
-
- if self.ipaddr_exists(self._ifname, ipaddr):
+ elif self.ipaddr_exists(self._ifname, ipaddr):
return
# If an address is IPv6, then to create a static IPv6 address
@@ -111,6 +111,25 @@
self.execute_with_pfexec(cmd)
+ def create_addrconf(self, temp=True):
+ if not self.ifname_exists(self._ifname):
+ # create ip interface
+ cmd = ['/usr/sbin/ipadm', 'create-ip', self._ifname]
+ if temp:
+ cmd.append('-t')
+ self.execute_with_pfexec(cmd)
+ else:
+ cmd = ['/usr/sbin/ipadm', 'show-addr', '-po', 'type', self._ifname]
+ stdout = self.execute(cmd)
+ if 'addrconf' in stdout:
+ return
+
+ cmd = ['/usr/sbin/ipadm', 'create-addr', '-T', 'addrconf',
+ self._ifname]
+ if temp:
+ cmd.append('-t')
+ self.execute_with_pfexec(cmd)
+
def delete_address(self, ipaddr):
if not self.ipaddr_exists(self._ifname, ipaddr):
return
@@ -149,11 +168,12 @@
@classmethod
def datalink_exists(cls, dlname):
-
- cmd = ['/usr/sbin/dladm', 'show-link', '-po', 'link']
- stdout = utils.execute(cmd)
-
- return dlname in stdout
+ try:
+ cmd = ['/usr/sbin/dladm', 'show-link', '-po', 'link', dlname]
+ utils.execute(cmd, log_fail_as_error=False)
+ except Exception:
+ return False
+ return True
def connect_vnic(self, evsvport, tenantname=None, temp=True):
if self.datalink_exists(self._dlname):
@@ -178,7 +198,8 @@
cmd = ['/usr/sbin/dladm', 'show-linkprop', '-co', 'value',
'-p', 'default_tag', lower_link]
stdout = utils.execute(cmd)
- if stdout.splitlines()[0].strip() == vid:
+ default_tag = stdout.splitlines()[0].strip()
+ if default_tag == vid or (vid == '1' and default_tag == '0'):
vid = '0'
else:
vid = '0'
@@ -197,8 +218,8 @@
self.execute_with_pfexec(cmd)
@classmethod
- def show_vnic(cls):
- cmd = ['/usr/sbin/dladm', 'show-vnic', '-po', 'link']
+ def show_link(cls):
+ cmd = ['/usr/sbin/dladm', 'show-link', '-po', 'link']
stdout = utils.execute(cmd)
return stdout.splitlines()