Commit Graph

162 Commits

Author SHA1 Message Date
Xiangfei Zhu 19b4d3c7c7 Add PBM WSDL for vSphere 8.0
Adding WSDL files for SPBM APIs in vSphere 8.0.

Change-Id: Id43ff86e7b22940ecc1ca2dca950b28c3faa20a1
2023-09-15 05:15:54 +00:00
Hervé Beraud 4f58211e7a Bump bandit and make oslo.messaging compatible with latest rules
- Move from lxml lib direct usage to defusedxml lib [1] to fix B320 [2]

[1] https://pypi.org/project/defusedxml/0.7.1/
[2] https://bandit.readthedocs.io/en/1.7.5/blacklists/blacklist_calls.html#b313-b320-xml

Change-Id: Id1faa9227415884d15c737ace5a0e0e5de3afa81
2023-06-22 15:22:55 +02:00
OpenStack Proposal Bot 456db41c33 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I7286ea54a4ca641d5a2187ad5c884bc8fc8276fc
2022-07-06 03:56:41 +00:00
Fabian Wiesel 42ca5ddb26 Download ISO in more simple way.
In order to add support of transferring an ISO from one datastore
to another, below changes are done:
- Return and close connection for read_connection
- Add FileReadHandle similar to FileWriteHandle
- Add common headers to _create_connection
- Accept pre-build cookie for FileReadHandle/FileWriteHandle
- DatastoreUrl as parameter for FileReadHandle/FileWriteHandle

Closes-bug: #1975618
Change-Id: I311c98201e3a89db561b7a0c64592803b32a8b31
2022-05-24 19:55:45 +00:00
Stephen Finucane e991194cbd Don't use 'requests.PreparedRequest'
We're using 'requests.PreparedRequest' in one place in the tests.
However, the requests docs have a warning that one shouldn't do this:

  Instances are generated from a Request object, and should not be
  instantiated manually; doing so may produce undesirable effects.

It seems we're now seeing just such an effect, as requests has started
attempting to do proxy-related things resulting in the following error:

    Traceback (most recent call last):
      File "/usr/lib64/python3.6/unittest/mock.py", line 1183, in patched
    return func(*args, **keywargs)
      File ".../oslo.vmware/oslo_vmware/tests/test_service.py", line 518, in test_send_with_local_file_url
    resp = transport.session.send(request)
      File ".../oslo.vmware/.tox/py36/lib/python3.6/site-packages/requests/sessions.py", line 636, in send
    kwargs.setdefault('proxies', self.rebuild_proxies(request, self.proxies))
      File ".../oslo.vmware/.tox/py36/lib/python3.6/site-packages/requests/sessions.py", line 301, in rebuild_proxies
    if 'Proxy-Authorization' in headers:
    TypeError: argument of type 'NoneType' is not iterable

Do what we should have done from the beginning and use
'requests.Request.prepare' instead.

[1] https://docs.python-requests.org/en/master/api/#requests.PreparedRequest

Change-Id: I072c64904298cf83cb113e402d85fb62626f39f7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-09-21 15:41:58 +01:00
Hemna 60f6c5e8f5 Ignore already deleted lease
When we try and release a lease, we might get an object not found
exception meaning that the lease doesn't exist.  So there is no need
to release something that doesn't exist.

Change-Id: I7912a7adf95f97074ee41441d7bfb8d2405b6533
2021-04-26 14:47:52 -04:00
Johannes Kulik 4f16088462 Add serialize_object() helper function
This function converts a SUDS object to a dictionary.

Originally implemented in Nova as "object_to_dict()", this function
moves to oslo.vmware to stop leaking the abstraction around the backing
SOAP library into depending projects. This is especially necessary since
we want to switch the backing SOAP library in [1].

[1] https://specs.openstack.org/openstack/oslo-specs/specs/victoria/oslo-vmware-soap-library-switch.html

Change-Id: Ie1d42609104e604f9386c1b1a46be7dcd286e855
2021-04-16 11:05:02 +02:00
Xiangfei Zhu f1a3f78ead Add PBM WSDL for vSphere 7.0
Adding WSDL files for SPBM APIs in vSphere 7.0.

