166 Commits

Author SHA1 Message Date
Dean Troyer
b2783dc3c4 Low-level Compute v2 API: network
api.compute.APIv2 network functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: If230f128e91cda44461fe93c976cac2aecec2252
2017-04-17 19:45:21 -05:00
Dean Troyer
4289ddd47a Low-level Compute v2 API: security group
api.compute.APIv2 starts with security group functions.

novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.

Change-Id: Id007535f0598226a8202716232313e37fe6247f9
2017-04-11 02:08:04 -05:00
Cedric Brandily
7f9814860a Enable to specify which fixed-ip to add to a vm.
This change enables to specify which fixed-ip will be added to a vm using:

 openstack server add fixed ip <vm> <network> --fixed-ip-address <ip>

This change uses interface_attach instead of add_fixed_ip[1] which is
less flexible and uses a deprecated API.

[1] https://review.openstack.org/384261

Closes-Bug: #1678140
Change-Id: I7fe4621439ef0d8dca080551ffaeb614c5a91174
2017-04-04 11:15:29 -05:00
Jenkins
c7e7f2b730 Merge "Help/docs cleanups: marker, limit, ip-address metavars" 2017-04-04 12:32:55 +00:00
Dean Troyer
1686dc54f0 Help/docs cleanups: marker, limit, ip-address metavars
Cleanup help strings and docs for clarity and to keep things consistent:
* --limit metavar should be <num-resource> to indicate what is being counted
* --marker metavar should be <resource> or <resource-id> to indicate the
  type of value being specified
* <*-ip-address> metavars should be just <ip-address> as there is no difference
  in format between fixed and floating IPs
* Move all occurances of '(name or ID)' to end of help text

Change-Id: I2c31746ed6ded3845244e03e57d809f8bc0e6b9d
2017-04-04 03:56:19 +00:00
Jenkins
d0f368ba0e Merge "Enable to add/remove port to/from a server" 2017-04-03 20:51:20 +00:00
Cedric Brandily
21510ac1a9 Enable to add/remove port to/from a server
This change enables to add/remove a specific port to/from a server using
the new commands:

 openstack server add port <vm> <port>
 openstack server remove port <vm> <port>

Closes-Bug: #1678137
Change-Id: I6ee57df089235ccc1fb9d38316bd484956b1134d
2017-04-03 20:19:40 +02:00
Jens Rosenboom
61cde9c8e8 Fix block-device-mapping when volume_size is empty
The Nova API responds with an validation error when a bdm is submitted
containing an empty volume_size. So instead omit that attribute when it
is empty.

Change-Id: Iba905fca8c440a03e828c20922f3b813bba3fa3a
Closes-Bug: 1677236
2017-04-03 11:26:35 +00:00
Jenkins
49e866174f Merge "Enable to specify which vm fixed-ip to publish" 2017-03-21 01:55:51 +00:00
Cedric Brandily
f5527877bb Enable to specify which vm fixed-ip to publish
This change enables to specify which vm fixed-ip will be associated to a
floating ip using:

 openstack server add floating ip <vm> <fip> --fixed-ip-address <ip>

Closes-Bug: #1624524
Change-Id: I2ddb68c5873bfed7293b0e661d1adbe111681136
2017-03-20 22:33:51 +01:00
Jenkins
495d013431 Merge "Adds missing flavor information in the server list long command" 2017-03-20 17:57:38 +00:00
Jose Castro Leon
429b43a331 Adds missing flavor information in the server list long command
Closes-Bug: #1672396

Change-Id: Ie2a664fd1c3db1b8269ea079df181f87afc702a7
2017-03-13 16:32:15 +01:00
Rikimaru Honjo
7063ffb3ca Add a validation about options for server migrate command
The behavior of server migrate command are different depending on
whether user specify --live option or not.
server migrate command will call live migration API if user specify
--live option.
Ohterwise server migrate command will call migration(cold migration)
API.

Now then, "--block-migraiton" option and "--disk-overcommit" option
only affect live-migration.
But, openstackclient doesn't warn user if user specify these options
without "--live".
But, user can't recognize that specifying options are ignored.

This patch adds a validation that checks whether or not user specify
these options without "--live".

