megam_api 0.17 → 0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/megam/api.rb +20 -35
- data/lib/megam/api/{nodes.rb → assemblies.rb} +9 -9
- data/lib/megam/api/domains.rb +30 -0
- data/lib/megam/api/organizations.rb +30 -0
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/assemblies.rb +180 -0
- data/lib/megam/core/{node_collection.rb → assemblies_collection.rb} +44 -65
- data/lib/megam/core/csar.rb +0 -1
- data/lib/megam/core/domains.rb +129 -0
- data/lib/megam/core/json_compat.rb +17 -4
- data/lib/megam/core/organizations.rb +129 -0
- data/test/test_accounts.rb +1 -1
- data/test/test_assemblies.rb +10 -0
- data/test/test_domains.rb +27 -0
- data/test/test_helper.rb +25 -16
- data/test/test_organizations.rb +26 -0
- metadata +12 -38
- data/lib/megam/api/app_request.rb +0 -27
- data/lib/megam/api/appdefns.rb +0 -47
- data/lib/megam/api/bolt_request.rb +0 -27
- data/lib/megam/api/boltdefns.rb +0 -39
- data/lib/megam/api/cloud_tools.rb +0 -35
- data/lib/megam/api/logs.rb +0 -18
- data/lib/megam/api/predefs.rb +0 -35
- data/lib/megam/builder/delete_node.rb +0 -107
- data/lib/megam/builder/make_node.rb +0 -133
- data/lib/megam/core/app_request.rb +0 -227
- data/lib/megam/core/app_request_collection.rb +0 -148
- data/lib/megam/core/appdefns.rb +0 -182
- data/lib/megam/core/appdefns_collection.rb +0 -148
- data/lib/megam/core/bolt_request.rb +0 -225
- data/lib/megam/core/bolt_request_collection.rb +0 -148
- data/lib/megam/core/boltdefns.rb +0 -207
- data/lib/megam/core/boltdefns_collection.rb +0 -148
- data/lib/megam/core/cloudinstruction.rb +0 -110
- data/lib/megam/core/cloudinstruction_collection.rb +0 -145
- data/lib/megam/core/cloudinstruction_group.rb +0 -99
- data/lib/megam/core/cloudtemplate.rb +0 -127
- data/lib/megam/core/cloudtemplate_collection.rb +0 -145
- data/lib/megam/core/cloudtool.rb +0 -152
- data/lib/megam/core/cloudtool_collection.rb +0 -145
- data/lib/megam/core/node.rb +0 -366
- data/lib/megam/core/predef.rb +0 -201
- data/lib/megam/core/predef_collection.rb +0 -164
- data/test/test_appdefns.rb +0 -35
- data/test/test_appreqs.rb +0 -25
- data/test/test_boltdefns.rb +0 -32
- data/test/test_boltreqs.rb +0 -26
- data/test/test_cloudtools.rb +0 -22
- data/test/test_nodes.rb +0 -140
- data/test/test_predefs.rb +0 -72
@@ -1,148 +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 AppRequestCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
|
21
|
-
attr_reader :iterator
|
22
|
-
def initialize
|
23
|
-
@appreqs = Array.new
|
24
|
-
@appreqs_by_name = Hash.new
|
25
|
-
@insert_after_idx = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def all_appreqs
|
29
|
-
@appreqs
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](index)
|
33
|
-
@appreqs[index]
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(index, arg)
|
37
|
-
is_megam_appreq(arg)
|
38
|
-
@appreqs[index] = arg
|
39
|
-
@appreqs_by_name[arg.id] = index
|
40
|
-
end
|
41
|
-
|
42
|
-
def <<(*args)
|
43
|
-
args.flatten.each do |a|
|
44
|
-
is_megam_appreq(a)
|
45
|
-
@appreqs << a
|
46
|
-
@appreqs_by_name[a.id] = @appreqs.length - 1
|
47
|
-
end
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
# 'push' is an alias method to <<
|
52
|
-
alias_method :push, :<<
|
53
|
-
|
54
|
-
def insert(appreq)
|
55
|
-
is_megam_appreq(appreq)
|
56
|
-
if @insert_after_idx
|
57
|
-
# in the middle of executing a run, so any Appreqss inserted now should
|
58
|
-
# be placed after the most recent addition done by the currently executing
|
59
|
-
# appreqs
|
60
|
-
@appreqs.insert(@insert_after_idx + 1, appreq)
|
61
|
-
# update name -> location mappings and register new appreqs
|
62
|
-
@appreqs_by_name.each_key do |key|
|
63
|
-
@appreqs_by_name[key] += 1 if @appreqs_by_name[key] > @insert_after_idx
|
64
|
-
end
|
65
|
-
@appreqs_by_name[appreq.id] = @insert_after_idx + 1
|
66
|
-
@insert_after_idx += 1
|
67
|
-
else
|
68
|
-
@appreqs << appreq
|
69
|
-
@appreqs_by_name[appreq.id] = @appreqs.length - 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def each
|
74
|
-
@appreqs.each do |appreq|
|
75
|
-
yield appreq
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def each_index
|
80
|
-
@appreqs.each_index do |i|
|
81
|
-
yield i
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def empty?
|
86
|
-
@appreqs.empty?
|
87
|
-
end
|
88
|
-
|
89
|
-
def lookup(appreq)
|
90
|
-
lookup_by = nil
|
91
|
-
if appreq.kind_of?(Megam::AppRequest)
|
92
|
-
lookup_by = appreq.id
|
93
|
-
elsif appreq.kind_of?(String)
|
94
|
-
lookup_by = appreq
|
95
|
-
else
|
96
|
-
raise ArgumentError, "Must pass a Megam::Appreqs or String to lookup"
|
97
|
-
end
|
98
|
-
res = @appreqs_by_name[lookup_by]
|
99
|
-
unless res
|
100
|
-
raise ArgumentError, "Cannot find a appreq matching #{lookup_by} (did you define it first?)"
|
101
|
-
end
|
102
|
-
@appreqs[res]
|
103
|
-
end
|
104
|
-
|
105
|
-
# Transform the ruby obj -> to a Hash
|
106
|
-
def to_hash
|
107
|
-
index_hash = Hash.new
|
108
|
-
self.each do |appreq|
|
109
|
-
index_hash[appreq.id] = appreq.to_s
|
110
|
-
end
|
111
|
-
index_hash
|
112
|
-
end
|
113
|
-
|
114
|
-
# Serialize this object as a hash: called from JsonCompat.
|
115
|
-
# Verify if this called from JsonCompat during testing.
|
116
|
-
def to_json(*a)
|
117
|
-
for_json.to_json(*a)
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
def self.json_create(o)
|
122
|
-
collection = self.new()
|
123
|
-
o["results"].each do |appreqs_list|
|
124
|
-
appreqs_array = appreqs_list.kind_of?(Array) ? appreqs_list : [ appreqs_list ]
|
125
|
-
appreqs_array.each do |appreq|
|
126
|
-
collection.insert(appreq)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
collection
|
130
|
-
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
def is_megam_appreq(arg)
|
137
|
-
unless arg.kind_of?(Megam::AppRequest)
|
138
|
-
raise ArgumentError, "Members must be Megam::Appreq's"
|
139
|
-
end
|
140
|
-
true
|
141
|
-
end
|
142
|
-
|
143
|
-
def to_s
|
144
|
-
Megam::Stuff.styled_hash(to_hash)
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|
data/lib/megam/core/appdefns.rb
DELETED
@@ -1,182 +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 Appdefns < Megam::ServerAPI
|
18
|
-
|
19
|
-
def initialize(email=nil, api_key=nil)
|
20
|
-
@id = nil
|
21
|
-
@node_id = nil
|
22
|
-
@node_name = nil
|
23
|
-
@appdefns ={}
|
24
|
-
@created_at = nil
|
25
|
-
@some_msg = {}
|
26
|
-
super(email, api_key)
|
27
|
-
end
|
28
|
-
|
29
|
-
def appdefns
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def id(arg=nil)
|
35
|
-
if arg != nil
|
36
|
-
@id = arg
|
37
|
-
else
|
38
|
-
@id
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def node_id(arg=nil)
|
43
|
-
if arg != nil
|
44
|
-
@node_id = arg
|
45
|
-
else
|
46
|
-
@node_id
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def node_name(arg=nil)
|
51
|
-
if arg != nil
|
52
|
-
@node_name = arg
|
53
|
-
else
|
54
|
-
@node_name
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def appdefns(arg=nil)
|
59
|
-
if arg != nil
|
60
|
-
@appdefns = arg
|
61
|
-
else
|
62
|
-
@appdefns
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def created_at(arg=nil)
|
67
|
-
if arg != nil
|
68
|
-
@created_at = arg
|
69
|
-
else
|
70
|
-
@created_at
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def some_msg(arg=nil)
|
75
|
-
if arg != nil
|
76
|
-
@some_msg = arg
|
77
|
-
else
|
78
|
-
@some_msg
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def error?
|
83
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
84
|
-
end
|
85
|
-
|
86
|
-
# Transform the ruby obj -> to a Hash
|
87
|
-
def to_hash
|
88
|
-
index_hash = Hash.new
|
89
|
-
index_hash["json_claz"] = self.class.name
|
90
|
-
index_hash["id"] = id
|
91
|
-
index_hash["node_id"] = node_id
|
92
|
-
index_hash["node_name"] = node_name
|
93
|
-
index_hash["appdefns"] = appdefns
|
94
|
-
index_hash["created_at"] = created_at
|
95
|
-
index_hash["some_msg"] = some_msg
|
96
|
-
index_hash
|
97
|
-
end
|
98
|
-
|
99
|
-
# Serialize this object as a hash: called from JsonCompat.
|
100
|
-
# Verify if this called from JsonCompat during testing.
|
101
|
-
def to_json(*a)
|
102
|
-
for_json.to_json(*a)
|
103
|
-
end
|
104
|
-
|
105
|
-
def for_json
|
106
|
-
result = {
|
107
|
-
"id" => id,
|
108
|
-
"node_id" => node_id,
|
109
|
-
"node_name" => node_name,
|
110
|
-
"appdefns" => appdefns,
|
111
|
-
"created_at" => created_at
|
112
|
-
}
|
113
|
-
result
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
def self.json_create(o)
|
118
|
-
appdefns = new
|
119
|
-
appdefns.id(o["id"]) if o.has_key?("id")
|
120
|
-
appdefns.node_id(o["node_id"]) if o.has_key?("node_id")
|
121
|
-
appdefns.node_name(o["node_name"]) if o.has_key?("node_name")
|
122
|
-
appdefns.created_at(o["created_at"]) if o.has_key?("created_at")
|
123
|
-
|
124
|
-
#APP DEFINITIONS
|
125
|
-
op = o["appdefns"]
|
126
|
-
appdefns.appdefns[:timetokill] = op["timetokill"] if op && op.has_key?("timetokill")
|
127
|
-
appdefns.appdefns[:metered] = op["metered"] if op && op.has_key?("metered")
|
128
|
-
appdefns.appdefns[:logging]= op["logging"] if op && op.has_key?("logging")
|
129
|
-
appdefns.appdefns[:runtime_exec] = op["runtime_exec"] if op && op.has_key?("runtime_exec")
|
130
|
-
appdefns.appdefns[:env_sh] = op["env_sh"] if op && op.has_key?("env_sh")
|
131
|
-
|
132
|
-
appdefns.some_msg[:code] = o["code"] if o.has_key?("code")
|
133
|
-
appdefns.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
134
|
-
appdefns.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
135
|
-
appdefns.some_msg[:links] = o["links"] if o.has_key?("links")
|
136
|
-
|
137
|
-
appdefns
|
138
|
-
end
|
139
|
-
|
140
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
141
|
-
appdefns = self.new(tmp_email, tmp_api_key)
|
142
|
-
appdefns.from_hash(o)
|
143
|
-
appdefns
|
144
|
-
end
|
145
|
-
|
146
|
-
def from_hash(o)
|
147
|
-
@id = o["id"] if o.has_key?("id")
|
148
|
-
@node_id = o["node_id"] if o.has_key?("node_id")
|
149
|
-
@node_name = o["node_name"] if o.has_key?("node_name")
|
150
|
-
@appdefns = o["appdefns"] if o.has_key?("appdefns")
|
151
|
-
@created_at = o["created_at"] if o.has_key?("created_at")
|
152
|
-
self
|
153
|
-
end
|
154
|
-
|
155
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil)
|
156
|
-
acct = from_hash(o,tmp_email, tmp_api_key)
|
157
|
-
acct.create
|
158
|
-
end
|
159
|
-
|
160
|
-
# Create the node via the REST API
|
161
|
-
def create
|
162
|
-
megam_rest.post_appdefn(to_hash)
|
163
|
-
end
|
164
|
-
|
165
|
-
# Load a account by email_p
|
166
|
-
def self.show(id,tmp_email=nil, tmp_api_key=nil)
|
167
|
-
appdefns = self.new(tmp_email, tmp_api_key)
|
168
|
-
appdefns.megam_rest.get_appdefn(id)
|
169
|
-
end
|
170
|
-
|
171
|
-
# Load a account by email_p
|
172
|
-
def self.show_by_node(node_name, id,tmp_email=nil, tmp_api_key=nil)
|
173
|
-
appdefns = self.new(tmp_email, tmp_api_key)
|
174
|
-
appdefns.megam_rest.get_appdefn(node_name,id)
|
175
|
-
end
|
176
|
-
|
177
|
-
def to_s
|
178
|
-
Megam::Stuff.styled_hash(to_hash)
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
182
|
-
end
|
@@ -1,148 +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 AppdefnsCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
|
21
|
-
attr_reader :iterator
|
22
|
-
def initialize
|
23
|
-
@appdefns = Array.new
|
24
|
-
@appdefns_by_name = Hash.new
|
25
|
-
@insert_after_idx = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def all_appdefns
|
29
|
-
@appdefns
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](index)
|
33
|
-
@appdefns[index]
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(index, arg)
|
37
|
-
is_megam_appdefn(arg)
|
38
|
-
@appdefns[index] = arg
|
39
|
-
@appdefns_by_name[arg.id] = index
|
40
|
-
end
|
41
|
-
|
42
|
-
def <<(*args)
|
43
|
-
args.flatten.each do |a|
|
44
|
-
is_megam_appdefn(a)
|
45
|
-
@appdefns << a
|
46
|
-
@appdefns_by_name[a.id] = @appdefns.length - 1
|
47
|
-
end
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
# 'push' is an alias method to <<
|
52
|
-
alias_method :push, :<<
|
53
|
-
|
54
|
-
def insert(appdefn)
|
55
|
-
is_megam_appdefn(appdefn)
|
56
|
-
if @insert_after_idx
|
57
|
-
# in the middle of executing a run, so any Appdefnss inserted now should
|
58
|
-
# be placed after the most recent addition done by the currently executing
|
59
|
-
# appdefns
|
60
|
-
@appdefns.insert(@insert_after_idx + 1, appdefn)
|
61
|
-
# update name -> location mappings and register new appdefns
|
62
|
-
@appdefns_by_name.each_key do |key|
|
63
|
-
@appdefns_by_name[key] += 1 if @appdefns_by_name[key] > @insert_after_idx
|
64
|
-
end
|
65
|
-
@appdefns_by_name[appdefn.id] = @insert_after_idx + 1
|
66
|
-
@insert_after_idx += 1
|
67
|
-
else
|
68
|
-
@appdefns << appdefn
|
69
|
-
@appdefns_by_name[appdefn.id] = @appdefns.length - 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def each
|
74
|
-
@appdefns.each do |appdefn|
|
75
|
-
yield appdefn
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def each_index
|
80
|
-
@appdefns.each_index do |i|
|
81
|
-
yield i
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def empty?
|
86
|
-
@appdefns.empty?
|
87
|
-
end
|
88
|
-
|
89
|
-
def lookup(appdefn)
|
90
|
-
lookup_by = nil
|
91
|
-
if appdefn.kind_of?(Megam::Appdefns)
|
92
|
-
lookup_by = appdefn.id
|
93
|
-
elsif appdefn.kind_of?(String)
|
94
|
-
lookup_by = appdefn
|
95
|
-
else
|
96
|
-
raise ArgumentError, "Must pass a Megam::Appdefns or String to lookup"
|
97
|
-
end
|
98
|
-
res = @appdefns_by_name[lookup_by]
|
99
|
-
unless res
|
100
|
-
raise ArgumentError, "Cannot find a appdefn matching #{lookup_by} (did you define it first?)"
|
101
|
-
end
|
102
|
-
@appdefns[res]
|
103
|
-
end
|
104
|
-
|
105
|
-
# Transform the ruby obj -> to a Hash
|
106
|
-
def to_hash
|
107
|
-
index_hash = Hash.new
|
108
|
-
self.each do |appdefn|
|
109
|
-
index_hash[appdefn.id] = appdefn.to_s
|
110
|
-
end
|
111
|
-
index_hash
|
112
|
-
end
|
113
|
-
|
114
|
-
# Serialize this object as a hash: called from JsonCompat.
|
115
|
-
# Verify if this called from JsonCompat during testing.
|
116
|
-
def to_json(*a)
|
117
|
-
for_json.to_json(*a)
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
def self.json_create(o)
|
122
|
-
collection = self.new()
|
123
|
-
o["results"].each do |appdefns_list|
|
124
|
-
appdefns_array = appdefns_list.kind_of?(Array) ? appdefns_list : [ appdefns_list ]
|
125
|
-
appdefns_array.each do |appdefn|
|
126
|
-
collection.insert(appdefn)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
collection
|
130
|
-
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
def is_megam_appdefn(arg)
|
137
|
-
unless arg.kind_of?(Megam::Appdefns)
|
138
|
-
raise ArgumentError, "Members must be Megam::Appdefn's"
|
139
|
-
end
|
140
|
-
true
|
141
|
-
end
|
142
|
-
|
143
|
-
def to_s
|
144
|
-
Megam::Stuff.styled_hash(to_hash)
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|