227 Commits

Author SHA1 Message Date
Matt Riedemann
6a199bd141 Support type=image with --block-device-mapping option
The --block-device-mapping option on the server create
command currently only supports booting from volume and
volume snapshot. A common boot-from-volume scenario is
providing an image and letting nova orchestrate the
creation of the image-backed volume and attaching it to
the server.

This adds support for type=image in the --block-device-mapping
option. The volume size is required in this case. Note that
the CLI currently says if type=snapshot that size is also required
but that's technically not true. When booting from a volume
snapshot, the compute API will use the size of the volume snapshot
to create the volume if an explicit size is not provided. For the
purposes of this patch, we need the size anyway for the image
being the block device mapping source type.

Change-Id: I57b3c261d8309f7b9f62a3e91612bce592a887a3
Story: 2006302
Task: 36016
2019-08-09 16:36:17 +00:00
Zuul
c474319909 Merge "Add host and hypervisor_hostname to create servers" 2019-07-23 01:32:32 +00:00
zhu.boxiang
340f25fa14 Add host and hypervisor_hostname to create servers
Adds the --host and --hypervisor-hostname options to
``openstack server create`` CLI.

Depends-On: https://review.opendev.org/670558

Change-Id: If188c3d96fa506dbe62ef256418f2f9bca1520c2
Blueprint: add-host-and-hypervisor-hostname-flag-to-create-server
2019-07-19 15:45:18 +00:00
melanie witt
bfc34e11b3 Fix BFV server list handling with --name-lookup-one-by-one
When the --name-lookup-one-by-one option passed to the 'server list'
command, the image and flavor names will be looked up for each
server being listed instead of fetching all image/flavor names.

The current code assumes all servers have an image attribute, but
servers booted from volumes have no image, so the following error is
raised when listing BFV servers with --name-lookup-one-by-one:

  AttributeError: ('unicode'|'str') object has no attribute 'get'

The error occurs when the code attempts server.image.get('id').

This fixes the --name-lookup-one-by-one code not to assume an image
for a server. The unit tests for 'server list' have also been
robustified to feature one BFV server to enhance our test coverage.

Story: #2006063
Task: #34777

Change-Id: I312c971346c7ded93f6fcaa515098554b8580295
2019-06-28 22:06:39 +00:00
Zuul
0bc70a344f Merge "Add server add/remove volume description for microversion 2.20" 2019-06-22 00:27:31 +00:00
Zuul
17611a72c5 Merge "Microversion 2.73: Support adding the reason behind a server lock" 2019-06-21 20:59:49 +00:00
Surya Seetharaman
187be0ac22 Microversion 2.73: Support adding the reason behind a server lock
This patch adds a new parameter ``--reason`` to ``openstack server lock``
command and ``--locked``, ``unlocked`` filtering parameters to
``openstack server list`` command. This can help users to provide a
reason when locking the server and to filter instances based on their
locked value from 2.73 microversion.

Implements blueprint add-locked-reason
Depends-On: https://review.opendev.org/#/c/661785/

Change-Id: Ib2714f98b24d47e570da8a6c231e765acd2ff595
2019-06-21 11:35:51 -05:00
Martin Chlumsky
1aad94349b Allow "server migrate" (not live) to take "--host" option
Currently, doing a cold migration while specifying a target host is not
possible however nova api supports it since version 2.56.

This patch allows passing "--host" when doing a cold migration.
It runs normally if --os-compute-api-version is 2.56 or greater and
returns an error otherwise.

Change-Id: I960109008096ce8bb4e4c8ca6ffb22c33aacd995
Story: 2003325
Task: 24359
2019-06-21 14:47:07 +00:00
Matt Riedemann
3df5f92b44 Add server add/remove volume description for microversion 2.20
The compute API 2.20 microversion allows attaching and detaching
a volume to/from a server with status SHELVED or SHELVED_OFFLOADED.
For OSC this just means the user has to specify the appropriate
minimum microversion to make that work, so this change mentions
that in the "server add volume" and "server remove volume" command
description.

Related to nova blueprint volume-ops-when-shelved

