286 Commits

Author SHA1 Message Date
ZhiQiang Fan
1c39f8fabf Don't record time when self.timing is False
The expected behavior is when timing is True, then we record each
request's time, then we should call reset_timings() to release memory.

However, the shell, client.{HTTPClient,SessionClient} will record each
request's time no matter what timing is set, then after long running
time in service like ceilometer-agent-compute, the memory keeps increasing.

We'd better not record request's time when timing is set to False.
Users are not responiable to call reset_timings() when they don't want
timing functionality.

Change-Id: I3e7d2fadf9a21be018781d528a1b6562228da6dd
Closes-Bug: #1433491
2015-03-21 19:27:36 +08:00
jichenjc
8679eedb83 Revert 'Remove image to local block device mapping'
https://review.openstack.org/#/c/153203/3 added check
for novaclient, removed the logic for both
--image and --block-device are added.

But actually the following valid boot command failed
due to the change here, so this patch reverted original
one and add some descriptions to avoid further removal.

nova boot test-vm --flavor m1.medium --image centos-vm-32
--nic net-id=c3f40e33-d535-4217-916b-1450b8cd3987
--block-device id=26b7b917-2794-452a-95e5-2efb2ca6e32d,bus=sata,
source=volume,bootindex=1

Change-Id: Ia29e63c72b34d3038aa591c466425e65edf5755b
Partial-Bug: #1433609
2015-03-19 22:58:17 +08:00
melanie witt
e0f5072907 Ensure the use of volume endpoint in volumes apis
Currently, several of the volumes apis depend on callers to pass
service_type='volume' as a parameter when creating a client object,
to route correctly. The problem is, it makes it impossible for
callers to work with both the compute and volume endpoints at the
same time. They can either work with compute and have volumes.* calls
return 404, or they can work with volume and have servers.* images.*
flavors.* calls return 404.

The CLI sets service_type='volume' for client objects for the
following commands via a decorator:

volume-list
volume-show
volume-create
volume-delete
volume-snapshot-list
volume-snapshot-show
volume-snapshot-create
volume-snapshot-delete
volume-type-list
volume-type-create
volume-type-delete

With this change, the service_type 'volume' is set in the api,
so the decorators on the shell commands are no longer needed.

Closes-Bug: #1431154

Change-Id: I11b48ac14fa4c64d8aae528552ec5b363be384c5
2015-03-17 01:19:11 +00:00
Jenkins
5e0e430d00 Merge "Add a test for the TCPKeepAliveAdapter" 2015-03-12 18:32:40 +00:00
Jenkins
b4fc9e0d2c Merge "nova client cinder query param changed to display_name" 2015-03-12 18:32:26 +00:00
melanie witt
8c0baaea57 Add a test for the TCPKeepAliveAdapter
Related-Bug: #1430935

Change-Id: Idfea26c8eb6448a4c6adc0f3a916515bd4655c1a
2015-03-11 21:03:25 +00:00
Jenkins
3db98546cf Merge "nova flavor-show command is inconsistent" 2015-03-11 20:14:17 +00:00
Anand Shanmugam
41ef74971e nova client cinder query param changed to display_name
nova client is not able to show the list of volumes when
querying by name.This is because cinder api accepts only
display_name as query parameter and when qeried with 'name'
parameter returns a empty list

Change-Id: Ie4ffc275d1754052d9e239d8457baf6f7fd53b83
Closes-Bug: #1430415
2015-03-11 20:48:46 +05:30
Abhishek Talwar
4e79285b45 nova flavor-show command is inconsistent
The nova flavor-show command accepts a flavor
name as its parameter. The command show inconsistency
as it works with the exact flavor name and flavor name
in all lowercase but fails for any other case pattern.

So, updated the code so that if we run the command
with flavor-name case patern it runs fine.

Closes-Bug: #1423885
Change-Id: I713bf2b5aca977df40dc745e29d4fe98a950c991
2015-03-11 09:52:44 +05:30
Jenkins
6c59d708ce Merge "Cleanup in asserts in python-novaclient" 2015-03-03 22:50:56 +00:00
Jenkins
9c719d17d4 Merge "Moved set of asserts from post_servers_1234_action methods." 2015-03-03 17:59:08 +00:00
Pavel Kholkin
560eeafb6d Cleanup in asserts in python-novaclient
The following replacements were done:

1) assertEqual(True, *) -> assertTrue(*)
2) assertEqual(False, *) -> assertFalse(*)
3) assertTrue(a in b) -> assertIn(a, b)
4) assertTrue(* is not None) -> assertIsNotNone(*)

TrivialFix

Change-Id: I8d8a2d7b5d3505e07728544b683b301d1a8850cf
2015-03-03 15:36:49 +03:00
Pavel Kholkin
9f4d64a1bf Cleanup in test_images and image_fakes
Unused code was removed in fixture_data/images.py
for unknown image requests that relate to
v2/images.py and test_images for them.

