summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--novaclient/tests/functional/v2/legacy/test_virtual_interface.py40
-rw-r--r--novaclient/tests/unit/v2/test_shell.py4
-rw-r--r--novaclient/v2/shell.py10
3 files changed, 54 insertions, 0 deletions
diff --git a/novaclient/tests/functional/v2/legacy/test_virtual_interface.py b/novaclient/tests/functional/v2/legacy/test_virtual_interface.py
new file mode 100644
index 00000000..30c090aa
--- /dev/null
+++ b/novaclient/tests/functional/v2/legacy/test_virtual_interface.py
@@ -0,0 +1,40 @@
+# Copyright 2015 IBM Corp.
+# 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
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from novaclient.tests.functional import base
+from novaclient.v2 import shell
+
+
+class TestConsolesNovaClient(base.ClientTestBase):
+ """Consoles functional tests."""
+
+ COMPUTE_API_VERSION = "2.1"
+
+ def _create_server(self):
+ name = self.name_generate(prefix='server')
+ network = self.client.networks.list()[0]
+ server = self.client.servers.create(
+ name, self.image, self.flavor, nics=[{"net-id": network.id}])
+ shell._poll_for_status(
+ self.client.servers.get, server.id,
+ 'building', ['active'])
+ self.addCleanup(server.delete)
+ return server
+
+ def _test_virtual_interface_list(self, command):
+ server = self._create_server()
+ completed_command = command % server.id
+ self.nova(completed_command)
+
+ def test_virtual_interface_list(self):
+ self._test_virtual_interface_list('virtual-interface-list %s')
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index 8b4f1f58..071ba0b3 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -2576,6 +2576,10 @@ class ShellTest(utils.TestCase):
self.run_command('server-group-list --all-projects')
self.assert_called('GET', '/os-server-groups?all_projects')
+ def test_list_server_os_virtual_interfaces(self):
+ self.run_command('virtual-interface-list 1234')
+ self.assert_called('GET', '/servers/1234/os-virtual-interfaces')
+
def test_versions(self):
exclusions = set([
1, # Same as version 2.0
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index 8ac88043..23e17a66 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -37,6 +37,7 @@ import six
import novaclient
from novaclient import api_versions
+from novaclient import base
from novaclient import client
from novaclient import exceptions
from novaclient.i18n import _
@@ -4778,3 +4779,12 @@ def do_version_list(cs, args):
print (_("\nServer supported API versions:"))
utils.print_list(result, columns)
+
+
+@cliutils.arg('server', metavar='<server>', help=_('ID of server.'))
+def do_virtual_interface_list(cs, args):
+ """Show virtual interface info about the given server."""
+ server = _find_server(cs, args.server)
+ interface_list = cs.virtual_interfaces.list(base.getid(server))
+ columns = ['Id', 'Mac address']
+ utils.print_list(interface_list, columns)