Change-Id: I4824175e5d9e124e3bd9e9a8fd5a89277efc6cff
2019-06-12 11:39:54 -04:00
Zuul
25ccca4063 Merge "Deprecate openstack server migrate --host option" 2019-06-06 19:05:46 +00:00
Zuul
86d7490f77 Merge "Add changes-before attribute to server list" 2019-06-06 17:40:48 +00:00
Zuul
95626f1acb Merge "Compute: Add description support for server" 2019-06-05 03:25:46 +00:00
zhangbailin
ef1fd38815 Add changes-before attribute to server list
Closes-Bug: #1827844
Part of bp support-to-query-nova-resources-filter-by-changes-before

Change-Id: I4f28168188973730247bcbcb70ba0e70eb81e3be
2019-05-31 05:39:29 +00:00
Matt Riedemann
3057989714 Deprecate openstack server migrate --host option
Per the discussion at the Train Forum [1] this deprecates
the problematic --live option on the server migrate command
which, depending on the compute API version used, forcefully
bypasses the scheduler and also does not allow you to live
migrate a server and let the scheduler pick a host.

The --live option is replaced here with two new options:

* --live-migration: this simply tells the command you want to
  perform a live rather than cold migration; if specified with
  --live the --live-migration option takes priority.

* --host: when specified, this will request a target host for
  the live migration and will be validated by the scheduler;
  if not specified, the scheduler will pick a host. This option
  is mutually exclusive with --live.

We can build on the --host option by supporting cold migrations
with a specified host when using compute API version 2.56 or
greater but that will come in a separate change.

If the --live option is ever used we log a warning.

Note there are several related changes for this issue:

- https://review.openstack.org/#/c/628334/
- https://review.openstack.org/#/c/626949/
- https://review.openstack.org/#/c/627801/
- https://review.openstack.org/#/c/589012/
- https://review.openstack.org/#/c/460059/

This change allows us to deprecate the --live option and provide
a replacement which is backward compatible without having to use
something potentially error-prone like nargs='?'.

Closes-Bug: #1411190

[1] https://etherpad.openstack.org/p/DEN-osc-compute-api-gaps

Change-Id: I95d3d588e4abeb6848bdccf6915f7b5da40b5d4f
2019-05-24 15:57:54 -04:00
Chen
c77a9621be Compute: Add description support for server
This patch adds functionality to configure server's description with:
1 server create
2 server set
3 server unset
4 server rebuild

Change-Id: Ic06d97b29e51828b29d7ac5172645c288e4ada9e
Story: 2002005
Task: 19640
2019-05-17 20:56:45 +00:00
Matt Riedemann
42cd4b2e40 Document that server dump create requires 2.17
There is no indication to the user in the command
help that they have to use 2.17 or greater [1] to run
the "openstack server dump create" command. This
mentions that requirement in the help of the command.

[1] https://developer.openstack.org/api-ref/compute/#trigger-crash-dump-in-server

Change-Id: I02c06e10a26eb38ddecb70f970cfcbfad962201c
2019-05-01 18:00:17 -04:00
Zuul
e59b9f4261 Merge "Add note about version 2.5 when listing servers using --ip6" 2019-03-07 21:05:01 +00:00
Zuul
7feb9d38d0 Merge "API microversion 2.69: Handles Down Cells" 2019-03-07 08:01:45 +00:00
Surya Seetharaman
239b103849 API microversion 2.69: Handles Down Cells
This patch explicitly points out the change needed while
forming the detailed lists for servers. In those cases
where the server response for ``openstack server list``
has the flavor and image keys missing for the instances
in the down cell, the servers will be skipped from being
processed.

Depends-On: https://review.openstack.org/591657/
Related to blueprint handling-down-cell
Change-Id: Ibcfe9febdc45db1cb86c6e88f65976feceb01c02
2019-03-06 08:35:25 +00:00
Christian Schneemann
6475882fd8 Typo fix
Just a typo fix.

