forked from puppetlabs/SplunkTAforPuppetEnterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuppet_enterprise_factors.py
110 lines (92 loc) · 5.05 KB
/
puppet_enterprise_factors.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
import splunktaforpuppetenterprise_declare
import os
import sys
import time
import datetime
import json
import modinput_wrapper.base_modinput
from solnlib.packages.splunklib import modularinput as smi
import input_module_puppet_enterprise_factors as input_module
bin_dir = os.path.basename(__file__)
'''
Do not edit this file!!!
This file is generated by Add-on builder automatically.
Add your modular input logic to file input_module_puppet_enterprise_factors.py
'''
class ModInputpuppet_enterprise_factors(modinput_wrapper.base_modinput.BaseModInput):
def __init__(self):
if 'use_single_instance_mode' in dir(input_module):
use_single_instance = input_module.use_single_instance_mode()
else:
use_single_instance = False
super(ModInputpuppet_enterprise_factors, self).__init__("splunktaforpuppetenterprise", "puppet_enterprise_factors", use_single_instance)
self.global_checkbox_fields = None
def get_scheme(self):
"""overloaded splunklib modularinput method"""
scheme = super(ModInputpuppet_enterprise_factors, self).get_scheme()
scheme.title = ("Puppet Enterprise Factors")
scheme.description = ("Go to the add-on\'s configuration UI and configure modular inputs under the Inputs menu.")
scheme.use_external_validation = True
scheme.streaming_mode_xml = True
scheme.add_argument(smi.Argument("name", title="Name",
description="",
required_on_create=True))
"""
For customized inputs, hard code the arguments here to hide argument detail from users.
For other input types, arguments should be get from input_module. Defining new input types could be easier.
"""
scheme.add_argument(smi.Argument("token_", title="Token:",
description="curl -k -X POST -H \'Content-Type: application/json\' -d \'{\"login\": \"\", \"password\": \"\",\"lifetime\": \"9y\" }\' https://$:4433/rbac-api/v1/auth/token",
required_on_create=True,
required_on_edit=False))
scheme.add_argument(smi.Argument("token_generation_date_", title="Token Generation Date:",
description="Input the date when you generated your token.",
required_on_create=True,
required_on_edit=False))
scheme.add_argument(smi.Argument("server_", title="Server:",
description="Input your Puppet Enterprise Server address.",
required_on_create=True,
required_on_edit=False))
scheme.add_argument(smi.Argument("puppet_enterprise_server_", title="Puppet Enterprise Server:",
description="Input your Puppet Enterprise Server",
required_on_create=True,
required_on_edit=False))
scheme.add_argument(smi.Argument("port_", title="Port:",
description="Input your Puppet Enterprise DB Port (HTTPS 8081, HTTP: 8080)",
required_on_create=True,
required_on_edit=False))
scheme.add_argument(smi.Argument("environment", title="Environment",
description="Puppet Enterprise Environment you want to monitor.",
required_on_create=True,
required_on_edit=False))
return scheme
def get_app_name(self):
return "SplunkTAforPuppetEnterprise"
def validate_input(self, definition):
"""validate the input stanza"""
input_module.validate_input(self, definition)
def collect_events(self, ew):
"""write out the events"""
input_module.collect_events(self, ew)
def get_account_fields(self):
account_fields = []
return account_fields
def get_checkbox_fields(self):
checkbox_fields = []
return checkbox_fields
def get_global_checkbox_fields(self):
if self.global_checkbox_fields is None:
checkbox_name_file = os.path.join(bin_dir, 'global_checkbox_param.json')
try:
if os.path.isfile(checkbox_name_file):
with open(checkbox_name_file, 'r') as fp:
self.global_checkbox_fields = json.load(fp)
else:
self.global_checkbox_fields = []
except Exception as e:
self.log_error('Get exception when loading global checkbox parameter names. ' + str(e))
self.global_checkbox_fields = []
return self.global_checkbox_fields
if __name__ == "__main__":
exitcode = ModInputpuppet_enterprise_factors().run(sys.argv)
sys.exit(exitcode)