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,77 @@
|
|
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
|
+
|
13
|
+
|
14
|
+
class Server
|
15
|
+
attr_accessor :description
|
16
|
+
attr_accessor :dns
|
17
|
+
attr_accessor :domainName
|
18
|
+
attr_accessor :emailID
|
19
|
+
attr_accessor :CI
|
20
|
+
attr_accessor :deploymentStatus
|
21
|
+
attr_accessor :instanceId
|
22
|
+
attr_accessor :imageID
|
23
|
+
attr_accessor :launcheduser
|
24
|
+
attr_accessor :build
|
25
|
+
attr_accessor :appName
|
26
|
+
attr_accessor :deployTempLoc
|
27
|
+
attr_accessor :buildLocation
|
28
|
+
attr_accessor :privateKeyLoc
|
29
|
+
attr_accessor :publicKeyLoc
|
30
|
+
attr_accessor :loginUser
|
31
|
+
attr_accessor :serverType
|
32
|
+
attr_accessor :assetType
|
33
|
+
attr_accessor :status
|
34
|
+
attr_accessor :startTime
|
35
|
+
attr_accessor :provider
|
36
|
+
attr_accessor :region
|
37
|
+
attr_accessor :cmserver
|
38
|
+
attr_accessor :assetName
|
39
|
+
attr_accessor :instanceSize
|
40
|
+
attr_accessor :serverName
|
41
|
+
attr_accessor :password
|
42
|
+
attr_accessor :sshport
|
43
|
+
attr_accessor :tier
|
44
|
+
|
45
|
+
def initialize
|
46
|
+
@description=""
|
47
|
+
@dns=""
|
48
|
+
@domainName=""
|
49
|
+
@emailID=""
|
50
|
+
@CI=""
|
51
|
+
@deploymentStatus=""
|
52
|
+
@instanceId=""
|
53
|
+
@imageID=""
|
54
|
+
@launcheduser=""
|
55
|
+
@build=""
|
56
|
+
@appName=""
|
57
|
+
@deployTempLoc=""
|
58
|
+
@buildLocation=""
|
59
|
+
@privateKeyLoc=""
|
60
|
+
@publicKeyLoc=""
|
61
|
+
@loginUser=""
|
62
|
+
@serverType=""
|
63
|
+
@assettype=""
|
64
|
+
@status=""
|
65
|
+
@starttime=""
|
66
|
+
@provider=""
|
67
|
+
@region=""
|
68
|
+
@cmserver=""
|
69
|
+
@assetname=""
|
70
|
+
@instancesize=""
|
71
|
+
@servername=""
|
72
|
+
@password=""
|
73
|
+
@sshport=22
|
74
|
+
@tier=""
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,284 @@
|
|
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 ServerHelper
|
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
|
+
# ### This method retreives the details of server from cloudmunch.
|
30
|
+
# ### @param string $servername Name of the server as registered in cloudmunch.
|
31
|
+
# ### @return \CloudMunch\Server
|
32
|
+
# ###
|
33
|
+
def getServerName(serverName)
|
34
|
+
server = nil
|
35
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + serverName
|
36
|
+
log("DEBUG", "serverurl from serverhelper:" + serverUrl)
|
37
|
+
|
38
|
+
deployResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(),nil)
|
39
|
+
if deployResult == nil then
|
40
|
+
return false
|
41
|
+
else
|
42
|
+
deployResult = JSON.parse(deployResult)
|
43
|
+
deployData = deployResult["data"]
|
44
|
+
if deployData.nil? then
|
45
|
+
log("ERROR", "Server does not exist")
|
46
|
+
return nil
|
47
|
+
else
|
48
|
+
if (deployResult[serverName].include?("assetname")) && (deployResult[serverName]["assetname"] == "ElasticBeanStalk") then
|
49
|
+
server = ElasticBeanStalkServer.new
|
50
|
+
else
|
51
|
+
server = Server.new
|
52
|
+
|
53
|
+
server.servername = deployData["id"]
|
54
|
+
server.description = deployData["description"]
|
55
|
+
server.dns = deployData["dnsName"]
|
56
|
+
server.domainName = deployData["domainName"]
|
57
|
+
server.CI = deployData["CI"]
|
58
|
+
server.deploymentStatus = deployData["deploymentStatus"]
|
59
|
+
server.instanceId = deployData["instanceId"]
|
60
|
+
server.imageID = deployData["amiID"]
|
61
|
+
server.launcheduser = deployData["username"]
|
62
|
+
server.build = deployData["build"]
|
63
|
+
server.appName = deployData["appName"]
|
64
|
+
server.deployTempLoc = deployData["deployTempLoc"]
|
65
|
+
server.buildLocation = deployData["buildLoc"]
|
66
|
+
server.privateKeyLoc = deployData["privateKeyLoc"]
|
67
|
+
server.publicKeyLoc = deployData["publicKeyLoc"]
|
68
|
+
server.loginUser = deployData["loginUser"]
|
69
|
+
server.serverType = deployData["serverType"]
|
70
|
+
server.assetType = deployData["assettype"]
|
71
|
+
server.status = deployData["status"]
|
72
|
+
server.startTime = deployData["starttime"]
|
73
|
+
server.provider = deployData["provider"]
|
74
|
+
server.region = deployData["region"]
|
75
|
+
server.cmserver = deployData["cmserver"]
|
76
|
+
server.assetName = deployData["assetname"]
|
77
|
+
server.instanceSize = deployData["instancesize"]
|
78
|
+
server.password = deployData["password"]
|
79
|
+
server.sshport = deployData["sshport"]
|
80
|
+
server.tier = deployData["tier"]
|
81
|
+
|
82
|
+
if server.instance_of?(ElasticBeanStalkServer) then
|
83
|
+
server.environmentName = deployData["environmentName"]
|
84
|
+
server.bucketName = deployData["bucketName"]
|
85
|
+
server.applicationName = deployData["applicationName"]
|
86
|
+
server.templateName = deployData["templateName"]
|
87
|
+
end
|
88
|
+
|
89
|
+
return server
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# ###
|
97
|
+
# ### This method can be used to add or register a server to cloudmunch data .
|
98
|
+
# ### @param \CloudMunch\Server server
|
99
|
+
# ### @param string docker
|
100
|
+
# ###
|
101
|
+
def addServer(server, serverStatus, docker)
|
102
|
+
|
103
|
+
if serverStatus.empty? then
|
104
|
+
log("ERROR", "Server status need to be provided")
|
105
|
+
return false
|
106
|
+
end
|
107
|
+
|
108
|
+
statusArray = [::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_NIL]
|
109
|
+
if !statusArray.include?(serverStatus) then
|
110
|
+
log("ERROR", "Invalid status")
|
111
|
+
return false
|
112
|
+
end
|
113
|
+
|
114
|
+
paramHash = {}
|
115
|
+
paramHash["description"] = server.description
|
116
|
+
paramHash["dnsName"] = server.dns
|
117
|
+
paramHash["domainName"] = server.domainName
|
118
|
+
paramHash["emailID"] = server.emailID
|
119
|
+
paramHash["CI"] = server.CI ? "y" : "n"
|
120
|
+
paramHash["deploymentStatus"] = server.deploymentStatus
|
121
|
+
paramHash["instanceId"] = server.instanceId
|
122
|
+
paramHash["amiID"] = server.imageID
|
123
|
+
paramHash["username"] = server.username
|
124
|
+
paramHash["build"] = server.build
|
125
|
+
paramHash["appName"] = server.appName
|
126
|
+
paramHash["deployTempLoc"] = server.deployTempLoc
|
127
|
+
paramHash["buildLoc"] = server.buildLocation
|
128
|
+
paramHash["privateKeyLoc"] = server.privateKeyLoc
|
129
|
+
paramHash["publicKeyLoc"] = server.publicKeyLoc
|
130
|
+
paramHash["loginUser"] = server.loginUser
|
131
|
+
paramHash["serverType"] = server.serverType
|
132
|
+
paramHash["type"] = "server"
|
133
|
+
paramHash["status"] = server.status
|
134
|
+
paramHash["starttime"] = server.startTime
|
135
|
+
paramHash["provider"] = server.provider
|
136
|
+
paramHash["region"] = server.region
|
137
|
+
paramHash["cmserver"] = server.cmserver
|
138
|
+
paramHash["name"] = server.serverName
|
139
|
+
paramHash["instancesize"] = server.instanceSize
|
140
|
+
paramHash["password"] = server.password
|
141
|
+
paramHash["sshport"] = server.sshport
|
142
|
+
paramHash["tier"] = server.tier
|
143
|
+
|
144
|
+
if server.instance_of?(ElasticBeanStalkServer) then
|
145
|
+
paramHash["applicationName"] = server.applicationName
|
146
|
+
paramHash["templateName"] = server.templateName
|
147
|
+
paramHash["environmentName"] = server.environmentName
|
148
|
+
paramHash["bucketName"] = server.bucketName
|
149
|
+
end
|
150
|
+
|
151
|
+
paramHash["status"] = serverStatus
|
152
|
+
|
153
|
+
if docker then
|
154
|
+
dataInnerHash = {}
|
155
|
+
dataInnerHash["buildNo"] = server.build
|
156
|
+
dataServerNode = {}
|
157
|
+
dataServerNode[server.appName] = dataInnerHash
|
158
|
+
paramHash["projects"] = dataServerNode
|
159
|
+
end
|
160
|
+
|
161
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/"
|
162
|
+
@cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), paramHash)
|
163
|
+
end
|
164
|
+
|
165
|
+
# ###
|
166
|
+
# ### This method is used to update server data.
|
167
|
+
# ### @param \CloudMunch\Server server
|
168
|
+
# ###
|
169
|
+
def updateServer(server, serverID)
|
170
|
+
paramHash = {}
|
171
|
+
paramHash["description"] = server.description
|
172
|
+
paramHash["dnsName"] = server.dns
|
173
|
+
paramHash["domainName"] = server.domainName
|
174
|
+
paramHash["emailID"] = server.emailID
|
175
|
+
paramHash["CI"] = server.CI ? "y" : "n"
|
176
|
+
paramHash["deploymentStatus"] = server.deploymentStatus
|
177
|
+
paramHash["instanceId"] = server.instanceId
|
178
|
+
paramHash["amiID"] = server.imageID
|
179
|
+
paramHash["username"] = server.username
|
180
|
+
paramHash["build"] = server.build
|
181
|
+
paramHash["appName"] = server.appName
|
182
|
+
paramHash["deployTempLoc"] = server.deployTempLoc
|
183
|
+
paramHash["buildLoc"] = server.buildLocation
|
184
|
+
paramHash["privateKeyLoc"] = server.privateKeyLoc
|
185
|
+
paramHash["publicKeyLoc"] = server.publicKeyLoc
|
186
|
+
paramHash["loginUser"] = server.loginUser
|
187
|
+
paramHash["serverType"] = server.serverType
|
188
|
+
paramHash["type"] = "server"
|
189
|
+
paramHash["status"] = server.status
|
190
|
+
paramHash["starttime"] = server.startTime
|
191
|
+
paramHash["provider"] = server.provider
|
192
|
+
paramHash["region"] = server.region
|
193
|
+
paramHash["cmserver"] = server.cmserver
|
194
|
+
paramHash["name"] = server.serverName
|
195
|
+
paramHash["instancesize"] = server.instanceSize
|
196
|
+
paramHash["password"] = server.password
|
197
|
+
paramHash["sshport"] = server.sshport
|
198
|
+
paramHash["tier"] = server.tier
|
199
|
+
|
200
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + serverID
|
201
|
+
return @cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), paramHash)
|
202
|
+
end
|
203
|
+
|
204
|
+
# ###
|
205
|
+
# ### This method is to delete server from cloudmunch.
|
206
|
+
# ### @param $serverName Name of server.
|
207
|
+
# ###
|
208
|
+
def deleteServer(serverID)
|
209
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + serverID
|
210
|
+
return @cloudmunchDataService.deleteDataForContext(serverUrl, @appContext.getAPIKey() )
|
211
|
+
end
|
212
|
+
|
213
|
+
# ###
|
214
|
+
# ### This method checks if server exists or is registered in cloudmunch data.
|
215
|
+
# ### @param $servername Name of server.
|
216
|
+
# ### @return boolean
|
217
|
+
# ###
|
218
|
+
def checkServerExists(serverName)
|
219
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + serverName
|
220
|
+
|
221
|
+
serverResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(), "")
|
222
|
+
if serverResult == nil then
|
223
|
+
return nil
|
224
|
+
else
|
225
|
+
serverResult = JSON.parse(serverResult)
|
226
|
+
serverData = serverResult["data"]
|
227
|
+
if serverData.nil? then
|
228
|
+
log("ERROR", "Server does not exist")
|
229
|
+
return false
|
230
|
+
else
|
231
|
+
return true
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
# ###
|
237
|
+
# ### Checks if server is up and running
|
238
|
+
# ###
|
239
|
+
# ### @param string dns : dns of target server
|
240
|
+
# ### @param number sshport : ssh port (22) to be used to check for connection
|
241
|
+
# ### @return string Success : displays an appropriate message
|
242
|
+
# ### Failure : exits with a failure status with an appropriate message
|
243
|
+
# ###
|
244
|
+
def checkConnect(dns, sshport)
|
245
|
+
connectionTimeout = Time.now
|
246
|
+
connectionTimeout = connectionTimeout + (10 * 10)
|
247
|
+
connection = false
|
248
|
+
|
249
|
+
while ((connection == false) && ( Time.now < connectionTimeout )) do
|
250
|
+
if dns.nil? || dns.empty? then
|
251
|
+
log("ERROR", "Invalid dns" + dns)
|
252
|
+
return false
|
253
|
+
end
|
254
|
+
log("INFO", "Checking connectivity to: " + dns)
|
255
|
+
|
256
|
+
connection = ssh2_connect(dns, sshport)
|
257
|
+
if connection == false then
|
258
|
+
sleep(10)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
if connection == false then
|
263
|
+
log("ERROR", "Failed to connect to " + dns )
|
264
|
+
return false
|
265
|
+
else
|
266
|
+
return true
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def checkConnectionToServer(servername)
|
271
|
+
end
|
272
|
+
|
273
|
+
def getConnectionToServer(servername)
|
274
|
+
end
|
275
|
+
|
276
|
+
# ###
|
277
|
+
# ### This method returns SSHConnection helper
|
278
|
+
# ### @return \CloudMunch\sshConnection
|
279
|
+
# ###
|
280
|
+
def getSSHConnectionHelper()
|
281
|
+
return SSHConnection.new
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
@@ -7,11 +7,19 @@ class ServiceProvider
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def load_data(param)
|
10
|
-
|
10
|
+
if param[@providername].nil?
|
11
|
+
return nil
|
12
|
+
else
|
13
|
+
@SP_data = param[@providername]["configuration"]
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def get_data(keyname)
|
14
|
-
@SP_data
|
18
|
+
if @SP_data.nil?
|
19
|
+
return nil
|
20
|
+
else
|
21
|
+
@SP_data[keyname]
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
17
25
|
end
|
@@ -61,11 +61,6 @@ module Util
|
|
61
61
|
logger.close
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
def Util.getJSONArgsTEMP(jsonString)
|
66
|
-
JSON.parse(jsonString)
|
67
|
-
end
|
68
|
-
|
69
64
|
def Util.getJSONArgs()
|
70
65
|
jsonin = nil
|
71
66
|
loop { case ARGV[0]
|
@@ -85,40 +80,40 @@ module Util
|
|
85
80
|
end
|
86
81
|
end
|
87
82
|
|
88
|
-
def Util.generateReport(reportFileName, reportContent)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
83
|
+
# def Util.generateReport(reportFileName, reportContent)
|
84
|
+
# begin
|
85
|
+
# fp=File.new(reportFileName, 'w')
|
86
|
+
# fp.write(reportContent)
|
87
|
+
# fp.close
|
88
|
+
# return true
|
89
|
+
# rescue
|
90
|
+
# puts("ERROR: Could not open output file. Framework error!")
|
91
|
+
# # exit 1
|
92
|
+
# return false
|
93
|
+
# end
|
94
|
+
# end
|
100
95
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
96
|
+
# def Util.getUrlForViewCards(server, endpoint, params)
|
97
|
+
# newParam = {
|
98
|
+
# :action => "listcustomcontext",
|
99
|
+
# :fields => "*",
|
100
|
+
# }
|
106
101
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
102
|
+
# newParam = params.merge(newParam)
|
103
|
+
# cqlQuery = CloudmunchService.getDataContext(server, endpoint, newParam)
|
104
|
+
# cqlQuery = JSON.parse(cqlQuery)
|
105
|
+
# if !cqlQuery[0].nil? && !cqlQuery[0]["url"].nil?
|
106
|
+
# url = cqlQuery[0]["url"]
|
107
|
+
# else
|
108
|
+
# url = ""
|
109
|
+
# end
|
115
110
|
|
116
|
-
|
117
|
-
|
111
|
+
# return url
|
112
|
+
# end
|
118
113
|
|
119
|
-
|
120
|
-
|
121
|
-
|
114
|
+
# def Util.getTemplate(template_name)
|
115
|
+
# openJSONFile(File.dirname(__FILE__) +"/templates/#{template_name}.json")
|
116
|
+
# end
|
122
117
|
|
123
118
|
end
|
124
119
|
|