/
svcdict.py
5180 lines (4814 loc) · 193 KB
/
svcdict.py
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import os
from rcGlobalEnv import rcEnv
from textwrap import TextWrapper
from rcNode import node_get_node_env
# deprecated => supported
deprecated_keywords = {
"DEFAULT.mode": None,
"DEFAULT.cluster_type": "topology",
"DEFAULT.service_type": "env",
"DEFAULT.affinity": "hard_affinity",
"DEFAULT.anti_affinity": "hard_anti_affinity",
"disk.lvm.vgname": "name",
"disk.pool.poolname": "name",
"disk.vg.vgname": "name",
"sync.rsync.exclude": "options",
"disk.zpool.poolname": "name",
"always_on": None,
}
# supported => deprecated
reverse_deprecated_keywords = {
"DEFAULT.env": "service_type",
"DEFAULT.hard_affinity": "affinity",
"DEFAULT.hard_anti_affinity": "anti_affinity",
"disk.lvm.name": "vgname",
"disk.pool.name": "poolname",
"disk.vg.name": "vgname",
"sync.rsync.options": "exclude",
"disk.zpool.name": "poolname",
}
deprecated_sections = {
"disk.pool": ["disk", "zpool"],
"drbd": ["disk", "drbd"],
"loop": ["disk", "loop"],
"pool": ["disk", "zpool"],
"vdisk": ["disk", "vdisk"],
"vmdg": ["disk", "vmdg"],
"vg": ["disk", "vg"],
}
class MissKeyNoDefault(Exception):
pass
class KeyInvalidValue(Exception):
pass
class Keyword(object):
def __init__(self, section, keyword,
rtype=None,
order=100,
required=False,
generic=False,
at=False,
inheritance="leaf > head",
scope_order="specific > generic",
default=None,
default_text=None,
candidates=None,
strict_candidates=True,
convert=None,
depends=[],
text="",
example="foo",
provisioning=False):
self.section = section
self.keyword = keyword
if rtype is None or type(rtype) == list:
self.rtype = rtype
else:
self.rtype = [rtype]
self.order = order
self.generic = generic
self.at = at
self.required = required
self.default = default
self.default_text = default_text
self.candidates = candidates
self.strict_candidates = strict_candidates
self.depends = depends
self.text = text
self.example = example
self.provisioning = provisioning
self.convert = convert
self.inheritance = inheritance
self.scope_order = scope_order
if self.default_text is None:
self.default_text = self.default
def __lt__(self, o):
return self.order < o.order
def deprecated(self):
if self.keyword in deprecated_keywords:
return True
if self.rtype is None:
if self.section+"."+self.keyword in deprecated_keywords:
return True
else:
return False
for rtype in self.rtype:
if self.section+"."+rtype+"."+self.keyword in deprecated_keywords:
return True
return False
def template(self, fmt="text", section=None):
if self.deprecated():
return ''
if fmt == "text":
return self.template_text()
elif fmt == "rst":
return self.template_rst(section=section)
else:
return ""
def template_text(self):
wrapper = TextWrapper(subsequent_indent="#%18s"%"", width=78)
depends = " && ".join(map(lambda d: "%s in %s"%(d[0], d[1]), self.depends))
if depends == "":
depends = None
if type(self.candidates) in (list, tuple, set):
candidates = " | ".join(map(lambda x: str(x), self.candidates))
else:
candidates = str(self.candidates)
if not self.strict_candidates:
candidates += " ..."
s = '#\n'
s += "# keyword: %s\n"%self.keyword
s += "# ----------------------------------------------------------------------------\n"
s += "# scopable: %s\n"%str(self.at)
s += "# required: %s\n"%str(self.required)
s += "# provisioning: %s\n"%str(self.provisioning)
s += "# default: %s\n"%str(self.default_text)
s += "# inheritance: %s\n"%str(self.inheritance)
s += "# scope order: %s\n"%str(self.scope_order)
if self.candidates:
s += "# candidates: %s\n"%candidates
if depends:
s += "# depends: %s\n"%depends
if self.convert:
s += "# convert: %s\n"%str(self.convert)
s += '#\n'
if self.text:
wrapper = TextWrapper(subsequent_indent="#%9s"%"", width=78)
s += wrapper.fill("# desc: "+self.text) + "\n"
s += '#\n'
if self.default_text is not None:
val = self.default_text
elif self.candidates and len(self.candidates) > 0:
val = self.candidates[0]
else:
val = self.example
s += ";" + self.keyword + " = " + str(val) + "\n\n"
return s
def template_rst(self, section=None):
depends = " && ".join(map(lambda d: "%s in %s"%(d[0], d[1]), self.depends))
if depends == "":
depends = None
if type(self.candidates) in (list, tuple, set):
candidates = " | ".join(map(lambda x: str(x), self.candidates))
else:
candidates = str(self.candidates)
if not self.strict_candidates:
candidates += " ..."
s = ""
if section:
s += ".. _%s.%s:\n\n" % (section, self.keyword)
s += ':kw:`%s`\n' % self.keyword
s += "=" * (len(self.keyword) + 6) + "\n"
s += "\n"
s += "================= ================================================================\n"
s += "**scopable** %s\n"%str(self.at)
s += "**required** %s\n"%str(self.required)
s += "**provisioning** %s\n"%str(self.provisioning)
s += "**default** %s\n"%str(self.default_text)
s += "**inheritance** %s\n"%str(self.inheritance)
s += "**scope order** %s\n"%str(self.scope_order)
if self.candidates:
s += "**candidates** %s\n"%candidates
if depends:
s += "**depends** %s\n"%depends
if self.convert:
s += "**convert** %s\n"%str(self.convert)
s += "================= ================================================================\n"
s += '\n'
if self.text:
s += self.text + "\n"
s += '\n'
return s
def __str__(self):
if self.deprecated():
return ''
wrapper = TextWrapper(subsequent_indent="%16s"%"", width=78)
depends = ""
for d in self.depends:
depends += "%s in %s\n"%(d[0], d[1])
if depends == "":
depends = None
if type(self.candidates) in (list, tuple, set):
candidates = " | ".join(map(lambda x: str(x), self.candidates))
else:
candidates = str(self.candidates)
if not self.strict_candidates:
candidates += " ..."
s = ''
s += "------------------------------------------------------------------------------\n"
s += "section: %s\n"%self.section
s += "keyword: %s\n"%self.keyword
s += "------------------------------------------------------------------------------\n"
s += " required: %s\n"%str(self.required)
s += " provisioning: %s\n"%str(self.provisioning)
s += " default: %s\n"%str(self.default)
s += " candidates: %s\n"%candidates
s += " depends: %s\n"%depends
s += " scopable: %s\n"%str(self.at)
if self.text:
s += wrapper.fill(" help: "+self.text)
if self.at:
s += "\n\nPrefix the value with '@<node> ', '@nodes ', '@drpnodes ', '@flex_primary', '@drp_flex_primary' or '@encapnodes '\n"
s += "to specify a scope-specific value.\n"
s += "You will be prompted for new values until you submit an empty value.\n"
s += "\n"
return s
def form(self, d):
if self.deprecated():
return
# skip this form if dependencies are not met
for d_keyword, d_value in self.depends:
if d is None:
return d
if d_keyword not in d:
return d
if d[d_keyword] not in d_value:
return d
# print() the form
print(self)
# if we got a json seed, use its values as default
# else use the Keyword object default
if d and self.keyword in d:
default = d[self.keyword]
elif self.default is not None:
default = self.default
else:
default = None
if default is not None:
default_prompt = " [%s] "%str(default)
else:
default_prompt = ""
req_satisfied = False
while True:
try:
val = raw_input(self.keyword+default_prompt+"> ")
except EOFError:
break
if len(val) == 0:
if req_satisfied:
return d
if default is None and self.required:
print("value required")
continue
# keyword is optional, leave dictionary untouched
return d
elif self.at and val[0] == '@':
l = val.split()
if len(l) < 2:
print("invalid value")
continue
val = ' '.join(l[1:])
d[self.keyword+l[0]] = val
req_satisfied = True
else:
d[self.keyword] = val
req_satisfied = True
if self.at:
# loop for more key@<scope> = values
print("More '%s' ? <enter> to step to the next parameter."%self.keyword)
continue
else:
return d
class Section(object):
def __init__(self, section):
self.section = section
self.keywords = []
def __iadd__(self, o):
if not isinstance(o, Keyword):
return self
self.keywords.append(o)
return self
def __str__(self):
s = ''
for keyword in sorted(self.keywords):
s += str(keyword)
return s
def template(self, fmt="text"):
k = self.getkey("type")
if k is None:
return self._template(fmt=fmt)
if k.candidates is None:
return self._template(fmt=fmt)
s = ""
if not k.strict_candidates:
s += self._template(fmt=fmt)
for t in k.candidates:
s += self._template(t, fmt=fmt)
return s
def _template(self, rtype=None, fmt="text"):
section = self.section
if self.section in deprecated_sections:
return ""
if rtype and self.section+"."+rtype in deprecated_sections:
return ""
if fmt == "text":
return self._template_text(rtype, section)
elif fmt == "rst":
return self._template_rst(rtype, section)
else:
return ""
def _template_text(self, rtype, section):
dpath = rcEnv.paths.pathdoc
fpath = os.path.join(dpath, "template."+section+".conf")
if rtype:
section += ", type "+rtype
fpath = os.path.join(dpath, "template."+self.section+"."+rtype+".conf")
s = "#"*78 + "\n"
s += "# %-74s #\n" % " "
s += "# %-74s #\n" % section
s += "# %-74s #\n" % " "
s += "#"*78 + "\n\n"
if section in ("DEFAULT", "env"):
s += "[%s]\n" % self.section
else:
s += "[%s#0]\n" % self.section
if rtype is not None:
s += ";type = " + rtype + "\n\n"
for keyword in sorted(self.getkeys(rtype)):
s += keyword.template(fmt="text")
for keyword in sorted(self.getprovkeys(rtype)):
s += keyword.template(fmt="text")
if rtype is not None:
for keyword in sorted(self.getkeys()):
if keyword.keyword == "type":
continue
s += keyword.template(fmt="text")
with open(fpath, "w") as f:
f.write(s)
return s
def _template_rst(self, rtype, section):
dpath = os.path.join(rcEnv.paths.pathtmp, "rst")
if not os.path.exists(dpath):
os.makedirs(dpath)
if rtype:
section += "."+rtype
fpath = os.path.join(dpath, "template."+self.section+"."+rtype+".rst")
else:
fpath = os.path.join(dpath, "template."+section+".rst")
s = section + "\n"
s += "*" * len(section) + "\n\n"
for keyword in sorted(self.getkeys(rtype)):
s += keyword.template(fmt="rst", section=section)
for keyword in sorted(self.getprovkeys(rtype)):
s += keyword.template(fmt="rst", section=section)
if rtype is not None:
for keyword in sorted(self.getkeys()):
if keyword.keyword == "type":
continue
s += keyword.template(fmt="rst", section=section)
with open(fpath, "w") as f:
f.write(s)
return s
def getkeys(self, rtype=None):
if rtype is None:
return [k for k in self.keywords if k.rtype is None and not k.provisioning]
else:
return [k for k in self.keywords if k.rtype and rtype in k.rtype and not k.provisioning]
def getprovkeys(self, rtype=None):
if rtype is None:
return [k for k in self.keywords if k.rtype is None and k.provisioning]
else:
return [k for k in self.keywords if k.rtype and rtype in k.rtype and k.provisioning]
def getkey(self, keyword, rtype=None):
if '@' in keyword:
l = keyword.split('@')
if len(l) != 2:
return
keyword, node = l
if rtype:
fkey = ".".join((self.section, rtype, keyword))
if fkey in deprecated_keywords:
keyword = deprecated_keywords[fkey]
if keyword is None:
return
for k in self.keywords:
if k.keyword != keyword:
continue
if k.rtype is None:
return k
elif isinstance(k.rtype, list) and rtype in k.rtype:
return k
elif rtype == k.rtype:
return k
else:
fkey = ".".join((self.section, keyword))
if fkey in deprecated_keywords:
keyword = deprecated_keywords[fkey]
for k in self.keywords:
if k.keyword == keyword:
return k
return
class KeywordStore(dict):
def __init__(self, provision=False):
self.sections = {}
self.provision = provision
def __iadd__(self, o):
if not isinstance(o, Keyword):
return self
o.top = self
if o.section not in self.sections:
self.sections[o.section] = Section(o.section)
self.sections[o.section] += o
return self
def __getattr__(self, key):
return self.sections[str(key)]
def __getitem__(self, key):
k = str(key)
if k not in self.sections:
return Section(k)
return self.sections[str(key)]
def __str__(self):
s = ''
for section in self.sections:
s += str(self.sections[section])
return s
def print_templates(self, fmt="text"):
for section in sorted(self.sections.keys()):
print(self.sections[section].template(fmt=fmt))
def required_keys(self, section, rtype=None):
if section not in self.sections:
return []
return [k for k in sorted(self.sections[section].getkeys(rtype)) if k.required is True]
def purge_keywords_from_dict(self, d, section):
if section == "env":
return d
if 'type' in d:
rtype = d['type']
else:
rtype = None
delete_keywords = []
for keyword, value in d.items():
key = self.sections[section].getkey(keyword)
if key is None and rtype is not None:
key = self.sections[section].getkey(keyword, rtype)
if key is None:
if keyword != "rtype":
print("Remove unknown keyword '%s' from section '%s'"%(keyword, section))
delete_keywords.append(keyword)
for keyword in delete_keywords:
del d[keyword]
return d
def update(self, rid, d):
""" Given a resource dictionary, spot missing required keys
and provide a new dictionary to merge populated by default
values
"""
import copy
completion = copy.copy(d)
# decompose rid into section and rtype
if rid in ('DEFAULT', 'env'):
section = rid
rtype = None
else:
if '#' not in rid:
return {}
l = rid.split('#')
if len(l) != 2:
return {}
section = l[0]
if 'type' in d:
rtype = d['type']
elif self[section].getkey('type') is not None and \
self[section].getkey('type').default is not None:
rtype = self[section].getkey('type').default
else:
rtype = None
# validate command line dictionary
for keyword, value in d.items():
if section == "env":
break
if section not in self.sections:
raise KeyInvalidValue("'%s' driver family is not valid in section '%s'"%(section, rid))
key = self.sections[section].getkey(keyword)
if key is None and rtype is not None:
key = self.sections[section].getkey(keyword, rtype)
if key is None:
continue
if key.strict_candidates and key.candidates is not None and value not in key.candidates:
raise KeyInvalidValue("'%s' keyword has invalid value '%s' in section '%s'"%(keyword, str(value), rid))
# add missing required keys if they have a known default value
for key in self.required_keys(section, rtype):
fkey = ".".join((section, str(rtype), key.keyword))
if fkey in deprecated_keywords:
continue
if key.keyword in d:
continue
if key.keyword in map(lambda x: x.split('@')[0], d.keys()):
continue
if key.default is None:
raise MissKeyNoDefault("No default value for required key '%s' in section '%s'"%(key.keyword, rid))
print("Implicitely add [%s] %s = %s" % (rid, key.keyword, str(key.default)))
completion[key.keyword] = key.default
# purge unknown keywords and provisioning keywords
completion = self.purge_keywords_from_dict(completion, section)
return completion
def form_sections(self, sections):
wrapper = TextWrapper(subsequent_indent="%18s"%"", width=78)
candidates = set(self.sections.keys()) - set(['DEFAULT'])
print("------------------------------------------------------------------------------")
print("Choose a resource type to add or a resource to edit.")
print("Enter 'quit' to finish the creation.")
print("------------------------------------------------------------------------------")
print(wrapper.fill("resource types: "+', '.join(candidates)))
print(wrapper.fill("resource ids: "+', '.join(sections.keys())))
print
return raw_input("resource type or id> ")
def free_resource_index(self, section, sections):
indices = []
for s in sections:
l = s.split('#')
if len(l) != 2:
continue
sname, sindex = l
if section != sname:
continue
try:
indices.append(int(sindex))
except:
continue
i = 0
while True:
if i not in indices:
return i
i += 1
def form(self, defaults, sections):
for key in sorted(self.DEFAULT.getkeys()):
defaults = key.form(defaults)
while True:
try:
section = self.form_sections(sections)
except EOFError:
break
if section == "quit":
break
if '#' in section:
rid = section
section = section.split('#')[0]
else:
index = self.free_resource_index(section, sections)
rid = '#'.join((section, str(index)))
if section not in self.sections:
print("unsupported resource type")
continue
for key in sorted(self.sections[section].getkeys()):
if rid not in sections:
sections[rid] = {}
sections[rid] = key.form(sections[rid])
if 'type' in sections[rid]:
specific_keys = self.sections[section].getkeys(rtype=sections[rid]['type'])
if len(specific_keys) > 0:
print("\nKeywords specific to the '%s' driver\n"%sections[rid]['type'])
for key in sorted(specific_keys):
if rid not in sections:
sections[rid] = {}
sections[rid] = key.form(sections[rid])
# purge the provisioning keywords
sections[rid] = self.purge_keywords_from_dict(sections[rid], section)
return defaults, sections
class KeywordLockTimeout(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="lock_timeout",
order=10,
default=60,
convert="duration",
text="A duration expression, like '1m30s'. The maximum wait time for the action lock acquire. The svcmgr --waitlock option overrides this parameter."
)
class KeywordMode(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="mode",
order=10,
default="hosted",
candidates=["hosted"],
text="Deprecated. The value is always 'hosted'. The keyword is kept around for now the ease transition from older agents."
)
class KeywordRollback(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="rollback",
at=True,
order=11,
default=True,
convert="boolean",
text="If set to False, the default rollback on action error is inhibited, leaving the service in its half-started state."
)
class KeywordCompSchedule(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="comp_schedule",
at=True,
order=11,
default="00:00-06:00@361",
text="The service compliance run schedule. See usr/share/doc/template.node.conf for the schedule syntax."
)
class KeywordStatusSchedule(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="status_schedule",
at=True,
order=11,
default="@10",
text="The service status evaluation schedule. See usr/share/doc/template.node.conf for the schedule syntax."
)
class KeywordDefaultSyncSchedule(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="sync_schedule",
at=True,
order=11,
default="04:00-06:00@121",
text="The default sync resources schedule. See usr/share/doc/template.node.conf for the schedule syntax."
)
class KeywordDefaultAws(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="aws",
at=True,
order=11,
text="The aws cli executable fullpath. If not provided, aws is expected to be found in the PATH."
)
class KeywordDefaultAwsProfile(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="aws_profile",
at=True,
default="default",
order=11,
text="The profile to use with the AWS api."
)
class KeywordResinfoSchedule(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="resinfo_schedule",
at=True,
order=11,
default="@60",
text="The service resource info push schedule. See usr/share/doc/template.node.conf for the schedule syntax."
)
class KeywordMonitorSchedule(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="monitor_schedule",
at=True,
order=11,
default="@1",
text="The service resource monitor schedule. See usr/share/doc/template.node.conf for the schedule syntax."
)
class KeywordPushSchedule(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="push_schedule",
at=True,
order=11,
default="00:00-06:00@361",
text="The service configuration emission to the collector schedule. See usr/share/doc/template.node.conf for the schedule syntax."
)
class KeywordFlexPrimary(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="flex_primary",
at=True,
order=11,
depends=[('topology', ["flex"])],
default_text="<first node of the nodes parameter>",
text="The node in charge of syncing the other nodes. --cluster actions on the flex_primary are execute on all peer nodes (ie, not drpnodes)."
)
class KeywordDrpFlexPrimary(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="drp_flex_primary",
at=True,
order=11,
depends=[('topology', ["flex"])],
default_text="<first node of the drpnodes parameter>",
text="The drpnode in charge of syncing the other drpnodes. --cluster actions on the drp_flex_primary are execute on all drpnodes (ie, not pri nodes)."
)
class KeywordDockerSwarmManagers(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="docker_swarm_managers",
order=20,
at=True,
text="List of nodes promoted as docker swarm managers.The flex primary node is implicitely a manager. Whitespace separated."
)
class KeywordDockerExe(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="docker_exe",
at=True,
order=12,
text="If you have multiple docker versions installed and want the service to stick to a version whatever the PATH definition, you should set this parameter to the full path to the docker executable.",
example="/usr/bin/docker-1.8"
)
class KeywordDockerdExe(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="dockerd_exe",
at=True,
order=12,
text="If you have multiple docker versions installed and want the service to stick to a version whatever the PATH definition, you should set this parameter to the full path to the docker daemon executable.",
example="/usr/bin/dockerd-1.8"
)
class KeywordDockerDataDir(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="docker_data_dir",
at=True,
order=12,
text="If the service has docker-type container resources and docker_daemon_private is set to True, the service handles the startup of a private docker daemon. Its socket is <pathvar>/services/<svcname>/docker.sock, and its data directory must be specified using this parameter. This organization is necessary to enable service relocalization.",
example="/srv/svc1/data/docker"
)
class KeywordDockerDaemonPrivate(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="docker_daemon_private",
at=True,
default=True,
convert="boolean",
order=11,
text="If set to False, this service will use the system's shared docker daemon instance. This is parameter is forced to False on non-Linux systems.",
example="True"
)
class KeywordDockerDaemonArgs(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="docker_daemon_args",
at=True,
order=12,
text="If the service has docker-type container resources, the service handles the startup of a private docker daemon. OpenSVC sets the socket and data dir parameters. Admins can set extra parameters using this keyword. For example, it can be useful to set the --ip parameter for a docker registry service.",
example="--ip 1.2.3.4"
)
class KeywordDockerSwarmArgs(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="DEFAULT",
keyword="docker_swarm_args",
at=True,
order=12,
text="The arguments passed to docker swarm init on the flex primary, and to docker swarm join on the the other nodes. The --token argument must not be specified, as it is handled by the agent. Scoping this parameter permits to set additional parameters on the flex_primary for use with swarm init only, like --autolock.",
example="--advertize-addr {ip#0.ipname} --listen-addr {ip#0.ipname}",
)
class KeywordSubsetParallel(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="subset",
keyword="parallel",
at=True,
candidates=(True, False),
default=False,
convert="boolean",
text="If set to true, actions are executed in parallel amongst the subset member resources.",
order=2
)
class KeywordContainerType(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="type",
at=True,
candidates=rcEnv.vt_supported,
text="The type of container.",
required=True,
order=1
)
class KeywordContainerZoneDeleteOnStop(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
rtype="zone",
keyword="delete_on_stop",
at=True,
candidates=(True, False),
text="If set to true, the zone configuration is deleted after a resource stop. The agent maintains an export of the configuration for the next start. This export is replicated to the other nodes and drp nodes so they can take over the zone even if it is completely hosted on a shared disk.",
default=False,
convert="boolean",
order=1
)
class KeywordDockerDockerService(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="docker_service",
at=True,
order=9,
rtype="docker",
default=False,
convert="boolean",
candidates=(True, False),
text="If set to True, run this container as a docker service, which is possible if the :kw:`topology` is set to flex and the docker swarm properly initialized.",
example=False
)
class KeywordDockerRunImage(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="run_image",
at=True,
required=True,
order=9,
rtype="docker",
text="The docker image pull, and run the container with.",
example="83f2a3dd2980"
)
class KeywordDockerRunCommand(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="run_command",
at=True,
order=1,
rtype="docker",
text="The command to execute in the docker container on run.",
example="/opt/tomcat/bin/catalina.sh"
)
class KeywordDockerRunArgs(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="run_args",
at=True,
order=2,
rtype="docker",
text="Extra arguments to pass to the docker run command, like volume and port mappings.",
example="-v /opt/docker.opensvc.com/vol1:/vol1:rw -p 37.59.71.25:8080:8080"
)
class KeywordVirtinst(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="virtinst",
rtype=["kvm", "xen", "ovm"],
text="The virt-install command to use to create the container.",
required=True,
provisioning=True
)
class KeywordSnap(Keyword):
def __init__(self):
Keyword.__init__(
self,
section="container",
keyword="snap",
rtype=["kvm", "xen", "ovm", "zone", "esx"],
text="The target snapshot/clone full path containing the new container disk files.",
required=True,
provisioning=True
)
class KeywordSnapof(Keyword):
def __init__(self):
Keyword.__init__(
self,