56 Commits

Author SHA1 Message Date
jimmygc
4214fc2d75 Clean /tmp after upload when using glance v2 client
When using glance v2 client, it will leave an upload
tmp file in /tmp folder, which will cause upload error
if its filesystem (in memory) is full.

Change-Id: I0a7267db894e7be4216a346752d299132df9a29a
Closes-Bug: #1689694
2017-08-04 10:54:51 +08: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
Jenkins
4b32a7051a Merge "Image list function should normalize owner filter" 2017-05-05 14:50:16 +00:00
Mark Mielke
445117eb1f Image list function should normalize owner filter
The api.glance.image_list_detailed() function accepts a list of
filters which it then translates into a form that is acceptable for
Glance v1 or Glance v2. These translations included support for
mapping 'is_public' to 'visibility', but did not include support for
mapping 'property-owner_id' to 'owner'.

This changes adds support for mapping 'property-owner_id' to 'owner'
for Glance v2, and mapping 'owner' to 'property-owner_id' for Glance
v1.

Before this fix, "rebuild instance" from the instances page did not
properly list project-specific images as options.  After this fix,
"rebuild instance" is working as expected.

Change-Id: Ica750f8b36bdbadd02a81aed41fd250864a49a66
Closes-Bug: 1671693
2017-04-12 09:50:11 +00:00
Gábor Antal
34a3aa0ba8 Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
2017-03-31 20:59:16 +09: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
Paulo Matias
446e5aefb4 Always pass the public endpoint to the client
Even if Horizon is configured to use internal endpoints for requests
made by its server side to other OpenStack services, the client side
should not be restricted to run only in networks which have access to
the internal endpoints.

Change-Id: Ibdc663a133670e8f07530c0d7c5ed7df2d92b99b
Closes-Bug: #1639080
2017-03-02 14:57:16 -03: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
Akihiro Motoki
35d2becdd6 Fix docstring warnings
Partial-Bug: #1411719
Partial-Bug: #1486222

Change-Id: I2d649295e7425ab73f09f3a5d91076350bf7ed7a
2016-09-24 20:44:48 +09:00
Julie Pichon
cf0aac9400 Support for Glance v2
Implements wrappers necessary for Horizon to work with either Glance
v1 or v2 and removes the dependency on the Glance v1 endpoint.
Handles the differences between setting properties with v1 and v2 and
restricts some Glance functions that aren't supported in v2.

Implements blueprint: horizon-glance-v2
Co-Authored-By: Travis Tripp <travis.tripp@hp.com>
Co-Authored-By: Brad Pokorny <Brad_Pokorny@symantec.com>
Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Co-Authored-By: Liuqing Jing <jing.liuqing@99cloud.net>

Change-Id: Icca91c53eabf18c3109b3931ed53f70eaaaa0e56
2016-09-12 11:16:33 -07:00
Timur Sufiev
7e65af5f13 Embed support for external data sinks into api.glance
In case 'data' image attribute is a base string (instead of in-memory
or on-disk file), api.glance sends back an image wrapper with a redirect
url and a token to its caller, so the caller could upload the file to
that url directly.

Provide a unit test for api.glance behavior when an external upload
location is used. That also requires to fix glance stub endpoint data
in keystone_data.py since it didn't reflect the reality.

Also document the new HORIZON_IMAGES_UPLOAD_MODE setting that will
govern direct images upload and the define approach to deprecating the
old HORIZON_IMAGES_ALLOW_UPLOAD setting. The old setting is deprecated
as of Newton release and planned to be removed in P. 'Removing' means
that it will no longer be used / referenced at all in code, not the
actual presence in settings.py (it is removed from settings.py in this
commit). What really matters is if the customized value of
HORIZON_IMAGES_ALLOW_UPLOAD in local_settings.py will be still
considered during the deprecation period.

Help text in Django Create Image form in case if local file upload was
enabled was wrong, fixed that.