Change-Id: Ifa278abb23ecdba4b13f3742998359ac74eb7ad4
Closes-bug: #1662755
2017-03-01 17:37:39 +09:00
Rui Chen
c051c5f090 Fix "server create" command failed when --nic auto or none
"auto" and "none" options was added into --nic argument of server create
command in patch https://review.openstack.org/#/c/412698/ , but that
don't work and raise internal error when execute command. The patch
fix that issue and add unit and functional tests.

Change-Id: Ia718c3bac0a5172a0cdbe9f0d97972a9346c1172
Co-Authored-By: Kevin_Zheng <zhengzhenyu@huawei.com>
Closes-Bug: #1663520
2017-02-15 14:25:37 +08:00
Dean Troyer
16aeee4303 Cleanup for 3.8.0 release
Release notes and proofreading cleanups.

Change-Id: Iddc6a64e6ea3082aa220a2465793e6f7f2aecaa9
2017-01-26 10:41:30 -06:00
Jenkins
d189e807fd Merge "Add options to "server list" command" 2017-01-26 06:38:27 +00:00
Nikita Gerasimov
95c8661f86 Switch server create to block_device_mapping_v2
Current compute_client.servers.create() relies on block_device_mapping
arg which is legacy[1]. "block_device_mapping" format require
device_name which is leads to hard-coded hack in --volume key handler
to KVM specific. "block_device_mapping_v2" format is more friendly
to hypervisiors.
Support of block_device_mapping_v2 appear in python-novaclient 2.16.0,
openstackclient require at least 2.29.0

Makes options --volume and --block-device-mapping work simultaneously.
Appends --block-device-mapping data even if --volume used.
After bug 1383338 only --volume was taken when both are used.

[1]http://docs.openstack.org/developer/nova/block_device_mapping.html

NOTE(dtroyer): I moved the new test_boot_from_volume() functional
test to Ie51b1c375c5940856ec76a5770df3c6bd18a3eba to test our
previous behaviour.  The only changes required to support the new
behaviour should be that the empty_volume is now attached in that test.

Change-Id: I7bac3d870dd9ca404093142f8bce22a62e49180d
Closes-Bug: 1647406
Closes-Bug: 1497845
2017-01-26 02:02:30 +00:00
jiahui.qiang
c46f9dc501 Add options to "server list" command
Add "--deleted" and "--changes-since" options to "server list" command.

Change-Id: Id94f6e5831a60b172b6cfcfca29b1d89de8db621
Closes-Bug:#1647242
2017-01-25 21:31:45 +00:00
Artom Lifshitz
98f803e0f0 Use image client for images instead of compute
With the deprecation of the Nova proxy APIs in microversion 2.36 [1],
any operation that uses a microversion higher than 2.36 and works with
images will fail because the /images endpoint will return 404. This
patch updates openstackclient to query images using the image client
in places where previously the compute client was used.

[1] http://docs.openstack.org/developer/nova/api_microversion_history.html#id33

Change-Id: Ia66e44e530799ce6531922dcf6a84e38528c8725
Closes-bug: 1630161
2017-01-24 16:56:35 +00:00
jiahui.qiang
89d9449dcf Error in the return of command server show, create
The raw output in the command 'openstack server create'(also in show) is
used in display table directily. the item like
os-extended-volumes:volumes_attached and security_groups needs to convert.

the worry output:
  os-extended-volumes:volumes_attached | [{u'id': u'c3525de9-1cbf-4ac8-8b7a-ca295c46633b'}]
  security_groups                      | [{u'name': u'default'}]

Change-Id: Id9db251c315f989e1dc5b1b6231ab328014213e3
2017-01-17 17:49:16 +08:00
licanwei
0948aa6aeb update server migrate '--wait' description
'Wait for resize to complete'
==>
'Wait for migrate to complete'

Change-Id: I0e08968c0132f0a8e1ef1ce2e6179001315372c3
2016-12-30 14:16:32 +08:00
Kevin_Zheng
ff18e3d0e9 Should support 'auto' and 'none' as network parameter when boot instances
Nova added support using 'auto' and 'none' as network parameters since
microversion 2.37:
http://git.openstack.org/cgit/openstack/nova/tree/nova/api/openstack/rest_api_version_history.rst#n389
we should also add support for this in OSC.

