57 Commits

Author SHA1 Message Date
Akihiro Motoki
cd7c1b5110 Address RemovedInDjango40Warning (2)
django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
ungettext(), and ungettext_lazy() are deprecated in favor of the
functions that they’re aliases for: django.utils.translation.gettext(),
gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3

Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250
2022-02-04 16:22:07 +09:00
Tobias Urdin
c87f0e7a90 Change with_data=False for swift_get_container
This function is only used in the Container get
method which retrieves details about a container.

It's not used for listing data in the container
even though with_data was True doing a GET instead
of a HEAD on the container.

This indirectly also fixes the Ceph bug [1] in the
Swift API implementation that doesn't expose metadata
correctly for a GET but does for a HEAD.

[1] https://tracker.ceph.com/issues/47861

Change-Id: Iba4215b2e3a414d1794faa05be31bf69e0e48bec
2021-04-07 16:26:37 +02:00
Akihiro Motoki
e5d09edc20 Use python3-style super()
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.

pylint provides a check for this.
Let's enable 'super-with-arguments' check.

NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.

Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
2020-10-15 14:37:20 +09:00
Akihiro Motoki
692778f8cf pylint: Address no-else-return warning
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.

Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
2020-09-27 12:44:16 +09:00
Simon Merrick
2735f2c08d Add support for multiple swift storage policies
+ Adds endpoint for listing available policies
+ Support to select a storage policy for new containers
+ Display container storage polcy on dashboard.

Change-Id: I588452fd5d6417859f5dd19ccedcb18f420ab646
2020-04-16 22:18:06 +12: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
Ivan Kolodyazhny
f33e5fd8ac Drop deprecated Keystone V2 API support
Keystone V2 API was deprecated in Stein release in Horizon and
removed from Keystone in Queens release.

Change-Id: I917e273d3174adf0874e516b3d635ccb8ba58a27
2019-09-12 17:15:07 +00: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
Akihiro Motoki
6e1348d05f pylint: fix several warnings
openstack_dashboard/theme_settings.py:63:8: W1201: Specify string format arguments as logging function parameters (logging-not-lazy)
openstack_dashboard/settings.py:412:24: W0122: Use of exec (exec-used)
openstack_dashboard/dashboards/identity/domains/workflows.py:476:44: W0640: Cell variable group_id defined in loop (cell-var-from-loop)
openstack_dashboard/dashboards/identity/projects/workflows.py:906:49: W0640: Cell variable group_id defined in loop (cell-var-from-loop)
openstack_dashboard/dashboards/admin/networks/views.py:42:0: W0404: Reimport 'views' (imported line 28) (reimported)
openstack_dashboard/api/swift.py:204:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
openstack_dashboard/api/swift.py:214:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
openstack_dashboard/api/cinder.py:248:30: W0631: Using possibly undefined loop variable 'cinder_url' (undefined-loop-variable)
openstack_auth/backend.py:123:28: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/backend.py:129:39: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/backend.py:131:39: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/views.py:39:0: W0611: Unused Login imported from openstack_auth.forms (unused-import)
horizon/exceptions.py:348:8: W0125: Using a conditional statement with a constant value (using-constant-test)
horizon/tables/base.py:353:12: W0715: Exception arguments suggest string formatting might be intended (raising-format-tuple)

Change-Id: Icf4f22abda77c9dbf98c780de876b7836c31d669
2019-01-15 00:22:27 +09:00
BubaVV
4d6a1b327a Hide Swift network info in Horizon error message
In case of error Swift API return some details about unsuccessful
request, i.e. internal IP, full object pass, etc. This response is not
processed by Horizon and presented to user as-is, which is potentially
insecure. Proposed patch adds error processing striping network location
from error message

Change-Id: Ieef9669a1be3ed7bbc685a457eb1fe86b34c3c7e
Closes-bug: #1794767
2018-09-28 11:56:02 +00:00
Keiichi Hikita
60a78e1958 Add swift object copy function
Current Horizon does not have object copy page for swift.
This blueprint is for adding above one as Angular application.
- One row action is added as "Copy" menu
- User can copy which bytes > 0
  Because bytes = 0 means, true 0 byte object or separated file.
  Copying of separated object is not allowed in Swift API.

Change-Id: I60d731f79e5c9ab55fd2a73b7687b47723fe901f
Implements: blueprint swift-object-copy-function
2018-03-14 08:12:11 +09:00
Akihiro Motoki
e6b78f92f2 Use flake8-import-order plugin
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
This flake8 plugin is already used in tempest.
It enforces loose checking so it sounds good to use.

Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.