Change-Id: I1d1fe6eb95c0b167265b3664314d764e3c316fe2
2019-02-27 09:06:18 +01:00
Noam Angel
7276610595 fix multiple server delete produce multiple new lines
Closes-Bug: #1809874
Change-Id: Ib988b189b41af03d3d871b660bb5b5cc090c3f30
2019-01-16 19:33:56 +00:00
Zuul
c3a60e1173 Merge "Add --name-lookup-one-by-one option to server list" 2018-11-08 19:07:02 +00:00
melanie witt
013c9a4f3a Handle multiple ports in AddFloatingIP
AddFloatingIP refers to an old nova proxy API to neutron that was
deprecated in nova. The neutron API for floating IP associate requires
a port to be specified. Currently, the code is selecting the first port
if the server has multiple ports. But, an attempt to associate the
first port with a floating IP can fail if the first port is not on a
network that is attached to an external gateway.

In order to make the command work better for users who have a server
with multiple ports, we can:

  1. Select the port corresponding to the fixed_ip_address, if one was
     specified

  2. Try to associate the floating IP with each port until one of the
     attempts succeeds, else re-raise the last exception.
     (404 ExternalGatewayForFloatingIPNotFound from neutron)

This also fixes incorrect FakeFloatingIP attributes that were being set
in the TestServerAddFloatingIPNetwork unit tests, which were causing
the tests to use None as parsed args for ip-address and
--fixed-ip-address and thus bypassing code in the
'if parsed_args.fixed_ip_address:' block.

Task: 27800
Story: 2004263

Change-Id: I11fbcebf6b00f12a030b000c84dcf1d6b5e86250
2018-11-06 20:18:13 +00:00
Zuul
1894a3cb17 Merge "Add --key-name and --key-unset option for server rebuild API." 2018-11-02 19:41:24 +00:00
Pavlo Shchelokovskyy
e782f49927 Add --name-lookup-one-by-one option to server list
usually in a big cloud there are many images and flavors,
while each given project might use only some of those.

This patch introduces '--name-lookup-one-by-one' argument to
server list command (mutually exclusive with '--no-name-lookup')

When provided (or either '--image' or '--flavor' is specified) to the
`server list` command, name resolving for
corresponding entity is now using targeted GET commands instead of
full entities list.

In some situations this can significantly speedup the execution of the
`server list` command by reducing the number of API requests performed.

Change-Id: I59cbf3f75c55e5d3747654edcc9be86ad954cf40
Story: #2002039
Task: #19682
2018-11-02 12:01:36 -05:00
Zuul
0fa3c84b4f Merge "Default --nic to 'auto' if creating a server with >= 2.37" 2018-10-26 03:20:17 +00:00
Fan Zhang
f82c5b85ce Add --key-name and --key-unset option for server rebuild API.
Change-Id: I6d4793a8e961080ea1d6d414cef8d6bbed0c53e7
Story: 2002609
Task: 22228
Signed-off-by: Fan Zhang <zh.f@outlook.com>
2018-10-09 14:34:44 +08:00
Ruby Loo
e3dc30fe8c Add --property option to 'server rebuild' command
Add '--property' option to the 'server rebuild' command, to provide
the ability to specify properties of the rebuilt instance.

This is equivalent to the '--meta' option of the compute's
'nova rebuild' command.

Change-Id: I25ea6622e970416090109316e1e28fab8b0b3f07
Story: #2003979
Task: #26922
2018-10-05 16:33:48 -04:00
Artom Lifshitz
d6121782d3 Don't sent disk_over_commit if nova api > 2.24
In API microversion 2.25 Nova removed the disk_over_commit parameter
to the live migration server action. This patch makes sure that we
don't include it in our request if we're running with 2.25 or higher.

Story: #2002963
Task: #22966
Change-Id: I1bbdd33be96d82422a05982508e370237c3560f3
2018-07-24 11:09:27 -04:00
Pavlo Shchelokovskyy
b9fab849f7 Skip calls to glance and nova when got no servers
save (potentially many) HTTP calls to Glance API for image list
and a call to Nova API for flavor list when the server list
actually returned no servers.

