summaryrefslogtreecommitdiff
path: root/openstackclient/tests/common
Commit message (Collapse)AuthorAgeFilesLines
* Propagate AttributeErrors when lazily loading pluginsTim Burke2016-04-141-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if an AttributeError was raised in a plugin's make_client method, the plugin simply wouldn't be an attribute of the ClientManager, producing tracebacks like Traceback (most recent call last): File ".../openstackclient/shell.py", line 118, in run ret_val = super(OpenStackShell, self).run(argv) ... File ".../openstackclient/object/v1/container.py", line 150, in take_action data = self.app.client_manager.object_store.container_list( File ".../openstackclient/common/clientmanager.py", line 66, in __getattr__ raise AttributeError(name) AttributeError: object_store This made writing minimal third-party auth plugins difficult, as it obliterated the original AttributeError. Now, AttributeErrors that are raised during plugin initialization will be re-raised as PluginAttributeErrors, and the original traceback will be preserved. This gives much more useful information to plugin developers, as in Traceback (most recent call last): File ".../openstackclient/shell.py", line 118, in run ret_val = super(OpenStackShell, self).run(argv) ... File ".../openstackclient/object/v1/container.py", line 150, in take_action data = self.app.client_manager.object_store.container_list( File ".../openstackclient/common/clientmanager.py", line 57, in __get__ err_val, err_tb) File ".../openstackclient/common/clientmanager.py", line 51, in __get__ self._handle = self.factory(instance) File ".../openstackclient/object/client.py", line 35, in make_client interface=instance._interface, File ".../openstackclient/common/clientmanager.py", line 258, in get_endpoint_for_service_type endpoint = self.auth_ref.service_catalog.url_for( PluginAttributeError: 'NoneType' object has no attribute 'url_for' Change-Id: I0eee7eba6eccc6d471a699a381185c4e76da10bd
* Merge "Support client certificate/key"Jenkins2016-04-061-0/+17
|\
| * Support client certificate/keyCedric Brandily2016-04-061-0/+17
| | | | | | | | | | | | | | | | | | | | This change enables to specify a client certificate/key with: * usual CLI options (--os-cert/--os-key) * usual environment variables ($OS_CERT/$OS_KEY) * os-client-config Change-Id: Ibeaaa5897ae37b37c1e91f3e47076e4e8e4a8ded Closes-Bug: #1565112
* | Don't mask authorization errorsHidekazu Nakamura2016-04-011-0/+12
|/ | | | | | | | | Project show with name argument returns 'Could not find resource' error when the user is not authorized. It should report the authorization error instead. This patch makes that change. Change-Id: Iac3521f8a411060b0ec9ef46c8f0e1f3551e56ae Closes-Bug: #1511625
* Use assertItemsEqual() instead of assertListEqual()Tang Chen2016-03-141-10/+2
| | | | | | | | assertListEqual() is order sensitive. So we need to sort the lists before we compare them. Use assertItemsEqual() instead is better. Change-Id: I9eaa98716c7401f5b099b007438acc916dae619b
* Merge "Fixed command list"Jenkins2016-03-111-6/+10
|\
| * Fixed command listBrandon Palm2016-03-091-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cliff module expects an array of tuples however the array that this function was returning was an array of tuples that was also containing an array of values for the commands attached to each group and the cliff module wasn't liking it. The output now comes out looking like: | openstack.common | limits show | | | extension list | | openstack.baremetal.v1 | baremetal set | Change-Id: Ifa1c149cb5c66ba27dc72bf72d7c8f2f50e42f73 Closes-Bug: 1545609
* | Enhance list extension unit testFang Zhen2016-03-111-40/+117
|/ | | | | | | | Extension list involves identity, compute, volume and network. Current test covers only identity and network. This patch added test against compute and volum. Also refactored current implentation. Change-Id: If9b36cba24c50a817a17f685801e418fb898596a
* Add MultiKeyValueAction to custom parser actionTang Chen2016-02-271-0/+129
| | | | | | | | | | | | | | Class MultiKeyValueAction will be used to parse arguments like this: --route destination=xxx,gateway=xxx --route destination=yyy,gateway=yyy The result is a list like this: [{destination:xxx, gateway:xxx}, {destination:yyy, gateway:yyy}] This action also contain validation of the parameters. Change-Id: Ie3aa8635c6a13fc2e429fe6922acd681dc7244cf
* Fixed a bunch of spacingBrandon Palm2016-02-236-1/+9
| | | | | | | Nothing too complicated here. I fixed a bunch of spacing issues that I saw in OSC. Change-Id: I935ab48e7c5bac5f88ecdb3a05f73fb44fc9f41d
* Support unscoped token requestguang-yee2016-02-191-0/+25
| | | | | | | | Make scope check optional for the "token issue" command as unscoped token is a valid Keystone V2/V3 API. Change-Id: Ie1cded4dbfdafd3a78c0ebdf89e3f66762509930 Closes-Bug: #1543214
* Don't use Mock.called_once_with that does not existTang Chen2016-02-191-1/+1
| | | | | | | | | | | Class mock.Mock does not exist method "called_once_with()", it just exists method "assert_called_once_with()". "called_once_with()" does nothing because it's a mock object. In OSC, only one place is still using "called_once_with()". Fix it. Change-Id: Ib890e95d775c3fc43df80fa05c82d726e78cdac8 Partial Bug: 1544522
* Fix DisplayCommandBase comments for cliff Lister subclass testsTang Chen2016-02-094-13/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As bug #1477199 describes, the wrong comment below is all over the unit test code of OSC. # DisplayCommandBase.take_action() returns two tuples There is no such class named DisplayCommandBase in OSC. It is in cliff. All OSC command classes inherit from the base classes in cliff, class Command, class Lister and class ShowOne. It is like this: Object |--> Command |--> DisplayCommandBase |--> Lister |--> ShowOne take_action() is an abstract method of class Command, and generally is overwritten by subclasses. * Command.take_action() returns nothing. * Lister.take_action() returns a tuple which contains a tuple of columns and a generator used to generate the data. * ShowOne.take_action() returns an iterator which contains a tuple of columns and a tuple of data. So, this problem should be fixed in 3 steps: 1. Remove all DisplayCommandBase comments for tests of classes inheriting from class Command in cliff as it returns nothing. 2. Fix all DisplayCommandBase comments for tests of classes inheriting from class Lister in cliff. Lister.take_action() returns a tuple and a generator. 3. Fix all DisplayCommandBase comments for tests of classes inheriting from class ShowOne in cliff. ShowOne.take_action() returns two tuples. This patch finishes step 2 in all but identity tests. There are too many such comments in identity tests. So fix them all in another patch. Change-Id: I00f38d12f55abe20fa708f6349073da658622f8d Partial-bug: #1477199
* Merge "Use assert_not_called() in common tests"Jenkins2016-02-041-7/+7
|\
| * Use assert_not_called() in common testsDean Troyer2016-02-031-7/+7
| | | | | | | | | | | | | | | | | | In https://review.openstack.org/#/c/273653/ Bryan Jones made a point about using mock_sleep.assert_not_called() rather than self.assertFalse(mock_sleep.called), so let's make that change throughout these tests. Change-Id: I826d608836955383891b303355edcca7b62faa16
* | Merge "Support listing network availability zones"Jenkins2016-02-041-0/+65
|\ \
| * | Support listing network availability zonesRichard Theis2016-02-021-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the "os availability zone list" command to support listing network availability zones along with the currently listed compute and volume availability zones. This adds the --network option to the command in order to only list network availability zones. By default, all availability zones are listed. The --long option was also updated to include a "Zone Resource" column which is applicable to network availability zones. Example zone resources include "network" and "router". If the Network API does not support listing availability zones then a warning message will be issued when the --network option is specified. This support requires an updated release of the SDK in order to pull in [1]. [1] https://bugs.launchpad.net/python-openstacksdk/+bug/1532274 Change-Id: I78811d659b793d9d2111ea54665d5fe7e4887264 Closes-Bug: #1534202
* | | Merge "Allow wait_for_delete to work for all clients"Jenkins2016-02-041-0/+22
|\ \ \ | | |/ | |/|
| * | Allow wait_for_delete to work for all clientsMark Vanderwiel2016-01-281-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the exception and error status strings to be passed in such that other plugins can make use of this function. There is a comment in find_resource: The exception to catch here is dependent on which client library the manager passed in belongs to. Eventually this should be pulled from a common set of client exceptions. Since I think that is a long ways off, this change will work now and also work when a common exception is defined and used. Change-Id: Iab56cd1166028caed4f1e657e0b1ee81af3f48d8
* | | Add "os port show" commandRichard Theis2016-02-021-0/+9
| |/ |/| | | | | | | | | | | | | Add "os port show" command. Change-Id: Id87c81640e74c60ae8f247c722c64fdadff022a2 Partial-Bug: #1519909 Partially-Implements: blueprint neutron-client
* | Fix showing network quotas for a projectRichard Theis2016-02-021-7/+18
|/ | | | | | | | | | | | | | | | | The OpenStack SDK is now used for the network client. However, the 'openstack quota show' command wasn't updated for the client change. As a result, the command will fail to show network quotas when a project name is specified. For example: $ openstack quota show admin 'Proxy' object has no attribute 'show_quota' This patch set fixes the command by using the OpenStack SDK to get network quotas for a project. Change-Id: I59a7b6780a7b80cd09e79d40d214751b25d3016e Related-To: blueprint neutron-client Closes-Bug: #1528249
* Merge "Support listing volume availability zones"Jenkins2016-01-221-10/+89
|\
| * Support listing volume availability zonesRichard Theis2016-01-141-10/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the "os availability zone list" command to support listing volume availability zones along with the currently listed compute availability zones. This adds a --compute and --volume option to the command in order to select the availability zones to list. By default, all availability zones are listed. If the Block Storage API does not support listing availability zones then an warning message will be issued. Change-Id: I8159509a41bd1fb1b4e77fdbb512cf64a5ac11a9 Closes-Bug: #1532945
* | Merge "Refactor "os availability zone list""Jenkins2016-01-221-0/+113
|\ \ | |/
| * Refactor "os availability zone list"Richard Theis2016-01-141-0/+113
| | | | | | | | | | | | | | | | | | | | | | | | Refactor the "os availability zone list" command to make it a common command instead of a compute-only command. Since availability zones are common to compute, volume and network (new), this refactoring allows availability zone support to be added for volume and network. In addition to the refactor, unit and functional tests were added. Change-Id: I63e9d41d229b21cd38e5a083493042c096d65e05 Partial-Bug: #1532945
* | Set up logger of each command by metaclassAkihiro Motoki2016-01-201-0/+32
| | | | | | | | | | | | | | compute.v2.flavor is changed in this commit as an initial example. Partial-Bug: #1532294 Change-Id: I262af6ade0ae03fbe1cd2ad198faf4ebb4ecf7ce
* | Merge "Changed the abstract columns and datalists from test cases of common ↵Jenkins2016-01-143-37/+33
|\ \ | | | | | | | | | and Identity"
| * | Changed the abstract columns and datalists from test cases of common and ↵SaiKiran2016-01-123-37/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Identity columns and datalist has been set in each test case in compute, which is not necessary. This patch abstract it out and remove all redundant code. Change-Id: I45a3582088161f12e60e7c933da8e7dcc0ae8e7b Closes-Bug: #1532384
* | | Merge "Refactor network endpoint enablement checking"Jenkins2016-01-141-0/+33
|\ \ \ | |_|/ |/| |
| * | Refactor network endpoint enablement checkingRichard Theis2016-01-041-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the network endpoint enablement checking from the 'server create' command to the common client manager. This allows future network commands to use either nova or neutron networking based on the cloud environment. This patch set also includes related unit test enhancements to the common client manager to trigger authentication on the tests. Change-Id: Ia37e81d4fb05a1e2fceb3e5d367bda769ab8e64b Related-Bug: #1519511 Related-to: blueprint neutron-client
* | | Use assertTrue/False instead of assertEqual(T/F)Swapnil Kulkarni (coolsvap)2016-01-071-3/+3
|/ / | | | | | | | | | | | | | | The usage of assertEqual(True/False, ***) should be changed to a meaningful format of assertTrue/False(***). Change-Id: I3437634329fc8ecef25082b43b5fc0e1030cdbda Closes-Bug:#1512207
* | Merge "Improve output for "os security group show""Jenkins2015-12-281-0/+7
|\ \
| * | Improve output for "os security group show"Richard Theis2015-12-231-0/+7
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the security group rules output when running the "os security group show" command. Each security group rule is now displayed on a separate line. Current output example: $ openstack security group show default +-------------+------------------------- ... ---+ | Field | Value ... | +-------------+------------------------- ... ---+ | description | Default security group ... | | id | 048a5fc3-3be1-407d-ae47-9... | | name | default ... | | project_id | 3b96bb2020c1459da76963f9e... | | rules | [u"id='5d812367-9829-4340...t"] | +-------------+------------------------- ... ---+ New output example: +-------------+------------------------- ... ---+ | Field | Value ... | +-------------+------------------------- ... ---+ | description | Default security group ... | | id | 048a5fc3-3be1-407d-ae47-9... | | name | default ... | | project_id | 3b96bb2020c1459da76963f9e... | | rules | id='5d812367-9829-4340-95...lt' | | | id='ee451d1c-ade3-4975-8e...lt' | +-------------+------------------------- ... ---+ Change-Id: I1386075310896c58a2b776e2bbec3603bd00eff1 Partial-Bug: #1519511 Related-To: blueprint neutron-client
* | Refactor: Initialize parser in setUp() in TestNonNegativeActionTang Chen2015-12-281-26/+10
| | | | | | | | Change-Id: I12846acc4450d31d19897bbdfc6846bde8c8f2ce
* | Refactor: Initialize parser in setUp() in TestKeyValueActionTang Chen2015-12-281-52/+9
| | | | | | | | | | | | | | | | No need to initialize parser in each test case. Do it in setUp(). Also remove the test_default_values case because it could be tested in the test_good_values case. Change-Id: Ia2ed7c9e46bf6baabbd62b9d50511c5e8103e5e2
* | Replace assertEqual(None, *) with assertIsNone(*)Xi Yang2015-12-251-1/+1
|/ | | | | | | | This patch is going to replace assertEqual(None, *) with assertIsNone(*) in unit test code to have more clear messages in case of failure. Change-Id: I6f85498347e8fc7cad5ea7afb832b9acda7daafc
* SDK integration extensions and server create networksTerry Howe2015-12-091-3/+3
| | | | | | | Finish up the SDK integration with server create network and port find and extension list. Change-Id: I18dbada784d8aa92a45a937f251023ddf899c53e
* Add project name/ID validation for "openstack quota show"xiexs2015-11-291-0/+121
| | | | | | | A validation is necessary to check the existence of project. This patch is similar to Ia2d8c96527820e25b074e6486d3f39c5ad7eae60. Change-Id: Id8895ba7a21ecad05942619a82a87c0dc68eae53
* Unable to set some compute quotasRichard Theis2015-11-201-0/+26
| | | | | | | | | | | | | | | | | | | | | | The OpenStackClient mapping of 'openstack quota set' arguments isn't correct for compute quota items that have to different names. For example, the --injected-file-size argument is mapped to injected_file_size, but the compute quotas item is actually injected_file_content_bytes. This incorrect mapping prevented the impacted compute quota items from being set. The problem impacts the following 'openstack quota set' arguments: --injected-file-size --injected-path-size --properties --secgroup-rules --secgroups This patch set also expands the compute quota unit tests to verify all compute quota items that can be set. Change-Id: I0a2f241e425f4811e4ae55be183ac0c8b0805c2a Closes-Bug: #1475831
* Allow error status to be specifiedMark Vanderwiel2015-11-181-0/+40
| | | | | | | | For some apis, heat, the error status is "failed". This patch changes the wait_for_status method to allow for the error status to be passed in the same way as the success status. Change-Id: I20db4051d3f5611a4b13fe23ea8798b82a40da81
* Merge "Add project-name/-id validation for the OSC "openstack quota set""Jenkins2015-11-121-6/+20
|\
| * Add project-name/-id validation for the OSC "openstack quota set"xiexs2015-11-041-6/+20
| | | | | | | | | | | | | | | | | | The quota info would be set into DB, even though the project actually does not exist. This patch tried to add a validation to forbid this undesirable behavior. Change-Id: Ia2d8c96527820e25b074e6486d3f39c5ad7eae60 Closes-Bug: #1512638
* | Fix the bug of "openstack console log show"xiexs2015-11-091-0/+55
|/ | | | | | | | The behaviors are inconsistent while different negative line numbers specified. Change-Id: I2573f3e789f5603c896758971830ffc0b94c5e2b Closes-Bug: #1512263
* Merge "Rename context.py to logs.py"Jenkins2015-10-301-32/+32
|\
| * Rename context.py to logs.pyTerry Howe2015-10-301-32/+32
| | | | | | | | | | | | | | | | | | At one point this file contained the context for logging, but the reason for its existence is now for logging. Implements: blueprint logging-migration Change-Id: I4ba42bbef97b09d31236ac8c01b6fb23827b8bee
* | Add tests for find_resource()Dean Troyer2015-10-011-0/+54
| | | | | | | | | | | | | | Add a couple of tests for utils.find_resource() for the odd resources and managers without resource_class. Change-Id: I2ed9b491d1361b5259b3a5f80b4fac787a7087c1
* | Merge "Add tests for volume quota set"Jenkins2015-09-191-0/+45
|\ \
| * | Add tests for volume quota setTerryHowe2015-08-111-0/+45
| | | | | | | | | | | | | | | | | | | | | Add some tests for volume quota set and get rid of TODO about using the value instead of the key to get the attribute. Change-Id: I57aa57951aeea65965966e63af922cda532d759d
* | | Merge "Create log configuration class"Jenkins2015-09-091-42/+110
|\ \ \ | | |/ | |/|
| * | Create log configuration classTerryHowe2015-08-261-42/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Configuration of logging gets triggered twice. The first time it uses the CLI options when the application is started and second it uses the configuration file after that is read. The state of the logging needs to be saved from the first to the second time, so I created a class. Implements: blueprint logging-migration Change-Id: I7b8d1a3b6fd128e98cafd7c16009c7b694a52146