Skip to content

Commit

Permalink
Update model changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-v committed Mar 3, 2021
1 parent 4fdb14c commit 5be7fcb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 76 deletions.
29 changes: 14 additions & 15 deletions delfin/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,27 @@ class DiskLogicalType(object):

class FilesystemStatus(object):
NORMAL = 'normal'
OFFLINE = 'offline'
UNKNOWN = 'unknown'
FAULTY = 'faulty'

ALL = (NORMAL, OFFLINE, UNKNOWN)
ALL = (NORMAL, FAULTY)


class WORMType(object):
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'
WINDOWS = 'windows'
NTFS = 'ntfs'
UNIX = 'unix'

ALL = (MIXED, NATIVE, WINDOWS, UNIX)
ALL = (MIXED, NATIVE, NTFS, UNIX)


class QuotaState(object):
Expand All @@ -174,7 +182,7 @@ class QuotaState(object):
ALL = (NORMAL, SOFT, HARD, ABNORMAL)


class ShareType(object):
class ShareProtocol(object):
CIFS = 'cifs'
NFS = 'nfs'
FTP = 'ftp'
Expand All @@ -183,15 +191,6 @@ class ShareType(object):
ALL = (CIFS, NFS, FTP, UNKNOWN)


class ShareOfflineMode(object):
MANUAL = 'manual'
DOCUMENTS = 'documents'
PROGRAMS = 'programs'
NONE = 'none'

ALL = (MANUAL, DOCUMENTS, PROGRAMS, NONE)


# Enumerations for alert severity
class Severity(object):
FATAL = 'Fatal'
Expand Down
21 changes: 6 additions & 15 deletions delfin/db/sqlalchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ class Filesystem(BASE, DelfinBase):
storage_id = Column(String(36))
native_filesystem_id = Column(String(255))
status = Column(String(255))
allocation_type = Column(String(255))
type = Column(String(255))
security_mode = Column(String(255))
total_capacity = Column(BigInteger)
used_capacity = Column(BigInteger)
free_capacity = Column(BigInteger)
compression = Column(Boolean)
deduplication = Column(Boolean)
worm = Column(Boolean)
compressed = Column(Boolean)
deduplicated = Column(Boolean)
worm = Column(String(255))


class Qtree(BASE, DelfinBase):
Expand All @@ -201,15 +201,8 @@ class Qtree(BASE, DelfinBase):
storage_id = Column(String(36))
native_qtree_id = Column(String(255))
native_filesystem_id = Column(String(255))
capacity_hard_limit = Column(BigInteger)
capacity_soft_limit = Column(BigInteger)
file_hard_limit = Column(BigInteger)
file_soft_limit = Column(BigInteger)
used_capacity = Column(BigInteger)
file_count = Column(BigInteger)
path = Column(String(255))
security_mode = Column(String(255))
state = Column(String(255))


class Share(BASE, DelfinBase):
Expand All @@ -220,10 +213,8 @@ class Share(BASE, DelfinBase):
storage_id = Column(String(36))
native_share_id = Column(String(255))
native_filesystem_id = Column(String(255))
qtree_id = Column(String(255))
type = Column(String(255))
offline_mode = Column(String(255))
oplock = Column(Boolean)
native_qtree_id = Column(String(255))
protocol = Column(String(255))
path = Column(String(255))


Expand Down
40 changes: 11 additions & 29 deletions delfin/drivers/fake_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ def list_filesystems(self, ctx):
boolean = [True, False]
sts = list(constants.FilesystemStatus.ALL)
sts_len = len(constants.FilesystemStatus.ALL) - 1
worm = list(constants.WORMType.ALL)
worm_len = len(constants.WORMType.ALL) - 1
alloc_type = list(constants.VolumeType.ALL)
alloc_type_len = len(constants.VolumeType.ALL) - 1
security = list(constants.NASSecurityMode.ALL)
Expand All @@ -287,15 +289,14 @@ def list_filesystems(self, ctx):
"storage_id": self.storage_id,
"native_filesystem_id": "fake_original_id_" + str(idx),
"status": sts[random.randint(0, sts_len)],
"allocation_type":
alloc_type[random.randint(0, alloc_type_len)],
"type": alloc_type[random.randint(0, alloc_type_len)],
"security_mode": security[random.randint(0, security_len)],
"total_capacity": total,
"used_capacity": used,
"free_capacity": free,
"worm": boolean[random.randint(0, 1)],
"deduplication": boolean[random.randint(0, 1)],
"compression": boolean[random.randint(0, 1)],
"worm": worm[random.randint(0, worm_len)],
"deduplicated": boolean[random.randint(0, 1)],
"compressed": boolean[random.randint(0, 1)],
}
filesystem_list.append(c)
return filesystem_list
Expand All @@ -306,28 +307,14 @@ def list_qtrees(self, ctx):
% (self.storage_id, rd_qtrees_count))
qtree_list = []
for idx in range(rd_qtrees_count):
state = list(constants.QuotaState.ALL)
state_len = len(constants.QuotaState.ALL) - 1
security = list(constants.NASSecurityMode.ALL)
security_len = len(constants.NASSecurityMode.ALL) - 1
c_limit = random.randint(1000, 2000)
h_limit = int(random.randint(0, 100) * c_limit / 100)
s_limit = int(random.randint(0, 100) * h_limit / 100)
fc_limit = random.randint(1000, 2000)
fh_limit = int(random.randint(0, 100) * fc_limit / 100)
fs_limit = int(random.randint(0, 100) * fh_limit / 100)