Change-Id: I6e5f616dfa48895ebd13144effe9fda7cb94c649
Closes-bug: #1651288
2016-12-22 10:01:02 +00:00
Steve Martinelli
0ef8535036 translate all command help strings
Leverage the new cliff command class attribute (_description)
to get the help of a command, this allows us to mark strings
for translation. We could not do this before since the help
was grabbed from the docstring.

This also depends on a new release of cliff and a bump to the
minimum level in osc's requirements.

Closes-Bug: 1636209
Depends-On: Id915f6aa7d95a0ff3dc6e2ceaac5decb3f3bf0da
Change-Id: I8673080bb5625e8e3c499feaefd42dfc7121e96f
2016-11-17 02:33:42 +00:00
Cedric Brandily
694a24c309 Fix --shared/block-migration options in server migrate command
Currently, --shared-migration and --block-migration options effects are
reversed: --block-migration requests a migration with share,
--shared-migration a block-migration.

This change corrects OSC implementation and clarifies arguments passed
to novaclient (the root cause of the bug).

Change-Id: Ib682cff0c44d3b1304670f8606907b1762d8b1e7
Closes-Bug: #1518059
2016-10-11 22:01:16 +02:00
Cedric Brandily
e6b09eef0c Correct login name deduction in SshServer
Currently SshServer ("server ssh" command) raises an AttributeError if
no explicit login is provided because it uses an attribute which no more
exists.

Change-Id: I86f68230037d51efb41aca62e07e058733ecd67a
Closes-Bug: #1624085
2016-09-15 21:57:17 +02:00
Rajasi Kulkarni
e26eecc12f Pass security group id to novaclient while adding security
group to server

In AddServerSecurityGroup, we currently pass the security group
name to novaclient. If multiple security groups with same name
exist, then even while passing secuity group using id to
command 'openstack server add security group <server> <group>'
it results in error 'Multiple security_group matches found'.
Added unit test case to test the command.

Change-Id: I6097eb36e1545c85209cfd767c477e10f82c6999
Closes-Bug: 1604076
2016-07-28 21:39:02 +05:30
Jenkins
719c5d79ce Merge ""server list": "Image Name", "Image ID" columns" 2016-07-22 20:38:20 +00:00
Rajasi Kulkarni
8405db900f Pass security group id to novaclient
In RemoveServerSecurityGroup we currently pass the entire security
group object, which results in TypeError in novaclient.
Added unit test case to test command 'openstack server remove
security group -h <server> <group>'

Change-Id: I6d486403a83804c3a30d6f89d2cf7f64f09797c6
Closes-Bug: 1590883
2016-07-11 22:34:35 +05:30
Marc Abramowitz
b74be57300 "server list": "Image Name", "Image ID" columns
The `Image Name` column is shown by default (i.e.: without passing `--long`). E.g.:

```
$ openstack server list
WARNING: openstackclient.common.utils is deprecated and will be removed after Jun 2017. Please use osc_lib.utils
+--------------------------------------+-----------------+---------+----------------------+----------------------+
| ID                                   | Name            | Status  | Networks             | Image Name           |
+--------------------------------------+-----------------+---------+----------------------+----------------------+
| abe67035-b14f-4541-b436-e0e778ec4227 | n9anonw302mgm1  | ACTIVE  | mnky3-3000=10.3.0.55 | Koala.2016-07-01-175 |
| 8f6a2d12-2bc3-4d89-ba94-8916ce9cdf92 | n9anonw301mgm1  | ACTIVE  | mnky3-3000=10.3.0.37 | Koala.2016-07-01-175 |
| b316d6d1-67cf-4f75-94a4-4c9a2b03f6a4 | n9dobby301mgm0  | ACTIVE  | mnky3-3000=10.3.0.36 | Koala.2016-05-04-130 |
+--------------------------------------+-----------------+---------+----------------------+----------------------+
```

The `Image ID` column is only available with `--long`. E.g.:

