Commit Graph

27 Commits

Author SHA1 Message Date
Takashi Kajinami a7be9c3824 Nova: Remove unused server operations
Some of the APIs implemented in manila.compute.nova.API are not used
by any implementation. This change drops unused implementations rather
than keeping them maintained for no use.

Change-Id: I5195c31c6a95ed22eb89d734f3eea6a077eb2f68
2022-07-18 11:17:48 +00:00
Takashi Kajinami 39a031e65c Nova: Remove unused image apis
Currently images are managed by Glance, instead of Nova, and these
implementations are no longer used.

Change-Id: Iabd4591b6782b135faa137a1e14a1fb760127ee6
2022-07-18 11:17:37 +00:00
Goutham Pacha Ravi 04e06968fd Handle service client authorization errors
Authorization errors when connecting
to nova/glance/neutron/cinder can be raised as
BadConfigurationExceptions in the logs. We shouldn't
be raising exceptions derived from the service client
libraries.

Change-Id: I2d47dbb1251dfa8d529f813724fb7fd97d7d3a0b
Closes-Bug: #1921927
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2021-06-24 15:45:04 +00:00
Goutham Pacha Ravi 598223985a Use unittest.mock instead of third party lib
mock was adopted into standard python
in version 3.3 [1]. Since manila no longer
supports python2.7, we can use the inbuilt
mock package rather than the third party
lib.

Fix some issues with imports that weren't
following our import conventions of grouping
imports [3]

Add a hacking test to ensure we don't regress
on this.

[1] https://docs.python.org/3/library/unittest.mock.html
[2] http://lists.openstack.org/pipermail/openstack-discuss/2020-March/013281.html
[3] https://docs.openstack.org/hacking/latest/user/hacking.html#imports

Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Change-Id: If857a49fbf526983e712282a25d7e8bef5093533
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-04-17 16:24:27 -07:00
ericxiett a7aa847097 Fix error that failed to get image for booting server
Glance image list API supports pagination, but `_get_service_image`
uses novaclient.glance.list() that only return images in one page.
When the image needed by share server is not returned in the first
page, the exception occurs. This patch uses `find_image` method
to get the image.
Since latest novaclient has no proxy to lookup image, so only
novaclient.glance.

Change-Id: I57b15b7ebb29c545c9780a90734988565fa1f6b7
Closes-Bug: #1844046
2019-12-13 01:31:22 +00:00
Goutham Pacha Ravi 198bea78ac Deprecate old keystone session config opts
In the past, the options ca_certificates_file,
nova_ca_certificates_file, cinder_ca_certificates_file,
api_insecure, nova_api_insecure, cinder_api_insecure
were supplied to instantiate nova, neutron and cinder
clients. These options have now been subsumed in a more
generic way into the Keystone session logic as 'cafile'
and 'insecure'. Deprecate the older options in Stein so
that we can remove them in a future release.

This deprecation began many releases ago when we switched
to using keystone sessions [1]. However, we were still
overriding the values of "insecure" and "cafile" if provided,
forcing users to continue using deprecated parameters
"api_insecure" and "ca_certificates_file". So despite
this fix originating in the Stein release, it would be
prudent to backport it to all maintained releases and
remove support for these older options in/beyond Train
release (9.0.0).

[1] Ic211a11308a3295409467efd88bff413482ee58d
Change-Id: I148e9079c7c1ab119f519f727d4ad97758473325
Related-Bug: #1802393
Closes-Bug: #1809318
2018-12-20 17:29:40 -08:00
lijunbo 7969d94078 Remove deprecated DEFAULT options
Cinder, nova, neutron has deprecated some default options
since last release, so it is time to remove those options
in this version. refer to the following deprecation patch.

Ref: https://review.openstack.org/#/c/290511/

Closes-bug: #1766384

Change-Id: I595ff2c82ef40566145fedb202e549be69c45e0c
2018-04-23 21:01:10 +08:00
zhongjun 341161eead Use parenthesis instead of backslashes in tests folder
Use parenthesis instead of backslashes in tests folder

TrivialFix
Change-Id: I6c2ea07b0bfc5852b28e44989406cc10eb972e53
2017-06-19 17:56:01 +08:00
Valeriy Ponomaryov 5d5666b10e [Generic driver] Fix incompatibility with novaclient
Novaclient has removed lots of proxies to other clients such as
'images' [1], 'networks' [2] and 'security_groups' [3].
So, fix incompatibilities the way we can work with old and
new novaclient versions.

[1] I2d9fd0243d42538bd1417a42357c17b09368d2a5
[2] I8c520100a0016eed3959619c71dae037ebd72939
[3] I6fa14f43d48f1e035ef54bd2d0078506f0c6d6e0