Change-Id: I7e31a572116b1e5cf0df9f431f8e53470d27d066
2015-03-02 19:07:46 +03:00
Sergey Nikitin
53f0c5428f Enable check for E124 rule
Fix E124 failures and enable check for E124

E124 closing bracket does not match visual indentation

Change-Id: Iec6af44362dcf613cfaccbccbe53de82aba51a6a
2015-02-27 16:30:03 +03:00
Jenkins
7a1066fb79 Merge "allow --endpoint-type internal|admin|public" 2015-02-26 01:21:18 +00:00
yatin karel
e6883d24d0 allow --endpoint-type internal|admin|public
other openstack clients like glance, cinder  use --endpoint-type
(internal|admin|public). This allows users to use the same arguments
with the nova cli.

Partial-bug: #1367389

Change-Id: Ia55cad797ac0dca7fa60f55c1f2dfba0b64d0fd3
2015-02-25 10:02:41 +00:00
Pavel Kholkin
f2a581ee28 Fixed redeclared test_names
Fixed redeclared test_names for two test functions that pass now:
 1) 'test_list_security_groups_all_tenants_on'
 2) 'test_find_by_str_name'

Small spelling corrections

TrivialFix

Change-Id: Iacb0ce5697779f9342c22a22cb2f29a8e063b459
2015-02-24 19:29:23 +03:00
Andrew Laski
ac6636a54d Revert "Overhaul bash-completion to support non-UUID based IDs"
This reverts commit 4c8cefb98a425382204df2f38f24e6b5b71520dd.

The cache completion was causing a bug where 'nova volume-attach' would
then try to query Nova for volume information using a URL that was not
valid.  This caused it to appear that the attach had failed.

Additionally the idea of making extra API queries for a bash completion
cache should be thought through more.

Conflicts:

	novaclient/client.py
	novaclient/shell.py
	novaclient/v2/client.py
	novaclient/v3/client.py

Closes-Bug: #1423695
Change-Id: I6676a11f9b5318a1cda2d03a5d4550bda549d5c2
2015-02-20 01:35:57 +00:00
Haiwei Xu
dfc752d725 Change commands name from net-* to tenant-network-*
Currently the commands of os-tenant-network API use net-*
which may confuse users sometime. This patch changes commands
to tenant-network-*, and marks net-* commands as DEPRECATED.

Closes-Bug: #1152862
Change-Id: I8c3a0be08763a6f626d7fc7cf84811ac61ccc526
2015-02-13 17:47:18 +09:00
Jenkins
3870216567 Merge "Add all tenants search opt to del instnce by name" 2015-02-10 17:29:27 +00:00
Jenkins
78fd2ed0de Merge "Add support for keypair-add command reading public key from stdin" 2015-02-10 17:25:59 +00:00
Ritesh Paiboina
a0481e1c80 Add all tenants search opt to del instnce by name
Nova delete command deletes an instance by name
or ID. Nova delete command is able to delete an
instance within the same the tenant by name or
ID. When admin credentials are sourced and try
to delete a non admin tenant instances, nova
delete command is able to delete an instance by
ID only, it is not able to delete an instance by
name.

Nova delete command deletes an instances by id
using following api call
/v2/{tenant_id}/servers/{server_id}
But to delete an instance by name, nova delete
command first find the resources by name using
following api call
/servers?name={server_name}
This api call is not able to retrive the list
of other tenant instances.
Adding all tenants parameter to this api call
will retrive the list of other tenant
instances. The following will be new api
call
/servers?all_tenants=1&name={server_name}

Closes-Bug: #1247030

Change-Id: I03e578d58214c835d9a411752bd618d77ced37ff
2015-02-10 06:03:09 +01:00
Andrey Kurilin
f84c6531fd Check 'auth_url' is presented while authentication
If 'auth_url' is missed in HTTPClient, authenticate method failed with
non-friendly error while trying to parse it.

Change-Id: Iaec95527293f3e1a34eb7f9ffa81097ba48107b3
2015-02-09 21:47:48 +02:00
Natsuki Maruyama
45000677ec Add support for keypair-add command reading public key from stdin
If given filename is `-` for `--pub-key` option, reads public key
from stdin.

  $ cat id_rsa.pub | nova keypair-add --pub-key - keyname

Change-Id: Ib6dfe5a7b08d588868a923defb9ddd15fc28e01f
Closes-Bug: #1333476
2015-02-08 02:53:53 +09:00
Jenkins
578390ee7e Merge "Change the unsuitable item caching for completion" 2015-02-07 00:52:15 +00:00
Jenkins
805731885f Merge "Compare dicts for POST data in test_client_reauth" 2015-02-06 23:41:39 +00:00
Jenkins
91e9068305 Merge "Remove image to local block device mapping" 2015-02-06 23:04:42 +00:00
melanie witt
edb42ed4dc Compare dicts for POST data in test_client_reauth
I observed a transient unit test failure [1] where occasionally the
ordering of the keys in the string result from json.dumps() didn't
match the ordering in the call_args_list, causing the test to fail.

