cloudmunch_sdk 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cloudmunch_Ruby_sdk_v2/AppAbstract.rb +60 -71
- data/lib/cloudmunch_Ruby_sdk_v2/AppContext.rb +44 -2
- data/lib/cloudmunch_Ruby_sdk_v2/AssetHelper.rb +127 -0
- data/lib/cloudmunch_Ruby_sdk_v2/CloudmunchConstants.rb +24 -0
- data/lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb +88 -546
- data/lib/cloudmunch_Ruby_sdk_v2/ElasticBeanStalkServer.rb +52 -0
- data/lib/cloudmunch_Ruby_sdk_v2/EnvironmentHelper.rb +292 -0
- data/lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb +770 -0
- data/lib/cloudmunch_Ruby_sdk_v2/IntegrationHelper.rb +69 -0
- data/lib/cloudmunch_Ruby_sdk_v2/PluginLoaderAbstract.rb +140 -0
- data/lib/cloudmunch_Ruby_sdk_v2/PluginReporterAbstract.rb +141 -0
- data/lib/cloudmunch_Ruby_sdk_v2/RoleHelper.rb +170 -0
- data/lib/cloudmunch_Ruby_sdk_v2/Server.rb +77 -0
- data/lib/cloudmunch_Ruby_sdk_v2/ServerHelper.rb +284 -0
- data/lib/cloudmunch_Ruby_sdk_v2/ServiceProvider.rb +10 -2
- data/lib/cloudmunch_Ruby_sdk_v2/Util.rb +30 -35
- data/lib/cloudmunch_Ruby_sdk_v2/version.rb +1 -1
- metadata +13 -11
- data/lib/cloudmunch_Ruby_sdk_v2/templates/costview_meta.json +0 -22
- data/lib/cloudmunch_Ruby_sdk_v2/templates/coverageview_meta.json +0 -34
- data/lib/cloudmunch_Ruby_sdk_v2/templates/defecttrendview_meta.json +0 -67
- data/lib/cloudmunch_Ruby_sdk_v2/templates/ilityview_meta.json +0 -66
- data/lib/cloudmunch_Ruby_sdk_v2/templates/inboundoutboundview_meta.json +0 -67
- data/lib/cloudmunch_Ruby_sdk_v2/templates/riskview_meta.json +0 -19
- data/lib/cloudmunch_Ruby_sdk_v2/templates/scopeview_meta.json +0 -60
- data/lib/cloudmunch_Ruby_sdk_v2/templates/timeview_meta.json +0 -60
- data/lib/cloudmunch_Ruby_sdk_v2/templates/velocityview_meta.json +0 -22
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
###
|
3
|
+
### (c) CloudMunch Inc.
|
4
|
+
### All Rights Reserved
|
5
|
+
### Un-authorized copying of this file, via any medium is strictly prohibited
|
6
|
+
### Proprietary and confidential
|
7
|
+
###
|
8
|
+
### ganesan@cloudmunch.com
|
9
|
+
###
|
10
|
+
|
11
|
+
$LOAD_PATH << '.'
|
12
|
+
require 'json'
|
13
|
+
require_relative "CloudmunchConstants"
|
14
|
+
|
15
|
+
class IntegrationHelper
|
16
|
+
include CloudmunchService
|
17
|
+
include Util
|
18
|
+
|
19
|
+
@appContext = nil;
|
20
|
+
@logHelper = nil;
|
21
|
+
|
22
|
+
def initialize()
|
23
|
+
end
|
24
|
+
|
25
|
+
def getService(jsonParams)
|
26
|
+
cloudproviders = jsonParams["cloudproviders"]
|
27
|
+
cloudproviders = JSON.parse(cloudproviders)
|
28
|
+
providerName = jsonParams["providername"]
|
29
|
+
log("DEBUG", "Provider Name: " + providerName)
|
30
|
+
integrationDetailsHash = nil
|
31
|
+
|
32
|
+
if !providerName.nil? && providerName.chop.length > 0 then
|
33
|
+
regFields = cloudproviders[providerName]
|
34
|
+
|
35
|
+
integrationDetailsHash = {}
|
36
|
+
regFields.each do |k,v|
|
37
|
+
integrationDetailsHash[k] = v
|
38
|
+
end
|
39
|
+
|
40
|
+
return integrationDetailsHash
|
41
|
+
else
|
42
|
+
return nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def getIntegration(jsonParams, integrationHash)
|
48
|
+
providerName = jsonParams["providername"]
|
49
|
+
log("DEBUG", "Provider Name: " + providerName)
|
50
|
+
integrationDetailsHash = nil
|
51
|
+
|
52
|
+
if !providerName.nil? && providerName.chop.length > 0 then
|
53
|
+
regFields = integrationHash[providerName]["configuration"]
|
54
|
+
|
55
|
+
integrationDetailsHash = {}
|
56
|
+
regFields.each do |k,v|
|
57
|
+
integrationDetailsHash[k] = v
|
58
|
+
end
|
59
|
+
|
60
|
+
return integrationDetailsHash
|
61
|
+
else
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
$LOAD_PATH << '.'
|
3
|
+
|
4
|
+
require_relative "CloudmunchService"
|
5
|
+
require_relative "Util"
|
6
|
+
require_relative "ServiceProvider"
|
7
|
+
require_relative "AppContext"
|
8
|
+
|
9
|
+
class AppAbstract
|
10
|
+
include CloudmunchService
|
11
|
+
include Util
|
12
|
+
|
13
|
+
@@config = nil
|
14
|
+
|
15
|
+
def initialize(param = nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def logInit(log_level)
|
20
|
+
@logger = @logger ? @logger : Util.logInit()
|
21
|
+
@log_level = log_level
|
22
|
+
end
|
23
|
+
|
24
|
+
def log(level,logString)
|
25
|
+
if @logger.nil?
|
26
|
+
logInit("DEBUG")
|
27
|
+
end
|
28
|
+
Util.logIt(@logger, @log_level, level.to_s.downcase, logString)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def logClose()
|
33
|
+
Util.logClose(@logger)
|
34
|
+
end
|
35
|
+
|
36
|
+
def getJSONArgs()
|
37
|
+
jsonin = nil
|
38
|
+
varin=nil
|
39
|
+
integrations=nil
|
40
|
+
loop { case ARGV[0]
|
41
|
+
when '-jsoninput' then ARGV.shift; jsonin = ARGV.shift
|
42
|
+
when '-variables' then ARGV.shift; varin = ARGV.shift
|
43
|
+
when '-integrations' then ARGV.shift; integrations = ARGV.shift
|
44
|
+
|
45
|
+
when /^-/ then usage("Unknown option: #{ARGV[0].inspect}")
|
46
|
+
else break
|
47
|
+
end; }
|
48
|
+
@json_input = JSON.load(jsonin)
|
49
|
+
@var_input =JSON.load(varin)
|
50
|
+
@integration_input=JSON.load(integrations)
|
51
|
+
createAppContext();
|
52
|
+
return @json_input
|
53
|
+
end
|
54
|
+
|
55
|
+
def createAppContext()
|
56
|
+
@appContext = AppContext.new(@var_input)
|
57
|
+
end
|
58
|
+
|
59
|
+
def getAppContext()
|
60
|
+
return @appContext
|
61
|
+
end
|
62
|
+
|
63
|
+
def getCloudmunchContext(context)
|
64
|
+
begin
|
65
|
+
return @@config[context+"_context"]
|
66
|
+
rescue
|
67
|
+
return false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def getCloudmunchService()
|
72
|
+
@cloudmunchservice = self.extend(CloudmunchService)
|
73
|
+
return @cloudmunchservice
|
74
|
+
end
|
75
|
+
|
76
|
+
def getIntegrationDetails(param = nil)
|
77
|
+
serviceProvider = ServiceProvider.new(@json_input["providername"])
|
78
|
+
serviceProvider.load_data(@integration_input)
|
79
|
+
return serviceProvider
|
80
|
+
end
|
81
|
+
|
82
|
+
def initializeApp()
|
83
|
+
end
|
84
|
+
|
85
|
+
def process()
|
86
|
+
end
|
87
|
+
|
88
|
+
def cleanupApp()
|
89
|
+
log("INFO", "\nExiting app")
|
90
|
+
end
|
91
|
+
|
92
|
+
def start()
|
93
|
+
initializeApp()
|
94
|
+
process()
|
95
|
+
cleanupApp()
|
96
|
+
end
|
97
|
+
|
98
|
+
# def openJSONFile(fileNameWithPath)
|
99
|
+
# Util.openJSONFile(fileNameWithPath)
|
100
|
+
# end
|
101
|
+
|
102
|
+
# def generateReport(reportFilename, reportString)
|
103
|
+
# Util.generateReport(reportFilename, reportString)
|
104
|
+
# end
|
105
|
+
|
106
|
+
# def getDataContextFromCMDB(param)
|
107
|
+
# appContext = getAppContext()
|
108
|
+
# params = {
|
109
|
+
# "username" => @@config['username'],
|
110
|
+
# "customcontext" => param["job"] + "_" + param["context"],
|
111
|
+
# "action" => "listcustomcontext"
|
112
|
+
# }
|
113
|
+
# param.delete("context")
|
114
|
+
# params = param.merge(params)
|
115
|
+
|
116
|
+
# return CloudmunchService.getDataContext(appContext.get_data('masterurl'), @@config["endpoint"], params)
|
117
|
+
# end
|
118
|
+
|
119
|
+
# def updateDataContextToCMDB(param)
|
120
|
+
# appContext = getAppContext()
|
121
|
+
# params = {
|
122
|
+
# "username" => @@config['username'],
|
123
|
+
# "customcontext" => param["job"] + "_" + param["context"],
|
124
|
+
# "action" => "updatecustomcontext"
|
125
|
+
# }
|
126
|
+
# param.delete("context")
|
127
|
+
# params = param.merge(params)
|
128
|
+
# return CloudmunchService.updateDataContext(appContext.get_data('masterurl'), @@config['endpoint'], params)
|
129
|
+
# end
|
130
|
+
|
131
|
+
# def getTemplate(template_name)
|
132
|
+
# begin
|
133
|
+
# Util.getTemplate(template_name)
|
134
|
+
# rescue
|
135
|
+
# return false
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
|
139
|
+
|
140
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
$LOAD_PATH << '.'
|
3
|
+
|
4
|
+
require_relative "CloudmunchService"
|
5
|
+
require_relative "Util"
|
6
|
+
require_relative "ServiceProvider"
|
7
|
+
require_relative "AppContext"
|
8
|
+
|
9
|
+
class AppAbstract
|
10
|
+
include CloudmunchService
|
11
|
+
include Util
|
12
|
+
|
13
|
+
@@config = nil
|
14
|
+
|
15
|
+
def initialize(param = nil)
|
16
|
+
@domain, @project, @logfile = "", "", ""
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def logInit(log_level)
|
21
|
+
@logger = @logger ? @logger : Util.logInit()
|
22
|
+
@log_level = log_level
|
23
|
+
end
|
24
|
+
|
25
|
+
def log(level,logString)
|
26
|
+
if @logger.nil?
|
27
|
+
logInit("DEBUG")
|
28
|
+
end
|
29
|
+
Util.logIt(@logger, @log_level, level.to_s.downcase, logString)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def logClose()
|
34
|
+
Util.logClose(@logger)
|
35
|
+
end
|
36
|
+
|
37
|
+
def getJSONArgs()
|
38
|
+
jsonin = nil
|
39
|
+
varin=nil
|
40
|
+
integrations=nil
|
41
|
+
loop { case ARGV[0]
|
42
|
+
when '-jsoninput' then ARGV.shift; jsonin = ARGV.shift
|
43
|
+
when '-variables' then ARGV.shift; varin = ARGV.shift
|
44
|
+
when '-integrations' then ARGV.shift; integrations = ARGV.shift
|
45
|
+
|
46
|
+
when /^-/ then usage("Unknown option: #{ARGV[0].inspect}")
|
47
|
+
else break
|
48
|
+
end; }
|
49
|
+
@json_input = JSON.load(jsonin)
|
50
|
+
@var_input =JSON.load(varin)
|
51
|
+
@integration_input=JSON.load(integrations)
|
52
|
+
createAppContext();
|
53
|
+
return @json_input
|
54
|
+
end
|
55
|
+
|
56
|
+
def createAppContext()
|
57
|
+
@appContext = AppContext.new(@var_input)
|
58
|
+
end
|
59
|
+
|
60
|
+
def getAppContext()
|
61
|
+
return @appContext
|
62
|
+
end
|
63
|
+
|
64
|
+
def getCloudmunchContext(context)
|
65
|
+
begin
|
66
|
+
return @@config[context+"_context"]
|
67
|
+
rescue
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def getCloudmunchService()
|
73
|
+
@cloudmunchservice = self.extend(CloudmunchService)
|
74
|
+
return @cloudmunchservice
|
75
|
+
end
|
76
|
+
|
77
|
+
def getIntegrationDetails(param = nil)
|
78
|
+
serviceProvider = ServiceProvider.new(@json_input["providername"])
|
79
|
+
serviceProvider.load_data(@integration_input)
|
80
|
+
return serviceProvider
|
81
|
+
end
|
82
|
+
|
83
|
+
def initializeApp()
|
84
|
+
end
|
85
|
+
|
86
|
+
def process()
|
87
|
+
end
|
88
|
+
|
89
|
+
def cleanupApp()
|
90
|
+
log("INFO", "\nExiting app")
|
91
|
+
end
|
92
|
+
|
93
|
+
def start()
|
94
|
+
initializeApp()
|
95
|
+
process()
|
96
|
+
cleanupApp()
|
97
|
+
end
|
98
|
+
|
99
|
+
# def openJSONFile(fileNameWithPath)
|
100
|
+
# Util.openJSONFile(fileNameWithPath)
|
101
|
+
# end
|
102
|
+
|
103
|
+
# def generateReport(reportFilename, reportString)
|
104
|
+
# Util.generateReport(reportFilename, reportString)
|
105
|
+
# end
|
106
|
+
|
107
|
+
# def getDataContextFromCMDB(param)
|
108
|
+
# appContext = getAppContext()
|
109
|
+
# params = {
|
110
|
+
# "username" => @@config['username'],
|
111
|
+
# "customcontext" => param["job"] + "_" + param["context"],
|
112
|
+
# "action" => "listcustomcontext"
|
113
|
+
# }
|
114
|
+
# param.delete("context")
|
115
|
+
# params = param.merge(params)
|
116
|
+
|
117
|
+
# return CloudmunchService.getDataContext(appContext.get_data('masterurl'), @@config["endpoint"], params)
|
118
|
+
# end
|
119
|
+
|
120
|
+
# def updateDataContextToCMDB(param)
|
121
|
+
# appContext = getAppContext()
|
122
|
+
# params = {
|
123
|
+
# "username" => @@config['username'],
|
124
|
+
# "customcontext" => param["job"] + "_" + param["context"],
|
125
|
+
# "action" => "updatecustomcontext"
|
126
|
+
# }
|
127
|
+
# param.delete("context")
|
128
|
+
# params = param.merge(params)
|
129
|
+
# return CloudmunchService.updateDataContext(appContext.get_data('masterurl'), @@config['endpoint'], params)
|
130
|
+
# end
|
131
|
+
|
132
|
+
# def getTemplate(template_name)
|
133
|
+
# begin
|
134
|
+
# Util.getTemplate(template_name)
|
135
|
+
# rescue
|
136
|
+
# return false
|
137
|
+
# end
|
138
|
+
# end
|
139
|
+
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
###
|
3
|
+
### (c) CloudMunch Inc.
|
4
|
+
### All Rights Reserved
|
5
|
+
### Un-authorized copying of this file, via any medium is strictly prohibited
|
6
|
+
### Proprietary and confidential
|
7
|
+
###
|
8
|
+
### ganesan@cloudmunch.com
|
9
|
+
###
|
10
|
+
|
11
|
+
$LOAD_PATH << '.'
|
12
|
+
require 'json'
|
13
|
+
require_relative "CloudmunchConstants"
|
14
|
+
|
15
|
+
class RoleHelper
|
16
|
+
include CloudmunchService
|
17
|
+
include Util
|
18
|
+
|
19
|
+
@appContext = nil;
|
20
|
+
@cmDataManager = nil;
|
21
|
+
@logHelper = nil;
|
22
|
+
|
23
|
+
def initialize(appContext)
|
24
|
+
@appContext = appContext
|
25
|
+
@cloudmunchDataService = CloudmunchService.new
|
26
|
+
end
|
27
|
+
|
28
|
+
# ###
|
29
|
+
# ### Check if given name of the role is unique with existing ones
|
30
|
+
# ### @param string roleName : name of the environment name to be created
|
31
|
+
# ### @param string existingRoles : list of existing environments
|
32
|
+
# ### @return boolean true if name is unique
|
33
|
+
# ###
|
34
|
+
def isRoleNameUnique(existingRoles, roleName)
|
35
|
+
existingRoles.each do |k,v|
|
36
|
+
if v["name"] == roleName then
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
|
43
|
+
# ###
|
44
|
+
# ###
|
45
|
+
# ### @param Json Object $filterdata In the format {"filterfield":"=value"}
|
46
|
+
# ### @return json object roledetails
|
47
|
+
# ###
|
48
|
+
# ###
|
49
|
+
def getExistingRoles(filterData)
|
50
|
+
paramHash = {}
|
51
|
+
if !filterData.nil?
|
52
|
+
paramHash["filter"] = filterData.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/tiers"
|
56
|
+
roleResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(), paramHash)
|
57
|
+
|
58
|
+
if roleResult == nil then
|
59
|
+
log("ERROR", "Unable to get data from cloudmunch")
|
60
|
+
return nil
|
61
|
+
else
|
62
|
+
roleResult = JSON.parse(roleResult)
|
63
|
+
roleData = roleResult["data"]
|
64
|
+
if roleData.nil? then
|
65
|
+
log("ERROR", "Role does not exist")
|
66
|
+
return nil
|
67
|
+
else
|
68
|
+
return roleData
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# ###
|
74
|
+
# ###
|
75
|
+
# ### @param String $roleID
|
76
|
+
# ### @param Json Object $filterdata In the format {"filterfield":"=value"}
|
77
|
+
# ### @return json object roledetails
|
78
|
+
# ###
|
79
|
+
# ###
|
80
|
+
def getRole(roleID, filterData)
|
81
|
+
paramHash = {}
|
82
|
+
if !filterData.nil?
|
83
|
+
paramHash["filter"] = filterData.to_json
|
84
|
+
end
|
85
|
+
|
86
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/tiers/" + roleID
|
87
|
+
roleResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(), paramHash)
|
88
|
+
|
89
|
+
if roleResult == nil then
|
90
|
+
log("ERROR", "Unable to get data from cloudmunch")
|
91
|
+
return nil
|
92
|
+
else
|
93
|
+
roleResult = JSON.parse(roleResult)
|
94
|
+
roleData = roleResult["data"]
|
95
|
+
if roleData.nil? then
|
96
|
+
log("ERROR", "Role does not exist")
|
97
|
+
return nil
|
98
|
+
else
|
99
|
+
return roleData
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# /**
|
105
|
+
# *
|
106
|
+
# * @param string $roleName Name of the role
|
107
|
+
# * @param string $role_status Role status ,valid values are success,failed,in-progress
|
108
|
+
# * @param array $roleData Array of role properties
|
109
|
+
# */
|
110
|
+
def addRole(roleName, roleData)
|
111
|
+
if roleName.empty? then
|
112
|
+
log("ERROR", "Role name need to be provided")
|
113
|
+
return false
|
114
|
+
end
|
115
|
+
|
116
|
+
roleData["name"] = roleName
|
117
|
+
|
118
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/tiers/"
|
119
|
+
retResult = @cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), roleData)
|
120
|
+
|
121
|
+
if retResult == nil then
|
122
|
+
return nil
|
123
|
+
else
|
124
|
+
retResult = JSON.parse(retResult)
|
125
|
+
retData = retResult["data"]
|
126
|
+
if retData.nil? then
|
127
|
+
return nil
|
128
|
+
else
|
129
|
+
return retData
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
# ###
|
136
|
+
# ###
|
137
|
+
# ### @param String Role ID
|
138
|
+
# ### @param JsonObject Role Data
|
139
|
+
# ###
|
140
|
+
def updateRole(roleID, roleData)
|
141
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/tiers/" + roleID
|
142
|
+
@cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), roleData)
|
143
|
+
end
|
144
|
+
|
145
|
+
# ###
|
146
|
+
# ### Checks if Role exists in cloudmunch.
|
147
|
+
# ### @param string $roleID
|
148
|
+
# ### @return boolean
|
149
|
+
# ###
|
150
|
+
def checkIfRoleExists(roleID)
|
151
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/tiers/" + roleID
|
152
|
+
|
153
|
+
roleResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(), "")
|
154
|
+
if roleResult == nil then
|
155
|
+
return nil
|
156
|
+
else
|
157
|
+
roleResult = JSON.parse(roleResult)
|
158
|
+
roleData = roleResult["data"]
|
159
|
+
if roleData.nil? then
|
160
|
+
log("ERROR", "Role does not exist")
|
161
|
+
return false
|
162
|
+
else
|
163
|
+
return true
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
end
|