Skip to content

Commit 7d1b5d2

Browse files
Merge pull request #23 from hinashi/feature/specified_target
Add secified_target parameter to all actions
2 parents 4d51338 + 6fa6bf6 commit 7d1b5d2

27 files changed

+151
-6
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

33
## v1.2.0
4-
4+
* Add `specified_target` parameter to all actions.
55
* Added actions to operate IP address of NAT pool
66

77
## v1.1.0

actions/acoslib/action.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class BaseAction(Action):
99
DEFAULT_AXAPI_VERSION = acos.AXAPI_30
1010

1111
# These are the parameters for acos pack, not used by the ACOS Client
12-
PARAMS_FOR_PACK = ['appliance', 'action', 'object_path', 'one_target']
12+
PARAMS_FOR_PACK = ['appliance', 'action', 'object_path', 'one_target', 'specified_target']
1313

1414
def __init__(self, config):
1515
super(BaseAction, self).__init__(config)
@@ -18,9 +18,12 @@ def __init__(self, config):
1818

1919
self.config = config
2020

21-
def login(self, appliance):
21+
def login(self, target, specified_target=None):
2222
try:
23-
config = next(x for x in self.config['appliance'] if x['target'] == appliance)
23+
if specified_target:
24+
config = specified_target
25+
else:
26+
config = next(x for x in self.config['appliance'] if x['target'] == target)
2427
return acos.Client(config['target'],
2528
config['api_version'],
2629
config['userid'],
@@ -31,7 +34,7 @@ def login(self, appliance):
3134
self.logger.error(e)
3235
except StopIteration:
3336
self.logger.error("Specified appliance(%s) doesn't exist in the configuration file " %
34-
appliance)
37+
target)
3538

3639
def get_object(self, base_obj, object_path):
3740
obj = base_obj

actions/add_slb_server.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ parameters:
3636
type: string
3737
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
3838
required: true
39+
specified_target:
40+
type: object
41+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"

actions/add_slb_server_port.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ parameters:
3636
type: string
3737
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
3838
required: true
39+
specified_target:
40+
type: object
41+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"

actions/add_slb_service_group.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ parameters:
5555
type: string
5656
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
5757
required: true
58+
specified_target:
59+
type: object
60+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"

actions/add_slb_service_group_member.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ parameters:
4141
type: string
4242
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
4343
required: true
44+
specified_target:
45+
type: object
46+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"

actions/add_slb_virtual_server.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ parameters:
4141
type: string
4242
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
4343
required: true
44+
specified_target:
45+
type: object
46+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"

actions/add_slb_virtual_server_port.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ parameters:
7171
type: string
7272
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
7373
required: true
74+
specified_target:
75+
type: object
76+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"

actions/ax_action_runner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
class AXActionRunner(BaseAction):
77
def do_run(self, action, object_path, target, **kwargs):
8-
client = self.login(target)
8+
if kwargs.get('specified_target'):
9+
target = kwargs.get('specified_target').get("target")
10+
client = self.login(target, kwargs.get('specified_target'))
911
if client:
1012
try:
1113
# transforms user parameters as needed
@@ -25,6 +27,8 @@ def do_run(self, action, object_path, target, **kwargs):
2527
return (False, '[%s] Failed to initilaize Client object of acos_client' % target)
2628

2729
def run(self, action, object_path, one_target, **kwargs):
30+
if kwargs.get('specified_target'):
31+
return self.do_run(action, object_path, None, **kwargs)
2832
if one_target or kwargs.get('appliance'):
2933
return self.do_run(action, object_path, kwargs.get('appliance'), **kwargs)
3034
else:

actions/create_ip_nat_pool.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ parameters:
2020
appliance:
2121
type: string
2222
description: The appliance information to connect, which is specified at the 'appliance' parameter in the configuration.
23+
specified_target:
24+
type: object
25+
description: "Specify the target dynamically, (key: 'target', 'api_version', 'userid', 'passwd')"
2326
pool_name:
2427
type: string
2528
description: Pool name or pool group

0 commit comments

Comments
 (0)