Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAP: Add affinity UUID validation #182

Open
wants to merge 151 commits into
base: stable/wallaby-m3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
cb7308a
[SAP] implement size expansion when creating volume from template-bas…
imitevm Mar 30, 2018
f504c32
[SAP] netapp/dataontap: ignore certificate
notandy Jul 25, 2018
2ec0b48
[SAP] Fix pep8 warnings
fwiesel Sep 6, 2018
e8a1a3a
[SAP] Change the minimal virtual disk capacity to 4MB
joker-at-work Nov 30, 2018
c5d3f7c
[SAP] Create volume from image with expected size
joker-at-work Jun 27, 2019
a8c3937
[SAP] Remove all NICs from snapshot
joker-at-work Oct 14, 2019
e092283
[SAP] Online resize of cinder volumes (#24)
Scsabiii Nov 13, 2019
3e858e4
[SAP] scheduler: Add ShardFilter
joker-at-work Jan 17, 2020
016718f
[SAP] Backup: send data needed to build an ImportVApp spec
leust Jan 8, 2020
ade0d6e
[SAP] Normalize the new backing during terminate_connection
leust Jan 15, 2020
dcbe1a3
[SAP] fix pep8
joker-at-work Jan 29, 2020
fdede66
[SAP] run `tox -e genopts` for "scheduler: Add ShardFilter"
joker-at-work Jan 29, 2020
d4e04e2
[SAP] vmware: Optionally storage-profile on attach
joker-at-work Jan 29, 2020
f88515c
[SAP] scheduler: ShardFilter lets snapshots pass
joker-at-work Feb 10, 2020
2a90644
[SAP] scheduler: Allow shard override via hint
joker-at-work Feb 10, 2020
6dfb790
[SAP] Add loci consumed custom requirements
hemna Feb 24, 2020
8777ae9
[SAP] add reporting of thin provisioning
hemna Feb 24, 2020
1a19797
[SAP] added some missing custom requirements
hemna Feb 27, 2020
3378806
[SAP] need redis for osprofiler
hemna Feb 27, 2020
cd50472
[SAP] Chunkeddriver - no seek (#30)
mariusleu Mar 24, 2020
e391b72
[SAP] add concourse_unit_test_task
hemna Mar 26, 2020
3663c1b
[SAP] upgrade pip for concourse_unit_test_task
hemna Mar 27, 2020
d635115
[SAP] fix volume migration for vmware
hemna Mar 30, 2020
d1603bf
[SAP] Fix when migration status is None
hemna Apr 14, 2020
7e0c94d
[SAP] fix force detach when connector is None
hemna Apr 14, 2020
43f066e
[SAP] add cinder host to notify log line
hemna May 6, 2020
e69177c
[SAP] Added validation for vmware_storage_profile
hemna May 7, 2020
ada8b43
[SAP] Improve the deletion of object readers in BackupRestoreHandle (…
mariusleu May 19, 2020
bb62c09
[SAP] Allow a driver to specify additional RPC endpoints
leust Apr 9, 2020
3dea1ba
[SAP] implementation of volume migration
leust Apr 9, 2020
785043b
[SAP] Reporting location_info
leust Apr 23, 2020
5267d19
[SAP] Ability to reschedule and migrate volumes upon attachment (#50)
mariusleu Jun 9, 2020
212e6b9
[SAP] fix - scheduler manager find_backend_for_connector return value
leust Jun 12, 2020
0511e2c
[SAP] FIX vmware migrations issues (#55)
mariusleu Jun 15, 2020
3aff53a
[SAP] Added fix for check_for_setup_error
hemna Jun 19, 2020
f292c6d
[SAP] need jaeger-client for osprofiler
chuan137 Aug 6, 2020
66ad4ff
[SAP] Randomize the selection of best datastores
hemna Sep 4, 2020
b4a04e8
[SAP] added openstack-rate-limit-middleware to custom requirements.
galkindmitrii Dec 18, 2020
a5cd2f6
[SAP] fix pep8 checks
leust May 28, 2020
8f06b23
[SAP] fix DB migration scripts
hemna Sep 15, 2020
1ab2ef7
[SAP] Add db 120_cinder_init.py migration
hemna Sep 25, 2020
5d6c232
[SAP] Fix create from snapshot with larger size
hemna Nov 16, 2020
8e65962
[SAP] add sap custom requirements
hemna Jan 28, 2021
3a8f980
[SAP] Add libpq-dev to concourse_unit_test_task
hemna Sep 28, 2020
c905d2a
[SAP] Fix pep8, missing backup restore feature
hemna Sep 14, 2020
045082f
[SAP] Fix more pep8 checks
hemna Sep 11, 2020
82f3a3a
[SAP] Handle sharding-enabled in scheduler shard filter
grandchild Jan 6, 2021
01ef3ac
[SAP] Fix py3 unit tests
hemna Sep 25, 2020
2cc1857
SAP Rework backup process to make it async
hemna Apr 1, 2021
97f8b42
SAP fix the backup_rework unit tests
hemna May 10, 2021
49c2e0e
[SAP] Force volume create from backup to restoring
hemna Jul 8, 2021
6945494
VmWare: Relocate with Storage IO Profile
fwiesel Aug 2, 2021
f546097
Vmware: Create empty backing for live-migration
fwiesel Jul 12, 2021
cf48b38
[SAP] Also migrate on attachment creation
fwiesel Aug 6, 2021
69df27f
VmWare: Use WithRetrieval instead of own continue_/cancel_retrieval
fwiesel Aug 3, 2021
ece2de8
[SAP] Filter out hosts that are marked buildup
hemna Aug 16, 2021
66a0db5
[SAP] Add vmware extension for migration
hemna Sep 22, 2021
95aa930
[SAP] Removed the automatic call to migration
hemna Oct 8, 2021
f76b34a
[SAP] Fixed name of migrate_volume method name
hemna Oct 19, 2021
f905782
[SAP] add support for reporting pools
hemna Mar 11, 2020
2fe210f
[SAP] Change the API return code for ConnectorRejected
hemna Oct 20, 2021
67f5a97
[SAP] put volume in maintenance mode during migrate
hemna Nov 3, 2021
70968e4
[SAP] Update connection_capabilities reporting in stats
hemna Nov 29, 2021
b7b214b
[SAP] ShardFilter passes everything for find_backend_for_connector
joker-at-work Jan 14, 2022
c991564
[SAP] add SAPLargeVolumeFilter
hemna Jan 21, 2022
dd37300
[SAP] Fix log.debug entry for migrate_by_connector
hemna Jan 25, 2022
982f7bc
[SAP] Remove the tracing from _get_datastores_for_profiles
hemna Jan 26, 2022
ee8868b
[SAP] Handle reserved status in live-migrations
fwiesel Feb 1, 2022
5efb247
[SAP] Pass cinder_host for live-migrations
fwiesel Feb 1, 2022
e32d958
Delete attachment on exception in create
fwiesel Feb 2, 2022
1756bcf
[SAP] Fix an issue with SAPLargeVolumeFilter
hemna Feb 3, 2022
75bf357
[SAP] Ensure pools specify thick_provisioning_support enabled
hemna Feb 14, 2022
e192eea
[SAP] update size check to Gib units
hemna Feb 24, 2022
0588cf5
Vmware: Remove nvp.vm-uuid extraConfig
fwiesel Mar 4, 2022
afd2c7f
[SAP] Add any custom attributes to pool stats
hemna Feb 21, 2022
b5d2e63
[SAP] Account for volumes already provisioned to a host
hemna Feb 24, 2022
de967b0
[SAP] Added sap_affinity_filter.py
hemna Mar 24, 2022
4b1a73a
[SAP] Fixes to better account for allocated_capacity_gb
hemna Apr 1, 2022
09f4228
[SAP] Rework Capacitty filter
hemna Mar 11, 2022
9af2de4
[SAP] Replace CapacityFilter
hemna Mar 15, 2022
3622acd
[SAP] Update allocated_capacity on remote host
hemna May 4, 2022
c9c85f5
[SAP] Trap negative values for allocated_capacity_gb
hemna May 12, 2022
1db5293
[vmware] Allow pulling images from Swift
leust May 10, 2022
ecda4c7
[SAP] ensure affinty/antiaffinity is maintained at migration time
hemna Apr 21, 2022
929cbce
[SAP] Fix migration by connector filter_properties
hemna Jun 8, 2022
86b77bc
[SAP] fix the metadata for affinity/anti-affinity
hemna Jun 13, 2022
5a6d320
[SAP] Fix for allocated_capacity_gb not being updated
hemna Jun 20, 2022
925562e
[SAP] Added pool_state tracking. Updated backend_state
hemna Jul 1, 2022
088d9c7
[SAP] update the new remote host allocated_capacity_gb
hemna Jul 6, 2022
23d06a9
[SAP] Add attached volume migration for vmware
Scsabiii Mar 10, 2022
12cea1a
[SAP] prevent cross host/shard migration
hemna Jul 11, 2022
3de81f6
[SAP] Add option to disable incremental backup
hemna Jul 21, 2022
1b9e148
Migrate the volume if resize can't happen on current host
leust Jul 17, 2022
97c6565
[SAP] Fix misnamed StorageMigrationFailed call
hemna Aug 30, 2022
332e59b
[SAP] Add new recount_host_stats API
hemna Aug 17, 2022
458a424
[SAP] Add ability to disable updating provider_info
hemna Sep 22, 2022
eb3dee7
[SAP] Fix multiattach reporting for vmdk
hemna Sep 22, 2022
3fd7350
[SAP] Fix rpc call to remote host to update host capacity
hemna Sep 23, 2022
99fa054
SAP propagate scheduler hints for volumes
hemna Sep 19, 2022
35093f5
[SAP] Mark a pool as down if overcommited
hemna Sep 7, 2022
0a8d8a5
[SAP] Mark datastore down if it has specific alert
hemna Aug 16, 2022
7a0054f
[SAP] change overcommit log to info
hemna Sep 30, 2022
e3ae4c2
[SAP] fix default max_oversubscription_ratio to float
hemna Oct 3, 2022
6dcc5a5
[SAP] fix default max_oversubscription_ratio to float
hemna Oct 3, 2022
e90bf86
[SAP] Add context to the volume-stats tooz lock
hemna Oct 5, 2022
06f86fb
[SAP] vmware: Add helper to fetch properties for given objects
joker-at-work Oct 6, 2022
9074927
[SAP] Optimize vCenter queries in filter_hosts()
joker-at-work Oct 6, 2022
59c20f5
[SAP] catch TemplateNotFoundException during delete
hemna Oct 11, 2022
c191aa8
update custom-requirements to wallaby-m3
leust Oct 24, 2022
df00fe5
fix concourse_unit_test_task for wallaby
leust Oct 24, 2022
37f6523
remove oslo-vmware and os-brick from requirements.txt
leust Oct 24, 2022
36b0296
fix pep8 and unit for wallaby
leust Nov 1, 2022
315786c
[SAP] Update requirements.txt to include memcached for tooz
hemna Nov 2, 2022
19a6b0b
[SAP] set the correct vmdk_size when restoring backups
leust Oct 31, 2022
78c9875
[SAP] Fix the shard filter for group creation
hemna Nov 3, 2022
33ad0d8
Allow snapshots to be independent
hemna Nov 17, 2022
f5c24c6
Allow independent cloning of volumes
hemna Dec 6, 2022
4ee8e79
SAPCC: don't log in method called by eventlet.tpool.execute()
Carthaca Dec 14, 2022
ec9b720
Mark pool as down if datastore draining
hemna Jan 5, 2023
3aa26a1
[SAP] drop existing SAP constraint
hemna Jan 25, 2023
4d647b8
Fix setting the restore handle size
hemna Feb 9, 2023
510f1a6
[SAP] Fix logging formats
hemna Feb 28, 2023
9f5f695
[SAP]Get ready for tox 4
hemna Feb 28, 2023
50da075
[SAP] Fix vmdk stats reporting
hemna Mar 16, 2023
f2d13c9
[SAP] Update shard filter to filter only on vmware
hemna Feb 23, 2023
297adb9
[SAP] Add action_track to format specific logs for easier debugging
hemna Feb 1, 2023
ad2c75d
[SAP] ensure snapshot clones accounted for
hemna May 9, 2023
4793198
SAP: allow volume migrations with snapshots
hemna May 26, 2023
19ac429
[SAP] Use snapshot hidden backend for new volumes
hemna Jun 12, 2023
b44fcab
Change FCD driver to use volume.name attribute for directory naming, …
Scsabiii Jul 7, 2023
aee5ac6
Fix pep8 issues
Scsabiii Jul 7, 2023
f8e4827
Pep8
Scsabiii Jul 7, 2023
d0092e6
Fix unit tests
Scsabiii Jul 10, 2023
53cf6d2
Fix pep8 again
Scsabiii Jul 10, 2023
682845f
pep8
Scsabiii Jul 10, 2023
dbc8e74
Fix volume creation from snapshot
Scsabiii Jul 11, 2023
b4e1acf
Modify driver to update vmdk uuid to cinder volume id
Scsabiii Jul 13, 2023
331125b
Fix unittests
Scsabiii Jul 19, 2023
f92a1ae
Fix pep8
Scsabiii Jul 19, 2023
63e996c
[SAP] Fix vmware fcd driver delete_volume on failure
hemna Aug 24, 2023
f8d0868
[SAP] Add envlist to tox.ini
hemna Aug 31, 2023
1798b5a
K8S volumes to be scheduled in the same shard
leust Jun 13, 2023
b1a7803
Refactored using low-level DB query on volume_metadata
leust Jul 3, 2023
fa53970
[SAP] Rework Capacitty filter
hemna Mar 11, 2022
767aaad
[SAP] Replace CapacityFilter
hemna Mar 15, 2022
694462a
[SAP] k8s shard filter ignores migrate-by-connector
joker-at-work Oct 9, 2023
186f3f2
Merge pull request #184 from sapcc/shard-filter-k8s-ignore-migrate-by…
hemna Oct 9, 2023
c12b43b
ShardFilter: allow existing K8S clusters with more than 1 shard
leust Oct 9, 2023
dc1cd7f
[SAP] Fix migrate_volume_by_connector error msg
joker-at-work Oct 10, 2023
6dd928f
Merge pull request #185 from sapcc/k8s-shard-query-fix
hemna Oct 10, 2023
1a6d03d
SAP: Add affinity UUID validation
hemna Sep 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions cinder/action_track.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Copyright 2023 Openstack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import abc
import inspect
import traceback

import decorator
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils

from cinder import context as cinder_context


CONF = cfg.CONF
LOG = logging.getLogger(__name__)

ACTION_VOLUME_CREATE = "volume_create"
ACTION_VOLUME_DELETE = "volume_delete"
ACTION_VOLUME_RESERVE = "volume_reserve"
ACTION_VOLUME_ATTACH = "volume_attach"
ACTION_VOLUME_EXTEND = "volume_extend"
ACTION_VOLUME_DETACH = "volume_detach"
ACTION_VOLUME_MIGRATE = "volume_migrate"
ACTION_VOLUME_RETYPE = "volume_retype"
ACTION_VOLUME_BACKUP = "volume_backup"
ACTION_BACKUP_RESTORE = "volume_restore"
ACTION_VOLUME_BACKUP_DELETE = "volume_backup_delete"
ACTION_VOLUME_COPY_TO_IMAGE = "volume_copy_to_image"
ACTION_VOLUME_BACKUP_RESET_STATUS = "volume_backup_reset_status"
ACTION_SNAPSHOT_CREATE = "snapshot_create"
ACTION_SNAPSHOT_DELETE = "snapshot_delete"


VALID_RESOURCE_NAMES = [
'volume', 'backup', 'snapshot'
]
VALID_CONTEXT_NAMES = [
'context', 'ctxt'
]

log_level_map = {
logging.CRITICAL: LOG.error,
logging.ERROR: LOG.error,
logging.WARNING: LOG.warning,
logging.INFO: LOG.info,
logging.DEBUG: LOG.debug,
}


class ActionTrack(object, metaclass=abc.ABCMeta):
"""Base class for the 'trace' api.

The purpose of this trace facility is to be able to
keep track of critical parts of operations against resources.
This will create a standardized object/log entry for troubleshooting
actions against resources.

This is not for performance tracing, but for action/operation tracking.
by default it will simply format a log entry such that the entries are
easy to find with a standard format and information.
"""

@staticmethod
@abc.abstractmethod
def track(context, action, resource, message, loglevel=logging.INFO):
pass

@staticmethod
@abc.abstractmethod
def track_with_file_info(context, action, resource, message,
filename, line_number, function,
loglevel=logging.INFO):
pass


class LogActionTrack(ActionTrack):
@staticmethod
def _track_with_info(context, action, resource, message,
filename, line_number, function,
loglevel=logging.INFO):
entry = f"ACTION:'{action}' "
if loglevel == logging.ERROR or loglevel == logging.CRITICAL:
# The action failed and this trace is the reason
entry += "FAILED "

msg = message.replace("\n", "")

entry += (
f"MSG:'{msg}' "
f"FILE:{filename}:{line_number}:{function} "
f"RSC:{resource} "
)
log_func = log_level_map[loglevel]
log_func(entry, resource=resource)

@staticmethod
def track(context, action, resource, message, loglevel=logging.INFO):
# Do not call this directly. Call action_track.track() instead.

# We only want the frame of the caller
# we should always be called from the trace() method in this module
# not called directly in this static method
info = list(traceback.walk_stack(None))[1][0]
LogActionTrack._track_with_info(context, action, resource, message,
info.f_code.co_filename,
info.f_lineno,
info.f_code.co_name,
loglevel=loglevel)

@staticmethod
def track_with_file_info(context, action, resource, message,
filename, line_number, function,
loglevel=logging.INFO):
# Do not call this directly.
# Call action_track.track_with_file_info() instead.
LogActionTrack._track_with_info(
context, action, resource, message,
filename, line_number, function, loglevel=loglevel
)


def track(context, action, resource, message, loglevel=logging.INFO):
"""For now we only implement LogActionTrack.

TODO(waboring): add rabbitmq trace? to send entries to a msg queue
or add: DBtrace to send traces to the DB instead?
"""
LogActionTrack.track(context, action, resource, message,
loglevel=loglevel)


def track_with_info(context, action, resource, message, file, line_number,
function, loglevel=logging.INFO):
"""For now we only implement LogActionTrack.

TODO(waboring): add rabbitmq trace? to send entries to a msg queue
or add: DBtrace to send traces to the DB instead?
"""
LogActionTrack.track_with_file_info(context, action, resource, message,
file, line_number, function,
loglevel=loglevel)


def track_decorator(action):
"""Decorator to automatically handle exceptions raised as failures.

Place this decorator on a function that you want to mark as an
action failure and the action_track tracing will get called
for the action.

@track_decorator(action_track.ACTION_VOLUME_ATTACH)
def initialize_connection(....)
If initialize_connection raises an exception then you will get a
action_track.track called with action of ACTION_VOLUME_ATTACH
and a failure.

"""
@decorator.decorator
def inner(func, *args, **kwargs):
# Find the context and the volume/backup object
resource = None
context = None
call_args = inspect.getcallargs(func, *args, **kwargs)
for key in call_args:
if key in VALID_RESOURCE_NAMES:
resource = call_args[key]
elif (key in VALID_CONTEXT_NAMES and
isinstance(call_args[key], cinder_context.RequestContext)):
context = call_args[key]

track(context, action, resource, "called")

try:
return func(*args, **kwargs)
except Exception:
with excutils.save_and_reraise_exception() as exc:
# We only want the frame of the caller
tl = traceback.extract_tb(exc.tb)
i = tl[1]
message = str(exc.value)
track_with_info(
context, action, resource, message,
i.filename, i.lineno, i.name,
loglevel=logging.ERROR
)
return inner
2 changes: 2 additions & 0 deletions cinder/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

METADATA_TYPES = enum.Enum('METADATA_TYPES', 'user image')

SAP_HIDDEN_METADATA_KEY = "__cinder_internal"


def get_pagination_params(params, max_limit=None):
"""Return marker, limit, offset tuple from request.
Expand Down
11 changes: 11 additions & 0 deletions cinder/api/contrib/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ def _failover(self, req, context, clustered, body):
cluster_name, body.get('backend_id'))
return webob.Response(status_int=HTTPStatus.ACCEPTED)

@validation.schema(os_services.recount_host_stats)
def _recount_host_stats(self, req, context, body):
"""Ask the volume manager to recount allocated capacity for host."""
cluster_name, host = common.get_cluster_host(req, body,
mv.REPLICATION_CLUSTER)
self._volume_api_proxy(self.volume_api.recount_host_stats, context,
host)
return webob.Response(status_int=HTTPStatus.ACCEPTED)

def _log_params_binaries_services(self, context, body):
"""Get binaries and services referred by given log set/get request."""
query_filters = {'is_up': True}
Expand Down Expand Up @@ -273,6 +282,8 @@ def update(self, req, id, body):
return self._set_log(req, context, body=body)
elif support_dynamic_log and id == 'get-log':
return self._get_log(req, context, body=body)
elif id == "recount_host_stats":
return self._recount_host_stats(req, context, body=body)
else:
raise exception.InvalidInput(reason=_("Unknown action"))

Expand Down
74 changes: 74 additions & 0 deletions cinder/api/contrib/vmware_migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) 2021 SAP Corporation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""The Migrate by connector API."""


from oslo_log import log as logging
from oslo_utils import strutils
from six.moves import http_client

from cinder.api.contrib import admin_actions
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.schemas import vmware_extension_actions as vmware_actions
from cinder.api import validation


LOG = logging.getLogger(__name__)


class VMWareVolumeExtensionsController(admin_actions.VolumeAdminController):

collection = 'volumes'

@wsgi.response(http_client.ACCEPTED)
@wsgi.action('os-migrate_volume_by_connector')
@validation.schema(vmware_actions.migrate_volume_by_connector)
def _migrate_volume_by_connector(self, req, id, body):
"""Migrate a volume based on connector.

This is an SAP VMWare extension that requires
the connector of the vmware vcenter to be provided.
The connector will contain the correct vcenter uuid
so that the scheduler can find the right cinder backend
to migrate the volume.
"""
context = req.environ['cinder.context']
# Not found exception will be handled at the wsgi level
volume = self._get(context, id)
self.authorize(context, 'migrate_volume', target_obj=volume)
params = body['os-migrate_volume_by_connector']
connector = params.get('connector', {})
lock_volume = strutils.bool_from_string(
params.get('lock_volume', False),
strict=True)

self.volume_api.migrate_volume_by_connector(
context, volume, connector, lock_volume)


class Vmware_migrate(extensions.ExtensionDescriptor):
"""Enable admin actions."""

name = "Vmware_migrate"
alias = "os-vmware-admin-actions"
updated = "2021-09-25T00:00:00+00:00"

def get_controller_extensions(self):
controller = VMWareVolumeExtensionsController()
extension = extensions.ControllerExtension(
self, controller.collection, controller)
return [extension]
35 changes: 35 additions & 0 deletions cinder/api/contrib/volume_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# License for the specific language governing permissions and limitations
# under the License.
from http import HTTPStatus
import logging

from castellan import key_manager
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_utils import strutils
import webob

from cinder import action_track
from cinder.api import extensions
from cinder.api import microversions as mv
from cinder.api.openstack import wsgi
Expand Down Expand Up @@ -77,11 +79,20 @@ def _attach(self, req, id, body):
msg = _("Error attaching volume - %(err_type)s: "
"%(err_msg)s") % {
'err_type': error.exc_type, 'err_msg': error.value}
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, msg, loglevel=logging.ERROR
)
raise webob.exc.HTTPBadRequest(explanation=msg)
else:
# There are also few cases where attach call could fail due to
# db or volume driver errors. These errors shouldn't be exposed
# to the user and in such cases it should raise 500 error.
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, f"Attach failed because {error}",
loglevel=logging.ERROR
)
raise

@wsgi.response(HTTPStatus.ACCEPTED)
Expand Down Expand Up @@ -159,16 +170,40 @@ def _initialize_connection(self, req, id, body):
volume = self.volume_api.get(context, id)
connector = body['os-initialize_connection']['connector']
try:
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, "Call initialize_connection",
)
info = self.volume_api.initialize_connection(context,
volume,
connector)
except exception.InvalidInput as err:
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, "Invalid Input", loglevel=logging.ERROR
)
raise webob.exc.HTTPBadRequest(
explanation=err.msg)
except exception.ConnectorRejected:
msg = _("Volume needs to be migrated before attaching to this "
"instance")
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, msg
)
raise webob.exc.HTTPNotAcceptable(explanation=msg)
except exception.VolumeBackendAPIException:
msg = _("Unable to fetch connection information from backend.")
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, msg, loglevel=logging.ERROR
)
raise webob.exc.HTTPInternalServerError(explanation=msg)
except messaging.RemoteError as error:
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, f"Failed because {error}", loglevel=logging.ERROR
)
if error.exc_type == 'InvalidInput':
raise exception.InvalidInput(reason=error.value)
raise
Expand Down
Loading