20 Commits

Author SHA1 Message Date
jacky06
038146d500 Remove six
We don't need this in a Python 3-only world.

Change-Id: I7f39c971de09684ad34cdd21ae6819bde797efb0
2020-05-06 00:42:29 +08:00
Sean McGinnis
3eafa2a001
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I4a5b1ec999110a50fc904f3ae93e3983efa64f88
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:58:37 -05:00
Andreas Jaeger
5d93b51900 Update hacking for Python3
The repo is Python 3 now, so update hacking to version 2.0 which
supports Python 3.

Fix problems found.

Change-Id: I81cf5e317bb2f791888e75d87cfd27dfdd2b5f96
2020-03-28 15:54:06 +01:00
Erik Olof Gunnar Andersson
b4120a1352 Use oslo_serialization instead of the json module directly
* Always use oslo jsonutils.
* Consistently import jsonutils as-is.
* Use dump_as_bytes instead of dumps.
https://wiki.openstack.org/wiki/Python3#Serialization:_base64.2C_JSON.2C_etc.

Change-Id: Ifb6c673da24276b0528e5975f63ac326d558936d
2019-01-21 16:32:15 -08:00
yatin
806e660654 Increase UT Coverage
UT Coverage for following is increased:
- magnumclient/tests/v1/test_certificates_shell.py
- magnumclient/tests/test_utils.py

Change-Id: If15aaf9206599126dde14d237bb56b52222ea0cf
Partially-Implements: blueprint magnumclient-ut-coverage
2017-01-24 11:48:48 +05:30
yatin
eab1ba38ae Append value using comma if key exists in label
Magnum allows "labels" to be Dict of string, but currently
magnumclient creates a list of values if same key is specified
more than once when creating a baymodel.
Now if two labels of same key are passed to baymodel-create
the first value is joined with second using comma.

Change-Id: Idcee5c27e29b8d6889fd2c9fa839202ffb8a2f4e
Closes-Bug: #1521461
2016-08-23 13:03:40 +05:30
wangqun
bbdc05d227 Add mesos_slave_executor_environment_variables validate in CLI
mesos_slave_executor_environment_variables is a file path to deliver
the data for mesos executor environment variables, and validate the
file if existing or matching the json form.

Change-Id: Iaeb912184f8789321526887d25e281b5181089ef
Partially-Implements:blueprint mesos-slave-flags
2016-05-20 08:33:42 +00:00
wangqun
406528ec21 Fix the bug when some value in labels has comma, it will fail.
Now using 'comma' split the labels list result in the fail when some
value in labels list has comma, for example, mesos_slave_isolation=
docker/runtime,filesystem/linux

The patch fix the bug that some value in labels list has comma will
fail.

Change-Id: I1553b512e4e2efa7677efadf44e959f1601d39ad
Closes-Bug: #1578498
2016-05-06 19:14:59 +00:00
wangqun
71967890b6 Fix the container-list with --limit 'a negative number'
When running the command "magnum container-list --limit -1 --bay
swarmbay" with "--limit -1" , it can get the containers successfully.

Change-Id: I359a9b90bd80cfeb97db2ada8fb1ada0f5eb127e
Closes-Bug: #1562790
2016-03-31 06:19:20 +00:00
Jenkins
cf38202997 Merge "Allow semicolons in list of labels" 2016-03-23 21:50:15 +00:00
phelanm
905e6ee481 Allow semicolons in list of labels
* can use commas or semicolons in label list
* add two tests, all semicolons and mixed
  semicolons and commas

Closes-bug: #1497042
Change-Id: I6c243b09343b92fc54a991facf874d1e5f0f1f51
2016-03-23 18:59:31 +00:00
Hongbin Lu
c991639a6b Fix incorrect initialization of OrderedDict
According to the doc[1], initialize OrderedDict as below won't
perserve the order:

  collections.OrderedDict({...})

This causes occasional failures of the tests. This patch changed it
to:

  collections.OrderedDict([...])

[1] https://docs.python.org/3/library/collections.html#
ordereddict-objects

Change-Id: I863f9d2879a6c119501fe1d5175ecb8a70e7e9f1
Closes-Bug: #1556475
2016-03-12 13:45:08 -05:00
Yang Hongyang
df08393491 Use six.u instead of u''
There's no u'' in python3.4, strings are always unicode or bytes in
python3. use six.u() to convert strings.