Change-Id: Id7383329b2491f76579f042cbed06585c2214815
Closes-Bug: #1691445
2017-06-06 13:05:10 +03:00
Valeriy Ponomaryov 11b38f3188 Add support of endpoint_type and region_name to clients manila uses
Since change [1] it is impossible to set endpoint_type and region_name
for nova, cinder and neutron clients that are used by manila in some
cases.
So, to fix it, add additional options called 'endpoint_type' and
'region_name' for each of config groups related to these clients.
These options can be defined in appropriate config group as following:

[nova]
endpoint_type = publicURL
region_name = SomeRegionName

[cinder]
endpoint_type = internalURL
region_name = SomeRegionName

[neutron]
endpoint_type = adminURL
region_name = SomeRegionName

[1] Ic211a11308a3295409467efd88bff413482ee58d

Change-Id: I6be0e77bbc0e4b1e9905eba7a7b48ff540e9e377
Closes-Bug: #1633454
2016-11-02 18:14:04 +02:00
Thomas Bechtold bca18c6f10 service instance: also recognize instance name
Using the generic driver needs a service instance. The variable
"service_instance_name_or_id" indicates that it's possible to use
the UUID or the name of the Nova VM. Using the VM name currently only
works, when the instance is in the current tenant.
This fix searches the instance at first in the current tenant and
if not found, it searches again over all tenants.
Without this fix, you get the following error when using the name:

Failed to get Nova VM. No server with a name or ID of 'myname' exists.

Change-Id: I8770eff9752b76ebe490abf03a7ea6548282bf9b
Closes-Bug: #1535775
2016-03-16 12:48:17 +01:00
Thomas Bechtold 296ca1ba7c Remove unused server_get() method
server_get() from the compute/nova.py file is not used anymore.
So remove it.

Change-Id: I36308563720c006980c10200d886eb73bd78d666
2016-01-21 09:16:14 +01:00
Jenkins 7e6108c967 Merge "Change assertTrue(isinstance()) by optimal assert" 2016-01-08 05:29:17 +00:00
vponomaryov 95940a4085 Fix handling of Novaclient exceptions
If Novaclient returns exception, then Manila wrapper for Novaclient
fails with following error:

File "/opt/stack/new/manila/manila/compute/nova.py", line 160, in wrapper
    return res
UnboundLocalError: local variable 'res' referenced before assignment

So, fix it and cover with unit tests.

Change-Id: I5eec4b9e9f3857307daa2ade516f76c044c01631
Closes-Bug: #1530811
2016-01-04 12:46:03 +02:00
Shuquan Huang 75e7b788a4 Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of assertTrue(isinstance(A, B)) or
assertEqual(type(A), B). The correct way is to use assertIsInstance(A,
B) provided by testtools.

Change-Id: I9053c9deaa71ee12e10db73b19250b3a32f3d93c
Closes-bug: #1268480
2015-12-31 16:14:44 +08:00
Yusuke Hayashi d3e50fd70f Fix order of arguments in assertEqual
Fix incorrect order assertEqual(observed, expected) as below.
  assertEqual(observed, expected) => assertEqual(expected, observed)