Related-Bug: #1403129
Partially implements blueprint: horizon-glance-large-image-upload

Change-Id: I24ff55e0135514fae89c20175cf9c764e871969b
2016-07-26 13:38:58 +00:00
Jenkins
ba2bc3503e Merge "Support properties_target when fetching namespaces" 2016-02-05 06:21:42 +00:00
Timur Sufiev
f8e595b0fa Sort images list in ascending alphabetical order
Move most of the pagination-logic to `api.glance.image_list_detailed`,
thus making code in Admin/Project->Images->get_data() less confusing
(and remove hard-coded 'asc'|'desc' values).

Also prepare to get images both from glanceclient.v1 and
glanceclient.v2 (which doesn't set `is_public` attr on images using
`visibility` attr instead).

Change-Id: Ibe6d3dd1e94a1d1fbf95382599a5f53c3559ce5a
Closes-Bug: #1534670
Closes-Bug: #1336317
2016-01-30 12:00:03 +00:00
Justin Pomeroy
e55240d882 Support properties_target when fetching namespaces
This allows specifying a properties target when fetching metadata
definitions namespaces from glance, and updates the instance
metadata widget to show only "metadata" properties (as opposed to
"scheduler_hints") when creating an instance or updating the
metadata.

Closes-Bug: #1537842
Change-Id: I64dd279139eca2cbd0c0a6e808ade4cbcba8df95
2016-01-29 15:47:28 -06:00
Rajat Vig
0cd8c89731 API for Metadata Definitions
Adding REST API calls for use in the new angularized
panels for Metadata definitions.

Set DISABLED = False in
openstack_dashboard/enabled/_2131_admin_metadata_defs_panel.py

Change-Id: I08c9c05a7b0870160ede7eb7645fc9daa83e2dd5
Partially-Implements: blueprint ng-metadata-defs-panel
2016-01-13 10:01:53 -08:00
LiuNanke
a566ba7713 Python 3 deprecated the logger.warn method in favor of warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning, so we
prefer to use warning to avoid DeprecationWarning.

Closes-Bug: #1529913

Change-Id: Ief1ebbbc8198d2d7a01a5ec41b61d8b6d466da1f
2015-12-30 19:16:32 +00:00
Jenkins
22b87e180e Merge "Eliminate mutable default arguments" 2015-12-28 08:12:06 +00:00
hgangwx
f89247d436 Misspelling in message
Misspelling in the message:
"some time and is handed off to a seperate thread."
Should be "some time and is handed off to a separate thread."
Totally 1 occasion in horizon base code.

