'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
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
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
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
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>
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
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
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
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
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
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
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
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
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
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
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
Remove service_name argument from the is_service_enabled function.
The argument is unused and complicates the function's logic.
Change-Id: I1ac8a037bd7908ef1101d5fec359a8fe0e16e24a
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
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/152243https://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
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>
* 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
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
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
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
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
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
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
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>
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
Also ensure that the correct quota is displayed in the Floating IPs
allocation page (Security & Access panel).
Closes-Bug: #1109140
Change-Id: I30d207fbf149bfbcfefeaddf91af49082b7b1f53
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
This patch replaces some method imports with module imports and
makes H302 test enabled.
Fixes bug 1188531
Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
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
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
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
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
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
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