Merge "Allow command line for virtual-interface-list"

This commit is contained in:
Jenkins 2015-12-17 19:33:21 +00:00 committed by Gerrit Code Review
commit 36e125a61e
3 changed files with 54 additions and 0 deletions

View File

@ -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')

View File

@ -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

View File

@ -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)