Allow command line for virtual-interface-list
There is virtual-interface-list API support in nova but no command line interface in novaclient, this patch adds it. Closes-Bug: 1522424 Change-Id: Ib3078125beb7beaa08a3408486db54e0d10763e6
This commit is contained in:
parent
06af0bf79b
commit
6b0fe2a424
|
@ -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')
|
|
@ -2528,6 +2528,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
|
||||
|
|
|
@ -36,6 +36,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 _
|
||||
|
@ -4681,3 +4682,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)
|
||||
|
|
Loading…
Reference in New Issue