openstack flavor unset NoneType error whn used without --proprty

Bug #1474237 reported by Attila Fazekas
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Medium
jiaxi

Bug Description

#openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 4 baremetal
+----------------------------+--------------------------------------+
| Field | Value |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 40 |
| id | 86208670-8088-46f3-b77e-98e748d506c9 |
| name | baremetal |
| os-flavor-access:is_public | True |
| ram | 4096 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 4 |
+----------------------------+--------------------------------------+
# openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
+----------------------------+-----------------------------------------------------+
| Field | Value |
+----------------------------+-----------------------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 40 |
| id | 86208670-8088-46f3-b77e-98e748d506c9 |
| name | baremetal |
| os-flavor-access:is_public | True |
| properties | capabilities:boot_option='local', cpu_arch='x86_64' |
| ram | 4096 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 4 |
+----------------------------+-----------------------------------------------------+
# openstack flavor unset baremetal
ERROR: openstack 'NoneType' object is not iterable

The client should fail with `missing argument --property`.

According to the help it is not a required argument.
# openstack help flavor unset
usage: openstack flavor unset [-h] [-f {html,json,shell,table,value,yaml}]
                              [-c COLUMN] [--max-width <integer>]
                              [--prefix PREFIX] [--property <key>]
                              <flavor>

The help also needs to be updated.

The exception.:
DEBUG: openstackclient.shell clean_up UnsetFlavor: 'NoneType' object is not iterable
ERROR: openstackclient.shell Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/openstackclient/shell.py", line 152, in run
    return super(OpenStackShell, self).run(argv)
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 241, in run
    result = self.run_subcommand(remainder)
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 314, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/site-packages/cliff/display.py", line 92, in run
    column_names, data = self.take_action(parsed_args)
  File "/usr/lib/python2.7/site-packages/openstackclient/compute/v2/flavor.py", line 311, in take_action
    resource_flavor.unset_keys(parsed_args.property)
  File "/usr/lib/python2.7/site-packages/novaclient/v2/flavors.py", line 78, in unset_keys
    for k in keys:
TypeError: 'NoneType' object is not iterable

jiaxi (tjxiter)
Changed in python-openstackclient:
assignee: nobody → jiaxi (tjxiter)
Revision history for this message
Terry Howe (thowe-g) wrote :

diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py
index eb18a43..50a9fdf 100644
--- a/openstackclient/compute/v2/flavor.py
+++ b/openstackclient/compute/v2/flavor.py
@@ -292,6 +292,7 @@ class UnsetFlavor(show.ShowOne):
         parser.add_argument(
             "--property",
             metavar="<key>",
+ required=True,
             action='append',
             help='Property to remove from flavor '
                  '(repeat option to unset multiple properties)',

Revision history for this message
Steve Martinelli (stevemar) wrote :

@terry, that works, but it's also weird to have an optional parameter be required.

Might want to make the change for all 'unset' commands (volume, volume type, volume_qos)

Changed in python-openstackclient:
importance: Undecided → Critical
importance: Critical → Medium
status: New → Confirmed
Revision history for this message
jiaxi (tjxiter) wrote :

stack@openstack:~$ openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 4 baremetal
ERROR: openstack compute

???Why the command line error ???

Revision history for this message
jiaxi (tjxiter) wrote :

@Steve Martinelli (stevemar)

A optional choice is when openstack flavor unset without --property, we offer a kind remainding like 'You should specify what to unset use --property'

Of course,have an optional parameter be required is another choice.But it's a little weird as you said.

Revision history for this message
jiaxi (tjxiter) wrote :

@Steve Martinelli (stevemar)

After discussing with Terry Howe, --property should be a required argument.
Becanuse openstack flavor unset can't work without --property.

The optional argument means that a command line can work fine without it.

Please visit https://review.openstack.org/#/c/203327/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/203327
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=2fc800aace36211f576fd447375854218c29cfd1
Submitter: Jenkins
Branch: master

commit 2fc800aace36211f576fd447375854218c29cfd1
Author: jiaxi <email address hidden>
Date: Sat Jul 18 03:33:03 2015 -0400

    Making --property as required when openstack flavor unset

    When using openstack flavor unset, the --property is needed,
    so the --property should be a required parameter.

    Close-Bug: #1474237
    Change-Id: Id6913e1b263eddeb5dd44c3edb957206b68f816c

jiaxi (tjxiter)
Changed in python-openstackclient:
status: Confirmed → In Progress
jiaxi (tjxiter)
Changed in python-openstackclient:
status: In Progress → Fix Committed
Changed in python-openstackclient:
milestone: none → 1.6.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.