19 Commits

Author SHA1 Message Date
Maxime Belanger
b227a39912 Raise on NodeManager get when invalid identifier provided
When calling the NodeManager get method with resource_id
equal to [], {}, (), None, "" or False the client returns a bad
data structure.

In order to be consistent with the API and the CLI the
resource_id is now validated before calling the API
and raises ValidationError in case of invalid value.

Change-Id: Idb2b424ab17e79da948595fb74df3ef9d81732c0
Closes-Bug: #1652142
2017-01-09 08:06:46 -05:00
Ruby Loo
109b438527 If no resource, don't call Resource.to_dict()
This adds a new method base.Manager._get_as_dict() which
checks whether there is a resource first, before calling
Resource.to_dict(). Code was modified to call this new
method, instead of calling Resource.to_dict() directly.

This fixes the AttributeError that occurs if, for example, one
tries to get the list of driver passthru methods of the 'fake'
driver (via 'ironic driver-get-vendor-passthru-methods fake').
There are no methods, and without this change, an AttributeError
exception is raised. With this fix, an empty list is returned.

Change-Id: Ib6b691cd39ede9c5902b4df29023fd974b367a7d
Closes-Bug: #1626806
2016-10-04 12:10:08 -04:00
Ruby Loo
1e37be4484 Add invalid attribute names to exception
When creating a resource via CreateManager.create(),
an InvalidAttribute could be raised for invalid attributes
(attributes that are not needed to create the resource).
The raised exception had no message.

This changes the exception to include a list of all the
invalid attributes as well as indicate what the problem
is.

Change-Id: Iaea056ea6946a6f813f8081c26f62dcfe63d1bbd
2016-06-28 22:13:44 -04:00
Sinval Vieira
20cefcf0bd Refactoring and removing duplicate code of "base.Manager" heirs
without changing the API

This commit does refactoring regarding the base.Manager and the
specific managers that inherit from it (Chassis, Node, Port and
Driver).

The specific managers had a lot of duplicate code in methods like:
get, create, delete and update, they were literally equal, what does
not make sense once we already had the base.Manager inheritance to
avoid this type of problem.

This change moves the duplicate code to the parent (base.Manager) and
make the specific managers simpler by making the base.Manager more
useful regarding code reuse for these methods.

Change-Id: Ic77a86196d5bcd956f0a3ae517200824a4d70aa8
Closes-Bug: #1517631
2015-12-09 19:31:20 -03:00
John L. Villalovos
861b1f4b8e Revert "Refactoring and removing duplicate code of "base.Manager" heirs"
This reverts commit 46b279bb36b2647bf04097fe271586fca76f5ed0.

The patch being reverted has broken the API compatibility. Until a fix
for this issue has been created, the patch should be reverted.

Change-Id: I1295c3e0d5ca228253874719befd7ed842d505fa
Closes-Bug: #1521429
2015-11-30 19:02:21 -08:00
Sinval Vieira
46b279bb36 Refactoring and removing duplicate code of "base.Manager" heirs
This commit does refactoring regarding the base.Manager and the
specific managers that inherit from it (Chassis, Node, Port and
Driver).

The specific managers had a lot of duplicate code in methods like:
get, create and vendor_passthru, they were literally equal, what does
not make sense once we already had the base.Manager inheritance to
avoid this type of problem.

This change moves the duplicate code to the parent (base.Manager) and
make the specific managers simpler by making the base.Manager more
useful regarding code reuse for these methods.

Change-Id: I9acef9ecc815df61d7ddabe3fae9eccdafe2eeed
Closes-Bug: #1517631
2015-11-30 10:22:06 -03:00
Lin Tan
4d966622ef Sync with oslo-incubator
According to the latest agreement in Oslo team, apiclient and
clituils will be removed from Oslo incubator. We should keep
the local copy by ourselfs:
1. rename openstack/common/apiclient to common/apiclient
2. Because Ironic only use base.py and exception.py, so delete others.
3. rename openstack/common/cliutils.py to common/clituils.py
4. Delete openstack/common/_i18n becuase we have common/i18n.py
5. Delete openstack folder because it is empty
6. Add related unit tests and add oslotest to test-requirements.

Change-Id: I9eecd0457e86e82e65db1d0bc9a4c5c0ed4bbf74
2015-11-17 09:22:53 -08:00
John L. Villalovos
2df670cf30 Remove unneeded 'utf-8' coding lines
This is basically a revert of commit:
  af741ec2236619880fa902d68aef4a6ae6cef534

It was decided that only files that need to have the line:
  # -*- coding: utf-8 -*-
