Class: AppAbstract
Constant Summary
collapse
- @@config_path =
ENV["SDK_CONFIG_PATH"]+"/sdk_config.json"
- @@config =
nil
Instance Method Summary
collapse
Methods included from Util
generateReport, getJSONArgs, getJSONArgsTEMP, getUrlForViewCards, log, logClose, logInit, logIt, openJSONFile
getCustomDataContext, getDataContext, http_get, http_post, putCustomDataContext, updateDataContext
Constructor Details
#initialize(param = nil) ⇒ AppAbstract
Returns a new instance of AppAbstract.
16
17
18
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 16
def initialize(param = nil)
@domain, @project, @logfile = "", "", ""
end
|
Instance Method Details
#cleanupApp ⇒ Object
109
110
111
112
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 109
def cleanupApp()
log("INFO", "\nExiting app")
end
|
#generateReport(reportFilename, reportString) ⇒ Object
46
47
48
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 46
def generateReport(reportFilename, reportString)
Util.generateReport(reportFilename, reportString)
end
|
#getAppContext(param = nil) ⇒ Object
57
58
59
60
61
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 57
def getAppContext(param = nil)
@json_input = @json_input ? @json_input : getJSONArgs()
appContext = AppContext.new(@json_input)
return appContext
end
|
#getCMContext(context) ⇒ Object
89
90
91
92
93
94
95
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 89
def getCMContext(context)
begin
return @@config[context+"_context"]
rescue
return false
end
end
|
#getDataContextFromCMDB(param) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 63
def getDataContextFromCMDB(param)
appContext = getAppContext()
params = {
"username" => @@config['username'],
"customcontext" => param["job"] + "_" + param["context"],
"action" => "listcustomcontext"
}
param.delete("context")
params = param.merge(params)
return CloudmunchService.getDataContext(appContext.get_data('masterurl'), @@config["endpoint"], params)
end
|
#getJSONArgs ⇒ Object
38
39
40
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 38
def getJSONArgs()
@json_input = Util.getJSONArgs()
end
|
#getServiceProvider(param = nil) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 50
def getServiceProvider(param = nil)
@json_input = @json_input ? @json_input : getJSONArgs()
serviceProvider = ServiceProvider.new(@json_input["providername"])
serviceProvider.load_data(@json_input)
return serviceProvider
end
|
#initializeApp ⇒ Object
101
102
103
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 101
def initializeApp()
end
|
#log(level, logString) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 26
def log(level,logString)
if @logger.nil?
logInit("DEBUG")
end
Util.logIt(@logger, @log_level, level.to_s.downcase, logString)
end
|
#logClose ⇒ Object
34
35
36
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 34
def logClose()
Util.logClose(@logger)
end
|
#logInit(log_level) ⇒ Object
21
22
23
24
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 21
def logInit(log_level)
@logger = @logger ? @logger : Util.logInit()
@log_level = log_level
end
|
#openJSONFile(fileNameWithPath) ⇒ Object
42
43
44
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 42
def openJSONFile(fileNameWithPath)
Util.openJSONFile(fileNameWithPath)
end
|
#process ⇒ Object
105
106
107
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 105
def process()
end
|
#start ⇒ Object
114
115
116
117
118
119
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 114
def start()
load_config()
initializeApp()
process()
cleanupApp()
end
|
#updateDataContextToCMDB(param) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/cloudmunch_sdk/AppAbstract.rb', line 76
def updateDataContextToCMDB(param)
appContext = getAppContext()
params = {
"username" => @@config['username'],
"customcontext" => param["job"] + "_" + param["context"],
"action" => "updatecustomcontext"
}
param.delete("context")
params = param.merge(params)
return CloudmunchService.updateDataContext(appContext.get_data('masterurl'), @@config['endpoint'], params)
end
|