Change-Id: I8ccd05eb70350a2441cc2a4d1eafc09ee690b83b
2017-07-03 08:02:23 +00:00
Luis Daniel Castellanos
277d15abff Added Server-side filtering for swift UI
Added server-side filtering for containers in swift UI using the
magic search directive.

Change-Id: Id0eaa818fab8b2c7d7a0ab40c1a943c2e7342f10
Partial-Implements: blueprint server-side-filtering
2017-02-06 15:28:58 -06:00
Paul Karikh
97945b5f6a Wrap api calls with tracing decorators
Since Horizon is going to be the first (or, one of the first)
OpenStack component using the new MongoDB driver, it won't be able to
retrieve traces made by other components using MongoDB driver (which
it should use because Ceilometer driver was too slow) for a
while. This means that Horizon itself is responsible for tracing the
rendering of its pages down to the layer where the flow of control
leaves Horizon domain. So, a lot of api wrappers in
openstack_dashboard.api are augmented with tracing decorator to
achieve this goal.

Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Implements-blueprint: openstack-profiler-at-developer-dashboard
Change-Id: Ib36692f0e9e68ed7fa0cd47919ba6581c9c8ab57
2016-12-01 19:31:10 +00:00
Eddie Ramirez
9963867cd9 Enable sorting by size in containers pane
The containers module was using an incorrect ID in the "Size" column,
preventing the user from sorting by "Size". This change updates the
ID s/size/bytes/ which is the resource property holding the actual object size
in Bytes.

This change also updates the default "subdir" size to 0, that is the
default value returned in the "Content-Length" header for "subdirectories"

Change-Id: I98d164ec1a08d15f25fcdbc92f45e46c9fa6e5c4
Closes-bug: 1643710
2016-11-30 17:49:10 +00:00
Richard Jones
053d0a669e Implement file update (edit) in Swift UI
The ability to update (edit contents of) an object was
never present in the previous Swift UI. It was
explicitly blocked due to code in the swift_upload_object()
function, which has been removed in this patch. To
replace that "upload would replace existing contents"
check, this patch implements a client-side check to warn
the user if the upload would do so.

Partially-Implements: blueprint swift-ui-functionality
Change-Id: I9fb57dda59322907f0661372f9ee223551ff8a6e
2016-08-22 14:47:23 +10:00
Richard Jones
2481d2b1ac Remove memoize that holds connections open
This memoize usage holds on to connection objects for a very long
time, resulting in exhaustion of file descriptors.

Change-Id: If7367819b050a65562b3e05175ab15bd93d0d398
Fixes-Bug: 1584109
2016-05-27 05:55:34 +00:00
Richard Jones
75d30cba48 Don't attempt to list the "folder" contents of Swift objects
Swift doesn't really have folders, it just has object listings
matching string prefixes. This will get confused if two objects
have the same string prefix name, so just don't do it.

Change-Id: Iab818cc965aab1470aa41ebebd5db7c50ed3836d
Fixes-Bug: 1583391
2016-05-19 11:29:20 +10:00
Timur Sufiev
80e52c1ae5 Fix new Swift UI to work with Ceph backend
First, tolerate missing '/info' API endpoint, which Ceph doesn't
support yet. Second, `content_type` attribute on objects may be not
set, don't rely heavily on it.

Change-Id: I101338aa9c96a6551bfbf2dd9c460a4801b4e7b6
Closes-Bug: #1564834
2016-04-04 18:24:18 +03:00
Richard Jones
672b6ae003 Add Swift REST API
Adding the REST API needed to support the new angular Swift UI.

Co-Author: Neill Cox <neill@ingenious.com.au>
Change-Id: Ife1073cf6aa481bdbd89f09805ac76fe7106d5df
Partially-Implements: blueprint angularize-swift
2016-02-25 12:12:14 -08:00
Javeme
de9449aab1 replace deprecated iso8601_from_timestamp
use datetime.utcfromtimestamp() and datetime.isoformat() instead of
the deprecated oslo.timeutils.iso8601_from_timestamp().

ref:
https://github.com/openstack/oslo.utils/blob/master/oslo_utils/timeutils.py#L192

Change-Id: Ife656079e332789235829ab138e8df057d91172f
2015-12-17 16:56:42 +08: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
Ryan Peters
5693109901 Fixed getting success msg on failing swift operation
Show error message instead of success message when attempting to
create a duplicate object or pseudo-folder. Added tests for
creating and creating duplicate pseudo-folders.