Change-Id: I93a56138c50b82fb4dce67a2f788107f71c5f423
Story: #2002039
Task: #19681
2018-07-09 15:07:24 +03:00
Zuul
0ba5dcbc6a Merge "Display private flavors in server list" 2018-06-29 13:57:45 +00:00
Matt Riedemann
da7572a5ff Fix server show for microversion 2.47
Compute API version 2.47 embeds the server's internal
flavor in the response. The original flavor id is not
preserved since it could have changed if the flavor
was deleted and re-created after the server was created,
which was the dreaded Horizon "Edit Flavor" issue.
So the flavor dict in the server response is a dict of
information about the flavor representing the server
"right now" excluding the id. The original flavor name
is shown though along with the ram/disk/vcpu etc
information.

The server list command has a similar issue which
will be fixed in a follow up change.

Change-Id: I1a92999758006d02567c542b6be8902a049899cc
Task: 13864
Story: 1751104
2018-06-08 15:52:31 -04:00
Matt Riedemann
752a2db332 Optimize _prep_server_detail to avoid redundant find_resource
When showing a server or doing a rebuild, we already have
the latest version of the server so _prep_server_detail
getting the server again is an unnecessary performance hit.

ShowServer is pretty obvious here. For RebuildServer, the
compute API actually refreshes the server before returning
it in the response, so the client already gets the latest
when the rebuild call returns.

The only other usage of _prep_server_detail that does require
a refresh is CreateServer since the POST /servers response is
a minimal version of the server object.

This adds a new refresh kwarg, backward compatible by default,
to _prep_server_detail but changes ShowServer and RebuildServer
to no longer refresh.

Change-Id: Ib1c9c424ed1cafc2dfd8be90af8de8a774bdfbf0
2018-06-08 11:46:29 -04:00
Matt Riedemann
56b3467549 Use Server.to_dict() rather than Server._info
There is a to_dict() method on the Server object from
python-novaclient which makes a deepcopy of the internal
Server._info - use this instead of accessing the _info
attribute directly.

Also, while in here, fixed a typo in _prep_server_detail.

Change-Id: I679b4489c815f8a54368ef6b23b9f77e75b4d0bc
2018-06-08 11:13:40 -04:00
Matt Riedemann
181f14319b Add note about version 2.5 when listing servers using --ip6
The --ip6 filter when listing servers as a non-admin user
only applies when also using --os-compute-api-microversion
2.5 or greater. This change simply adds a note about that in
the --ip6 option help text.

We could probably get more sophisticated by trying to determine
if the user has the admin role or not and if not, and using --ip6
without microversion >= 2.5, we could error out, but that seems
excessive at this point.

Change-Id: I665c64e0bdac04c695fa119a479df43f70b0fa62
Story: #2002184
Task: #20057
2018-06-08 10:13:10 -04:00
Julie Pichon
de9a6fc070 Prevent "server migrate --wait" from hanging
Migrate uses the same mechanism in the backend than Resize and so the
steps and step names are similar. Currently when using the --wait
option with 'migrate', we wait forever because the status won't get to
active until the user performs an action. This makes it return on
verify_resize status just like 'resize' does, so that the user can
perform the next manual step.

Change-Id: Ie1aeac52506bc8801f88fd6a6eb4f6094cf20050
Story: 2001994
Task: 19621
2018-05-09 18:02:14 +01:00
Zuul
5ed81c5a77 Merge "Add --image-property parameter in 'server create'" 2018-03-31 17:20:27 +00:00
Zuul
f21b0a073f Merge "Fix additional output encoding issues" 2018-03-29 04:23:16 +00:00
Chen Hanxiao
447d5d9e34 Add --image-property parameter in 'server create'
add --image-property option, just like --image-with of novaclient did.

Change-Id: Ic1a8976559255529a8785b1b301a0307812433cb
Signed-off-by: Chen Hanxiao <chenhx@certusnet.com.cn>
2018-03-28 16:03:45 +08:00
npraveen35
c615bcd75e Display private flavors in server list
Update the code so that "openstack server list --all"
also displays the names of private flavors.