Should have the line[1] as a general principle

This patch removes the 'utf-8' coding line from files that consist
entirely of ASCII characters.

[1]
http://eavesdrop.openstack.org/meetings/ironic/2015/ironic.2015-04-20-17.00.html

Partial-bug: #1325193
Change-Id: I88c1c37f7b580aa805eae9d4a1e66d33302a325f
2015-04-21 16:44:47 +00:00
Ghe Rivero
47236e2cf1 Bump hacking version
Current hacking version is incompatible with the one in the
global requirements. Match the hacking module version and made the
necessary changes to pass the tests.

Change-Id: Ie6b13a4ea112084d4c50dc27f97329dfad5777a1
2014-10-02 11:12:53 +00:00
Lucas Alvares Gomes
c3665d0916 Add pagination support to {node, port, chassis}-list
the presence of a 'next' field is the indicator to continue pagination
until there're no more values to be returned.

On the CLI two new options were added to commands used to list resources:

* --marker: Optional, the UUID of an item, eg the last item from a
  previous result set. Return the next result set.

* --limit: The maximum number of results to return per request, if:

  1) limit > 0, the maximum number of items to return.
  2) limit == 0, return the entire list of items.
  3) limit param is NOT specified (None), the number of items
  returned respect the maximum imposed by the Ironic API
  (see Ironic's api.max_limit option).

Closes-Bug: #1314992
Change-Id: I77cc7a7df65c3d2a84144b12a001487ff6832045
2014-07-15 11:04:02 +01:00
Martin Geisler
af741ec223 Add UTF-8 coding lines to all Python files
While not strictly necessary for files containing only ASCII
characters, adding a line with "coding: utf-8" can guard against
future SyntaxError's in case someone inserts a Unicode literal.

This commit adds such lines to all .py files. The syntax used by this
commit works with Python (of course). It also works with Emacs, which
will recognize the special "-*-" marker and use the "coding" variable
to correctly decode the file, even in an environment where UTF-8 is
not the default file encoding.

Existing coding lines were normalized to match the new lines added.

Partial-bug: #1325193
Change-Id: I58bf93fea711fd25890356a397e594bd820c99e3
2014-05-31 13:22:44 +02:00
Andrey Kurilin
64c9492855 Reuse Resource from oslo
In the process of unification of the clients code we should
reuse common functionality from Oslo.

Related to blueprint common-client-library-2

Change-Id: Ide0bb6bcef845d5cf746d71eaed38d425403e17a
2014-01-17 10:10:42 +00:00
Lucas Alvares Gomes
ab3a115024 Remove Python 2.4 all() implementation
Python 2.4 is not supported neither is being tested so I think it makes
sense to remove it.

Change-Id: Ie3d736f9756529c6f33d0c249bf18afabad9a041
2013-11-12 16:24:03 +00:00
Ghe Rivero
1b1dd31067 Reorder imports
As per hacking and PEP8, grouping third party libraries in
their own group.

http://www.python.org/dev/peps/pep-0008/#imports

Change-Id: I7a574d311b5171def0c6930162a46ce4c215097d
2013-11-11 18:12:58 +01:00
Lucas Alvares Gomes
ce93dd5ce1 Add node-set-power-state to cli
Add the node-set-power-state command to allow changing the power state
of a node using the cli.

Change-Id: I176bfe54db84e1c5677f7955b9cf247f0d09be4e
2013-11-01 17:42:50 +00:00
Kui Shi
8fa5e71b47 Use six.iteritems() for dict
In Python 3, dict.iteritems() is not supported anymore.

Partial implement: blueprint py33-support

Change-Id: Iec357ce5c5a6d2ffe4085bf26569a926e92e735a
2013-10-17 17:21:10 +08:00
Lucas Alvares Gomes
cc66495430 Implement *-update commands to resrouces
Added node-update, chassis-update and port-update commands for v1.

Change-Id: I051841fce2872f1e19f95117e8827d7a2b1b521c
2013-09-30 16:59:14 +01:00
Devananda van der Veen
2dda596558 Manager._list should always return a list
Convert single-row result sets to dicts for consistent
handling of single-element lists.

Change-Id: I2fc88743f8cee0112211cd837bbfcb7d95753d3d
2013-09-19 11:48:39 -07:00
Lucas Alvares Gomes
ba073c0707 Basic project structure
Mostly taken from other OpenStack client projects and adapted for Ironic.

Change-Id: I1ef9613b9e24bbb6caac9657dc1da3add899478e
2013-09-19 00:21:14 +01:00