352 Commits

Author SHA1 Message Date
Stephen Finucane
e2a9a9607c compute: Fix 'server group * -f yaml' output
Make use of 'FormattableColumn'-derived formatters, which provide better
output than what we were using before, particularly for the YAML output
format.

Change-Id: Id6d25a0a348596d5a0430ff7afbf87b049a76bc8
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-01-06 12:02:25 +00:00
Stephen Finucane
03776d82e5 compute: Fix 'server * -f yaml' output
Make use of 'FormattableColumn'-derived formatters, which provide better
output than what we were using before, particularly for the YAML output
format. For example, compare before for the 'server show' command:

  $ openstack --os-compute-api-version 2.79 server show test-server -f yaml
  ...
  addresses: private=fdff:77e3:9bb4:0:f816:3eff:fe6d:a944, 10.0.0.44
  flavor: disk='1', ephemeral='0', extra_specs.hw_rng:allowed='True', original_name='m1.tiny',
    ram='512', swap='0', vcpus='1'
  ...

To after:

  $ openstack --os-compute-api-version 2.79 server show test-server -f yaml
  ...
  addresses:
    private:
    - fdff:77e3:9bb4:0:f816:3eff:fe6d:a944
    - 10.0.0.44
  flavor:
    disk: 1
    ephemeral: 0
    extra_specs:
      hw_rng:allowed: 'True'
    original_name: m1.tiny
    ram: 512
    swap: 0
    vcpus: 1
  ...

Similarly, compare before for 'server list':

  $ openstack --os-compute-api-version 2.79 server list -f yaml
  - ...
    Networks: private=fdff:77e3:9bb4:0:f816:3eff:fe6d:a944, 10.0.0.44
    Power State: Running
    Properties: ''
    ...

To after:

  $ openstack --os-compute-api-version 2.79 server list -f yaml
  - ...
    Networks:
      private:
      - fdff:77e3:9bb4:0:f816:3eff:fe6d:a944
      - 10.0.0.44
    Power State: 1
    Properties: {}
    ...

We also fix the human-readable output for the 'tags' field.

Before:

  $ openstack --os-compute-api-version 2.79 server list
  ...
  | tags   | ['bar', 'foo']  |

After:

  $ openstack --os-compute-api-version 2.79 server list
  ...
  | tags   | bar, foo  |

Change-Id: I7a8349106e211c57c4577b75326b39b88bd9ac1e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-01-06 12:02:24 +00:00
Stephen Finucane
29a7c9afce image: Unset properties rather than setting to None
Currently, we attempt to unset an image property by setting it to None.
This doesn't work for known properties and is rightly rejected by the
Glance API with the following error:

  BadRequestException: 400: Client Error for url:
  http://172.20.4.87/image/v2/images/368c5751-2b0b-4a38-a255-fd146fe52d31,
  Bad Request

The solution is to actually unset the field by deleting it.

Change-Id: Ie156bedbe0f9244f82c81401679706f484caf9aa
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Story: #2008463
Task: #41493
2020-12-22 17:11:32 +00:00
Stephen Finucane
ebaf0eae2c tests: Remove 'agent' functional tests
The 'os-agents' API was recently removed from nova [1]. Remove the
functional tests, since they will always fail going forward but will
continue to run on older stable branches.

Also Squeeze https://review.opendev.org/#/c/762559/ inside, since those
2 are simultaneously blocking gate

[1] https://review.opendev.org/#/c/749309/

Change-Id: I0bf7d4c0ba2a9d4637db0d209d8d52163d772f12
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-11-16 15:54:27 +01:00
Stephen Finucane
ffd7e93961 functional: Remove test for 'quota set --force'
Change I1d1ac1ac46f49f64794ffc8631e166935537966c introduced the 'quota
set --force' parameter to force set nova quotas. As part of that fix, we
introduced a functional test, 'QuotaTests.test_quota_set_force' that
works by attempting to set the 'limit' of the quota for instances to the
current usage ('is_use') minus one.

