Commit Graph

54 Commits

Author SHA1 Message Date
Akihiro Motoki 74df97f57c pylint: Fix unnecessary-comprehension warning
'unnecessary-comprehension' warning is emitted when
unnecessary use of a comprehension is found.

classes attribute in Action can be a tuple,
so we need list() to ensure it is a list before adding 'disabled'.
I think it is time to introduce a method in Action class or somewhere
but it should be handled separately.

Change-Id: I16a98d56b6d0bd0af234b00735c6ed576620df7e
2020-09-27 12:44:16 +09:00
Ivan Kolodyazhny ee6fa9a245 Remove Keystone v2 related code
Kyestone V2 support was removed in Train, so it's safe to do such cleanup.

* Functions which just return horizon settings are dropped and
  the settings are referred directly now.
* The service catalog in the sample test data is updated to match
  the format of the keystone API v3.
* Related to the above change of the sample service catalog,
  openstack_dashboard.test.unit.api.test_keystone.ServiceAPITests is
  updated to specify the region name explicitly because 'RegionTwo'
  endpoint is no longer the second entry of the endpoint list in the
  keystone API v3.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: Ib60f360c96341fa5c618595f4a9bfdfe7ec5ae83
2020-04-23 11:43:12 +09:00
Akihiro Motoki ac3d139c06 Cleanup python 2.7 handling logic
We have several codes to handle the differences between py2 and py3.
py2 support has been dropped so there is no need for them now.

Change-Id: I30080f4e1a5ac04860c4341d966ee53131eb2022
2020-02-21 09:02:37 +09:00
Ivan Kolodyazhny d870b40583 Remove six usage from openstack_dashboard package
We don't support Python 2 anymore so we don't need this
compatibility library.

six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.

This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.

Change-Id: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Stephen Finucane 4ece14b28a Handle move of ABCs to collections.abc
Resolves the following warning:

  DeprecationWarning: Using or importing the ABCs from 'collections'
  instead of from 'collections.abc' is deprecated, and in 3.8 it will
  stop working

Change-Id: Ib2214e7560cda1ef510c08859d5ee0726eb66b7b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-09-10 19:21:20 +09:00
Akihiro Motoki 5fd5b4c893 Fix version handling compatible with python-semanticversion 2.8
It seems the behavior of 'partial' argument of Version class __init__
has been changed between semantic-version 2.6.0 and 2.8.1
(though I could not identify the root cause).
'partial' argument is marked as deprecated in semantic-vesion 2.7.0,
so it is a good chance not to depend on 'partial' argument in horizon.

This commit uses Version.coerce() [1] instead to convert non-semver
version into a valid semver version.
We also need to keep the original version information as it is passed
when initializing python-*client (cinderclient and keystoneclient).

In addition, the previous implementation based on semantic-version 2.6.0
returns True for "Version("3.55") == 3". It depends on the behavior
of "partial" argument of semantic_version.Version. It was not
documented and it looks tricky to depend on this behavior.
"major" and "minor" properties are now introduced and api/cinder.py
is updated accordingly. I believe this approach is clearer and stable.

Unit test coverage on dict behavior is improved.
Variable names in the unit tests are adjusted to more meaningful ones.

[1] https://python-semanticversion.readthedocs.io/en/latest/#coercing-an-arbitrary-version-string

Change-Id: If0deee9d0289ff91d58d942b9612f7736356ae18
2019-09-09 15:54:26 +09:00
Akihiro Motoki 9c19b07a26 Define default settings explicitly (openstack_dashboard 1/5)
Currently horizon defines default values of settings in the logic
using getattr(settings, <setting name>, <default value>) and
it is not easy to handle the default values of available settings.

This commit starts the effort to define default settings explicitly.
This is a preparation for ini-based-configurations.

It covers settings in openstack_dashboard/api.

Part of blueprint ini-based-configuration
Change-Id: Id4c3287f0a572fd14ea93b54bcab8fabda39e583
2019-04-24 02:32:47 +09:00
Zuul c9536342c2 Merge "pylint: fix len-as-condition warning" 2019-01-16 14:25:39 +00:00
Akihiro Motoki f6e1338cde pylint: fix unnecessary-pass warning
Change-Id: Ie2e5c6482a19553f6c73c50555d65834bb62ca9e
2019-01-16 13:10:16 +09:00
Akihiro Motoki c076db20c8 pylint: fix len-as-condition warning
Change-Id: Ib89c1854ad42b96e4caf281160d568fe98430afe
2019-01-16 12:56:20 +09:00
Akihiro Motoki 32d463a298 Generic volume group support
This commit adds cinder generic group support.
Consistency group support are not shown if the generic group
support is available.