```
$ openstack server list --long -c Name -c "Image Name" -c "Image ID"
WARNING: openstackclient.common.utils is deprecated and will be removed after Jun 2017. Please use osc_lib.utils
+-----------------+----------------------+--------------------------------------+
| Name            | Image Name           | Image ID                             |
+-----------------+----------------------+--------------------------------------+
| n9anonw302mgm1  | Koala.2016-07-01-175 | f587c6fc-1df3-42cd-ac86-8cd2c995a8d9 |
| n9anonw301mgm1  | Koala.2016-07-01-175 | f587c6fc-1df3-42cd-ac86-8cd2c995a8d9 |
| n9dobby301mgm0  | Koala.2016-05-04-130 | 37ff47a6-3e51-4986-bfa5-62afbfad5dfc |
+-----------------+----------------------+--------------------------------------+
```

Closes-Bug: #1599304

Change-Id: I477995b840eb9520b285948926ebbfe1777dd86c
2016-07-06 07:11:17 -07:00
Tang Chen
179ebe6d64 Transfer "ip fixed add/remove" to "server add/remove fixed ip"
This patch does the following things to transfer
"ip fixed add/remove" to "server add/remove fixed ip":
* Add new command "server add/remove fixed ip", and unit
  tests and doc.
* Deprecate "ip fixed add/remove" command.

compute/v2/fixedip.py is not removed because the arguments'
positions are different between the new and old commands.
* ip fixed add <network> <server>
  server add fixed ip <server> <network>
* ip fixed remove <ip-address> <server>
  server remove fixed ip <server> <ip-address>

Change-Id: Ica07ccf92a76c21fd5608ecaff86ff7c4d96f5a0
Implements: blueprint rework-ip-commands
Partial-bug: 1555990
Co-Authored-By: Dean Troyer <dtroyer@gmail.com>
2016-07-04 10:41:30 +08:00
Tang Chen
d1f9ea3f75 Transfer "ip floating add/remove" to "server add/remove
floating ip"

This patch does the following things to transfer
"ip floating add/remove" to "server add/remove floating ip":
* Add new command "server add/remove floating ip", and unit
  tests and doc.
* Deprecate "ip floating add/remove" command.

compute/v2/floatingip.py is not removed because the arguments'
positions are different between the new and old commands.
* ip floating add <ip-address> <server>
  server add floating ip <server> <ip-address>
* ip floating remove <ip-address> <server>
  server remove floating ip <server> <ip-address>

Change-Id: Ic0dd22ca6fb7b7bc3e820fd5a14d7c551e7ab963
Implements: blueprint rework-ip-commands
Partial-bug: 1555990
Co-Authored-By: Dean Troyer <dtroyer@gmail.com>
2016-07-04 10:40:59 +08:00
Tang Chen
047cb68493 Standardize logger usage
Use file logger for all command specific logs.

This patch also fixes some usage that doesn't
follow rules in:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html

After this patch, all self.log and self.app.log
will be standardized to LOG().

NOTE: In shell.py, we got the log in class OpenStackShell,
      which is also known as self.app.log in other classes.
      This logger is used to record non-command-specific logs.
      So we leave it as-is.

Change-Id: I114f73ee6c7e84593d71e724bc1ad00d343c1896
Implements: blueprint log-usage
2016-06-20 15:16:51 +00:00
Jenkins
b9a318156c Merge "Move server image create command to its own resource file." 2016-06-16 13:05:18 +00:00
Dean Troyer
9e2b8e6730 osc-lib: command
Leave command.py and test_command.py as a sanity check during the
deprecation period.

Change-Id: I24e1b755cbfbcbcaeb5273ec0c9706b82384fc85
2016-06-13 11:00:22 -05:00
Dean Troyer
be192676bd osc-lib: parseractions
Leave parseractions.py and test_parseractions.py as a sanity check during the
deprecation period.

Change-Id: I1a7469b6d872284e0276502a1a287bc0b87f8f83
2016-06-13 10:55:44 -05:00
Dean Troyer
e5e29a8fef osc-lib: utils
Use osc-lib directly for utils.

Leave openstackclient.common.utils for deprecation period.

Change-Id: I5bd9579abc4e07f45219ccd0565626e6667472f7
2016-06-13 10:50:44 -05:00
Dean Troyer
d20c863ebc osc-lib: exceptions
Use osc-lib directly for exceptions.

Leave openstackclient.common.exceptions for deprecation period.

Change-Id: Iea3e862302372e1b31ccd27f69db59b4953ca828
2016-06-13 10:50:01 -05:00
Lu lei
54e81a9984 Add newline to strings in stdout/stderr.write()
Function stdout/stderr.write() can't break line automatically.