Change-Id: I7a67c050c503c6fc7211f5191ea56bc0e8f6cb98
2015-12-23 17:53:57 +08:00
Timur Sufiev
7023050edd Eliminate mutable default arguments
The best practice in Python is not to use mutable object (i.e. list,
dictionary, or instances of most classes) as value of default
argument (see https://goo.gl/Kwhg0T). A hacking rule to enforce this 
practice is added as well.

The patch was inspired by CR https://review.openstack.org/#/c/198465/ 
and took most of its code from it as well. That's why original 
copyrights are kept.

Closes-Bug: #1471349
Change-Id: Ia77b1736dbc3d4e28ff2d2c3424e9cfcaefa5077
2015-12-17 09:58:46 +00:00
Bo Wang
7e02c996e8 Remove arguments "{}" in function definitions
remove mutable default arguments "{}" in function definitions
refer to:http://docs.python-guide.org/en/latest/writing/gotchas/

Close-Bug: #1526140

Change-Id: Ib85bd0238beaac95c53d9ae1779a5d566db9eb16
2015-12-15 14:30:22 +00:00
Justin Pomeroy
0578023d88 Add version check for listing namespaces
Listing metadata definitions namespaces requires glance API version
2. This adds a check that makes sure an empty array is returned if
any version less than 2 is being used.

Closes-Bug: #1516711
Partially-Implements: blueprint horizon-glance-v2
Change-Id: Ifc0a091318296da06168f9701a280eb7357632c7
2015-11-18 03:14:46 +00:00
Rajat Vig
7d004a34f1 Add REST API to get Glance API Version
This is needed to check if Image Metadata can be
updated.

Change-Id: I23f8b84f5f72a6423b0c453413faef25f2e139d2
Partially-Implements: blueprint angularize-images-table
2015-10-29 14:22:58 -07:00
David Lyle
efafd2ba96 Fixing docstring formatting errors and warnings
Correcting numerous errors and warnings for doc generation.

Partial-Bug: #1486222
Change-Id: I6d6b20a433aa9965a1bafbd098e64b19886e5fca
2015-08-18 17:14:22 -06:00
Jenkins
f08f3fa370 Merge "Create image directly in 'copy_from' and 'location' case" 2015-07-28 10:00:34 +00:00
Kirill Zaitsev
7eb4e3595c Handle errors during glance image updates correctly
Before an UnboundLocalError would occur in case an error would happen
during image updates, because of incorrect referencing of a variable.
Moreover the error was muted by exceptions.handle with ignore=True,
and could result in an incorrect success message.
This change removes references to unused image variable and allows
exceptions to be handled by the function, that calls image_update.

Change-Id: I35ea98a146690565582dd9beea62941f97d32474
Closes-Bug: #1464991
2015-06-15 23:48:46 +00:00
Frode Nordahl
4590f5fbde Create image directly in 'copy_from' and 'location' case
The Glance API will return immediately with a response. We need this
response to give a errror message back to the user in case of invalid
URL.

Any download operation will be executed in the background by the
Glance API server and there is no need for executing this step in a
separate thread.

Keep current logic for updating image with posted data in a background thread
One can argue that this too is uneccessary, but I can see that it may save
time for large images or when bandwidth between Horizon and Glance is limited.

Change-Id: I2ec9f714f9cfd6ca2271750133d6fcac29b94f35
Partial-Bug: 1438975
2015-06-10 22:06:09 +02:00
lincai
810ad30607 I/O error uploading image
Fixed two errors when upload an image from a file.
One is the file name doesn't exist error.
Another is file got closed in a new thread since Django 1.7.

Change-Id: Ia64c385d89e0d938b14182f2744251f76b892eac
Closes-Bug: #1451429
2015-06-02 13:35:36 +00:00
Szymon Wroblewski
9579280bf5 [Launch Instance Fix] Glance rest API fix
Adds support for resource_type, so retrieved namespaces will have
properties with proper prefixes.

Closes-Bug: 1439312
Change-Id: I4c2b450db8189c99624290a1d678fcaf509e1de6
2015-04-02 17:37:26 +02:00
Doug Fish
8bad0afcfb Add --location option to image create
Allow images to be created using glance's --location option
instead of always requiring --copy-from

Change-Id: I2aae47570f09a695adb032c210d7dc770f8cb746
Closes-Bug: #1433819
2015-03-30 10:08:22 -05:00
Yash Bathia
68291ecd97 Fixing typo in Glance API
Fixing typo in the comment of Glance API

Change-Id: I06f6520c46a83bd6e26cb066a21d950a848e3fb7
Closes-Bug: #1433729
2015-03-18 11:37:49 -07:00
Travis Tripp
1126054cf3 Glance Rest API for Angular Front End
This is the glance direct / non-abstracted rest API
for the angular front end.

This initial patch will only implement the APIs needed to
support the launch instance work.

This was refactored out of change: 141273
All v1 / v2 work is being done separately in change: 150084

Based on the work done for Keystone here:
https://review.openstack.org/#/c/150636

Partially Implements: blueprint launch-instance-redesign
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
Change-Id: I28735e242d610235695b1070a15f739e0d50b696
2015-02-18 15:30:38 -07:00
Jenkins
182dd6fcd1 Merge "Clean '/tmp' after image upload from horizon" 2015-01-21 18:24:15 +00:00
Travis Tripp
7e5f4d1594 Base Glance Metadata Definitions Admin UI
Provide a base admin UI for viewing, importing, and associating the
metadata definitions that can be used with various resource types
such as flavors, images, and host aggregates.

In Juno, Glance provided a metadata definitions catalog[1][2] where
users can register the available metadata definitions that can be used
on different types of resources (images, artifacts, volumes, flavors,
aggregates, etc). This includes key / value pairs such as
properties, extra specs, etc. Horizon landed several patches that
read these properties. You can view the functionality in the
"update metadata" action on Flavors, Images, and Host Aggregates.

This specific patch is to bring in the Admin UI for the basic coarse
grained actions on the definitions in the catalog. This includes creating
(importing) a namespace, viewing the overview details about
it, deleting the namespace, and associating the namespace for use with
specific resource types.

Future blueprints will be registered for:
 - CRUD on individual metadata definitions within the namespace
For example, editing the default value of an individual property.

[1] Approved Glance Juno Spec:
https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst

[2] Glance PTL Juno Feature Overview:
https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s

Co-Authored-By: Travis Tripp <travis.tripp@hp.com>
Co-Authored-By: Santiago Baldassin<santiago.b.baldassin@intel.com>
Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
DocImpact: Concept awareness
Change-Id: Ie34007f73af7e0941631a52f03841068e509a72c
Implements: blueprint glance-metadata-definitions-base-admin-ui
2014-12-17 16:10:53 -07:00
Vlad Okhrimenko
647c14e68b Clean '/tmp' after image upload from horizon
After image upload(successful or fails) from horizon, image
cleaned up from the /tmp

Closes-Bug: #1398766

Change-Id: I2c40e67234a8d0c8bdef9838b863ade9f5434083
2014-12-12 17:32:05 +02:00
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
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
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
Michal Dulko
2e3299dc57 Widget to expose the metadata catalog from glance
In Juno, Glance is providing a metadata definitions catalog[1][2] where
users can register the available metadata definitions that can be used
on different types of resources (images, artifacts, volumes, flavors,
aggregates, etc). This includes both simple tags and key / value pairs
(properties, specs, etc).

This widget will get the metadata definitions from Glance
and will let the user add the metadata to the resource being edited.
It provides value validation as well as description information
about the metadata.

An implementation for Images is included in this patch. Additional
patches will be made for other resource types.

This patch also removes Edit Image Custom Properties screen as new
widget provides the same functionality. To avoid regressions owner
property is added to Image Detail screen.

********************** TESTING **************************
You can test this code with Glance patches by following
the instructions at the bottom of this etherpad:
Go to: https://etherpad.openstack.org/p/j3-glance-patches
*********************************************************

[1] Approved Glance Juno Spec:
https://github.com/openstack/glance-specs/blob/master/specs/juno/metadata-schema-catalog.rst

[2] Glance PTL Juno Feature Overview:
https://www.youtube.com/watch?v=3ptriiw1wK8&t=14m27s

Implements: blueprint tagging
DocImpact

Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com>
Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com>
Co-Authored-By: Travis Tripp <travis.tripp@hp.com>
Co-Authored-By: Szymon Wroblewski <szymon.wroblewski@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
Co-Authored-By: Heather Whisenhunt <heather.whisenhunt@hp.com>

Change-Id: I335d4708f5ce8afe58fb88dbe9efd79e2c04fc9e
2014-09-11 19:10:41 +02:00
Radomir Dopieralski
0eca7449cc Fix Flake8 style warnings in openstack_dashboard/
Warnings H904, H307 and H405 are new or considerably changed, and will
be fixed in a separate patch.

Closes-bug: #1349820
Partial-bug: #1347472

Change-Id: I4fd28990dacf16f03a4eaa6074ef59c37f1a2c14
2014-07-30 14:13:24 +02:00
Justin Pomeroy
763b69b027 Add ability to manage image custom properties
This adds a new action on the admin images table for viewing the
image custom properties. From this new panel an admin can create,
delete, or update the custom properties. The new setting
IMAGE_RESERVED_CUSTOM_PROPERTIES can be used to specify any custom
properties that should not show up on this panel.

Change-Id: I10a6049e8cc6a06f31497e17a66d7031cd049c68
Implements: blueprint manage-image-custom-properties
2014-07-16 12:28:21 -05:00
Cindy Lu
2428d78a15 add Previous link to Admin > Images table
The Glance API supports a sort direction which we can use to paginate back

The Prev href tag contains a marker id of the first item in the table.
When clicked, a GET API call is made, passing in this marker and the sort_dir='asc'
This will return the previous page's data.  Then we have to re-sort the data because
it is ordered backwards.  We use the default sort_key='created_by' for this.

Once the patch #1252649 is restored, we can add the same behavior to Project > Images.

If we are able to get the consistency across the APIs to include the sort_dir, then we can
bring Prev to the other project tables as well.  There are some blueprints to enhance
API capabilities in this area.

Change-Id: I3e7c6a2db595838dbdff595dc8f0fdda288b6bcf
Partial-Bug: #1263142
Partial-Bug: #1282987
Partially-implements: blueprint pagination-add-prev-link
2014-06-27 18:29:02 -07:00
Nicolas Simonds
99aa842e97 Image uploads should always happen in the background
Sufficiently large image uploads into Glance from Horizon can cause
timeout errors, since the image upload needs to complete before the
view can render, and such activities can cause browser timeouts.
Since the webserver already has the file, and close-to-open semantics
should prevent cleanups from losing any data, just send it in a
background thread, the same way as if you told Horizon to fetch it
from a remote location.

Change-Id: Ia056367032e0d08edf6f36a8e9f900fddba85fdf
Closes-Bug: 1322399
2014-06-04 06:57:33 -07:00
Zhenguo Niu
af0e253d8d Do not delete properties when create image from URL
Set purge_props=False to ensure we do not delete properties that
we have set on the image.

Change-Id: I4d8a9b8b20ef946e86389c59e79e874f078e1db3
Closes-Bug: #1325787
2014-06-04 14:23:08 +08: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
Mike Moore
641c7da63b Stop altering the glance API URL
Horizon should treat the glance API endpoint URL the way it treats
other API endpoint URLs.
Horizon should trust that the retrieved URL is correct, and let the
python-glanceclient use the URL.

Change-Id: Ie6230b1e4b90f686c8a7ab7368944b6c3412b284
Closes-Bug: 1188182
2014-03-14 11:13:33 -06:00
Fengqian Gao
9133f5ad63 Use six.moves.urllib.parse instead of urlparse
To keep Python 3.x compatibility, use six.moves.urllib.parse to
replace urlparse.

Partial-Bug: #1279611

Change-Id: Ie49589651ed80d8fc3196fb0750cbb04661c19cd
2014-02-24 13:45:47 +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
Leandro I. Costantino
af5635a61c Cannot view detailed image with empty name.
After creating an image with empty name (only space characters in the name),
and attempting to view it, the view crashes.
Glance is not returning the name X-Meta-Header on the response if the
name is not set or empty.

Change-Id: I0c55e302d22552e932bdd32e10d00a103d252429
Closes-Bug: 1261367
2013-12-17 08:43:14 -05:00
David Lyle
e7a8a20d60 Centralizing page size code, reading cookie
Centralizing duplicate code around the default page size.
Additionally, we now read the 'horizon_pagesize' cookie set for
the user in the settings panel to reuse the value across sessions.

Closes-bug: #1251456

Change-Id: I78b6c978926f53a598f89745c517b8083270e5ba
2013-12-11 16:50:59 -07: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