blueprint cinder-generic-volume-groups
Change-Id: I038eeaf2508926f18b6053db0082a8aa3f3e20c6
2018-06-09 06:39:18 +00:00
Akihiro Motoki 986e90248b Exclude nova-network quotas properly
openstack_dashboard.api.nova.QuotaSet was introduced to exclude
nova-network properly, but it did not work because QuotaSet does
not support 'in' and 'del' operations.
This commit fixes the logic and add a unit test.

Closes-Bug: #1743589
Change-Id: I8c3bfe985cccdf53fd555bf185c293806c14b6f6
2018-04-12 00:09:17 +09:00
Akihiro Motoki 64d5ba8515 Improve mocking in REST API tests (test_cinder)
The current REST API tests have a lot of rooms to be improved like:
- mocking the whole module of the API wrapper
- Use test_data.cinder_data
- Use response.json attribute to decode responses as much as possible

APIResourceWrapper.to_dict() method of openstack_dashboard.api.base
is changed to refer attributes of an object itself instead of
self._apiresource. There is a case where APIResourceWrapper class
defines its own attributes and such attributes should be used in
to_dict() method. If self._apiresouce is referred these attributes
are not considered. We need to consume attributes of a class object
itself. It helps us write unit tests using sample test data.

Change-Id: I5b0c3bb52d97f377c6e5fe2b9a4ace2931114ab0
Partial-Bug: #1752917
2018-03-13 12:27:01 +09:00
Akihiro Motoki af3b7e4134 flake8-import-order: Ensure to place project imports last
To ensure project imports are placed after third party import,
we need to specify application-import-names.
Previously flake8-import-check checks only standard imports or not.

Change-Id: I9beb2105f686dc7d9aebfce8e21c5e182698e2fe
2017-09-20 01:19:38 +00:00
Akihiro Motoki b9d0243c33 Fix H405 (multi line docstring) warnings (openstack_dashboard)
H405: multi line docstring summary not separated with an empty line

Closes-Bug: #1696996

Change-Id: Id895695663b19522d9cdc22f8b012e49680d708b
2017-06-09 16:05:31 +00:00
Akihiro Motoki baa4ca8dce hacking: noqa cleanup in openstack_dashboard
attribute-level imports are not checked by hacking module now.
most noqa is used to disable warnings on attribute-level imports.
This commit drops noqa for this purpose.

After this, there are only 3 noqa under openstack_dashboard/ :)

Change-Id: I4a449802f5dbd6e44e4b8b5c378a555d47d9a99f
2017-03-17 19:38:47 +00:00
Radomir Dopieralski 7be8078910 Consistently hash Version objects
The semantic_version.Version objects don't properly support hashing,
so we need to handle that in our wrapper, so that the "in" operator
can work properly with sets and dicts.

Closes-Bug: #1649819
Change-Id: I85e2b2214546817ef4da136b7d4267985ced94dc
2017-03-09 19:32:21 +01:00
Jenkins 834722cf8a Merge "Properly compare versions in APIVersionManager" 2017-03-02 20:53:15 +00:00
liaozd 60db0269e0 wrong indentations
Change-Id: I967fbe1e1e92851f1ca330cf43b00fc1d65e5b36
Closes-Bug: 1657450
2017-01-30 16:51:48 +00:00
Radomir Dopieralski 8377fb9e18 Properly compare versions in APIVersionManager
Since the APIVersionManager stored the version numbers as ints and
floats, it was not possible to distinguish between version 1.2 and 1.20,
and also version 1.2 would be considered higher than version 1.13. With
the introduction of microversioning in some services, the version
numbers inflate quickly, making this a problem.

This patch wraps the version numbers in a Version object, that stores
the information as a semantic_version and correctly compares with other
Version objects, as well as ints, floats and strings.

It also removes the check for version being specified as a string, so
that it's possible to specify versions such as 1.20 without having to
explicitly create Version objects.

Change-Id: I0b0d87582d617290f08359ad181216cb99edb768
Closes-Bug: #1649819
2017-01-27 13:43:47 +00:00
Akihiro Motoki 11d973fbe3 Fix network duplication check logic
Previously api.neutron.Network object was compared by using _apidict
but it did not work when for example the order of subnet list is different.
This commit changes the comparison logic to use network ID explicitly.
In addition, it moves the logic to fetch external networks to api.neutron.

Change-Id: Ie3a42e29c32c17a7f3bf1596b0e09cb73eae9d2a
Closes-Bug: #1528465
2016-02-12 16:58:00 +00:00
zhu.rong 4636bf18d7 Delete the unused LOG configure code
Delete the unused LOG configure code and import code