Change-Id: I903c2d1cc1a669adb6be5aa4eb783d3b9943e685
2016-06-06 13:54:55 +08:00
Dean Troyer
eef2054109 Move server image create command to its own resource file.
Change-Id: If37e82072bd7a32b81bfb1a8bb048f018dd5b04f
2016-06-03 09:19:57 -05:00
Jenkins
21924f55b9 Merge "Fix output and error log in server.py" 2016-05-31 13:42:14 +00:00
Rui Chen
1a7284f63a Support to set server state
When a server is unexpected state, OSC don't support reset
the server to active or error state, that's supported by
novaclient, and it's an important command for operators, the
patch implement this function.

Change-Id: I3e7800feb192832b0719ef9a353945beb6bfd509
Implements: blueprint server-reset-state
2016-05-28 18:55:50 +08:00
Tang Chen
97162ecd22 Fix output and error log in server.py
This patch fixes 2 problems:

1. The '\n' should be in the end of a message,
   not the beginning.

i.e.:
   The original code was:
       sys.stdout.write(_('\nError deleting server'))
   It will make the output look like this:

   [root@tangchen /]# openstack server delete aaa bbb

   Error deleting server
   Error deleting server[root@tangchen /]#

   We change it to:
       sys.stdout.write(_('Error deleting server\n'))
   Then the output will become:

   [root@tangchen /]# openstack server delete aaa bbb
   Error deleting server
   Error deleting server
   [root@tangchen /]#

   which is much better.

2. Record the error in log for those who didn't.

Change-Id: I38b00c2321014757970183205f95f026e20a8090
2016-05-28 15:46:32 +08:00
Tang Chen
5398c96e2a Fix i18n support for help and error messages in compute
Change-Id: Id6eebcb48d1b7b49b6636524506294edbc44a83f
Partial-bug: #1574965
2016-05-24 11:03:49 +08:00
Steve Martinelli
ebcbd6ba71 remove #noqa from i18n imports
hacking checks no longer fail on `import _`

Change-Id: Idd60f0a0e71e5081691eacb39e5091ab08fcce6d
2016-05-13 13:14:02 -07:00
Jenkins
b60ff95edf Merge "Use find_resource() instead of get() in _prep_server_detail()" 2016-05-11 13:26:30 +00:00
Tang Chen
d58280a279 Use find_resource() instead of get() in _prep_server_detail()
There is such a comment in test_server.py:

    # Call .get() to retrieve all of the server information
    # as findall(name=blah) and REST /details are not the same
    # and do not return flavor and image information.

This is an out of date comment. There is no function named
findall() in OSC now. So use find_resource() instead of get(),
and remove this comment.

Change-Id: I8d79afc5f341fb5caf771d905506b7f1c7a41ae8
2016-05-09 14:59:39 +08:00
Tang Chen
809239ca1e Map server power state num to meanful string
In _prep_server_detail(), power_state is not formatted
by _format_servers_list_power_state(). So when executing
"server show" or "server create", the power state is
represented by number. This patch map the numbers to
meanful strings.

This patch also adds power_state attribute to FakeServer,
and improves unit tests for this attribute.

Change-Id: I2ec674327de4e5133b8712ba6bb53fa5ce55e3f4
2016-05-07 14:54:44 +08:00
Tang Chen
32c627eaf0 Doc: Unify repeatable option comments
There are lots of "this option can be repeated" comments
in the doc, which are not consistent to other similar
docs.

This patch changes them to the following format:

"repeat option to do something"

Change-Id: I54e01053091c428bf87bb36bb95f73a0b80ab6e7
2016-04-12 15:57:17 +08:00
Rui Chen
ee621509be Fix "server unset" document issue
Fix "--property" option describe issue in "server unset"
document, and update the help message to keep consistent.

Change-Id: I68022a187e83fad6320365400ad2a1b0c8cf9a61
2016-03-23 14:45:04 +08:00
Stephen Finucane
13e2bb9b96 Trivial: Use 'SSH' rather than 'Ssh'
This is reflected in the '--help' screen.

Change-Id: Ic22a65ff6a56b069b37a0ea8365cce2b3f93621c
2016-03-09 14:55:55 +00:00