Change-Id: I8e190d00f3140f9f0864b83b723f0aec9235f1e3
2021-01-25 15:36:23 +08:00
OpenStack Proposal Bot f7fceeb929 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I8ad3f9a82802c6233dd8776011560b845656d3d5
2020-10-11 07:51:42 +00:00
Zuul fc0678a7a6 Merge "Adding pre-commit" 2020-09-22 12:40:28 +00:00
Hervé Beraud cef0e7cc4c Adding pre-commit
Introduced changes:
- pre-commit config and rules
- Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.

Also commit hash will be used instead of version tags in pre-commit to
prevend arbitrary code from running in developer's machines.

pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker
  (check-byte-order-marker);
- Checks that non-binary executables have a proper
  shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings
  (check-merge-conflict);
- Check for debugger imports and py37+ breakpoint()
  calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)

For further details about tests please refer to:
https://github.com/pre-commit/pre-commit-hooks

Change-Id: I593196cf0d099fe1dcc3a6298fd6cc6b7a883ea2
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
2020-09-08 12:28:20 +02:00
Johannes Kulik dc4eb020ad Add backend-independent access to cookiejar
Having the cookiejar available as attribute on the client instead of
some child objects exposes an interface which depending code can rely
on. This will help with upcoming efforts to switch the SOAP library
backing oslo.vmware.

This is part of phase 1 of
https://specs.openstack.org/openstack/oslo-specs/specs/victoria/oslo-vmware-soap-library-switch.html

Change-Id: I72082f10a184a2451dfda3d002a9288fefcef961
2020-07-14 10:03:41 +02:00
Johannes Kulik 32c8d43a20 Add moref helper functions
Since the attribute access on a ManagedObjectReference can differ
depending on the SOAP library used in the backend, we and especially
depending projects should not rely on it, because that breaks the
abstraction layer oslo.vmware is supposed to provide. To help
transitioning to a newer backend library, we introduce two methods for
retrieving a ManagedObjectReference's value and type: get_moref_value()
and get_moref_type().

We cannot handle this by just returning our own ManagedObjectReference
object with uniform access, because it's hard to get control of all
morefs returned by the API.

In that spirit, we also change all references inside of oslo_vmware to
using `get_moref_value()` and `get_moref_type()` instead of directly
accessing the attributes.

This is part of phase 1 of
https://specs.openstack.org/openstack/oslo-specs/specs/victoria/oslo-vmware-soap-library-switch.html

Change-Id: I0b0a3d37f6c7d0c750b48596bc3d79b8b2cb0cee
2020-07-09 12:16:32 +02:00
Ivaylo Mitev 20bc961a4c Validation of VMDK upload completion
Validate the completion of VMDK upload in ImportVApp. Otherwise, an
incomplete upload is falsely marked as successful which results in
corrupted VM.

Change-Id: I0608afd31daf95b564d3fc32028401d4aa526055
2020-05-27 07:20:35 -07:00
Sean McGinnis c9c34169de
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I4d8eada1df0ec43162d4729bf75147eb40252b72
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-03-31 14:37:19 -05:00
Andreas Jaeger 724f36bd3e Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix:
F601 dictionary key 'cr_to_rp' repeated with different values
F841 local variable 'excep' is assigned to but never used
F821 undefined name 'excep'
E305 expected 2 blank lines after class or function definition, found 1
E731 do not assign a lambda expression, use a def

Blacklist:
W504 line break after binary operator

Update hacking extension for newer flake8 version.

Change-Id: I9f0d7b166e285091111c42fe978d29d7dd3bf5db
2020-03-30 11:56:00 +00:00
Zuul a7fd12bb19 Merge "Drop use of six" 2020-03-21 22:05:59 +00:00
Zuul 7c8be155eb Merge "Pass "base_image_ref" to backend when transfer volume to image" 2020-03-18 14:56:03 +00:00
xuel e9583c6963 Fix object has no attribute 'readinto' in Python3
File Object in Python3 do not have readinfo function.

Change-Id: Ifcda45d7641b895a58472a533655ca4d3f33f246
2020-03-11 19:52:15 +08:00
Rajat Dhasmana 74aeac3c5c Pass "base_image_ref" to backend when transfer volume to image
Cinder has a current implementation to support glance colocation
of volume images[1].
To support this feature for vmdk driver, we need to pass the
base image reference (from which the volume was originally created)
to the image service update method which this patch addresses.

[1] https://review.opendev.org/#/c/697636/

