megam_api 0.71 → 0.72
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/megam/api.rb +3 -3
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/assembly.rb +14 -2
- metadata +2 -7
- data/lib/megam/api/cloud_tool_settings.rb +0 -35
- data/lib/megam/core/cloudtoolsetting.rb +0 -217
- data/lib/megam/core/cloudtoolsetting_collection.rb +0 -168
- data/test/test_cloudtoolsettings.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10829b22401a59fc9bc209b0a3a107a37ab35b06
|
4
|
+
data.tar.gz: 79ec7f1a4bc07c1e111bef7ca3c71b2a5843f2f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feba2ff261c2964c2a51caef0c3629ba725cafaa2f5e872f9ee68596c7b5d1d7815d08de1ef9cba089b39d66e7342dbbdc43c01771ec4879cafbddc48f938828
|
7
|
+
data.tar.gz: d130ac562711645cd9b09d73f3d10d539328681bce844493286a4ce9c99b1fd048bd4ab89b391ed80f4a36fde23562de5c9af52ad352a1aa98e5c3a76c20e1e9
|
data/lib/megam/api.rb
CHANGED
@@ -14,7 +14,7 @@ require 'megam/api/errors'
|
|
14
14
|
require 'megam/api/version'
|
15
15
|
require 'megam/api/accounts'
|
16
16
|
require 'megam/api/requests'
|
17
|
-
require 'megam/api/cloud_tool_settings'
|
17
|
+
# require 'megam/api/cloud_tool_settings'
|
18
18
|
require 'megam/api/sshkeys'
|
19
19
|
require 'megam/api/marketplaces'
|
20
20
|
require 'megam/api/marketplace_addons'
|
@@ -45,8 +45,8 @@ require 'megam/core/error'
|
|
45
45
|
require 'megam/core/account'
|
46
46
|
require 'megam/core/request'
|
47
47
|
require 'megam/core/request_collection'
|
48
|
-
require 'megam/core/cloudtoolsetting'
|
49
|
-
require 'megam/core/cloudtoolsetting_collection'
|
48
|
+
# require 'megam/core/cloudtoolsetting'
|
49
|
+
# require 'megam/core/cloudtoolsetting_collection'
|
50
50
|
require 'megam/core/sshkey'
|
51
51
|
require 'megam/core/sshkey_collection'
|
52
52
|
require 'megam/core/marketplace'
|
data/lib/megam/api/version.rb
CHANGED
data/lib/megam/core/assembly.rb
CHANGED
@@ -18,6 +18,7 @@ module Megam
|
|
18
18
|
class Assembly < Megam::ServerAPI
|
19
19
|
def initialize(email=nil, api_key=nil, host=nil)
|
20
20
|
@id = nil
|
21
|
+
@asms_id = nil
|
21
22
|
@name = nil
|
22
23
|
@tosca_type = nil
|
23
24
|
@components = []
|
@@ -43,6 +44,14 @@ module Megam
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
47
|
+
def asms_id(arg=nil)
|
48
|
+
if arg != nil
|
49
|
+
@asms_id = arg
|
50
|
+
else
|
51
|
+
@asms_id
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
46
55
|
def name(arg=nil)
|
47
56
|
if arg != nil
|
48
57
|
@name = arg
|
@@ -50,7 +59,7 @@ module Megam
|
|
50
59
|
@name
|
51
60
|
end
|
52
61
|
end
|
53
|
-
|
62
|
+
|
54
63
|
def tosca_type(arg=nil)
|
55
64
|
if arg != nil
|
56
65
|
@tosca_type = arg
|
@@ -66,7 +75,7 @@ module Megam
|
|
66
75
|
@components
|
67
76
|
end
|
68
77
|
end
|
69
|
-
|
78
|
+
|
70
79
|
def requirements(arg=[])
|
71
80
|
if arg != []
|
72
81
|
@requirements = arg
|
@@ -132,6 +141,7 @@ module Megam
|
|
132
141
|
index_hash = Hash.new
|
133
142
|
index_hash["json_claz"] = self.class.name
|
134
143
|
index_hash["id"] = id
|
144
|
+
index_hash["asms_id"] = asms_id
|
135
145
|
index_hash["name"] = name
|
136
146
|
index_hash["tosca_type"] = tosca_type
|
137
147
|
index_hash["components"] = components
|
@@ -172,6 +182,7 @@ module Megam
|
|
172
182
|
def self.json_create(o)
|
173
183
|
asm = new
|
174
184
|
asm.id(o["id"]) if o.has_key?("id")
|
185
|
+
asm.asms_id(o["asms_id"]) if o.has_key?("asms_id")
|
175
186
|
asm.name(o["name"]) if o.has_key?("name")
|
176
187
|
asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type")
|
177
188
|
asm.components(o["components"]) if o.has_key?("components")
|
@@ -193,6 +204,7 @@ module Megam
|
|
193
204
|
|
194
205
|
def from_hash(o)
|
195
206
|
@id = o["id"] if o.has_key?("id")
|
207
|
+
@asms_id = o["asmd_id"] if o.has_key?("asms_id")
|
196
208
|
@name = o["name"] if o.has_key?("name")
|
197
209
|
@tosca_type = o["tosca_type"] if o.has_key?("tosca_type")
|
198
210
|
@components = o["components"] if o.has_key?("components")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: megam_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.72'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan,
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -139,7 +139,6 @@ files:
|
|
139
139
|
- lib/megam/api/balances.rb
|
140
140
|
- lib/megam/api/billinghistories.rb
|
141
141
|
- lib/megam/api/billings.rb
|
142
|
-
- lib/megam/api/cloud_tool_settings.rb
|
143
142
|
- lib/megam/api/components.rb
|
144
143
|
- lib/megam/api/credithistories.rb
|
145
144
|
- lib/megam/api/csars.rb
|
@@ -170,8 +169,6 @@ files:
|
|
170
169
|
- lib/megam/core/billinghistories_collection.rb
|
171
170
|
- lib/megam/core/billings.rb
|
172
171
|
- lib/megam/core/billings_collection.rb
|
173
|
-
- lib/megam/core/cloudtoolsetting.rb
|
174
|
-
- lib/megam/core/cloudtoolsetting_collection.rb
|
175
172
|
- lib/megam/core/components.rb
|
176
173
|
- lib/megam/core/components_collection.rb
|
177
174
|
- lib/megam/core/config.rb
|
@@ -215,7 +212,6 @@ files:
|
|
215
212
|
- test/test_billinghistories.rb
|
216
213
|
- test/test_billings.rb
|
217
214
|
- test/test_cat_requests.rb
|
218
|
-
- test/test_cloudtoolsettings.rb
|
219
215
|
- test/test_components.rb
|
220
216
|
- test/test_credithistories.rb
|
221
217
|
- test/test_csars.rb
|
@@ -266,7 +262,6 @@ test_files:
|
|
266
262
|
- test/test_billinghistories.rb
|
267
263
|
- test/test_billings.rb
|
268
264
|
- test/test_cat_requests.rb
|
269
|
-
- test/test_cloudtoolsettings.rb
|
270
265
|
- test/test_components.rb
|
271
266
|
- test/test_credithistories.rb
|
272
267
|
- test/test_csars.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Megam
|
2
|
-
class API
|
3
|
-
def get_cloudtoolsettings
|
4
|
-
@options = {:path => '/cloudtoolsettings',:body => ""}.merge(@options)
|
5
|
-
|
6
|
-
request(
|
7
|
-
:expects => 200,
|
8
|
-
:method => :get,
|
9
|
-
:body => @options[:body]
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_cloudtoolsetting(id)
|
14
|
-
@options = {:path => "/cloudtoolsettings/#{id}",:body => ""}.merge(@options)
|
15
|
-
|
16
|
-
request(
|
17
|
-
:expects => 200,
|
18
|
-
:method => :get,
|
19
|
-
:body => @options[:body]
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def post_cloudtoolsetting(new_cloudtoolsetting)
|
24
|
-
@options = {:path => '/cloudtoolsettings/content',
|
25
|
-
:body => Megam::JSONCompat.to_json(new_cloudtoolsetting)}.merge(@options)
|
26
|
-
|
27
|
-
request(
|
28
|
-
:expects => 201,
|
29
|
-
:method => :post,
|
30
|
-
:body => @options[:body]
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
module Megam
|
17
|
-
class CloudToolSetting < Megam::ServerAPI
|
18
|
-
|
19
|
-
def initialize(email=nil, api_key=nil, host=nil)
|
20
|
-
@id = nil
|
21
|
-
@accounts_id = nil
|
22
|
-
@cloud_type = nil
|
23
|
-
@repo_name = nil
|
24
|
-
@repo = nil
|
25
|
-
@vault_location=nil
|
26
|
-
@conf_location=nil
|
27
|
-
@created_at = nil
|
28
|
-
@some_msg = {}
|
29
|
-
super(email, api_key, host)
|
30
|
-
end
|
31
|
-
|
32
|
-
def cloud_tool_setting
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def id(arg=nil)
|
38
|
-
if arg != nil
|
39
|
-
@id = arg
|
40
|
-
else
|
41
|
-
@id
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def accounts_id(arg=nil)
|
46
|
-
if arg != nil
|
47
|
-
@accounts_id= arg
|
48
|
-
else
|
49
|
-
@accounts_id
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def cloud_type(arg=nil)
|
54
|
-
if arg != nil
|
55
|
-
@cloud_type = arg
|
56
|
-
else
|
57
|
-
@cloud_type
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def repo_name(arg=nil)
|
62
|
-
if arg != nil
|
63
|
-
@repo_name = arg
|
64
|
-
else
|
65
|
-
@repo_name
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def repo(arg=nil)
|
70
|
-
if arg != nil
|
71
|
-
@repo = arg
|
72
|
-
else
|
73
|
-
@repo
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def vault_location(arg=nil)
|
78
|
-
if arg != nil
|
79
|
-
@vault_location= arg
|
80
|
-
else
|
81
|
-
@vault_location
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def conf_location(arg=nil)
|
86
|
-
if arg != nil
|
87
|
-
@conf_location= arg
|
88
|
-
else
|
89
|
-
@conf_location
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def created_at(arg=nil)
|
94
|
-
if arg != nil
|
95
|
-
@created_at = arg
|
96
|
-
else
|
97
|
-
@created_at
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def some_msg(arg=nil)
|
102
|
-
if arg != nil
|
103
|
-
@some_msg = arg
|
104
|
-
else
|
105
|
-
@some_msg
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def error?
|
110
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
111
|
-
end
|
112
|
-
|
113
|
-
# Transform the ruby obj -> to a Hash
|
114
|
-
def to_hash
|
115
|
-
index_hash = Hash.new
|
116
|
-
index_hash["json_claz"] = self.class.name
|
117
|
-
index_hash["id"] = id
|
118
|
-
index_hash["accounts_id"] = accounts_id
|
119
|
-
index_hash["cloud_type"] = cloud_type
|
120
|
-
index_hash["repo_name"] = repo_name
|
121
|
-
index_hash["repo"] = repo
|
122
|
-
index_hash["vault_location"] = vault_location
|
123
|
-
index_hash["conf_location"] = conf_location
|
124
|
-
index_hash["created_at"] = created_at
|
125
|
-
index_hash["some_msg"] = some_msg
|
126
|
-
index_hash
|
127
|
-
end
|
128
|
-
|
129
|
-
# Serialize this object as a hash: called from JsonCompat.
|
130
|
-
# Verify if this called from JsonCompat during testing.
|
131
|
-
def to_json(*a)
|
132
|
-
for_json.to_json(*a)
|
133
|
-
end
|
134
|
-
|
135
|
-
def for_json
|
136
|
-
result = {
|
137
|
-
"id" => id,
|
138
|
-
"accounts_id" => accounts_id,
|
139
|
-
"cloud_type" => cloud_type,
|
140
|
-
"repo" => repo,
|
141
|
-
"repo_name" => repo_name,
|
142
|
-
"vault_location" => vault_location,
|
143
|
-
"conf_location" => conf_location,
|
144
|
-
"created_at" => created_at
|
145
|
-
}
|
146
|
-
result
|
147
|
-
end
|
148
|
-
|
149
|
-
#
|
150
|
-
def self.json_create(o)
|
151
|
-
cts = new
|
152
|
-
cts.id(o["id"]) if o.has_key?("id")
|
153
|
-
cts.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
|
154
|
-
cts.cloud_type(o["cloud_type"]) if o.has_key?("cloud_type")
|
155
|
-
cts.repo_name(o["repo_name"]) if o.has_key?("repo_name")
|
156
|
-
cts.repo(o["repo"]) if o.has_key?("repo")
|
157
|
-
cts.vault_location(o["vault_location"]) if o.has_key?("vault_location")
|
158
|
-
cts.conf_location(o["conf_location"]) if o.has_key?("conf_location")
|
159
|
-
|
160
|
-
cts.created_at(o["created_at"]) if o.has_key?("created_at")
|
161
|
-
#success or error
|
162
|
-
cts.some_msg[:code] = o["code"] if o.has_key?("code")
|
163
|
-
cts.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
164
|
-
cts.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
165
|
-
cts.some_msg[:links] = o["links"] if o.has_key?("links")
|
166
|
-
cts
|
167
|
-
end
|
168
|
-
|
169
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
170
|
-
cts = self.new(tmp_email,tmp_api_key, tmp_host)
|
171
|
-
cts.from_hash(o)
|
172
|
-
cts
|
173
|
-
end
|
174
|
-
|
175
|
-
def from_hash(o)
|
176
|
-
@id = o[:id] if o.has_key?(:id)
|
177
|
-
@accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
|
178
|
-
@cloud_type = o[:cloud_type] if o.has_key?(:cloud_type)
|
179
|
-
@repo_name = o[:repo_name] if o.has_key?(:repo_name)
|
180
|
-
@repo = o[:repo] if o.has_key?(:repo)
|
181
|
-
@vault_location = o[:vault_location] if o.has_key?(:vault_location)
|
182
|
-
@conf_location = o[:conf_location] if o.has_key?(:conf_location)
|
183
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
184
|
-
self
|
185
|
-
end
|
186
|
-
|
187
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
188
|
-
acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
|
189
|
-
acct.create
|
190
|
-
end
|
191
|
-
|
192
|
-
# Create the cloudtoolsetting via the REST API
|
193
|
-
def create
|
194
|
-
megam_rest.post_cloudtoolsetting(to_hash)
|
195
|
-
end
|
196
|
-
|
197
|
-
# Load all cloudtoolsettings -
|
198
|
-
# returns a cloudtoolsettingsCollection
|
199
|
-
# don't return self. check if the Megam::cloudtoolsettingCollection is returned.
|
200
|
-
def self.list(tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
201
|
-
cts = self.new(tmp_email, tmp_api_key, tmp_host)
|
202
|
-
cts.megam_rest.get_cloudtoolsettings
|
203
|
-
end
|
204
|
-
|
205
|
-
# Show a particular cloudtoolsetting by name,
|
206
|
-
# Megam::cloudtoolsetting
|
207
|
-
def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
208
|
-
pre = self.new(tmp_email, tmp_api_key, tmp_host)
|
209
|
-
pre.megam_rest.get_cloudtoolsetting(p_name)
|
210
|
-
end
|
211
|
-
|
212
|
-
def to_s
|
213
|
-
Megam::Stuff.styled_hash(to_hash)
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
217
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
module Megam
|
17
|
-
class CloudToolSettingCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
attr_reader :iterator
|
21
|
-
def initialize
|
22
|
-
@cloudtoolsettings = Array.new
|
23
|
-
@cloudtoolsettings_by_name = Hash.new
|
24
|
-
@insert_after_idx = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def all_cloudtoolsettings
|
28
|
-
@cloudtoolsettings
|
29
|
-
end
|
30
|
-
|
31
|
-
def [](index)
|
32
|
-
@cloudtoolsettings[index]
|
33
|
-
end
|
34
|
-
|
35
|
-
def []=(index, arg)
|
36
|
-
is_megam_cloudtoolsettings(arg)
|
37
|
-
@cloudtoolsettings[index] = arg
|
38
|
-
@cloudtoolsettings_by_name[arg.repo_name] = index
|
39
|
-
end
|
40
|
-
|
41
|
-
def <<(*args)
|
42
|
-
args.flatten.each do |a|
|
43
|
-
is_megam_cloudtoolsettings(a)
|
44
|
-
@cloudtoolsettings << a
|
45
|
-
@cloudtoolsettings_by_name[a.repo_name] =@cloudtoolsettings.length - 1
|
46
|
-
end
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# 'push' is an alias method to <<
|
51
|
-
alias_method :push, :<<
|
52
|
-
|
53
|
-
def insert(cloudtoolsettings)
|
54
|
-
is_megam_cloudtoolsettings(cloudtoolsettings)
|
55
|
-
if @insert_after_idx
|
56
|
-
# in the middle of executing a run, so any cloudtoolsettings inserted now should
|
57
|
-
# be placed after the most recent addition done by the currently executing
|
58
|
-
# cloudtoolsettings
|
59
|
-
@cloudtoolsettings.insert(@insert_after_idx + 1, cloudtoolsettings)
|
60
|
-
# update name -> location mappings and register new cloudtoolsettings
|
61
|
-
@cloudtoolsettings_by_name.each_key do |key|
|
62
|
-
@cloudtoolsettings_by_name[key] += 1 if@cloudtoolsettings_by_name[key] > @insert_after_idx
|
63
|
-
end
|
64
|
-
@cloudtoolsettings_by_name[cloudtoolsettings.repo_name] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@cloudtoolsettings << cloudtoolsettings
|
68
|
-
@cloudtoolsettings_by_name[cloudtoolsettings.repo_name] =@cloudtoolsettings.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def each
|
73
|
-
@cloudtoolsettings.each do |cloudtoolsettings|
|
74
|
-
yield cloudtoolsettings
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def each_index
|
79
|
-
@cloudtoolsettings.each_index do |i|
|
80
|
-
yield i
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def empty?
|
85
|
-
@cloudtoolsettings.empty?
|
86
|
-
end
|
87
|
-
|
88
|
-
def lookup(cloudtoolsettings)
|
89
|
-
lookup_by = nil
|
90
|
-
if cloudtoolsettings.kind_of?(Megam::CloudToolSetting)
|
91
|
-
lookup_by = cloudtoolsettings.repo_name
|
92
|
-
elsif cloudtoolsettings.kind_of?(String)
|
93
|
-
lookup_by = cloudtoolsettings
|
94
|
-
else
|
95
|
-
raise ArgumentError, "Must pass a Megam::cloudtoolsettings or String to lookup"
|
96
|
-
end
|
97
|
-
res =@cloudtoolsettings_by_name[lookup_by]
|
98
|
-
unless res
|
99
|
-
raise ArgumentError, "Cannot find a cloudtoolsettings matching #{lookup_by} (did you define it first?)"
|
100
|
-
end
|
101
|
-
@cloudtoolsettings[res]
|
102
|
-
end
|
103
|
-
|
104
|
-
# Transform the ruby obj -> to a Hash
|
105
|
-
def to_hash
|
106
|
-
index_hash = Hash.new
|
107
|
-
self.each do |cloudtoolsettings|
|
108
|
-
index_hash[cloudtoolsettings.repo_name] = cloudtoolsettings.to_s
|
109
|
-
end
|
110
|
-
index_hash
|
111
|
-
end
|
112
|
-
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
|
-
def to_json(*a)
|
116
|
-
for_json.to_json(*a)
|
117
|
-
end
|
118
|
-
|
119
|
-
=begin
|
120
|
-
{
|
121
|
-
"json_claz":"Megam::PredefCloudCollection",
|
122
|
-
"results":[{
|
123
|
-
"id":"NOD362554470640386048",
|
124
|
-
"name":"ec2_rails",
|
125
|
-
"account_id":"ACT362544229488001024",
|
126
|
-
"json_claz":"Megam::PredefCloud",
|
127
|
-
"spec":{
|
128
|
-
"type_name":"sensor-type",
|
129
|
-
"groups":"sens-group",
|
130
|
-
"image":"sens-image",
|
131
|
-
"flavor":"sens-flvr"
|
132
|
-
},
|
133
|
-
"access":{
|
134
|
-
"ssh_key":"sens-ssh",
|
135
|
-
"identity_file":"sens-identity-file",
|
136
|
-
"ssh_user":"sens-sshuser"
|
137
|
-
},
|
138
|
-
"ideal":"",
|
139
|
-
"performance":""
|
140
|
-
}]
|
141
|
-
}
|
142
|
-
=end
|
143
|
-
def self.json_create(o)
|
144
|
-
collection = self.new()
|
145
|
-
o["results"].each do |cloudtoolsettings_list|
|
146
|
-
cloudtoolsettings_array = cloudtoolsettings_list.kind_of?(Array) ? cloudtoolsettings_list : [ cloudtoolsettings_list ]
|
147
|
-
cloudtoolsettings_array.each do |cloudtoolsettings|
|
148
|
-
collection.insert(cloudtoolsettings)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
collection
|
152
|
-
end
|
153
|
-
|
154
|
-
private
|
155
|
-
|
156
|
-
def is_megam_cloudtoolsettings(arg)
|
157
|
-
unless arg.kind_of?(Megam::CloudToolSetting)
|
158
|
-
raise ArgumentError, "Members must be Megam::cloudtoolsetting's"
|
159
|
-
end
|
160
|
-
true
|
161
|
-
end
|
162
|
-
|
163
|
-
def to_s
|
164
|
-
Megam::Stuff.styled_hash(to_hash)
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
2
|
-
|
3
|
-
class TestApps < MiniTest::Unit::TestCase
|
4
|
-
#=begin
|
5
|
-
def test_post_cloudtoolsetting1
|
6
|
-
tmp_hash = { :cloud_type => "chef",
|
7
|
-
:repo_name => "test_chef",
|
8
|
-
:repo => "https://github.com",
|
9
|
-
:vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudrecipes/megam@mypaas.io/chef",
|
10
|
-
:conf_location => "megam@mypaas.io/chef/chef-repo/.chef/knife.rb"
|
11
|
-
}
|
12
|
-
|
13
|
-
response = megams.post_cloudtoolsetting(tmp_hash)
|
14
|
-
assert_equal(201, response.status)
|
15
|
-
end
|
16
|
-
#=end
|
17
|
-
=begin
|
18
|
-
def test_post_cloudtoolsetting2
|
19
|
-
tmp_hash = { :cloud_type => "chef",
|
20
|
-
:repo_name => "test_chef",
|
21
|
-
:repo => "https://github.com",
|
22
|
-
:vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/megam@mypaas.io/default"
|
23
|
-
}
|
24
|
-
response = megams.post_cloudtoolsetting(tmp_hash)
|
25
|
-
assert_equal(201, response.status)
|
26
|
-
end
|
27
|
-
=end
|
28
|
-
=begin
|
29
|
-
def test_get_cloudtoolsettings
|
30
|
-
response = megams.get_cloudtoolsettings
|
31
|
-
assert_equal(200, response.status)
|
32
|
-
end
|
33
|
-
=end
|
34
|
-
=begin
|
35
|
-
def test_get_cloudtoolsetting2
|
36
|
-
response = megams.get_cloudtoolsetting("rkspce_sundown_play")
|
37
|
-
assert_equal(200, response.status)
|
38
|
-
end
|
39
|
-
#=begin
|
40
|
-
def test_get_cloudtoolsetting1
|
41
|
-
response = megams.get_cloudtoolsetting("iaas_default")
|
42
|
-
assert_equal(200, response.status)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_get_cloudtoolsetting_not_found
|
46
|
-
assert_raises(Megam::API::Errors::NotFound) do
|
47
|
-
megams.get_cloudtoolsetting("stupid.megam.co")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
=end
|
51
|
-
end
|
52
|
-
|