This test is flawed. It doesn't create any instances so when it fires by
itself, it will always set the 'limit' to 0. When it fires at the same
time as other tests (remember, we run tests in parallel), notably tests
that rely on booting instances, it can cause other tests to fail with
the following error:

  Quota exceeded for instances: Requested 1, but already used 0 of 0
  instances (HTTP 403)

We could attempt to work around this by creating a new project and using
that project to fiddle with quotas. That's a lot of work though, and the
returns are questionable: the 'quota set' command is an admin-only
command by default and the '--force' parameter should almost never be
used. Simply remove this test.

Change-Id: Ic07ff6f4a7c1c27852c892eb906bb144aae91788
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Story: #2008327
Task: #41225
2020-11-06 17:40:13 +00:00
Artem Goncharov
ad3369ed1f Fix formatting of the flavor properties
Do not stringify flavor properties to allow proper output formatting to
json/yaml/etc

Change-Id: I9f4c42acb85b726af87123134dd19de98fe95074
2020-11-02 15:09:09 +01:00
Zuul
e7b2528c4a Merge "Show words indicating booted from volume for server image" 2020-09-30 20:34:53 +00:00
Zuul
03b9216318 Merge "Output correct json for security groups in 'openstack server show'" 2020-09-25 09:44:41 +00:00
jay
bae89b3014 Output correct json for security groups in 'openstack server show'
Fixes incorrect json output for 'openstack server show -f json'.
The security group json output groups all the json as one
for e.g. "security_groups": "name='group1'\nname='group2'"
The correct output should be
"security_groups" : [{"name" : "group1"}, {"name" : "group2"}]
properties and volumes_attached fields also has similar issue.

Story: 2007755

Change-Id: I1b1cac716329e0530400aff782c08000b21d8e1d
2020-09-14 15:22:27 +02:00
melanie witt
4a3c5207c1 Show words indicating booted from volume for server image
For a server booted from a volume, nova API does not store an image_id
and instead returns an empty string. Currently, openstackclient
similarly shows an empty string for Image Name and Image ID for servers
booted from volumes.

To aid CLI users in understanding the meaning of no image_id, we can
display the string "N/A (booted from volume)" in the image field if the
server was booted from a volume.

Change-Id: I9c62cf6fe23b2e934dcbf5ebbf706b2705d2e424
2020-08-27 20:24:48 +00:00
mb711d
4e2aefb5fa Delete the testcases that arent needed anymore
The file test_examples.py has never worked since its written and and cli in
the example directory are covered by other functional tests for container,
flavor and object lists and they have better asserts. So, deleting the file

Change-Id: Ib9af40da96e66354fe878e79a80048a58f8dd6fe
2020-07-23 17:08:42 -04:00
Zuul
d0741d7853 Merge "Add '--force; parameter to 'openstack quota set'" 2020-07-06 20:50:24 +00:00
Pete Zaitcev
52ff421e3d Resolve PEP8
No idea how this happened, but reviews started failing the
pep8 gate job. The failures are legitimate, see the commit.
I guess the pep8 tests became smarter and found these issues.

Change-Id: Id9a0dad644134dafd68eed37fe8f41c583d7a619
2020-05-14 13:53:38 -05:00
hackertron
b328cf74df Add '--force; parameter to 'openstack quota set'
The compute service allows us to to force set a quota, setting a
quota value that is less than the amount of the resource currently
consumed. Expose this feature by way of a '--force' boolean
parameter.

Change-Id: I1d1ac1ac46f49f64794ffc8631e166935537966c
2020-04-14 22:59:52 +02:00
Zuul
78b18030b5 Merge "Support for stateless security groups" 2020-04-08 08:31:28 +00:00
Tom Stappaerts
5e62411e5f Support for stateless security groups
Add support for stateful attribute of security groups,
using --stateful and --no-stateful flag on security group.
This allows a user to create security groups with stateful
false.