Change-Id: Iba7cbdd3f50877d360201391e87f1748433348a7
2020-03-06 07:59:45 +00:00
Hervé Beraud 88798e9ad8 Drop use of six
Change-Id: I7b1fd3412b815d88b6d54178566f4089433f98ff
2020-03-02 14:52:23 +01:00
Zuul cb40fac972 Merge "Add ability to change read chunk size" 2020-03-02 11:32:07 +00:00
Zuul d507db7b97 Merge "Ensure lease polling raises proper exception" 2020-03-02 11:25:26 +00:00
Hemna 7370c400c4 Ensure lease polling raises proper exception
This patch adds the ability to properly translate and raise
VimExceptions when polling the state of the lease.

Change-Id: Ie22808471d4c72e26607e817167e0e2283630b5a
2020-02-06 07:46:15 -05:00
Hemna 4f8726c814 Adds standard file operation functions
This patch adds some standard file handle functions to the
FileHandle class.

This adds
seek
fileno
tell
flush

Change-Id: I2ae5af9f79732a757788a03f2aabdf784f461d40
2020-02-05 16:17:23 +00:00
Hemna e9ec55ce1a Add ability to change read chunk size
This patch adds the ability to change the read chunk
size during a call to VmdkReadHandle.read calls.
The read size defaults to READ_CHUNKSIZE, which was
the previous behavior.

Change-Id: I2480a2dfc42b51a22a2fce071c62c97d84555cf1
2020-02-05 16:16:58 +00:00
Damon Li 60d23fb1e8 Pass "store_id" to backend when transfer volume to image
Glance supports multiple stores now. In order to use this feature, on
patch #661676, it added parameter "store_id" when call function
"image_transfer.upload_image". We need to parse this parameter and pass
it to "image_service.update" function.

Closes-Bug: #1857094

Change-Id: I03747f54545ae3f91bf10de76d07de6828a419d6
2020-01-10 07:16:49 +00:00
Zuul 97a6c8f8f1 Merge "Ensure that log message with non-ascii code does not raise exception" 2019-05-15 01:30:14 +00:00
Zuul 66d0efc53b Merge "Update NFC lease progress" 2019-05-14 22:43:37 +00:00
Gary Kotton 9eef65739a Ensure that log message with non-ascii code does not raise exception
This may cause the looping task to freeze.

Change-Id: Ibf1ace8f0c45a56738432028c8125154c5aa3c15
2019-05-14 16:18:15 +00:00
Vipin Balachandran 42d240a2eb Set locale to english
oslo.vmware library does not need to emit localized messages from
vCenter. Explicitly setting the locale to 'en' during session
establishment to avoid UnicodeDecodeError while handling non-
english vCenter messages.

Change-Id: Ifb26a7832c15af3ed3227c94131fe0b22579e889
2019-05-13 16:03:29 -07:00
Vipin Balachandran ae6c2ae1d2 Update NFC lease progress
Adding a looping call to periodically update NFC lease
progress during virtual disk copy from ESXi to file
handle.

Change-Id: Id562d200c92af94151b08d3ae4217da41edea55e
2019-05-10 18:30:13 -07:00
Vipin Balachandran 95d849ebe7 Add nosec to skip bandit check
Bandit is flagging one of the lines in unit test as a security
issue which is false positive. Adding nosec to skip that line.

Change-Id: I36feb93bc23ba5ef0cb497859140bb5f962f2bee
2019-05-10 18:27:04 -07:00
Gary Kotton b6b6e7bdd4 When looping call fails do not log the exception trace
This makes debugging terribly difficult when there are random
legitimate errors, for example a file is not found.

Change-Id: Iec76b95a70552de8e27683c0ea388b55b519db9f
2019-04-15 06:50:48 +00:00
Sean McGinnis 2a8b07b499 Fix invalid escape sequence warning
Python 3.6 is more strict about special characters in regular strings if
they are invalid escape sequences. This most often happens in regex
strings. This fixes one instance by switching the regex string to use a
raw string.

Change-Id: I73a7393fe04c920c7d82a2fa68f1cf0c7d453a7d
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-04-10 14:51:16 +00:00
Gary Kotton 009c5e3bfe Return None if no suitable datastore is found
In the case of a datastore cluster, if no datastor is found then
return None. Do not fail on a key exception for accessing a field
that does not exist

Change-Id: I036f8022e2b9f454f7cd10846b408153a18b7b60
2019-03-03 07:02:01 -08:00
Vipin Balachandran 507afb25b1 SDRS recommendation for create VM
Adding a method to return SDRS recommendation key for creating
a VM.

