5e508a09b3
This patch introduce the REST API modifications to attach/detach a share and list/show share mappings. Manila is the OpenStack Shared Filesystems service. These series of patches implement changes required in Nova to allow the shares provided by Manila to be associated with and attached to instances using virtiofs. Implements: blueprint libvirt-virtiofs-attach-manila-shares Change-Id: I0255a5697cd4ea148bd91c4f6fd183841d69a333
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
# 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.
|
|
|
|
from nova.api.openstack import common
|
|
from nova.api.openstack.compute.views import servers
|
|
|
|
|
|
class ViewBuilder(common.ViewBuilder):
|
|
_collection_name = 'shares'
|
|
|
|
def __init__(self):
|
|
super(ViewBuilder, self).__init__()
|
|
self._server_builder = servers.ViewBuilder()
|
|
|
|
def _list_view(self, db_shares):
|
|
shares = {'shares': []}
|
|
for db_share in db_shares:
|
|
share = {
|
|
'share_id': db_share.share_id,
|
|
'status': db_share.status,
|
|
'tag': db_share.tag,
|
|
}
|
|
shares['shares'].append(share)
|
|
return shares
|
|
|
|
def _show_view(self, context, db_share):
|
|
share = {'share': {
|
|
'share_id': db_share.share_id,
|
|
'status': db_share.status,
|
|
'tag': db_share.tag,
|
|
}}
|
|
|
|
if context.is_admin:
|
|
share['share']['export_location'] = db_share.export_location
|
|
share['share']['uuid'] = db_share.uuid
|
|
|
|
return share
|