-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3020: Archived S3 files shall be excluded from pipe storage & …
…pipe mount operations - pipe storage ls
- Loading branch information
1 parent
884e8fc
commit f092386
Showing
9 changed files
with
193 additions
and
18 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
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,36 @@ | ||
# Copyright 2023 EPAM Systems, Inc. (https://www.epam.com/) | ||
# | ||
# 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 .base import API | ||
from ..model.data_storage_lifecycle_model import DataStorageLifecycleModel | ||
|
||
|
||
class DataStorageLifecycle(API): | ||
|
||
def __init__(self): | ||
super(DataStorageLifecycle, self).__init__() | ||
|
||
@classmethod | ||
def load_hierarchy(cls, storage_id, path, is_file=False): | ||
api = cls.instance() | ||
request_url = '/datastorage/%s/lifecycle/restore/effectiveHierarchy?path=%s&pathType=%s' \ | ||
% (str(storage_id), path, 'FILE' if is_file else 'FOLDER&recursive=true') | ||
response_data = api.call(request_url, None) | ||
if 'payload' not in response_data: | ||
return None | ||
items = [] | ||
for lifecycles_json in response_data['payload']: | ||
lifecycle = DataStorageLifecycleModel.load(lifecycles_json) | ||
items.append(lifecycle) | ||
return items |
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,60 @@ | ||
# Copyright 2023 EPAM Systems, Inc. (https://www.epam.com/) | ||
# | ||
# 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 src.utilities import date_utilities | ||
|
||
|
||
class DataStorageLifecycleModel: | ||
|
||
def __init__(self): | ||
self.id = None | ||
self.datastorage_id = None | ||
self.user_actor_id = None | ||
self.path = None | ||
self.type = None | ||
self.restore_versions = None | ||
self.restore_mode = None | ||
self.days = None | ||
self.started = None | ||
self.updated = None | ||
self.restored_till = None | ||
self.status = None | ||
|
||
@classmethod | ||
def load(cls, json): | ||
model = DataStorageLifecycleModel() | ||
model.id = json['id'] | ||
if 'datastorageId' in json: | ||
model.datastorage_id = int(json['datastorageId']) | ||
if 'userActorId' in json: | ||
model.user_actor_id = int(json['userActorId']) | ||
if 'path' in json: | ||
model.path = json['path'] | ||
if 'type' in json: | ||
model.type = json['type'] | ||
if 'restoreVersions' in json: | ||
model.restore_versions = json['restoreVersions'] | ||
if 'restoreMode' in json: | ||
model.restore_mode = json['restoreMode'] | ||
if 'days' in json: | ||
model.days = int(json['days']) | ||
if 'started' in json: | ||
model.started = date_utilities.server_date_representation(json['started']) | ||
if 'updated' in json: | ||
model.updated = date_utilities.server_date_representation(json['updated']) | ||
if 'restoredTill' in json: | ||
model.restored_till = date_utilities.server_date_representation(json['restoredTill']) | ||
if 'status' in json: | ||
model.status = json['status'] | ||
return model |
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 2023 EPAM Systems, Inc. (https://www.epam.com/) | ||
# | ||
# 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 src.api.datastorage_lifecycle import DataStorageLifecycle | ||
|
||
|
||
class DataStorageLifecycleManager: | ||
|
||
def __init__(self, storage_id, path, is_file): | ||
self.storage_id = storage_id | ||
self.path = path | ||
self.is_file = is_file | ||
self.items = None | ||
self.sorted_paths = [] | ||
|
||
def find_lifecycle_status(self, file_path): | ||
if self.items is None: | ||
self.load_items() | ||
if not file_path.startswith('/'): | ||
file_path = '/' + file_path | ||
for path in self.sorted_paths: | ||
if path == file_path or file_path.startswith(path): | ||
item = self.items.get(path) | ||
if not item: | ||
return None, None | ||
if item.status == 'SUCCEEDED': | ||
restored_till = ' till %s' % item.restored_till\ | ||
if item.restored_till else '' | ||
return ' (Restored%s)' % restored_till, item.restore_versions | ||
else: | ||
return None, item.restore_versions | ||
return None, None | ||
|
||
def load_items(self): | ||
items = DataStorageLifecycle.load_hierarchy(self.storage_id, self.path, self.is_file) | ||
self.items = {} | ||
for item in items: | ||
self.items.update({item.path: item}) | ||
self.sorted_paths = sorted([item.path for item in items], key=len, reverse=True) |
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
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
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