Change-Id: If759114357c2929c813f55d57df3775f0eb9533d
Authored-by: Vipin Balachandran <vbala@vmware.com>
2019-03-03 07:00:29 -08:00
Gary Kotton 04f82ae934 Add DVS utility methods
Provide methods that wil enable nova/neutron to manage port
groups.

Change-Id: I81fc039e86b56388881427a6fbc4efd41207fafa
2018-09-04 04:29:56 -07:00
Radoslav Gerganov a47f0d0c4f Check if there is a context set before updating the store
There are cases when there is no request context set when calling an
async task in vCenter. Don't update the local store in those cases.

Change-Id: Ieef237bd5de0ad1c12afbf57426c29e3ca678dfc
2018-08-31 09:48:23 +03:00
Zuul 37bed90166 Merge "Set request context when polling vCenter tasks" 2018-08-23 20:43:44 +00:00
Radoslav Gerganov 44396c93b4 Set request context when polling vCenter tasks
There are various useful log messages which come when polling vCenter
tasks which are missing request context and thus are hard to correlate
to API requests.
This patch fixes this by passing the request context to the async
jobs which poll the vCenter tasks.

Change-Id: I8efbc343e5073d3deb18b5f87c378c271ea4d816
2018-08-07 15:43:36 +03:00
Corey Bryant 18a208d5d1 py37: deal with Exception repr changes
Under Python 3.7, a trailing comma is no longer added to
the init parameters generated by a repr() call:

    >>> repr(Exception('It Works'))
    "Exception('It Works')"

vs

    >>> repr(Exception('It Works'))
    "Exception('It Works',)"

Support pre and post Python 3.7 formats in test cases.

Change-Id: Idff8c841fd6c489e887bd72b49e91ef6f0e2d4f3
Closes-Bug: #1784487
2018-07-30 16:53:54 -04:00
Vipin Balachandran 01e404f5c2 Utility method to check SDRS enabled status
Adding a method to check whether vSphere Storage DRS is
enabled for a given datastore cluster.

Change-Id: Ib7441c8b2fe8a006d3eb5da70bf5b7230f4ae571
2018-07-18 05:01:13 -07:00
Radoslav Gerganov 02192f7c30 Add function for getting recommended datastore
Add utility function which returns the most recommended datastore from a
datastore cluster where a VM can be cloned to.

Change-Id: Ic532bb9c52270ba34f70d2b7977de49f8753d1d1
2018-07-17 11:30:19 +03:00
Radoslav Gerganov 80112baaf6 Add utility function for datastore clusters
Add new function which returns reference and name of the specified
datastore cluster. The cluster can be specified either by name or by its
moid.

Change-Id: I73df95294accc1954da571437efc8302edf544d2
2018-07-09 17:11:50 +03:00
Radoslav Gerganov c6456c6407 Add traversal spec for datastoreFolder
StoragePods (a.k.a datastore clusters) are located under
Datacenter.datastoreFolder, so we need a new traversal spec in order to
retrieve them.

Change-Id: I899f8f6ef05a94d21d13a55ca0a0f8fbd042a448
2018-06-19 10:13:57 +03:00
Radoslav Gerganov 3fdf495fe0 Fix docstring which breaks doc generation
Generating the documentation fails because the inherited docstring for
HTTPAdapter.send() gives a warning and warnings are treated as errors.
This patch fixes this by putting a sane docstring for the overridden
method.

Change-Id: Ief6c7964848e4acec29457bc29c327ce161524f7
2018-06-19 10:07:29 +03:00
Zuul f69970eeee Merge "Fix session re-establish failure with PBM APIs" 2018-06-02 17:55:58 +00:00
Zuul 08558b32f2 Merge "Refactor _start_transfer" 2018-06-02 17:55:58 +00:00
Radoslav Gerganov 984efbdfd2 Specify CA store when making secure connections with urllib3
We have been using FileHandle classes mostly in cases when we have to
establish secure connection and we have an SSL thumbprint of the host we
connect to. However, there are also cases when we don't have a
thumbprint and we need CA store. This patch uses the requests library to
provide such CA store.

Change-Id: I8567c8c273a3bff41c4b80a77e1fa8af743bf98c
2018-05-21 12:40:01 +03:00