Target of this patch:
  manila/tests/cmd/*
  manila/tests/compute/*
  manila/db/*
  manila/network/*

Change-Id: I6dd4f8057facc68e716b57229cbc4096af8bb152
Partial-Bug: #1259292
2015-10-03 10:05:41 +09:00
Yusuke Hayashi cb0a5c9829 Replace assertEqual(None, *) with assertIsNone in tests
Replace assertEqual(None, *) with assertIsNone in tests to have
more clear messages in case of failure.

Closes-Bug: #1280522
Change-Id: I2d5285add72678b5a61b4f66879c4d066afc34c7
2015-08-23 09:07:13 +09:00
Valeriy Ponomaryov 554b92e458 Fix exceptions handling for py34 compatibility
Fix following cases:

    "except SomeException, e:"
    "raise exc_value, msg, exc_trace"
    "e.message"

Partially-Implements: bp py3-compatibility

Change-Id: I8c20ae725000895b6b7b7c0da7d4bfba3e4849f0
2015-08-05 17:15:46 +03:00
Li, Chen b566f5ef61 Switch to v2 version of novaclient
Currently v1_1 version of novaclient is deprecated, so it's required
to switch for v2 version of novaclient.

Change-Id: I824e8659febfeb86721b610a03a8c3027042cb3d
2015-03-31 17:05:07 +08:00
Ponomaryov Valeriy e7dbe837f9 Add nova network plugin
Share drivers that handle share servers use network plugins to setup networking
for share hosts. And there were no support for nova-networking.

Add two new network plugins, both use Nova networking:
- NovaNetworkPlugin, uses network ID provided by share-networks
- NovaSingleNetworkPlugin, uses network ID defined within config
by opt 'nova_single_network_plugin_net_id'.

Both have same possibilities restricted by Nova networking:
- supported network types: 'flat' and 'vlan'
- supported IP versions: '4' and '6'
- support any amount of IP addresses to be dedicated/provided for share servers
while network has available/unused IP addresses.

Implements bp nova-network-plugin

Change-Id: I6391f168d93107d9152132830afde896aba2180a
2015-03-07 18:46:31 +00:00
Ponomaryov Valeriy 79949476ed Add Nova-network support to service_instance module
Till that moment it was possible to use Generic driver only with Neutron.
Nova network still is used in various deployments, so add support for it.

List of changes:
- Split service_instance to two parts - compute and networking.
- Implement networking part as 'network helpers'.
- Add new config option 'service_instance_network_helper_type' that supports
only two values - 'nova' and 'neutron' respectively.
It is required option. Default value is 'neutron'.

Details on Nova-network approach:
- Due to resctrictions of Nova network, where security group rules are applied
to all VM network interfaces, no need to create service network, because it
will be just duplication. Service instance will use only one network that is
provided within share-network entity.
- Host of manila-share service should have network connectivity for all
networks, that are going to be used for share creations.
- Nova network helper does not create resources, so, network is not configured
by Manila in that case. So, network infrastructure can be either flat or using
VLAN segmentation as well.

Implements BP nova-network-support-in-generic-driver
Implements BP split-service-instance
Change-Id: I7462fe3d6fa944d391628b8e2b374cf5593924ea
2015-02-25 14:07:32 +02:00
Clinton Knight 65d1158526 Replace legacy StubOutForTesting class
The Manila test module uses a class called StubOutForTesting, which
is an awkward holdover from when the unit tests were using Mox.
Alex wrote a more elegant and capable mocker method,
manila.test.TestCase.mock_object, in the Cinder project which we
have now added to Manila. So to remove the duplicate functionality
and legacy code, all references to self.stubs.Set() in the Manila
tests should be replaced with self.mock_object() and any related
dead code should be removed.

Resolves-bug: #1415602
Change-Id: Ie5f203c0b2cb57ad00d9ec8db0529075b6fef261
2015-02-03 14:31:17 +00:00
Valeriy Ponomaryov 53b40423f4 Implement additional driver mode for Generic driver
Add possibility to run Generic driver without handling of share servers. It
allows us to create shares, without share-networks defined, on one specific
Nova VM.
Added three (3) new config options that are used only with new mode:
- 'service_instance_name_or_id' expects string with name or id of Nova VM.
- 'service_net_name_or_ip' expects name of network that Nova VM is switched to
  or IP itself. Used for handle operation of share.
- 'tenant_net_name_or_ip' expects name of network that Nova VM is switched to
  or IP itself. Used for exporting share to end users.
All three new config options are required if new mode is enabled.
They will be skipped if driver mode with handling of share servers is enabled.

Implements bp single-svm-mode-for-generic-driver

Change-Id: I48864b002e4174728136d093b1a17dad2edec605
2015-02-02 13:57:19 +02:00
Valeriy Ponomaryov bfed689614 Use Cinder v2 API within Generic driver
Manila uses v1 Cinder API for it's Generic driver.
Cinder v1 API is deprecated and is going to be removed,
see: https://blueprints.launchpad.net/cinder/+spec/deprecate-v1-api
So, update our Generic driver to use v2 Cinder API.

Implements blueprint v2-cinder-api-for-generic-driver

Change-Id: I3cbd713a9a4c6eccee50ba4af4bdf2794db021d7
2015-01-05 23:05:01 +02:00
Andreas Jaeger 754e5f8587 Fix pep8 issues in manila/tests
Fix pep8 issues in some test files.

Partial-Fix: #1333290

Change-Id: If863267f0a3dae1efaf81433814f26a8ebdd1776
2014-08-19 17:04:06 +02:00
Christian Berendt 799319baab Enabled hacking checks H305 and H307
* H305  imports not grouped correctly
* H307  like imports should be grouped together

Change-Id: I9dc5f995ea07d7c319d944e847a9d1c126937240
2014-07-20 18:48:31 +02:00
Andrei V. Ostapenko 9a7e113b3a Adds nova api needed for generic driver implementation
Generic driver will use nova instances to reach multitenancy,
so this patch adds a module for interacting with nova.

Partially implements: bp generic-driver
Change-Id: Ic51971f0fe72bcbbe364e8f6aa4c59a8ec267c83
2014-02-10 10:10:32 +02:00