This change adds a dict comparison of the POST data payload instead
of comparing the json.dumps(data) strings.

[1] http://logs.openstack.org/03/153203/3/check/
gate-python-novaclient-python34/f8a12bc/

Change-Id: I6b8bd4169b92870f657bf4e7f7fca02722749017
2015-02-06 22:06:45 +00:00
zhangjl
5b598ab4e1 Remove image to local block device mapping
In the method named from_api in nova/block_device.py,

    if source_type == 'image' and destination_type == 'local':
        raise exception.InvalidBDMFormat(
            details=_("Mapping image to local is not supported."))

While, in the method named _boot in novaclient/v2/servers.py

    if image:
        bdm_dict = {'uuid': image.id, 'source_type': 'image',
                    'destination_type': 'local', 'boot_index': 0,
                    'delete_on_termination': True}
        block_device_mapping_v2.insert(0, bdm_dict)

Because of the above, if using --image and --block-device
params at the same time to create vm, nova would
raise InvalidBDMFormat exception

To resolve this problem, remove the codes in novaclient which
conflict with nova

Change-Id: I488322ba0160100a6d641fde68fa824d0581956a
Closes-Bug:#1418484
2015-02-06 14:00:08 +08:00
Ikuo Kumagai
9a6a7664c2 Change the unsuitable item caching for completion
This fix changes the item that cached for completion from
"human_id" to "name".
A string for completion shoud not be changed in any way,
because changed keyword can not use as command line parameter.
But the "human_id" means "human readable id" that is
changed from "name" by method "to_slug". "to_slug" is meant to
create a valid path name from a string.

The tools/nova.bash_completion take the completion string from
the file ".novaclient/*/*-cache". The file is created when client
call "list" command. For example , "nova list","nova image-list",
and the others.
Currently, items that are written to the cache file is the "id"
and "human_id".

Closes-Bug: #1193049

Change-Id: I241ec8b7c8729274ee43db6e360141fd381b265e
2015-02-06 05:14:05 +00:00
Sergey Nikitin
aeb8c0c5e9 Moved set of asserts from post_servers_1234_action methods.
Methods tests.v1_1.fakes.FakeHTTPClient.post_servers_1234_action
and tests.fixture_data.servers.V1.post_servers_1234_action
contain a set of same asserts. These asserts moved to method
check_server_actions. This method is shared between
post_servers_1234_action methods.

Some almost equal asserts are grouped.

Change-Id: I2643e77fe30400d462731bbc57351460fb28dc92
2015-02-05 14:11:11 +03:00
Tomofumi Hayashi
0fd8816aa5 Change logic in find_resource() to identify upper-case/lower-case name.
Currently find_resource() searches resource with human_id before does
with name_attr.  With this logic, find_resource() cannot identify
upper/lower case. In find_resource(), human_id always matches and
name_attr never used in find_resource() because human_id made from
small letters of name_attr string (see bug/1318503).

To identify upper/lower case, name_attr should be used before human_id.
This fix moves name_attr to ahead of human_id with unit-test cases.

Change-Id: I9b821d7111c11a97be38f19de06172daf410022d
Closes-Bug: #1318503
2015-02-05 02:48:24 +00:00
Andrey Kurilin
0a60aae852 Rename v1_1 to v2
Module novaclient.v1_1 is used as implementation of V1.1, V2 and V3.
Since future development(microversioning) will be done across V2,
implementation should be done in appropriate module(to prevent misleading).

Despite the fact that implementation for all versions are equal, discover
method for contrib path worked only for v1.1. This patch fixes this bug and
modifies shell tests to check all versions.

Change-Id: Ib6798f4dfe177586302141f522dc593560ce6a5b
2015-02-04 17:40:46 +02:00
Rui Chen
4e76f9590b Fix issue of quota-show and quota-defaults
quota-show and quota-defaults not work because 'SessionClient'
object has no attribute 'tenant_id'. Try to get project_id
from auth_ref when cs.client is SessionClient instance.

Change-Id: Ic125a99ba34e911485868454c3c7531a34eabdc9
Closes-Bug: #1407388
2015-02-03 10:29:04 +08:00
James Penick
a5ea58fec9 Refer to the admin password consistently
The docstrings refer to instance passwords as the admin password, root
password, or simply as "password". That makes documentation difficult to
understand. I've cleaned things up where appropriate.
 I did not change the 'root-password' command in this patch, im planning
to do that in a separate patch.

Cleaning that up to have everything
refer to the instance password as "admin password" for clarity.

Change-Id: I421edcaf18bf8536d5e43f71db6e868868154be3
2015-02-02 19:24:47 +00:00
Joe Gordon
3561772f8b Move unit tests into unit test directory
In order to pave the way for functional testing, move existing unit
tests into a directory labeled unit. A subsequent patch will add a
directory for functional tests.

Change-Id: I0adb8b9f14451acb382c725d31f5387b4b6d82bb
2015-01-27 13:06:06 -08:00