-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiller
executable file
·75 lines (56 loc) · 2.15 KB
/
filler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
import argparse
import os.path
import sys
import json
import aeolus.common
import configargparse as argparse
import armonic.frontends.utils
from armonic.serialize import Serialize
from armonic.client.smart import Provide, smart_call
import armonic.frontends.smartonic
import armonic.utils
parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]), default_config_files=armonic.common.CLI_CONF)
parser.add_argument('-w', '--workspace', type=str, default=None, required=True)
cli_base = armonic.frontends.utils.CliBase(parser)
cli_local = armonic.frontends.utils.CliLocal(parser)
cli_client = armonic.frontends.utils.CliClient(parser)
args = cli_base.parse_args()
args = cli_local.parse_args()
args = cli_client.parse_args()
file_armonic_replay = args.workspace + "/" + aeolus.common.FILE_ARMONIC_REPLAY
file_armonic_replay_filled = args.workspace + "/" + aeolus.common.FILE_ARMONIC_REPLAY_FILLED
dont_call = False
autofill = True
manage = True
import armonic.common
armonic.common.SIMULATION = True
armonic.common.DONT_VALIDATE_ON_CALL = True
lfms = {}
class MyProvide(Provide):
def on_lfm(self, host):
self.lfm_host = host
self.host = host
if host not in lfms:
lfms[host] = Serialize(os_type=armonic.utils.OsTypeAll())
self.lfm = lfms[host]
def on_specialize(self, specialized):
print "In %-40s on %s" % (specialized, self.host)
def on_manage(self, data):
return True
def do_call(self):
if dont_call:
return False
else:
return True
def ignore_error_on_variable(self, variable):
if variable.type in ['armonic_host', 'host', 'armonic_hosts'] or variable.belongs_provide_ret:
#print "Variable %s validation is ignored" % variable.xpath
return True
return False
root_provide = MyProvide(generic_xpath="//*")
prefill = {}
if os.path.exists(file_armonic_replay):
with open(file_armonic_replay) as fp:
prefill = json.load(fp)
armonic.frontends.smartonic.run(root_provide, prefill, output_file=file_armonic_replay_filled, automanage=manage, autofill=autofill, autocall=True)