diff --git a/adcm_client/base.py b/adcm_client/base.py index a9a7204..4826c69 100644 --- a/adcm_client/base.py +++ b/adcm_client/base.py @@ -61,7 +61,7 @@ class PagingEnds(Exception): """There are no more data in paginated mode.""" -class Paging(): +class Paging: def __init__(self, paged_object, limit=50, **args): self._paged_object = paged_object self._limit = limit @@ -123,7 +123,7 @@ def _find_endpoint(api, path): return result -class EndPoint(): +class EndPoint: def __init__(self, api, idname, path, path_args=None, awailable_filters=None): if idname is None: raise NotImplementedError @@ -237,7 +237,6 @@ def __init__(self, api: ADCMApiWrapper, path=None, path_args=None, **args): self._endpoint = EndPoint(api, self.IDNAME, path, path_args, self.FILTERS) self._api = api - self._api = api self._client = api.objects self._data = self._endpoint.search_one(**args) diff --git a/adcm_client/objects.py b/adcm_client/objects.py index 9c79e67..d3ade20 100644 --- a/adcm_client/objects.py +++ b/adcm_client/objects.py @@ -196,7 +196,6 @@ class ServicePrototype(Prototype): shared = None display_name = None required = None - shared = None components = None exports = None imports = None @@ -647,9 +646,13 @@ class Action(BaseAPIObject): type = None url = None subs = None + config = None - def config(self): - raise NotImplementedError + def _get_config(self): + config = {} + for item in self.config['config']: + config[item['name']] = item['value'] + return config def log_files(self): raise NotImplementedError @@ -662,6 +665,18 @@ def task_list(self, **args) -> "TaskList": def run(self, **args) -> "Task": with allure_step("Run action {}".format(self.name)): + + if 'config' in args and 'config_diff' in args: + raise TypeError("only one argument is expected 'config' or 'config_diff'") + + if 'config' not in args: + args['config'] = self._get_config() + + if 'config_diff' in args: + config_diff = args.pop('config_diff') + for key, value in config_diff.items(): + args['config'][key] = value + data = self._subcall("run", "create", **args) return Task(self._api, task_id=data["id"]) diff --git a/adcm_client/packer/__init__.py b/adcm_client/packer/__init__.py index e69de29..824dd6c 100644 --- a/adcm_client/packer/__init__.py +++ b/adcm_client/packer/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/adcm_client/packer/add_to_tar.py b/adcm_client/packer/add_to_tar.py index 2c5d711..dc436e6 100644 --- a/adcm_client/packer/add_to_tar.py +++ b/adcm_client/packer/add_to_tar.py @@ -1,4 +1,14 @@ - +# 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 re import sys from fnmatch import fnmatch diff --git a/adcm_client/packer/data/__init__.py b/adcm_client/packer/data/__init__.py index e69de29..824dd6c 100644 --- a/adcm_client/packer/data/__init__.py +++ b/adcm_client/packer/data/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/adcm_client/packer/naming_rules.py b/adcm_client/packer/naming_rules.py index ab2697e..5ab2005 100644 --- a/adcm_client/packer/naming_rules.py +++ b/adcm_client/packer/naming_rules.py @@ -1,3 +1,14 @@ +# 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 sys from time import gmtime, strftime diff --git a/adcm_client/packer/spec.py b/adcm_client/packer/spec.py index e3d9827..f9762ae 100644 --- a/adcm_client/packer/spec.py +++ b/adcm_client/packer/spec.py @@ -1,3 +1,14 @@ +# 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 logging import sys from os.path import join diff --git a/adcm_client/packer/types.py b/adcm_client/packer/types.py index 63dc925..df1827d 100644 --- a/adcm_client/packer/types.py +++ b/adcm_client/packer/types.py @@ -1,3 +1,15 @@ +# 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 codecs import os import random diff --git a/setup.py b/setup.py index b3d3330..0a247bf 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setuptools.setup( name="adcm_client", - version="2020.01.28.14", + version="2020.02.07.13", author="Anton Chevychalov", author_email="cab@arenadata.io", description="ArenaData Cluster Manager Client",