Change-Id: Ifd20b5fc47fd0ea0bb5aeda84820dcc0fb1e8847
Blueprint: stateless-security-groups
Depends-On: https://review.opendev.org/711513/
2020-03-31 12:05:18 +02:00
Bence Romsics
dba57c85d5 Add command: router add/remove route --route
Add commands to osc to call the two new API methods introduced by
new Neutron extension: extraroute-atomic.

Bump our openstacksdk requirement to >=0.38.0 which contains
the corresponding sdk change.

The lower-constraints of dogpile.cache and keystoneauth1 are bumped
because of requirements bumps in openstacksdk.

The lower-constraint of decorator is bumped because of problem already
fixed by amotoki here: https://review.opendev.org/701706

Change-Id: Ia9b9c216f1d1161ebedac31594a2c464d77f4ae2
Depends-On: https://review.opendev.org/674324
Partial-Bug: #1826396 (rfe)
Related-Change: https://review.opendev.org/655680 (spec)
2020-03-30 16:19:05 +02:00
Zuul
81dcc91214 Merge "Fix faulthy state argument choice" 2020-03-24 21:34:44 +00:00
Zuul
fc12033f1d Merge "Now we can add description for role creation in OSC" 2020-03-20 18:59:44 +00:00
Zuul
4d9f0f384b Merge "Create Volume v3 functional tests" 2020-01-13 22:31:19 +00:00
KeithMnemonic
f5384ae16a Fix openstack server list --deleted --marker option
This patch removes using the "name" option for a marker when
--deleted is also used. The find_resource() function
that is being called does not correctly handle using the marker
as the "name" in the search when also using deleted=True.
One simple way to fix this is force the marker to only be an ID
when --deleted is used. This is how the nova client works.

Using the --deleted option is available to users with the admin
role by default. If you're an admin listing --deleted servers
with a marker by name, find_resource() is going to fail to find
it since it doesn't apply the --deleted filter to find_resource().

The find_resource() function is trying to find the marker server
by name if it's not found by id, and to find it by name it's
listing servers with the given marker as the name, but not
applying the --deleted filter so it doesn't get back any results.

In the story it was suggested modifying find_resource to include
the deleted query param when it's specified on the command line but
that didn't work because it still results in something like this:

http://192.168.1.123/compute/v2.1/servers?deleted=True&name=4cecd49f-bc25-4a7e-826e-4aea6f9267d9

It seems like there are bugs in find_resource().

Restricting the marker to be the server ID when listing deleted servers
is probably OK since if you're using --deleted you're an admin and you could
be listing across all projects and if you're filtering by a server across all
projects anyway (not that you have to, I'm just saying if you are), or even
showing a server in another project, you have to do it by id rather than name
because find_resource() won't find the server in another project by name, only ID.

story: 2006761
Task: 37258

Change-Id: Ib878982b1d469212ca3483dcfaf407a8e1d2b417
2020-01-02 20:05:56 +00:00
Bram Verschueren
69870ae439
Fix faulthy state argument choice
The correct state name for a failing volume snapshot deletion is
'error_deleting' instead of 'error-deleting'. [1]

[1] 89d6a5042f/cinder/objects/fields.py (L126)

Task: #37844
Story: #2007037

Change-Id: Ia99900ece4f1cd29769b22ddaa3965789d719556
2019-12-19 09:48:17 +01:00
Dean Troyer
1c0160c8aa Create Volume v3 functional tests
Until now-ish Volume v3 has been a pass-through to v2.  In order
to prepare to make the Volume v3 commands stand-alone copy the
v2 functional tests to v3.

This is the first of a series of reviews to completely separate
Volume v2 and v3 commands.  Once these are split we can begin to
implement v3 microversion support and/or start using the
OpenStack SDK as the REST library.

Change-Id: Iefd78d8ef6bb851d7360596337a88ee8f8476767
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-11-18 14:47:56 -06:00
Eric Fried
3b409e4d0e Refactor AggregateTests
While investigating the referenced story/bug I noticed that
wait_for_status in
openstackclient.tests.functional.compute.v2.test_aggregate.AggregateTests
was doing a lot more than it should ever need to (it probably got copied
in from somewhere). The two places calling it only need to a) check the
output of `openstack aggregate show`, and b) try once -- since they just
got done creating the aggregate synchronously, there should never be a
need to delay/retry. So this commit removes the helper method and just
inlines the check.

