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

Add NAS resources for filesystem, qtree & share #491

Merged
merged 9 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 54 additions & 0 deletions delfin/api/v1/filesystems.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 filesystems as filesystem_view


class FilesystemController(wsgi.Controller):

def __init__(self):
super(FilesystemController, self).__init__()
self.search_options = ['name', 'status', 'id', 'storage_id',
'native_filesystem_id']

def _get_fs_search_options(self):
"""Return filesystems search options allowed ."""
return self.search_options

def index(self, req):
ctxt = req.environ['delfin.context']
query_params = {}
query_params.update(req.GET)
# update options other than filters
sort_keys, sort_dirs = api_utils.get_sort_params(query_params)
NajmudheenCT marked this conversation as resolved.
Show resolved Hide resolved
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_fs_search_options())

filesystems = db.filesystem_get_all(ctxt, marker, limit, sort_keys,
sort_dirs, query_params, offset)
return filesystem_view.build_filesystems(filesystems)

def show(self, req, id):
ctxt = req.environ['delfin.context']
filesystem = db.filesystem_get(ctxt, id)
return filesystem_view.build_filesystem(filesystem)


def create_resource():
return wsgi.Resource(FilesystemController())
55 changes: 55 additions & 0 deletions delfin/api/v1/qtrees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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 qtrees as qtree_view


class QtreeController(wsgi.Controller):

def __init__(self):
super(QtreeController, self).__init__()
self.search_options = ['name', 'state', 'id', 'storage_id',
'native_filesystem_id',
'native_qtree_id']

def _get_qtrees_search_options(self):
"""Return qtrees search options allowed ."""
return self.search_options

def index(self, req):
ctxt = req.environ['delfin.context']
query_params = {}
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_qtrees_search_options())

qtrees = db.qtree_get_all(ctxt, marker, limit, sort_keys,
sort_dirs, query_params, offset)
return qtree_view.build_qtrees(qtrees)

def show(self, req, id):
ctxt = req.environ['delfin.context']
qtree = db.qtree_get(ctxt, id)
return qtree_view.build_qtree(qtree)


def create_resource():
return wsgi.Resource(QtreeController())
19 changes: 17 additions & 2 deletions delfin/api/v1/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
from delfin.api.v1 import alert_source
from delfin.api.v1 import alerts
from delfin.api.v1 import controllers
from delfin.api.v1 import ports
from delfin.api.v1 import disks
from delfin.api.v1 import filesystems
from delfin.api.v1 import performance
from delfin.api.v1 import ports
from delfin.api.v1 import qtrees
from delfin.api.v1 import shares
from delfin.api.v1 import storage_pools
from delfin.api.v1 import storages
from delfin.api.v1 import volumes
from delfin.api.v1 import performance


class APIRouter(common.APIRouter):
Expand Down Expand Up @@ -109,3 +112,15 @@ def _setup_routes(self, mapper):
self.resources['disks'] = disks.create_resource()
mapper.resource("disk", "disks",
controller=self.resources['disks'])

self.resources['filesystems'] = filesystems.create_resource()
mapper.resource("filesystems", "filesystems",
controller=self.resources['filesystems'])

self.resources['qtrees'] = qtrees.create_resource()
mapper.resource("qtrees", "qtrees",
controller=self.resources['qtrees'])

self.resources['shares'] = shares.create_resource()
mapper.resource("shares", "shares",
controller=self.resources['shares'])
54 changes: 54 additions & 0 deletions delfin/api/v1/shares.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 shares as share_view


class ShareController(wsgi.Controller):

def __init__(self):
super(ShareController, self).__init__()
self.search_options = ['name', 'status', 'id', 'storage_id',
'native_share_id']

def _get_fs_search_options(self):
"""Return shares search options allowed ."""
return self.search_options

def index(self, req):
ctxt = req.environ['delfin.context']
query_params = {}
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_fs_search_options())

shares = db.share_get_all(ctxt, marker, limit, sort_keys,
sort_dirs, query_params, offset)
return share_view.build_shares(shares)

def show(self, req, id):
ctxt = req.environ['delfin.context']
share = db.share_get(ctxt, id)
return share_view.build_share(share)


def create_resource():
return wsgi.Resource(ShareController())
26 changes: 26 additions & 0 deletions delfin/api/views/filesystems.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
import copy


def build_filesystems(filesystems):
# Build list of filesystems
views = [build_filesystem(filesystem)
for filesystem in filesystems]
return dict(filesystems=views)


def build_filesystem(filesystem):
view = copy.deepcopy(filesystem)
return dict(view)
26 changes: 26 additions & 0 deletions delfin/api/views/qtrees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
import copy


def build_qtrees(qtrees):
# Build list of qtrees
views = [build_qtree(qtree)
for qtree in qtrees]
return dict(qtrees=views)


def build_qtree(qtree):
view = copy.deepcopy(qtree)
return dict(view)
26 changes: 26 additions & 0 deletions delfin/api/views/shares.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.
import copy


def build_shares(shares):
# Build list of shares
views = [build_share(share)
for share in shares]
return dict(shares=views)


def build_share(share):
view = copy.deepcopy(share)
return dict(view)
34 changes: 34 additions & 0 deletions delfin/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,40 @@ class DiskLogicalType(object):
ALL = (FREE, MEMBER, HOTSPARE, CACHE, UNKNOWN)


class FilesystemStatus(object):
NORMAL = 'normal'
FAULTY = 'faulty'

ALL = (NORMAL, FAULTY)


class WORMType(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very clear as WORM is basically compliance or protection. Can we call it WORMProtection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Filesystem's worm type. Filesystem can be either worm or non_worm, if Filesystem is worm we give the type of worm.

NON_WORM = 'non_worm'
AUDIT_LOG = 'audit_log'
COMPLIANCE = 'compliance'
ENTERPRISE = 'enterprise'

ALL = (NON_WORM, AUDIT_LOG, COMPLIANCE, ENTERPRISE)


class NASSecurityMode(object):
MIXED = 'mixed'
NATIVE = 'native'
NTFS = 'ntfs'
UNIX = 'unix'

ALL = (MIXED, NATIVE, NTFS, UNIX)


class ShareProtocol(object):
CIFS = 'cifs'
NFS = 'nfs'
FTP = 'ftp'
wisererik marked this conversation as resolved.
Show resolved Hide resolved
HDFS = 'hdfs'

ALL = (CIFS, NFS, FTP, HDFS)


# Enumerations for alert severity
class Severity(object):
FATAL = 'Fatal'
Expand Down
Loading