-
Notifications
You must be signed in to change notification settings - Fork 14
/
README.vtfp
161 lines (142 loc) · 5.22 KB
/
README.vtfp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
23/5/14 (kl2)
vtfp.pl
A utility for preprocessing template files for viv. Input should be JSON, with substitutable parameters.
Usage: vtfp.pl [-q] [-l <logname>] [-o <output_file_name>] [-keys <keyid> ...] [-vals <val> ...]
The keyid is specified in the template file with the "subst_param_name" attribute and the corresponding <val> is the value that should be substituted.
EXAMPLES (Note: newlines and spaces have been added to the JSON to aid readability)
Example template file (from examples/example_06.vtf):
{
"nodes":[
{
"id":"hello",
"type":"EXEC",
"cmd":"printf \"olleH\nyzarc\ndlrow\n\""
},
{
"id":"intercept_file",
"type":"RAFILE",
"name":{"subst_param_name":"intercept_file","required":"no","default":"ex03_hello_raw.txt"}
},
{
"id":"rev",
"type":"EXEC",
"cmd":"rev"
},
{
"id":"greetings_file",
"type":"OUTFILE",
"name":{"subst_param_name":"greetings_file","required":"yes","default":"must_replace.txt"}
}
],
"edges":[
{
"id":"hello_rev",
"from":"hello",
"to":"intercept_file"
},
{
"id":"hello_rev",
"from":"intercept_file",
"to":"rev"
},
{
"id":"output",
"from":"rev",
"to":"greetings_file"
}
]
}
Processing this with vtfp.pl in query mode ('-q' flag) gives:
kl2@sf2-farm-srv1:~/projects/viv$ grep -v "^#" examples/example_06.vtf | tr -d "\n\t" > example_06_vtf.json
kl2@sf2-farm-srv1:~/projects/viv$ bin/vtfp.pl -l ex06.log -q example_06_vtf.json
KeyID Req Id RawAttrib
greetings_file required greetings_file name
intercept_file not_required intercept_file name
Preprocessing this, specifying only the required KeyID "greetings_file" gives:
kl2@sf2-farm-srv1:~/projects/viv$ bin/vtfp.pl -l ex06.log -keys greetings_file -vals Hello.txt example_06_vtf.json
{
'nodes' => [
{
'id' => 'hello',
'type' => 'EXEC'
'cmd' => 'printf "olleH\nyzarc\ndlrow\n"',
},
{
'id' => 'intercept_file',
'type' => 'RAFILE'
'name' => 'ex03_hello_raw.txt',
},
{
'id' => 'rev',
'type' => 'EXEC'
'cmd' => 'rev',
},
{
'id' => 'greetings_file',
'type' => 'OUTFILE'
'name' => 'Hello.txt',
}
],
'edges' => [
{
'id' => 'hello_rev'
'from' => 'hello',
'to' => 'intercept_file',
},
{
'id' => 'hello_rev'
'from' => 'intercept_file',
'to' => 'rev',
},
{
'id' => 'output'
'from' => 'rev',
'to' => 'greetings_file',
}
]
}
Preprocessing this, both substitutable parameters gives:
kl2@sf2-farm-srv1:~/projects/viv$ bin/vtfp.pl -l ex06.log -keys greetings_file -vals Hello.txt -keys intercept_file -vals intercept.txt example_06_vtf.json
or:
kl2@sf2-farm-srv1:~/projects/viv$ bin/vtfp.pl -l ex06.log -keys greetings_file,intercept_file -vals Hello.txt,intercept.txt example_06_vtf.json
{
'nodes' => [
{
'id' => 'hello',
'type' => 'EXEC'
'cmd' => 'printf "olleH\nyzarc\ndlrow\n"',
},
{
'id' => 'intercept_file',
'type' => 'RAFILE'
'name' => 'intercept.txt',
},
{
'id' => 'rev',
'type' => 'EXEC'
'cmd' => 'rev',
},
{
'id' => 'greetings_file',
'type' => 'OUTFILE'
'name' => 'Hello.txt',
}
],
'edges' => [
{
'id' => 'hello_rev'
'from' => 'hello',
'to' => 'intercept_file',
},
{
'id' => 'hello_rev'
'from' => 'intercept_file',
'to' => 'rev',
},
{
'id' => 'output'
'from' => 'rev',
'to' => 'greetings_file',
}
]
}