-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #642 from sodafoundation/host_mapping
Host mapping feature merge
- Loading branch information
Showing
28 changed files
with
3,603 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# 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 delfin import db | ||
from delfin.api import api_utils | ||
from delfin.api.common import wsgi | ||
from delfin.api.views import masking_views | ||
|
||
|
||
class MaskingViewController(wsgi.Controller): | ||
|
||
def __init__(self): | ||
super(MaskingViewController, self).__init__() | ||
self.search_options = ['name', 'id', 'storage_id', | ||
'native_storage_host_group_id', | ||
'native_storage_port_group_id', | ||
'native_storage_volume_group_id', | ||
'native_storage_host_id', | ||
'native_volume_id', | ||
'native_port_id', | ||
'native_masking_view_id'] | ||
|
||
def _get_masking_view_search_options(self): | ||
"""Return masking view search options allowed .""" | ||
return self.search_options | ||
|
||
def show(self, req, id): | ||
ctxt = req.environ['delfin.context'] | ||
query_params = {"storage_id": id} | ||
query_params.update(req.GET) | ||
# Update options other than filters | ||
sort_keys, sort_dirs = api_utils.get_sort_params(query_params) | ||
marker, limit, offset = api_utils.get_pagination_params(query_params) | ||
# Strip out options except supported search options | ||
api_utils.remove_invalid_options( | ||
ctxt, query_params, self._get_masking_view_search_options()) | ||
|
||
masking_view_lists = db.masking_views_get_all(ctxt, marker, limit, | ||
sort_keys, sort_dirs, | ||
query_params, offset) | ||
return masking_views.build_masking_views(masking_view_lists) | ||
|
||
|
||
def create_resource(): | ||
return wsgi.Resource(MaskingViewController()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# 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 delfin import db | ||
from delfin.api import api_utils | ||
from delfin.api.common import wsgi | ||
from delfin.api.views import port_groups as port_group_view | ||
|
||
|
||
class PortGroupController(wsgi.Controller): | ||
|
||
def __init__(self): | ||
super(PortGroupController, self).__init__() | ||
self.search_options = ['name', 'id', 'storage_id', | ||
'native_port_group_id'] | ||
|
||
def _get_port_group_search_options(self): | ||
"""Return port group search options allowed .""" | ||
return self.search_options | ||
|
||
def show(self, req, id): | ||
ctxt = req.environ['delfin.context'] | ||
query_params = {"storage_id": id} | ||
query_params.update(req.GET) | ||
# Update options other than filters | ||
sort_keys, sort_dirs = api_utils.get_sort_params(query_params) | ||
marker, limit, offset = api_utils.get_pagination_params(query_params) | ||
# Strip out options except supported search options | ||
api_utils.remove_invalid_options( | ||
ctxt, query_params, self._get_port_group_search_options()) | ||
|
||
port_groups = db.port_groups_get_all( | ||
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset) | ||
return port_group_view.build_port_groups(port_groups) | ||
|
||
|
||
def create_resource(): | ||
return wsgi.Resource(PortGroupController()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# 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 delfin import db | ||
from delfin.api import api_utils | ||
from delfin.api.common import wsgi | ||
from delfin.api.views import storage_host_groups as storage_host_group_view | ||
|
||
|
||
class StorageHostGroupController(wsgi.Controller): | ||
|
||
def __init__(self): | ||
super(StorageHostGroupController, self).__init__() | ||
self.search_options = ['name', 'id', 'storage_id', | ||
'native_storage_host_group_id'] | ||
|
||
def _get_storage_host_group_search_options(self): | ||
"""Return storage host group search options allowed .""" | ||
return self.search_options | ||
|
||
def show(self, req, id): | ||
ctxt = req.environ['delfin.context'] | ||
query_params = {"storage_id": id} | ||
query_params.update(req.GET) | ||
# Update options other than filters | ||
sort_keys, sort_dirs = api_utils.get_sort_params(query_params) | ||
marker, limit, offset = api_utils.get_pagination_params(query_params) | ||
# Strip out options except supported search options | ||
api_utils.remove_invalid_options( | ||
ctxt, query_params, self._get_storage_host_group_search_options()) | ||
|
||
storage_host_groups = db.storage_host_groups_get_all( | ||
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset) | ||
return storage_host_group_view\ | ||
.build_storage_host_groups(storage_host_groups) | ||
|
||
|
||
def create_resource(): | ||
return wsgi.Resource(StorageHostGroupController()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# 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 delfin import db | ||
from delfin.api import api_utils | ||
from delfin.api.common import wsgi | ||
from delfin.api.views import storage_host_initiators as \ | ||
storage_host_initiator_view | ||
|
||
|
||
class StorageHostInitiatorController(wsgi.Controller): | ||
|
||
def __init__(self): | ||
super(StorageHostInitiatorController, self).__init__() | ||
self.search_options = ['name', 'status', 'wwn', 'id', 'storage_id', | ||
'native_storage_host_id', | ||
'native_storage_host_initiator_id'] | ||
|
||
def _get_storage_host_initiator_search_options(self): | ||
"""Return storage host initiator search options allowed .""" | ||
return self.search_options | ||
|
||
def show(self, req, id): | ||
ctxt = req.environ['delfin.context'] | ||
query_params = {"storage_id": id} | ||
query_params.update(req.GET) | ||
# Update options other than filters | ||
sort_keys, sort_dirs = api_utils.get_sort_params(query_params) | ||
marker, limit, offset = api_utils.get_pagination_params(query_params) | ||
# Strip out options except supported search options | ||
api_utils.remove_invalid_options( | ||
ctxt, query_params, | ||
self._get_storage_host_initiator_search_options()) | ||
|
||
storage_host_initiators = db.storage_host_initiators_get_all( | ||
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset) | ||
return storage_host_initiator_view.build_storage_host_initiators( | ||
storage_host_initiators) | ||
|
||
|
||
def create_resource(): | ||
return wsgi.Resource(StorageHostInitiatorController()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# 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 delfin import db | ||
from delfin.api import api_utils | ||
from delfin.api.common import wsgi | ||
from delfin.api.views import storage_hosts as storage_host_view | ||
|
||
|
||
class StorageHostController(wsgi.Controller): | ||
|
||
def __init__(self): | ||
super(StorageHostController, self).__init__() | ||
self.search_options = ['name', 'status', 'id', 'storage_id', | ||
'native_storage_host_id'] | ||
|
||
def _get_storage_host_search_options(self): | ||
"""Return storage host search options allowed .""" | ||
return self.search_options | ||
|
||
def _fill_storage_host_initiators(self, ctxt, storage_host, storage_id): | ||
"""Fills initiator list for storage host.""" | ||
|
||
storage_host_initiators = db.storage_host_initiators_get_all( | ||
ctxt, filters={"storage_id": storage_id, | ||
"native_storage_host_id": | ||
storage_host['native_storage_host_id']}) | ||
storage_host_initiator_list = [] | ||
for storage_host_initiator in storage_host_initiators: | ||
storage_host_initiator_list.append( | ||
storage_host_initiator['native_storage_host_initiator_id']) | ||
return storage_host_initiator_list | ||
|
||
def show(self, req, id): | ||
ctxt = req.environ['delfin.context'] | ||
query_params = {"storage_id": id} | ||
query_params.update(req.GET) | ||
# Update options other than filters | ||
sort_keys, sort_dirs = api_utils.get_sort_params(query_params) | ||
marker, limit, offset = api_utils.get_pagination_params(query_params) | ||
# Strip out options except supported search options | ||
api_utils.remove_invalid_options( | ||
ctxt, query_params, self._get_storage_host_search_options()) | ||
|
||
storage_hosts = db.storage_hosts_get_all(ctxt, marker, limit, | ||
sort_keys, sort_dirs, | ||
query_params, offset) | ||
for storage_host in storage_hosts: | ||
storage_host['storage_host_initiators'] \ | ||
= self._fill_storage_host_initiators(ctxt, storage_host, id) | ||
|
||
return storage_host_view.build_storage_hosts(storage_hosts) | ||
|
||
|
||
def create_resource(): | ||
return wsgi.Resource(StorageHostController()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2021 The SODA Authors. | ||
# | ||
# 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 delfin import db | ||
from delfin.api import api_utils | ||
from delfin.api.common import wsgi | ||
from delfin.api.views import volume_groups as volume_group_view | ||
|
||
|
||
class VolumeGroupController(wsgi.Controller): | ||
|
||
def __init__(self): | ||
super(VolumeGroupController, self).__init__() | ||
self.search_options = ['name', 'id', 'storage_id', | ||
'native_volume_group_id'] | ||
|
||
def _get_volume_group_search_options(self): | ||
"""Return volume group search options allowed .""" | ||
return self.search_options | ||
|
||
def show(self, req, id): | ||
ctxt = req.environ['delfin.context'] | ||
query_params = {"storage_id": id} | ||
query_params.update(req.GET) | ||
# Update options other than filters | ||
sort_keys, sort_dirs = api_utils.get_sort_params(query_params) | ||
marker, limit, offset = api_utils.get_pagination_params(query_params) | ||
# Strip out options except supported search options | ||
api_utils.remove_invalid_options( | ||
ctxt, query_params, self._get_volume_group_search_options()) | ||
|
||
volume_groups = db.volume_groups_get_all( | ||
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset) | ||
return volume_group_view.build_volume_groups(volume_groups) | ||
|
||
|
||
def create_resource(): | ||
return wsgi.Resource(VolumeGroupController()) |
Oops, something went wrong.