Change-Id: I4804fcd905eaf67b1ad9b461084eaf0caa820d2f
Closes-Bug: #1742453
2018-03-21 12:23:33 +00:00
Matt Riedemann
1008544882 Default --nic to 'auto' if creating a server with >= 2.37
Compute API version >= 2.37 requires a 'networks' value in
the server create request. The novaclient CLI defaults this
to 'auto' if not specified, but the novaclient ServerManager.create
python API binding code does not, as it wants clients to be explicit.

For the purposes of the OSC CLI, we should follow suit and if the
user is requesting OS_COMPUTE_API_VERSION>=2.37 without specific
nics, we should just default to 'auto'.

Change-Id: Ib760c55e31209223338a4086ff1f4fee88dc6959
Closes-Bug: #1750395
2018-03-21 01:44:29 +00:00
Dean Troyer
6df58b6366 Fix additional output encoding issues
This is a followup to https://review.openstack.org/#/c/541609/ that
changes most outstanding direct uses of sys.stdout to use the encoded
stdout set up by cliff.

Change-Id: I07cfc418385fc787d3b7d3c32d39676cf81bb91f
2018-03-20 15:40:23 -05:00
Dean Troyer
53e7aab7ed Re-implement novaclient bits removed in 10.0
a)

/os-floating-ips was removed in Compute API 2.36 and from novaclient's
Python API in 10.0

Add to api.computev2:
floating_ip_add()
floating_ip_remove()

Convert add floating IP command to nova-net/neutron split:
"server add floating ip"
"server remove floating ip"

b)

/os-hosts was removed in Compute API 2.43 and from novaclient's
Python API in 10.0.

Add to api.computev2:
host_list()
host_set()
host_show()

Convert host commands to use intenal api:
"host list"
"host set"
"host show"

c)

The introduction of the Network-style commands into the server group
broke cliff's autoprogram directive as it executes the get_parser() methods
without fully initializing the Command object.

NOTE: This is really three reviews squashed to get through the gate in one pass.

Depends-on: Id6de87211d6c4ea8fd14aa9203d8d5b17e9e2f04
Change-Id: I5116086f9a9e4b2b31a744bf8f4558c79f0bfe59
2018-03-13 09:10:45 -05:00
Zuul
8c5f755569 Merge "Send 'changes-since' instead of 'changes_since' query parameter" 2017-12-13 02:57:49 +00:00
Daniel Speichert
116526275d Send 'changes-since' instead of 'changes_since' query parameter
Per API reference, only 'changes-since' is accepted and the variant
with underscore is ignored, making the CLI functionality broken.

[dtroyer] added release note and fixed unit tests.

Change-Id: I0c596531a8af03da17d5ce39d75b12e941403aa5
Closes-Bug: 1732216
2017-12-11 18:07:45 -06:00
Hongbin Lu
809355894f Add RemoveNetwork command to server
This command will detach a server from a network. All server's
neutron ports that belongs to the specified networks will be removed.

Change-Id: I83a064ed62ab00c6f1016900b9cf30f1c15b8382
2017-11-14 00:13:08 +00:00
Zuul
a51ac0a889 Merge "Added AddNetwork command to server" 2017-10-30 04:21:41 +00:00
Jose Castro Leon
fd23ebfbf3 Add missing parameters on openstack server rescue
Change-Id: I27afca9e826378dbcb7feb7528e0c65c528b04b0
Closes-Bug: #1703278
2017-10-27 14:52:04 +00:00
Hongbin Lu
e3ad82164d Added AddNetwork command to server
Currently, if users want to add another NIC to a running instance,
they need to (i) create a neutron port and (ii) add the port to the
server via teh AddPort command. It would be more convenient to have
a single command to achieve the equivalent.

Novaclient already support adding network to an instance via the
interface-attach command. This patch introduces a similar capability
in OSC.

Change-Id: Ia3e39c57ae7ecb96aae1b66adc52c289daccb6ec
2017-10-26 15:34:04 +00:00
Jenkins
e0d7119c6d Merge "Start using 'cliff.sphinxext'" 2017-07-21 21:46:10 +00:00