c = {
"name": "fake_qtree_" + str(idx),
"storage_id": self.storage_id,
"native_qtree_id": "fake_original_id_" + str(idx),
"native_filesystem_id": "fake_filesystem_id_" + str(idx),
"capacity_hard_limit": h_limit,
"capacity_soft_limit": s_limit,
"file_hard_limit": fh_limit,
"file_soft_limit": fs_limit,
"used_capacity": c_limit,
"file_count": fc_limit,
"state": state[random.randint(0, state_len)],
"security_mode": security[random.randint(0, security_len)],
"path": "/",
}
Expand All @@ -340,20 +327,15 @@ def list_shares(self, ctx):
% (self.storage_id, rd_shares_count))
share_list = []
for idx in range(rd_shares_count):
boolean = [True, False]
st = list(constants.ShareType.ALL)
st_len = len(constants.ShareType.ALL) - 1
mode = list(constants.ShareOfflineMode.ALL)
mode_len = len(constants.ShareOfflineMode.ALL) - 1
pro = list(constants.ShareProtocol.ALL)
pro_len = len(constants.ShareProtocol.ALL) - 1
c = {
"name": "fake_share_" + str(idx),
"storage_id": self.storage_id,
"native_share_id": "fake_original_id_" + str(idx),
"native_filesystem_id": "fake_filesystem_id_" + str(idx),
"qtree_id": random.randint(0, 1000),
"type": st[random.randint(0, st_len)],
"offline_mode": mode[random.randint(0, mode_len)],
"oplock": boolean[random.randint(0, 1)],
"native_qtree_id": "fake_qtree_id_" + str(idx),
"protocol": pro[random.randint(0, pro_len)],
"path": "/",
}
share_list.append(c)
Expand Down
25 changes: 8 additions & 17 deletions delfin/tests/unit/task_manager/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@
"name": "fake_filesystem_" + str(id),
"storage_id": "793b26f9-6f16-4fd5-a6a2-d7453f050a41",
"native_filesystem_id": "fake_original_id_" + str(id),
"status": "offline",
"allocation_type": "thin",
"status": "normal",
"type": "thin",
"security_mode": "unix",
"total_capacity": 1055,
"used_capacity": 812,
"free_capacity": 243,
"compression": True,
"deduplication": False,
"worm": True
"compressed": True,
"deduplicated": False,
"worm": "non_worm"
}
]

Expand All @@ -142,15 +142,8 @@
"storage_id": "793b26f9-6f16-4fd5-a6a2-d7453f050a41",
"native_qtree_id": "fake_original_id_" + str(id),
"native_filesystem_id": "fake_filesystem_id_" + str(id),
"capacity_hard_limit": 316,
"capacity_soft_limit": 170,
"file_hard_limit": 1726,
"file_soft_limit": 759,
"used_capacity": 1093,
"file_count": 1726,
"path": "/",
"security_mode": "native",
"state": "normal"
"security_mode": "native"
}
]

Expand All @@ -161,10 +154,8 @@
"storage_id": "793b26f9-6f16-4fd5-a6a2-d7453f050a41",
"native_share_id": "fake_original_id_" + str(id),
"native_filesystem_id": "fake_filesystem_id_" + str(id),
"qtree_id": "859",
"type": "nfs",
"offline_mode": "none",
"oplock": True,
"native_qtree_id": "859",
"protocol": "nfs",
"path": "/"
}
]
Expand Down

0 comments on commit 5be7fcb

Please sign in to comment.