Change-Id: I875d471921d9a37bb6706a17d4fbca5e9428ae93
Closes-Bug: #1478126
2015-07-24 19:27:24 +00:00
Paul Karikh
8201d65cf9 Add missing content-length header
This patch adds missing content-length header
param into swift_upload_object() method.
Without it object upload handling could be failed
with "411 Length Required" error if Ceph is used
as an object storage.

Change-Id: Id0813806abb36a6f015efd13ec987492a3701476
Closes-Bug: #1352256
2015-06-18 09:41:22 +00:00
George Peristerakis
a545a4b63e Removed the '_safe_message' variable from the API exceptions
The variable _safe_message is linked to logic that is either no
longer used or not implemented. Removing the variable is a part
of improving the exception message by using 1 source to generate
the exception message

Partially Implements: blueprint improve-error-message-details-for-usability

Change-Id: Ied1acf22790cdedad685990fc628462d51b1477e
2015-05-06 15:33:10 +00:00
Timur Sufiev
46405d456d Fix web-server memory overrun when downloading objects from Swift
To prevent memory overrun when downloading large objects from Swift
* `resp_chunk_size` keyword should be passed to swiftclient
* `obj.data` iterator returned from swiftclient is passed to HttpResponse
  (or StreamingHttpResponse for Django>=1.5) as usual since both response
  classes work with iterators/files/byte strings (yet StreamingHttpResponse
  does it better).

The commit introduces new setting SWIFT_FILE_TRANSFER_CHUNK_SIZE that
defines the size of chunk in bytes for Swift objects downloading.

DocImpact

Change-Id: I18e5809b86bfa24948dc642da2a55dffaa1a4ce1
Closes-Bug: #1427819
2015-03-31 14:30:23 -07:00
lin-hua-cheng
0e95eb0441 Switch from oslo.utils to oslo_utils
oslo_utils moved out of the oslo namespace.

Partially Implements: blueprint drop-namespace-packages

Change-Id: I3c38426142de535b5474676b1214ea72b231ce76
2015-01-18 14:23:32 -08:00
Jenkins
8f2903ed2c Merge "wrong message while deleting non empty pseudo folder" 2014-12-09 09:37:28 +00:00
Masco Kaliyamoorthy
1565819d59 wrong message while deleting non empty pseudo folder
while try to delete a pseudo folder which contains some objects is
showing the success message but the folder is not actually deleted

added a check similar to delete container, the new check will
verify the pseudo folder is empty before call the swift client
call. if the folder is not empty it will throw a exception
with a appropriate error message and the message will be shown to
the user in the pop up message box.

Change-Id: I0bbea6ef6ac26ef357240610535b9d84053a89c2
Closes-Bug: #1347598
2014-10-30 15:18:04 +05:30
Akihiro Motoki
47f1d49690 Do not log keystone token
Previously token values are logged as DEBUG level when a new client
object is instantiated. In other project and clients, token values
are now not logged and is output as *REDACTED* instead.
In Horizon these log lines do not have much meaning and
we can simply remove them.

Change-Id: I67617ac6424907574d79ec2a57b513a548e220d2
Closes-Bug: #1380642
2014-10-17 16:10:41 +09:00
Jenkins
79df5b42ed Merge "Fix an encoding exception when creating a public_url" 2014-10-16 07:22:14 +00:00
Akihiro Motoki
26da6ed48c Fix E127 errors in remaining openstack_dashboard/
E127 continuation line over-indented for visual indent

Also fixes E127 introduces by other reviews
after other E127 fixes were merged.

Closes-Bug: #1375931
Change-Id: I0a09f1c2f74c707fc8a347f0ea5975bf2679976e
2014-10-15 13:50:07 +09:00
lin-hua-cheng
258ea5a172 Use timeutils from oslo.utils
Rather than sync'ing with oslo-incubator, let's use the library
oslo.utils instead. Removing the local copy of timeutils.

Change-Id: I4fbc7e7637577fcad8281897f4286690b1bbd14d
Partially-Implements: blueprint improve-oslo-usage
2014-10-13 12:08:00 -07:00
George Peristerakis
2e4ae8f05d Fix an encoding exception when creating a public_url
When using urlparse.quote, the string needs to be utf8 encoded,
or an exception is thrown.

