As we dropped Python 2 support we don't have to use the third party
mock library with Python 2 compatibility and can move to Python 3
standard library. The change updates the import statements to reflect
that.
Change-Id: I39d9410ae43a2d9e6f6d6eaf74d06a82f2c33524
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.
Fix problems found by updated hacking version.
Remove hacking and friends from lower-constraints, they are not needed
there.
Change-Id: I14aee6250d80b7485c5c582a20abf4efafcc28c2
Available notification types depend on what is enabled in Monasca
Notification. As such, we should avoid hard coding them into the
client and rely on the Monasca API to validate whether a type is
supported, and to list the supported types.
Change-Id: Icc18bffa04806235583459721f8cb8e36a247f05
Story: 2005551
Task: 37848
In some cases, users may want to send periodic notifications for
notification types other than webhooks.
Change-Id: I0256e9a8c3dacaf8bc6066b00daefaa993460a2d
Story: 2006837
Task: 37420
Python 3 uses unicode strings by default. This bug was caused by
attempting to join a byte string to a unicode string when running
with the Python 3 interpreter.
A unit test was added to reproduce the problem.
Whilst this fix allows alarm definitions to be listed, it doesn't
fix the formatting problem in Python 3. A better fix may be
to return unicode strings in Python 3 as part of a wider code
audit.
Story: 2004972
Task: 29427
Change-Id: Ib008ed2aacd93f499b15094cf5a7e1bb0bb50a1f
This way when someone use code like `sys.exit(main())` it will have
proper exit code on error (so different than `0`).
Story: 2001246
Task: 5776
Change-Id: I1c04fbf73d1fc44da7738c8f22296992d2e7a4f8
TimingSession is removed and replaced by keystone session (see [1]).
This patch remove it from monasca client.
[1] https://review.openstack.org/#/c/579139/
Change-Id: I4bfcef96bcb9c8fd14e2c57f318630aa508710ca
Story: #2002978
Task: #22987
The unicode() built-in does not exist under Python 3 so use
six.text_type, which is set correctly to str or unicode, instead.
Change-Id: I22265e35c04be2fa663b63aac208f7894588d629
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
* set the maximum line length to 100
* cleaned up the codes for pep8
Change-Id: Ib4398e601fbf36619a07822b6a616ab13adaa55d
Signed-off-by: Amir Mofakhar <amofakhar@op5.com>
If OS_CLOUD is not set the defalt value is parsed which is empty string. This
is wrong, as it deactivates all other environment variables for cloud
configuration.
Change-Id: I48452bb5300fcc46047f8e94501bba1c42629ea1
Story: 2001158
Task: 4890
Add possibility to reuse the session,
passed as kwarg, passed from a component
that initializes the client.
Change-Id: I35bb752680f499dac163305cd81daa2c7b7a817b
Removing *args in 94c5223f02,
turned out to break projects that are using monascaclient.
Following code adds it back with the note about the deprecation.
Change-Id: If2664b5054d668f5e088699ae1493c54692a2e8c
osc-lib library is foundation on which a CLI client
for openstack can be built. It is meant to facilitate several
aspects, that were previously hard-coded in client:
* keystone communication handling
* supporting multiple authentication methods (not only password)
* common authentication parameters (i.e. environmental OS_*)
* communicating over http with service endpoint
* interactive CLI mode
Thanks to those items, it was possible not only to drop
nearly 3k lines of code and replace them with osc-lib but also
increase reliabity of the client in terms of new openstack releases.
Also it allowed to greatly simpify existing set of unit-tests.
They are now testing only actual logic instead of mocking
entire process of calling shell (i.e. MonascaShell.run(args)) or
mocking HTTP communication. Both items are handled by osc-lib thus
not they are not subject of monascaclient unit tests layers.
Note:
This change is partial integration with osc-lib and its main
purpose is to move the responsibility of:
* keystone communication
* rest-ful communication with service endpoint
to underlying library thus allowing client to implement only
necessary functionality and not supporting boilerplate code,
mentioned above.
Story: 2000995
Task: 4172
Change-Id: I1712a24739438e2d8331a495f18f357749a633c5
We can use dict.items instead, as it will return iterators
in PY3* as well. And dict.items/keys will more readable.
Change-Id: I76683ba60193b725a668716366f020391f61ac4c
The type field was always being sent to the API even if a value wasn't
given. Change code to only send type field if --type was actually used
as an argument
Added tests for this case
Change-Id: Idb495eceb189db341753fd82be57d414e17cd64b
Closes-Bug: #1664326
The tenant-id query parameter was being passed as a list instead
of as a string
Added test
Change-Id: Ib8300530a3a17d9cb96962c1ffdf5362ed0553ca
Closes-Bug:#1664415
From looking through monasca server code there is nowhere that is
actuall reading the X-Auth-User, X-Auth-Key, X-Auth-Url or X-Auth-Region
headers. The shell also enforces that a user provide keystone
authentication. This means we are sending the server a user's password
for no reason. They were initially added in the very first monascaclient
commit so assume they were unneeded and remove it.
Change-Id: Ic6e6dd1a14474537ab9180bb4af1a3fae09fc8a6
Mocking out the entire http layer means there is no testing being
performed that a request is actually being sent out as expected.
requests-mock mocks requests and responses at the point where it would
be sent out over the wire so we can better see actual made requests.
Change-Id: I66657ecc6a53b23cecfe92c911aee6fd27c68f40
When an exception was caught and rethrown, it should
call 'raise' without any arguments because it shows
the place where an exception occured initially instead
of place where the exception re-raised
Change-Id: Ida52fc0078eebea9441c3caa0efc8f7f4c9b53f2
In Python 3 __ne__ by default delegates to __eq__ and inverts the
result, but in Python 2 they urge you to define __ne__ when you
define __eq__ for it to work properly [1].There are no implied
relationships among the comparison operators. The truth of x==y does
not imply that x!=y is false. Accordingly, when defining __eq__(),
one should also define __ne__() so that the operators will behave as
expected.
[1]https://docs.python.org/2/reference/datamodel.html#object.__ne__
Change-Id: I52d4b7396136dd3be7b8767dccb0613e8faba536
Preserves the 'next' link from list queries to allow pagination
and adds a new command to pick the last query where the limit
stopped it
Change-Id: I564c3824b0dd8458e3d6237ec546b4e6e1052334
As part of the first community-wide goal [1], teams were asked
to remove the openstack/common package of their projects
if one existed. This was a byproduct of the old oslo-incubator
form of syncing common functionality.
The package, apiclient, was moved to a top level location
and cliutils was moved to the common module. There are no oslo
specific libraries, the recommended solution is to move it
in tree and maintain it there.
[1] http://governance.openstack.org/goals/ocata/remove-incubated-oslo-code.html
Change-Id: If28f22e5ff6002bef8d9dfc27a694d1100535dc9
as part of the openstack wide ocata goal, all references to the
now obsolete oslo-incubator modules (in openstack/common) should
be removed. this is the first step in doing that, a future patch
will move the apiclient to be a top level module.
Change-Id: I0bcd01b3f6ff6c7e562bd9419c6a8e86989b1e27
When using CLI to query dimension value list,
monasca dimension-value-list --metric-name cpu.user_perc hostname
'Namespace' object has no attribute 'dimension_name'
The attribute name was 'dimension-name' instead of 'dimension_name'
Change-Id: I826fa95beafa106bbc7189928d258302fb288c44