At the same time, the addCleanup(aggregate delete) directives are moved
above their respective creates. This is a defensive best practice which
makes sure cleanup happens even if something fails very soon after the
actual back-end create (as was in fact the case with the referenced
bug/story).

It is unknown whether this will impact the referenced bug.

Change-Id: I0d7432f13642fbccd5ca79da9c76adfcbabb5fa9
Story: 2006811
Related-Bug: #1851391
2019-11-05 21:32:15 +00:00
Eric Fried
f1d742f32a Fix functional tests for py3
Fix various things so the functional tests will work under python3:

- A hashlib.md5() can only be update()d with an encoded string in py3.
- There's no dict.iteritems(), change to dict.items() (which is already
  an iterator).
- Open temp files with 'w+' mode rather than the default 'w+b' (as an
  alternative to encoding all the write and expected-read payloads as
  bytes).
- (This is a weird one) Explicitly raise SkipTest from unittest (rather
  than unittest2, which is where cls.skipException landed). Not sure why
  this is busted, but this moves the ball.

Change-Id: Ic9b2b47848a600e87a3674289ae7ae8c3e091fee
2019-10-31 00:17:35 +00:00
Dean Troyer
de8ab5e8fd More aggregate functional race chasing
AggregateTests.wait_for_status() was a classmethod, those often
are sources of conflict in parallel testing...

Change-Id: I6211fd9c36926ca97de51a11923933d4d9d2dfda
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-09-10 14:09:29 -05:00
Dean Troyer
31c47adebb Remove races in floating ip functional tests
Multiple subnets with the same name are occasionally created when
running tests in parallel.

Change-Id: Ifb85e39ee53b529e2b97abf782c7fba93d48e9e2
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-31 09:03:46 -05:00
Zuul
eed615e7d0 Merge "Remove token_endpoint auth type" 2019-08-29 00:02:31 +00:00
Zuul
c9cc8b0ae2 Merge "Format aggregate command fields and de-race functional tests" 2019-08-27 18:04:57 +00:00
Dean Troyer
6fcc2608b1 Remove token_endpoint auth type
The token_endpoint was a compatibility auth type to maintain support
for the --url global option that dated back to the beginning of
OpenStack CLI auth.  The common keystoneauth library implements
'admin_token' which provides the same functionality using
--endpoint rather than --url.

Change-Id: I1b9fbb96e447889a41b705324725a2ffc8ecfd9f
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-27 11:08:50 -05:00
Dean Troyer
03a2accb2f Format aggregate command fields and de-race functional tests
Rename metadata to property in all aggregate commands

Beef up functional tests to reduce street racing

Change-Id: I4598da73b85a954f3e6a3981db21891b45d9548c
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-26 17:50:06 -05:00
Dean Troyer
75f0f82c41 Add CLI argument tests before making changes
Add these tests before hacking on the global args and removing
the compatibility stuff so we can clearly see what actually changes.

Change-Id: Ic86c89da1475b4914ff7cb2396199cd219a12097
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-22 23:50:24 -05:00
Dean Troyer
3b2863e369 Fix functional.base.TestCase.openstack() to optionally omit --os-auth-type
Change the functional test TestCase.openstack() method to add a
way to not include the --os-auth-type option in order to test the
default auth-type logic.