Change-Id: I5e42a3b25aae89e62e20e8061b39c7be700aba33
2015-12-09 02:04:29 -05:00
Yves-Gwenael Bourhis 803209e237 Show external networks
Only shared networks were considered as external.
The Neutron policy since Icehouse is router:external=True and shared=False so
external networks were not seen anymore
We need to be able to see the external network to obtain its ID (e.g. for
heat templates in the orchestration panel).

We now display external networks and added an "external" field in the networks
view

Change-Id: Ice1f4e2c11825b8d86a8a126350e71a88741acb7
Closes-Bug: #1472281
2015-09-30 14:29:36 +00:00
IWAMOTO Toshihiro 232d5ac8fe Simplify is_service_enabled
Remove service_name argument from the is_service_enabled function.
The argument is unused and complicates the function's logic.

Change-Id: I1ac8a037bd7908ef1101d5fec359a8fe0e16e24a
2015-09-14 11:46:20 +09:00
Jenkins c8f4f5360f Merge "Updated parsing of catalog to handle bad format" 2015-03-31 02:05:33 +00:00
lin-hua-cheng 8d3c2baa5b Updated parsing of catalog to handle bad format
Don't assume that the service catalog is well-formed, added code
to safely parsing the catalog.

Parsing of region from service catalog has been fixed as well.
'region' has been deprecated in the Keystone V3 catalog in favor of
'region_id'. Fix how region is extracted by checking 'region_id' then
fallback to 'region'.

Change-Id: I9e027586847b7b7c0276e8c3ff6b73f06a32e2a5
Closes-Bug: #1424825
2015-03-09 12:47:30 -07:00
Mike Hagedorn 255340c596 REST API to support create instance angular (Neutron).
In this update:
- fixed tests
- fixed exception handling, params on ports
- fixed to_dict for a number of cases
- replaced use of request.DATA with request.GET for GET methods
- added handling of HTTP error raised with no status/code attr
- removed check for network_id in subnets as it's not required
- fix to_dict for Network with Subnets

Supercedes
https://review.openstack.org/#/c/152243
https://review.openstack.org/#/c/151313

Partially Implements: blueprint launch-instance-redesign
Co-Authored-By: Aaron Sahlin <asahlin@us.ibm.com>
Co-Authored-By: Michael Hagedorn <mike.hagedorn@hp.com>
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>

Change-Id: Ia40fde6d66720a03a531b516a6a53a2e86ec0d8f
2015-03-04 07:20:43 -05:00
Travis Tripp b915760a56 Nova Flavor Server Extensions Rest APIs - Angular
This provide flavor APIs for launch instance work.
This provides extension APIs for launch instance work.
This provides single server get for instance details work.
This provide single flavor get for instance details work.

Partially Implements: blueprint launch-instance-redesign
Partially Implements: blueprint instance-details-redesign

Change-Id: Ia1fd36ec31de21c60801f4d47716ef69aad7525f
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
2015-02-26 16:05:54 +11:00
keshy aed603d618 Fix typo errors in comments for api modules
Co-Authored-By: Lin Hua Cheng <os.lcheng@gmail.com>

Change-Id: I55327c2e7d44d01c8bc832c1a5228a6b3dc3184f
Closes-Bug: #1268253
2015-02-25 10:50:27 -08:00
Gabriel Hurley 59ad632a68 Quality of life improvements to APIVersionManager
* Verifies that the API version values provided are of the right type
  (currently all version keys are ints or floats, not strings).

* Provides a list of the version keys which would be acceptable if an
  invalid version is provided.

* Raises a useful and explanatory exception if these values are
  incorrect.

* Adds the "preferred" API version to the "supported" versions as
  a convenience during init.

Change-Id: I0bc75b145bba757ff6cd405e1a654aeef296f2df
Closes-Bug: 1411427
2015-01-30 21:53:55 -08:00
liyingjun 7985cfce77 Handle situation when endpoint deleted
when the cinder services exist but endpoint deleted, accessing
to /project/access_and_security will cause an error:
IndexError: list index out of range

Change-Id: Iad7f72cd5247f33245f25a8092c40a4d3a04cef9
Partial-Bug: #1394900
2014-12-01 22:05:00 +08:00
eric 88371c6660 horizon ignores region for identity service
this change will attempt to use a identity service in the selected region
when available.  before the region for the identity service was always the first
found

