Skip to content

Commit

Permalink
Merge pull request #14 from arenadata/adcm-681
Browse files Browse the repository at this point in the history
ADCM-681 Adding default parameter passing for actions
  • Loading branch information
acmnu authored Feb 10, 2020
2 parents 473038a + ada29bc commit d3cdb63
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 8 deletions.
5 changes: 2 additions & 3 deletions adcm_client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 18 additions & 3 deletions adcm_client/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class ServicePrototype(Prototype):
shared = None
display_name = None
required = None
shared = None
components = None
exports = None
imports = None
Expand Down Expand Up @@ -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
Expand All @@ -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"])

Expand Down
11 changes: 11 additions & 0 deletions adcm_client/packer/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 11 additions & 1 deletion adcm_client/packer/add_to_tar.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions adcm_client/packer/data/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions adcm_client/packer/naming_rules.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 11 additions & 0 deletions adcm_client/packer/spec.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions adcm_client/packer/types.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setuptools.setup(
name="adcm_client",
version="2020.01.28.14",
version="2020.02.07.13",
author="Anton Chevychalov",
author_email="[email protected]",
description="ArenaData Cluster Manager Client",
Expand Down

0 comments on commit d3cdb63

Please sign in to comment.