Change-Id: I0f1ca2f7517a41278afaad5aaf4e98accb16bea2
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-22 11:05:09 -05:00
Zuul
8ef2602447 Merge "Add openstack server create --boot-from-volume option" 2019-08-20 18:10:21 +00:00
Zuul
07fcb733fc Merge "Support type=image with --block-device-mapping option" 2019-08-20 17:58:30 +00:00
Matt Riedemann
b9d6310556 Add openstack server create --boot-from-volume option
This adds a --boot-from-volume option to the server create
command which is used with the --image or --image-property
option and will create a volume-backed server from the
specified image with the specified size. Similar to the
--volume option, the created root volume will not be deleted
when the server is deleted. The --boot-from-volume option
is not allowed with the --volume option since they both create
a block device mapping with boot_index=0.

Change-Id: I88c590361cb232c1df7b5bb010dcea307080d34c
Story: 2006302
Task: 36017
2019-08-09 16:44:46 +00:00
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
Dean Troyer
865e182970 Make configuration show not require auth
The configuration show should not require auth to just display the
OSC config object.  Changes to make it not require auth have
knock-on effects of needing to change a bunch of tests that use it
assuming it _does_ require auth so change those to use 'extension list'
instead.

This sets up further testing of the command line options for changes
in behaviour when we switch to straight SDK usage for configuration.

Change-Id: I6c52485341214ba401064c0f2d1e2b95fdc225c0
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-08-01 14:53:02 -05:00
Zuul
f0fafec54f Merge "Use cliff formattable columns in image commands" 2019-06-23 04:30:51 +00:00
Zuul
46ef850ce9 Merge "Use cliff formattable columns in volume v2 commands" 2019-06-23 00:45:37 +00:00
Akihiro Motoki
4cd614305f Use cliff formattable columns in volume v2 commands
Partial-Bug: #1687955
Partially implement blueprint osc-formattable-columns

Change-Id: I761ccac126208927594ad0d98a3cf5ad8b44bd48
2019-06-22 14:56:10 -05:00
Akihiro Motoki
1af3056e30 Use cliff formattable columns in volume v1 commands
Partial-Bug: #1687955
Partially implement blueprint osc-formattable-columns

Change-Id: Ib4c5798171e32a8ddc08a37ee1d416e366a71d76
2019-06-22 14:53:28 -05:00
Akihiro Motoki
8d63e3f0c3 Use cliff formattable columns in image commands
Related functional tests are converted into JSON format.
Otherwise, it is not easy to check results.

Partial-Bug: #1687955
Partially implement blueprint osc-formattable-columns

Change-Id: Ib82e15738544975fede0c54cc5eaf239f4c67277
2019-06-22 13:36:46 -05:00
Zuul
1a21f02bc7 Merge "Use cliff formattable columns in network commands" 2019-06-22 18:27:00 +00:00
Zuul
c20421c467 Merge "Remove deprecated volume commands and args" 2019-06-22 07:17:28 +00:00
Zuul
377c0ce0f7 Merge "Remove deprecated identity commands and args" 2019-06-21 23:00:56 +00:00
Zuul
82823f89f0 Merge "Rename review.openstack.org to review.opendev.org" 2019-06-14 02:25:02 +00:00
Zuul
57dec524c8 Merge "Batch up minor cleanups for release" 2019-06-06 23:19:12 +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
Sean McGinnis
e76e10c0ba Remove deprecated volume commands and args
The following were deprecated over two years ago and can now be removed:

* Remove ``backup`` commands in favor of ``volume backup``
* Remove ``snapshot`` commands in favor of ``volume snapshot``
* Remove ``volume create`` options ``--project``, ``--user`` and ``--multi-attach``
* Use of an auth-key positional argument in volume transfers
* ``volume transfer request`` no longer accepts 'auth_key' as a positional arg,
  ``--auth-key`` is now required

Internal (non-user-visible)
* Rename backup.py to volume_backup.py for Volume v1 and v2, update tests

These are backwards incompatible changes and will require a major
version bump after they are merged.

Change-Id: I94aa7a9824e44f9585ffb45e5e7637b9588539b4
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2019-05-20 14:05:18 -05:00