Change-Id: Idc64a32128bcee561cdbba956722adad0ee1eaf2
Closes-Bug: #1339382
2014-09-17 15:41:54 -06:00
woodm1979 e3bf9c4061 APIDictWrapper getitem lookups fail for non str
The APIDictWrapper class within openstack-dashboards/api/base.py can't
handle the "in" operator correctly.

Also, it will fail if a non-string is passed into it's __getitem__
method. (Which is what is called from a dict lookup.)

The get method also fails on non-strings.

Change-Id: Iaad66d3c6deb81d0570b1a8c6ddf580024fa46e6
Closes-Bug: 1326512
2014-06-04 14:10:29 -06:00
Alex Gaynor c1b4269443 Fixed several typos in comments
Change-Id: I230414c703cf47d7ec727362c20f1814324a2447
2014-05-24 14:42:14 -05:00
He Yongli e790ac070e Remove extraneous vim configuration comments
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4

at the top of source code files, except for files in
openstack/common.

Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
2014-05-06 15:30:10 +08:00
Radomir Dopieralski 20b414db2f Don't lose AttributeError in API Wrappers
Instead of (implicitly) catching the AttributeError, and later
creating and raising a new one, we just re-raise the original
exception. This way all the information from the original is
retained, including the name of the actual object on which it
happened.

Change-Id: Idc0c5a8ed5dfca6a8724e393c220baf9960564ed
Closes-bug: #1274097
2014-02-18 09:30:30 +01:00
Radomir Dopieralski 028332da4a Remove #noqa from most common imports and add them to import_exceptions
We have a lot of import with #noqa that is there to ignore h302,
because it's traditional to import and use a name directly, instead
of a whole module. This hides other errors and gives people the
impression that it's actually fine to import non-modules, you just
have to slap #noqa on those lines.

I went through the code and identified about a dozen names that are
most commonly imported this way. I remove the #noqa tag from them,
and added them to the list in import_exceptions.

I also removed a few unused imports that were revealed in the process.

Change-Id: I27afb8e2b1d4759ec974ded9464d8f010312ee78
2014-01-07 12:26:35 +01:00
Paul Belanger da8c69afa6 Gate on H4xx docstrings for pep8
In an effort to help horizon more friendly to OpenStack hacking
guidelines, we now gate on H40* violations.

Change-Id: Id07294543660368d2f7f5ac363710176ab23b874
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
2013-11-23 12:51:07 -05:00
Rob Raymond 2cdd0bb20e Allow region override for url_for
If region is passed in to url_for use that, otherwise continue
to use the region from the user's session.

Fixes bug #1231171

Change-Id: Ia7d2a4f12a3c0d4d45bb918255184d1736f5bddf
2013-09-25 16:42:12 -06:00
Julie Pichon 3852d1ce19 View and update Neutron project quotas
Also ensure that the correct quota is displayed in the Floating IPs
allocation page (Security & Access panel).

Closes-Bug: #1109140

Change-Id: I30d207fbf149bfbcfefeaddf91af49082b7b1f53
2013-08-27 19:13:10 +01:00
Julie Pichon fde88906b3 Show Neutron floating IPs quotas on Overview
Display the correct limits and usage when Neutron is in use and the
quotas extension is enabled. If Neutron is enabled but the quotas
extensions is not supported, assume the floating IPs quota is
unlimited (a floating IP quota is expected to exist in other places,
e.g. Security and Access panel)

Because quotas may not be configured or enabled even if the extension
is available, add an 'enable_quotas' setting.

Partial-Bug: #1109140

Change-Id: Id6345f4700f0ff45be8ce8acb69cca0d4e05e14a
2013-08-26 16:39:27 +01:00
Tatiana Mazur 953d1b9793 Enable H302 check
This patch replaces some method imports with module imports and
makes H302 test enabled.

Fixes bug 1188531

Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
2013-08-22 17:39:09 +04:00
Akihiro MOTOKI a06e263b60 Ignore non-existing attr in APIResourceWrapper __repr__
Fixes bug 1202415

__repr__ was added to APIResourceWrapper in the recent commit,
but it searches all attributes in _attrs list. When an attribute
defined in _attrs actually does not exist, __repr__() fails.
This commit changes __repr__ to ignore non-existing attributes.

Change-Id: Iebaeae78f3763d87f3993ba5c4bbed4c23e84c45
2013-07-25 21:45:17 +09:00
Akihiro MOTOKI 695bf560c0 Neutron Security Group native support
blueprint quantum-security-group

Rule table view
* Add direction and ethertype columns (which are specific to Neutron)
  It may be better to hide "Direction" and "Ether Type" columns
  unless Quantum security group is enabled.