Change-Id: I1e3d4abc136fbbbd03a54789f3df0855ceea98e1
Closes-Bug: 1346386
Co-Authored-By: Cédric Soulas <cedric.soulas@cloudwatt.com>
2014-10-08 15:00:52 -04:00
Akihiro Motoki
69e0d812f2 Reuse API client object in a request
Previously API client object like novaclient are created
every time methods in openstack_dashboard/api.
It leads to regeneration of API HTTP connections.
This commit caches API client object for a WSGI request
to reduce the number of HTTP connection to backends.
As WSGI request object is recreated, a cached API client
object will live in a single request to Horizon.

Change-Id: I66620b3b0a2737c7232d91006e65d0fabbd3090b
Closes-Bug: #1352144
2014-09-17 14:19:10 +09:00
Chuck Short
456c69e0b3 swift: Respect the OPENSTACK_SSL_NO_VERIFY setting
The swift API client connection does not respect the
OPENSTACK_SSL_NO_VERIFY setting in the local_settings.py.

As a result a SSL verfication error happens with a
self-signed certificate.

Closes-Bug: #1311357.

Change-Id: I907a8f7c5c631adfaf2ca66385749bb8e86734f2
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2014-09-16 10:38:21 +01: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
Fengqian Gao
b7d5a6e749 Keep py3.X compatibility for urllib
Use six.moves.urllib.parse instead of urllib

Partial-Bug: #1280105

Change-Id: Ie10e9fd8ff42b65b1610839eaeee09e3c56f2de7
2014-02-24 13:46:29 +08:00
Cristian A Sanchez
ccc0f7290f Allows the user to create an object without file
Now the user can create an Object without providing an actual file
in the containers view. This will submit an object with 0 bytes size.
Additionally, the 'Download' button will not be available for objects
with 0 bytes size.

Implements: blueprint metadata-only-object
Change-Id: Ib2ff2462b73d16c971ad0dfc60aaae1b0bbf0924
2013-12-14 11:05:18 -08: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
Jenkins
cdb06a48de Merge "Show success msg when container deletion succeeds" 2013-12-03 03:51:45 +00:00
Lin Hua Cheng
22ab3e0f87 Add ability to configure read access of container
Allow the user to set the container access to private or public.

For public containers, the public URL for accessing it is also provided
to the user.

List containers does not include the metadata of the container. Used ajax
to load the container metadata in the Container table to be able to render
the Container table immediately.

Change-Id: If1e848ad49f522eab8f1b264d54611615481848c
Implements: blueprint swift-container-public-access
2013-12-02 02:00:07 -08:00
Lin Hua Cheng
52957cc7d9 Show success msg when container deletion succeeds
When user tries to delete non-empty container, the success messsage
should not be displayed.

Change-Id: I02ba1e4bad8dbe2b52f06f2a8e079b5812cd5544
Closes-bug: 1214842
2013-11-27 20:32:59 -08:00
Jenkins
2d06e1b23f Merge "Adds pseudo-folder creation" 2013-11-26 20:30:04 +00: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
Laura Athanasiou
56ae1e84e4 Adds pseudo-folder creation
Users can create pseudo-folders independent of object upload

Implements: blueprint swift-pseudo-directory
Change-Id: I5797ae9aab83135643680a410b2394165dc55271
2013-10-16 13:15:16 -06:00
Jenkins
510eb5a5fc Merge "Use HEAD when retrieving Container details" 2013-10-14 19:09:28 +00:00
Lin Hua Cheng
22e8f839d1 Use HEAD when retrieving Container details
Change-Id: I0bb41bbf2ec8b0a515aa8a9ee9eba63761a60122
Closes-bug: 1236677
2013-10-08 14:08:38 -07:00
Lin Hua Cheng
2b36515e14 Use HEAD when viewing Object details
GET operation downloads the whole object, replaced the call
with HEAD which already contains the object metadata.

Change-Id: I87e1145d9571013db3dd87c3386d0dd66da3f012
Closes-bug: 1236681
2013-10-08 12:05:14 -07:00
Jasper Capel
12ab09a994 Custom CA certificate for verifying SSL connections
The various OpenStack client libaries support specifying a SSL
certificate that should be used to verify the SSL-connection, but
this option was not exposed in the horizon options. This patch
implements that. Note that although some clients do implement a
cacert-parameter, they do not necessarily actually verify the
certificate (Swift).

Change-Id: I9dfbd48a0d96103421da7d884e839d591a90cab1
Implements: blueprint ssl-cacert
2013-09-03 11:24:41 +02:00