Change-Id: I96be4305476ea74b4a2931fab550e8c21f1c8fad
2016-03-03 10:49:47 +08:00
Yang Hongyang
c7d2bbfc0f Sync with oslo-incubator
Apiclient[1] and cliutils[2] is removed form Oslo incubator, we should keep
the local copy by ourself.
1. copy openstack/common/apiclient to common/apiclient
2. only keep base, auth, exceptions from apiclient, others are unused
3. copy openstack/common/cliutils.py to common/cliutils.py
4. update all magnumclient.openstack.common.* users to use
   magnumclient.common.*

This is the first step to delete openstack common modules.

[1] Change: I2020d73fa9cedb3b3b87c1d8dbc8d437857ec7c2
[2] Change: Ibc5a8f11c6e5c308cec15a60eeb07a898254f9b7

Partial-Bug: #1545957
Change-Id: Ide3814d87ecdf3255868bf3b78fdceb58bd14295
2016-02-18 13:06:00 +08:00
Corey Bryant
c0a6829c15 Fix test_keys_and_vals_to_strs dict assert
Fix the assert of dictionary equality in test_keys_and_vals_to_strs
as the dictionary order can cause the test to fail.

Change-Id: Iaa0c7bf6cbcb456451d287c7ba8d9e2829e4edc5
Closes-Bug: #1532834
2016-01-11 15:00:25 -05:00
houming-wang
0c547422bb Remove references to _i18n and apiclient.exceptions
Since oslo-incubator is no longer maintained[1] after
90ae25e38915cc502d9e9c52d59e8fb668a72ae1. We should cleanup
the deprecated code.

This patch do the following cleanup actions:
1. Use magnumclient.i18n instead of
magnumclient.openstack.common._i18n.
2. Use magnumclient.exceptions instead of the deprecated
magnumclient.openstack.common.apiclient.exceptions[2].

[1] http://lists.openstack.org/pipermail/openstack-dev/2015-November/
    079343.html
[2] https://github.com/openstack/python-magnumclient/blob/master/
    magnumclient/openstack/common/apiclient/exceptions.py#L25

Change-Id: I6fae1f84d211d661bb363e43167cdf8b6b06fd4d
Partial-Bug: #1529316
2015-12-26 00:07:11 -05:00
Dane LeBlanc
a6d1bf0296 Magnum show cmds display dictionaries with unicode u chars
When a Magnum resource has an attribute that is implemented as a dictionary,
and that dictionary contains either unicode keys or unicode values, then
the Magnum client show commands display the dictionary keys/values
including a preceding 'u' character. For example, the output of the
'magnum baymodel-show <baymodel>' command includes this line:

| labels | {u'flannel_network_subnetlen': u'26',
            u'flannel_network_cidr': u'10.101.0.0/16',
            u'flannel_use_vxlan': u'true'} |

This patchset adds a recursive conversion of a dictionary's keys and
values from unicode to strings before the contents of the dictionary
are printed by the Magnum client.

Change-Id: I0fdc1f1d2dfc693652307ac66622c24f03899f8d
Closes-Bug: #1498071
2015-09-22 11:50:45 -04:00
Daneyon Hansen
ce8924bb43 Adds Labels Support
Adds labels attribute and associated tools/tests to the magnum
client.

Implements: blueprint extend-client-network-attributes

Change-Id: Ie8465275646b82aa9bd7a9de756c519bdd6ec0e2
2015-09-16 19:58:54 +00:00
Hongbin Lu
77084e6b84 Add support for updating a bay
Users can use these commands to add/remove/update bay attribute(s):
magnum bay-update <bay_id> replace <path=value>
magnum bay-update <bay_id> add <path=value>
magnum bay-update <bay_id> remove <path=value>

For example, this command updates the node_count attribute of a bay:
magnum bay-update 0aab40ba-3f48-4e6e-88a6-247be18b9711 replace node_count=1

Change-Id: If003beaca8e7e8bbdff2cf24d2810b0db9efdf41
Implements: blueprint update-node-count
2015-02-17 03:18:01 +00:00
Jay Lau (Guangya Liu)
61f20c3e01 Add unit test for magnumclient/common/utils.py
Change-Id: If3423ae2a74dedb11e97a424a4bf24d70dbbc7af
2015-01-03 21:27:26 -05:00