* Merge ip_protocol/from_port/to_port into one column for better view
* Use "::/0" for IPv6 ANY instead of "0.0.0.0/0"
* Rename "Source" column to "Remote".
  (The naming "source" does not fit egress rules)
* Display security group name in the title of rule detail view

Rule creation form
* New arguments 'direction' and 'ethertype' in security_group_rule_create()
* Set the default value of 'direction' to 'ingress' in forms.handle()
* Rename 'ip_protocol' to 'rule_menu' and 'source' to 'remote'
  Note that rule_menu is retrieved from rule.ip_protocol in the unit tests
  since they are tests for custom TCP/UDP/ICMP rules.

Network abstraction layer for security group management
* Move security group methods to api.network
* Add Neutron security group API implementation
* Move base classes for network abstraction to a separate module
  (api/network_base.py) to avoid circulated import between
  api.network and api.nova/api.neutron

Add a configuration parameter to control Neutron security group support
* Neutron security group support is enabled when Neutron is enabled and
  enable_security_group in OPENSTACK_NEUTRON_NETWORK in settings is True.
* Not all neutron plugins support security group, so we need a way
  to control neutron security group is enabled or not.
* It can be determined by supported extension list from Neutron
  and it is a possible future work.

Move get_int_or_uuid to openstack_dashboard/utils/filters.
* get_int_or_uuid is now used in security_group implementation as
  well as floating IP logics.
* In addition the depth of the directory tree becomes longer and
  it is hard to fit the import line in 80 chars.
  It is a good chance to move it to a common directory.

Add __repr__ to API**Wrapper to make it easier to debug.

Limitations:
Neutron supports per-port security group. security groups can be
associated with a port instead of an instace and each port can have
a different set of security groups. It is not a scope of this BP
and is a future work.

Change-Id: I5410e88043a364596037b9ebcc566cd50b317614
2013-07-12 21:03:40 +09:00
Jenkins d511d64edc Merge "Enable hacking H101 test" 2013-06-25 08:20:01 +00:00
Sergey Lukjanov d4ada3e555 Enable hacking H101 test
H101  Use TODO(NAME)

Change-Id: Ic30decbf72ac43845bf5b24fe4eead341bf1d2d5
2013-06-24 12:56:15 +04:00
David Lyle 917591428e Region selector enabling multi-region support.
This patch adds a region selector dropdown
at the top of both the Project and Admin dashboards if
more than one region is available in the user's service
catalog.  The user is allowed to choose from any region
available in the service catalog. By selecting a region,
the user is limited to accessing endpoints in that
region only as long as the go through api.base.url_for

If there are more than one endpoint for a service in a
region the first in the catalog is returned.  Further
work on the blueprint will handle that complexity.

Supporting Keystone v2.0 and v3 catalog formats.

Partially implements blueprint multiple-service-endpoints

Change-Id: I1ab6539c7c5f4b1ae4b1716059370e86b6ca4d2e
2013-06-20 14:01:10 -06:00
Dirk Mueller 315d30c337 Use Python 3.x compatible except construct
Python 3.x removed the "except x,y:" construct. Use
"except x as y:" instead which works with all
Python versions >= 2.6.

Change-Id: Iedb4c5a6d8580cbb6c9697933d006e94b1db916d
2013-06-14 23:19:28 +02:00
David Lyle 3f19461a80 Refactoring url_for to remove admin parameter
Removed unused admin parameter that was unused and removed tests
that were no longer necessary.

Added an option configuration setting SECONDARY_ENDPOINT_TYPE that
will be attempted if the OPENSTACK_ENDPOINT_TYPE does not exist
in the service catalog for the desired service.

The primary use case for this fix is in cloud configurations
where Keystone does not return all endpoint types for each
service, and only does so based on the user's privilege level.

Example use case would be set OPENSTACK_ENDPOINT_TYPE to 'adminURL'
and set SECONDARY_ENDPOINT_TYPE to 'publicURL'.  If adminURL is not
available to the user, then they get the publicURL back.

If SECONDARY_ENDPOINT_TYPE is not set in the settings, then the
current behavior is maintained.

Fixes: bug #1186379

Change-Id: Ieefb6ed5dd88e5c840ef6bad93ae87237a1b63f9
2013-06-04 17:23:50 -06:00
Lin Hua Cheng 3fd58f9f14 Make discovery of version for KS catalog smarter.
Instead of relying on the configuration file for determining how
the catalog should be parsed, make it flexible by inspecting the
structure of the service catalog passed to it.

Fixes bug 1180486

Change-Id: I0c8caf4c8365bf25377ab3a249ac280d8add0f17
2013-05-15 12:45:34 -07:00