megam_api 0.7.4 → 0.7.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 567e77145904043583d51b42540f6e9d7f448dbc
4
- data.tar.gz: cdcb2136da6829ea5a122cc729d954487450f768
3
+ metadata.gz: 102f1b08a1634e0299de9f614948ea96ec778582
4
+ data.tar.gz: 4737f0ebf23bd07d50b2a4839d2b885c308297bb
5
5
  SHA512:
6
- metadata.gz: a16c3b6745f7d34700f0566fb95f1e962f944f22ed7097300f4ef82272aa24dda316ad58573cdfd236628587f5a86981e28af31019a0fb41f0e42aa5ed233187
7
- data.tar.gz: 7faaf92acc98c9cca6391d80ddd14acd8e2eb8616b958665ed6422c4ba1c93c7a94930ea7e553bf2d60c8e3900307ee214ff65bf769b87c66ddbf6a742222547
6
+ metadata.gz: 8267e94e40f869513b80e966d9aa1907313003775445c8551cf9dba9f1df0801c2d94cc90f0d3e5f1a429788692a7d97d918d33b5f29ff78de00637d6ff7f96e
7
+ data.tar.gz: 2888e0eb803c614df338ad0d2dd6b2a2932bbba84aa4e69370f39139b696077bfa8353051d357f1c18c2af42a3d3a7f456b419660e428b7a1772b6de69ee12f1
data/lib/megam/api.rb CHANGED
@@ -27,6 +27,7 @@ require "megam/api/predefs"
27
27
  require "megam/api/predef_clouds"
28
28
  require "megam/api/cloud_tools"
29
29
  require "megam/api/cloud_tool_settings"
30
+ require "megam/core/server_api"
30
31
  require "megam/core/config"
31
32
  require "megam/core/stuff"
32
33
  require "megam/core/text"
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.7.4"
3
+ VERSION = "0.7.5"
4
4
  end
5
5
  end
@@ -14,15 +14,15 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class DeleteNode
18
- def megam_rest
19
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
20
- Megam::API.new(options)
17
+ class DeleteNode < Megam::ServerAPI
18
+
19
+ def initialize(email=nil, api_key=nil)
20
+ super(email, api_key)
21
21
  end
22
+
22
23
 
23
- def self.create(node_name, group, action)
24
-
25
- delete_command = self.new()
24
+ def self.create(node_name, group, action, tmp_email, tmp_api_key)
25
+ delete_command = self.new(tmp_email, tmp_api_key)
26
26
  begin
27
27
  node_collection = delete_command.megam_rest.get_node(node_name)
28
28
  ct_collection = delete_command.megam_rest.get_cloudtools
@@ -14,15 +14,16 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class MakeNode
18
- def megam_rest
19
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
20
- Megam::API.new(options)
17
+ class MakeNode < Megam::ServerAPI
18
+
19
+ def initialize(email=nil, api_key=nil)
20
+ super(email, api_key)
21
21
  end
22
-
23
- def self.create(data, group, action)
24
-
25
- make_command = self.new()
22
+
23
+
24
+
25
+ def self.create(data, group, action,tmp_email, tmp_api_key)
26
+ make_command = self.new(tmp_email, tmp_api_key)
26
27
  begin
27
28
  pc_collection = make_command.megam_rest.get_predefclouds
28
29
  ct_collection = make_command.megam_rest.get_cloudtools
@@ -121,11 +122,11 @@ module Megam
121
122
  node_hash
122
123
  end
123
124
 
124
- def self.change_runtime(deps, runtime, action)
125
+ def self.change_runtime(deps, runtime, action)
125
126
  project_name = File.basename(deps).split(".").first
126
127
  if /<projectname>/.match(runtime)
127
128
  runtime["unicorn_<projectname>"] = "unicorn_" + project_name
128
- end
129
+ end
129
130
  runtime
130
131
  end
131
132
  end
@@ -14,14 +14,15 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class Account
18
- def initialize
17
+ class Account < Megam::ServerAPI
18
+ def initialize(email=nil, api_key=nil)
19
19
  @id = nil
20
20
  @email = nil
21
21
  @api_key = nil
22
22
  @authority = nil
23
23
  @created_at = nil
24
24
  @some_msg = {}
25
+ super(email, api_key)
25
26
  end
26
27
 
27
28
  #used by resque workers and any other background job
@@ -29,11 +30,6 @@ module Megam
29
30
  self
30
31
  end
31
32
 
32
- def megam_rest
33
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
34
- Megam::API.new(options)
35
- end
36
-
37
33
  def id(arg=nil)
38
34
  if arg != nil
39
35
  @id = arg
@@ -132,17 +128,17 @@ module Megam
132
128
  end
133
129
 
134
130
  def self.from_hash(o)
135
- acct = self.new()
131
+ acct = self.new(o[:email], o[:api_key])
136
132
  acct.from_hash(o)
137
133
  acct
138
134
  end
139
135
 
140
136
  def from_hash(o)
141
137
  @id = o[:id] if o.has_key?(:id)
142
- @email = o[:email] if o.has_key?(:email)
138
+ @email = o[:email] if o.has_key?(:email)
143
139
  @api_key = o[:api_key] if o.has_key?(:api_key)
144
140
  @authority = o[:authority] if o.has_key?(:authority)
145
- @created_at = o[:created_at] if o.has_key?(:created_at)
141
+ @created_at = o[:created_at] if o.has_key?(:created_at)
146
142
  self
147
143
  end
148
144
 
@@ -152,9 +148,9 @@ module Megam
152
148
  end
153
149
 
154
150
  # Load a account by email_p
155
- def self.show(email)
156
- acct = self.new()
157
- acct.megam_rest.get_accounts(email)
151
+ def self.show(email,api_key=nil)
152
+ acct = self.new(email, api_key)
153
+ megam_rest.get_accounts(email)
158
154
  end
159
155
 
160
156
  # Create the node via the REST API
@@ -164,7 +160,6 @@ module Megam
164
160
 
165
161
  def to_s
166
162
  Megam::Stuff.styled_hash(to_hash)
167
- #"---> Megam::Account:[error=#{error?}]\n"+
168
163
  end
169
164
  end
170
165
  end
@@ -14,11 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class AppRequest
18
- # Each notify entry is a resource/action pair, modeled as an
19
- # Struct with a #resource and #action member
20
-
21
- def initialize
17
+ class AppRequest< Megam::ServerAPI
18
+
19
+ def initialize(email=nil, api_key=nil)
22
20
  @id = nil
23
21
  @req_type = nil
24
22
  @appdefns_id = nil
@@ -28,15 +26,13 @@ module Megam
28
26
  @lc_when = nil
29
27
  @created_at = nil
30
28
  @some_msg = {}
29
+ super(email,api_key)
31
30
  end
31
+
32
32
  def appreq
33
33
  self
34
34
  end
35
-
36
- def megam_rest
37
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
38
- Megam::API.new(options)
39
- end
35
+
40
36
 
41
37
  def id(arg=nil)
42
38
  if arg != nil
@@ -188,8 +184,8 @@ module Megam
188
184
  appreq
189
185
  end
190
186
 
191
- def self.from_hash(o)
192
- appreq = self.new()
187
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
188
+ appreq = self.new(tmp_email, tmp_api_key)
193
189
  appreq.from_hash(o)
194
190
  appreq
195
191
  end
@@ -206,8 +202,8 @@ module Megam
206
202
  self
207
203
  end
208
204
 
209
- def self.create(o)
210
- acct = from_hash(o)
205
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
206
+ acct = from_hash(o,tmp_email, tmp_api_key)
211
207
  acct.create
212
208
  end
213
209
 
@@ -217,15 +213,14 @@ module Megam
217
213
  end
218
214
 
219
215
  # Load a account by email_p
220
- def self.list(node_name)
221
- appreq = self.new()
216
+ def self.list(node_name,tmp_email=nil, tmp_api_key=nil)
217
+ appreq = self.new(tmp_email, tmp_api_key)
222
218
  appreq.megam_rest.get_appreq(node_name)
223
219
  #self
224
220
  end
225
221
 
226
222
  def to_s
227
223
  Megam::Stuff.styled_hash(to_hash)
228
- #"---> Megam::Account:[error=#{error?}]\n"+
229
224
  end
230
225
 
231
226
  end
@@ -14,28 +14,23 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class Appdefns
18
- # Each notify entry is a resource/action pair, modeled as an
19
- # Struct with a #resource and #action member
20
-
21
- def initialize
17
+ class Appdefns < Megam::ServerAPI
18
+
19
+ def initialize(email=nil, api_key=nil)
22
20
  @id = nil
23
21
  @node_id = nil
24
22
  @node_name = nil
25
23
  @appdefns ={}
26
24
  @created_at = nil
27
25
  @some_msg = {}
26
+ super(email, api_key)
28
27
  end
29
28
 
30
29
  def appdefns
31
30
  self
32
31
  end
33
32
 
34
- def megam_rest
35
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
36
- Megam::API.new(options)
37
- end
38
-
33
+
39
34
  def id(arg=nil)
40
35
  if arg != nil
41
36
  @id = arg
@@ -141,8 +136,8 @@ module Megam
141
136
  appdefns
142
137
  end
143
138
 
144
- def self.from_hash(o)
145
- appdefns = self.new()
139
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
140
+ appdefns = self.new(tmp_email, tmp_api_key)
146
141
  appdefns.from_hash(o)
147
142
  appdefns
148
143
  end
@@ -156,8 +151,8 @@ module Megam
156
151
  self
157
152
  end
158
153
 
159
- def self.create(o)
160
- acct = from_hash(o)
154
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
155
+ acct = from_hash(o,tmp_email=nil, tmp_api_key=nil)
161
156
  acct.create
162
157
  end
163
158
 
@@ -167,14 +162,14 @@ module Megam
167
162
  end
168
163
 
169
164
  # Load a account by email_p
170
- def self.show(id)
171
- appdefns = self.new()
165
+ def self.show(id,tmp_email=nil, tmp_api_key=nil)
166
+ appdefns = self.new(tmp_email, tmp_api_key)
172
167
  appdefns.megam_rest.get_appdefn(id)
173
168
  end
174
169
 
175
170
  # Load a account by email_p
176
- def self.shown(node_name, id)
177
- appdefns = self.new()
171
+ def self.show_by_node(node_name, id,tmp_email=nil, tmp_api_key=nil)
172
+ appdefns = self.new(tmp_email, tmp_api_key)
178
173
  appdefns.megam_rest.get_appdefn(node_name,id)
179
174
  end
180
175
 
@@ -14,18 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class BoltRequest
18
- # Each notify entry is a resource/action pair, modeled as an
19
- # Struct with a #resource and #action member
20
- =begin
21
- def self.hash_tree
22
- Hash.new do |hash, key|
23
- hash[key] = hash_tree
24
- end
25
- end
26
- =end
27
-
28
- def initialize
17
+ class BoltRequest < Megam::ServerAPI
18
+ def initialize(email=nil, api_key=nil)
29
19
  @id = nil
30
20
  @req_type = nil
31
21
  @boltdefns_id = nil
@@ -35,16 +25,14 @@ module Megam
35
25
  @lc_when = nil
36
26
  @created_at = nil
37
27
  @some_msg = {}
28
+ super(email, api_key)
38
29
  end
30
+
39
31
  def boltreqs
40
32
  self
41
33
  end
42
34
 
43
- def megam_rest
44
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
45
- Megam::API.new(options)
46
- end
47
-
35
+
48
36
  def id(arg=nil)
49
37
  if arg != nil
50
38
  @id = arg
@@ -108,6 +96,7 @@ module Megam
108
96
  @created_at
109
97
  end
110
98
  end
99
+
111
100
  def some_msg(arg=nil)
112
101
  if arg != nil
113
102
  @some_msg = arg
@@ -116,7 +105,6 @@ module Megam
116
105
  end
117
106
  end
118
107
 
119
-
120
108
  def error?
121
109
  crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
122
110
  end
@@ -157,7 +145,6 @@ module Megam
157
145
  result
158
146
  end
159
147
 
160
-
161
148
  # Create a Megam::Node from NodeResult-JSON
162
149
  #
163
150
  #[{
@@ -196,8 +183,8 @@ module Megam
196
183
  boltreqs
197
184
  end
198
185
 
199
- def self.from_hash(o)
200
- boltreqs = self.new()
186
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
187
+ boltreqs = self.new(tmp_email, tmp_api_key)
201
188
  boltreqs.from_hash(o)
202
189
  boltreqs
203
190
  end
@@ -214,8 +201,8 @@ module Megam
214
201
  self
215
202
  end
216
203
 
217
- def self.create(o)
218
- acct = from_hash(o)
204
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
205
+ acct = from_hash(o,tmp_email, tmp_api_key)
219
206
  acct.create
220
207
  end
221
208
 
@@ -225,14 +212,13 @@ module Megam
225
212
  end
226
213
 
227
214
  # Load a account by email_p
228
- def self.list(node_name)
229
- boltreq = self.new()
215
+ def self.list(node_name,tmp_email=nil, tmp_api_key=nil)
216
+ boltreq = self.new(tmp_email, tmp_api_key)
230
217
  boltreq.megam_rest.get_boltreq(node_name)
231
218
  end
232
219
 
233
220
  def to_s
234
221
  Megam::Stuff.styled_hash(to_hash)
235
- #"---> Megam::Account:[error=#{error?}]\n"+
236
222
  end
237
223
 
238
224
  end
@@ -15,33 +15,22 @@
15
15
  #
16
16
 
17
17
  module Megam
18
- class Boltdefns
19
- # Each notify entry is a resource/action pair, modeled as an
20
- # Struct with a #resource and #action member
21
- =begin
22
- def self.hash_tree
23
- Hash.new do |hash, key|
24
- hash[key] = hash_tree
25
- end
26
- end
27
- =end
28
- def initialize
18
+ class Boltdefns < Megam::ServerAPI
19
+ def initialize(email=nil, api_key=nil)
29
20
  @id = nil
30
21
  @node_id = nil
31
22
  @node_name = nil
32
23
  @boltdefns ={}
33
24
  @created_at = nil
34
25
  @some_msg = {}
26
+ super(email,api_key)
35
27
  end
36
28
 
37
29
  def boltdefns
38
30
  self
39
31
  end
40
32
 
41
- def megam_rest
42
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
43
- Megam::API.new(options)
44
- end
33
+
45
34
 
46
35
  def id(arg=nil)
47
36
  if arg != nil
@@ -172,8 +161,8 @@ end
172
161
  boltdefns
173
162
  end
174
163
 
175
- def self.from_hash(o)
176
- boltdefns = self.new()
164
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
165
+ boltdefns = self.new(tmp_email, tmp_api_key)
177
166
  boltdefns.from_hash(o)
178
167
  boltdefns
179
168
  end
@@ -187,8 +176,8 @@ end
187
176
  self
188
177
  end
189
178
 
190
- def self.create(o)
191
- acct = from_hash(o)
179
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
180
+ acct = from_hash(o,tmp_email, tmp_api_key)
192
181
  acct.create
193
182
  end
194
183
 
@@ -198,14 +187,14 @@ end
198
187
  end
199
188
 
200
189
  # Show all bolt defns by [node_name]/email
201
- def self.show(node_name)
202
- boltdefns = self.new()
190
+ def self.show(node_name,tmp_email=nil, tmp_api_key=nil)
191
+ boltdefns = self.new(tmp_email, tmp_api_key)
203
192
  boltdefns.megam_rest.get_boltdefn(node_name)
204
193
  end
205
194
 
206
195
  # Show a bolt defn by [node_name, defn id] for an email
207
- def self.shown(node_name,id)
208
- boltdefns = self.new()
196
+ def self.show_by_node(node_name,id,tmp_email=nil, tmp_api_key=nil)
197
+ boltdefns = self.new(tmp_email, tmp_api_key)
209
198
  boltdefns.megam_rest.get_boltdefn(node_name,id)
210
199
  end
211
200
 
@@ -14,24 +14,22 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class CloudTool
18
- def initialize
17
+ class CloudTool < Megam::ServerAPI
18
+
19
+ def initialize(email=nil, api_key=nil)
19
20
  @id = nil
20
21
  @name = nil
21
22
  @cli = nil
22
23
  @cloudtemplates = nil
23
24
  @some_msg = {}
25
+ super(email, api_key)
24
26
  end
25
27
 
26
28
  def cloud_tool
27
29
  self
28
30
  end
29
31
 
30
- def megam_rest
31
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
32
- Megam::API.new(options)
33
- end
34
-
32
+
35
33
  def id(arg=nil)
36
34
  if arg != nil
37
35
  @id = arg
@@ -133,15 +131,16 @@ module Megam
133
131
 
134
132
  # Load all cloudtools -
135
133
  # returns a CloudToolsCollection
136
- def self.list
137
- ct = self.new()
134
+ def self.list(tmp_email=nil, tmp_api_key=nil)
135
+ ct = self.new(tmp_email, tmp_api_key)
138
136
  ct.megam_rest.get_cloudtools
139
137
  end
140
138
 
141
139
  # Show a particular cloudtool by name,
142
140
  # Megam::CloudTool
143
- def self.show(p_name)
144
- megam_rest.get_cloudtool(p_name)
141
+ def self.show(p_name,tmp_email=nil, tmp_api_key=nil)
142
+ ct = self.new(tmp_email=nil, tmp_api_key=nil)
143
+ ct.megam_rest.get_cloudtool(p_name)
145
144
  self
146
145
  end
147
146
 
@@ -14,10 +14,9 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class CloudToolSetting
18
- # Each notify entry is a resource/action pair, modeled as an
19
- # Struct with a #resource and #action member
20
- def initialize
17
+ class CloudToolSetting < Megam::ServerAPI
18
+
19
+ def initialize(email=nil, api_key=nil)
21
20
  @id = nil
22
21
  @accounts_id = nil
23
22
  @cloud_type = nil
@@ -27,17 +26,14 @@ module Megam
27
26
  @conf_location=nil
28
27
  @created_at = nil
29
28
  @some_msg = {}
29
+ super(email, api_key)
30
30
  end
31
31
 
32
32
  def cloud_tool_setting
33
33
  self
34
34
  end
35
35
 
36
- def megam_rest
37
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
38
- Megam::API.new(options)
39
- end
40
-
36
+
41
37
  def id(arg=nil)
42
38
  if arg != nil
43
39
  @id = arg
@@ -170,8 +166,8 @@ module Megam
170
166
  cts
171
167
  end
172
168
 
173
- def self.from_hash(o)
174
- cts = self.new()
169
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
170
+ cts = self.new(tmp_email,tmp_api_key)
175
171
  cts.from_hash(o)
176
172
  cts
177
173
  end
@@ -188,8 +184,8 @@ module Megam
188
184
  self
189
185
  end
190
186
 
191
- def self.create(o)
192
- acct = from_hash(o)
187
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
188
+ acct = from_hash(o,tmp_email, tmp_api_key)
193
189
  acct.create
194
190
  end
195
191
 
@@ -201,21 +197,20 @@ module Megam
201
197
  # Load all cloudtoolsettings -
202
198
  # returns a cloudtoolsettingsCollection
203
199
  # don't return self. check if the Megam::cloudtoolsettingCollection is returned.
204
- def self.list
205
- cts = self.new()
200
+ def self.list(tmp_email=nil, tmp_api_key=nil)
201
+ cts = self.new(tmp_email, tmp_api_key)
206
202
  cts.megam_rest.get_cloudtoolsettings
207
203
  end
208
204
 
209
205
  # Show a particular cloudtoolsetting by name,
210
206
  # Megam::cloudtoolsetting
211
- def self.show(p_name)
212
- pre = self.new()
207
+ def self.show(p_name,tmp_email=nil, tmp_api_key=nil)
208
+ pre = self.new(tmp_email, tmp_api_key)
213
209
  pre.megam_rest.get_cloudtoolsetting(p_name)
214
210
  end
215
211
 
216
212
  def to_s
217
213
  Megam::Stuff.styled_hash(to_hash)
218
- #"---> Megam::Account:[error=#{error?}]\n"+
219
214
  end
220
215
 
221
216
  end
@@ -14,19 +14,10 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  require 'hashie'
17
- module Megam
18
- class Node
19
- # Each notify entry is a resource/action pair, modeled as an
20
- # Struct with a #resource and #action member
21
- =begin
22
- def self.hash_tree
23
- Hash.new do |hash, key|
24
- hash[key] = hash_tree
25
- end
26
- end
27
- =end
28
17
 
29
- def initialize
18
+ module Megam
19
+ class Node < Megam::ServerAPI
20
+ def initialize(email=nil, api_key=nil)
30
21
  @id = nil
31
22
  @node_name = nil
32
23
  @accounts_id = nil
@@ -37,23 +28,20 @@ module Megam
37
28
  @request ={}
38
29
  @predefs={}
39
30
  @some_msg = {}
40
- #@command = self.class.hash_tree
41
- @command = Hashie::Mash.new
42
- @appdefnsid = nil
43
- @boltdefnsid = nil
44
- @appdefns = {}
45
- @boltdefns = {}
31
+ @command = Hashie::Mash.new
32
+ @appdefnsid = nil
33
+ @boltdefnsid = nil
34
+ @appdefns = {}
35
+ @boltdefns = {}
46
36
  @created_at = nil
37
+ super(email, api_key)
47
38
  end
39
+
48
40
  def node
49
41
  self
50
42
  end
51
43
 
52
- def megam_rest
53
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
54
- Megam::API.new(options)
55
- end
56
-
44
+
57
45
  def node_name(arg=nil)
58
46
  if arg != nil
59
47
  @node_name = arg
@@ -149,6 +137,7 @@ module Megam
149
137
  @boltdefns
150
138
  end
151
139
  end
140
+
152
141
  def appdefnsid(arg=nil)
153
142
  if arg != nil
154
143
  @appdefnsid = arg
@@ -273,18 +262,18 @@ module Megam
273
262
 
274
263
  #Command
275
264
  =begin
276
- node.command[:systemprovider][:provider][:prov] = oc["systemprovider"]["provider"]["prov"]
277
- node.command[:compute][:cctype] = oc["compute"]["cctype"]
278
- node.command[:compute][:cc][:groups] = oc["compute"]["cc"]["groups"]
279
- node.command[:compute][:cc][:image] = oc["compute"]["cc"]["image"]
280
- node.command[:compute][:cc][:flavor] = oc["compute"]["cc"]["flavor"]
281
- node.command[:compute][:access][:ssh_key] = oc["compute"]["access"]["ssh_key"]
282
- node.command[:compute][:access][:identity_file] = oc["compute"]["access"]["identity_file"]
283
- node.command[:compute][:access][:ssh_user] = oc["compute"]["access"]["ssh_user"]
284
- node.command[:cloudtool][:chef][:command] = oc["cloudtool"]["chef"]["command"]
285
- node.command[:cloudtool][:chef][:plugin] = oc["cloudtool"]["chef"]["plugin"]
286
- node.command[:cloudtool][:chef][:run_list] = oc["cloudtool"]["chef"]["run_list"]
287
- node.command[:cloudtool][:chef][:name] = oc["cloudtool"]["chef"]["name"]
265
+ node.command[:systemprovider][:provider][:prov] = oc["systemprovider"]["provider"]["prov"]
266
+ node.command[:compute][:cctype] = oc["compute"]["cctype"]
267
+ node.command[:compute][:cc][:groups] = oc["compute"]["cc"]["groups"]
268
+ node.command[:compute][:cc][:image] = oc["compute"]["cc"]["image"]
269
+ node.command[:compute][:cc][:flavor] = oc["compute"]["cc"]["flavor"]
270
+ node.command[:compute][:access][:ssh_key] = oc["compute"]["access"]["ssh_key"]
271
+ node.command[:compute][:access][:identity_file] = oc["compute"]["access"]["identity_file"]
272
+ node.command[:compute][:access][:ssh_user] = oc["compute"]["access"]["ssh_user"]
273
+ node.command[:cloudtool][:chef][:command] = oc["cloudtool"]["chef"]["command"]
274
+ node.command[:cloudtool][:chef][:plugin] = oc["cloudtool"]["chef"]["plugin"]
275
+ node.command[:cloudtool][:chef][:run_list] = oc["cloudtool"]["chef"]["run_list"]
276
+ node.command[:cloudtool][:chef][:name] = oc["cloudtool"]["chef"]["name"]
288
277
  =end
289
278
  #predef
290
279
  op = o["predefs"]
@@ -321,8 +310,8 @@ module Megam
321
310
  node
322
311
  end
323
312
 
324
- def self.from_hash(o)
325
- node = self.new()
313
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
314
+ node = self.new(tmp_email, tmp_api_key)
326
315
  node.from_hash(o)
327
316
  node
328
317
  end
@@ -345,8 +334,8 @@ module Megam
345
334
  self
346
335
  end
347
336
 
348
- def self.create(o)
349
- acct = from_hash(o)
337
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
338
+ acct = from_hash(o, tmp_email, tmp_api_key)
350
339
  acct.create
351
340
  end
352
341
 
@@ -356,13 +345,13 @@ module Megam
356
345
  end
357
346
 
358
347
  # Load a account by email_p
359
- def self.show(node_name)
360
- node = self.new()
348
+ def self.show(node_name,tmp_email=nil, tmp_api_key=nil)
349
+ node = self.new(tmp_email, tmp_api_key)
361
350
  node.megam_rest.get_node(node_name)
362
351
  end
363
352
 
364
- def self.list
365
- node = self.new()
353
+ def self.list(tmp_email=nil, tmp_api_key=nil)
354
+ node = self.new(tmp_email, tmp_api_key)
366
355
  node.megam_rest.get_nodes
367
356
  end
368
357
 
@@ -14,9 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class Predef
18
-
19
- def initialize
17
+ class Predef < Megam::ServerAPI
18
+ def initialize(email=nil, api_key=nil)
20
19
  @id = nil
21
20
  @name = nil
22
21
  @provider = nil
@@ -25,17 +24,13 @@ module Megam
25
24
  @runtime_exec = nil
26
25
  @created_at = nil
27
26
  @some_msg = {}
27
+ super(email, api_key)
28
28
  end
29
29
 
30
30
  def predef
31
31
  self
32
32
  end
33
33
 
34
- def megam_rest
35
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
36
- Megam::API.new(options)
37
- end
38
-
39
34
  def id(arg=nil)
40
35
  if arg != nil
41
36
  @id = arg
@@ -67,7 +62,7 @@ module Megam
67
62
  @provider
68
63
  end
69
64
  end
70
-
65
+
71
66
  def provider_role(arg=nil)
72
67
  if arg != nil
73
68
  @provider_role = arg
@@ -155,8 +150,8 @@ module Megam
155
150
  node
156
151
  end
157
152
 
158
- def self.from_hash(o)
159
- node = self.new()
153
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
154
+ node = self.new(tmp_email, tmp_api_key)
160
155
  node.from_hash(o)
161
156
  node
162
157
  end
@@ -171,13 +166,12 @@ module Megam
171
166
  @created_at = o[:created_at] if o.has_key?(:created_at)
172
167
  self
173
168
  end
174
-
175
- def self.create
176
- predef = build
169
+
170
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
171
+ predef = from_hash(o,tmp_email, tmp_api_key)
177
172
  predef.create
178
173
  end
179
174
 
180
-
181
175
  # Create the predef via the REST API
182
176
  def create(predef_input)
183
177
  megam_rest.post_predef(predef_input)
@@ -187,21 +181,20 @@ module Megam
187
181
  # Load all predefs -
188
182
  # returns a PredefsCollection
189
183
  # don't return self. check if the Megam::PredefCollection is returned.
190
- def self.list
191
- prede = self.new()
184
+ def self.list(tmp_email=nil, tmp_api_key=nil)
185
+ prede = self.new(tmp_email,tmp_api_key)
192
186
  prede.megam_rest.get_predefs
193
187
  end
194
188
 
195
189
  # Show a particular predef by name,
196
190
  # Megam::Predef
197
- def self.show(p_name)
198
- prede = self.new()
191
+ def self.show(p_name,tmp_email=nil, tmp_api_key=nil)
192
+ prede = self.new(tmp_email,tmp_api_key)
199
193
  prede.megam_rest.get_predef(p_name)
200
194
  end
201
195
 
202
196
  def to_s
203
197
  Megam::Stuff.styled_hash(to_hash)
204
- #"---> Megam::Account:[error=#{error?}]\n"+
205
198
  end
206
199
 
207
200
  end
@@ -15,10 +15,8 @@
15
15
  # limitations under the License.
16
16
  #
17
17
  module Megam
18
- class PredefCloud
19
- # Each notify entry is a resource/action pair, modeled as an
20
- # Struct with a #resource and #action member
21
- def initialize
18
+ class PredefCloud < Megam::ServerAPI
19
+ def initialize(email=nil, api_key=nil)
22
20
  @id = nil
23
21
  @name = nil
24
22
  @accounts_id = nil
@@ -28,17 +26,14 @@ module Megam
28
26
  #@performance = nil
29
27
  @created_at = nil
30
28
  @some_msg = {}
29
+ super(email, api_key)
31
30
  end
32
31
 
33
32
  def predef_cloud
34
33
  self
35
34
  end
36
35
 
37
- def megam_rest
38
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
39
- Megam::API.new(options)
40
- end
41
-
36
+
42
37
  def id(arg=nil)
43
38
  if arg != nil
44
39
  @id = arg
@@ -200,8 +195,8 @@ module Megam
200
195
  self
201
196
  end
202
197
 
203
- def self.create(o)
204
- acct = from_hash(o)
198
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
199
+ acct = from_hash(o,tmp_email, tmp_api_key)
205
200
  acct.create
206
201
  end
207
202
 
@@ -213,16 +208,16 @@ module Megam
213
208
  # Load all predefs -
214
209
  # returns a PredefsCollection
215
210
  # don't return self. check if the Megam::PredefCollection is returned.
216
- def self.list
217
- predef = self.new()
211
+ def self.list(tmp_email=nil, tmp_api_key=nil)
212
+ predef = self.new(tmp_email,tmp_api_key)
218
213
  predef.megam_rest.get_predefclouds
219
214
  end
220
215
 
221
216
  # Show a particular predef by name,
222
217
  # Megam::Predef
223
- def self.show(p_name)
224
- pre = self.new()
225
- pre.megam_rest.get_predefcloud(p_name)
218
+ def self.show(p_name,tmp_email=nil, tmp_api_key=nil)
219
+ pre = self.new(tmp_email,tmp_api_key)
220
+ pre.megam_rest.get_predefcloud(p_name)
226
221
  end
227
222
 
228
223
  def to_s
@@ -14,8 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Megam
17
- class Request
18
- def initialize
17
+ class Request < Megam::ServerAPI
18
+ def initialize(email=nil, api_key=nil)
19
19
  @id = nil
20
20
  @node_id = nil
21
21
  @node_name = nil
@@ -23,17 +23,14 @@ module Megam
23
23
  @command =nil
24
24
  @some_msg = {}
25
25
  @created_at = nil
26
+ super(email, api_key)
26
27
  end
27
28
 
28
29
  def request
29
30
  self
30
31
  end
31
32
 
32
- def megam_rest
33
- options = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]}
34
- Megam::API.new(options)
35
- end
36
-
33
+
37
34
  def id(arg=nil)
38
35
  if arg != nil
39
36
  @id = arg
@@ -140,8 +137,8 @@ module Megam
140
137
  node
141
138
  end
142
139
 
143
- def self.from_hash(o)
144
- node = self.new()
140
+ def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
141
+ node = self.new(tmp_email, tmp_api_key)
145
142
  node.from_hash(o)
146
143
  node
147
144
  end
@@ -157,8 +154,8 @@ module Megam
157
154
  end
158
155
 
159
156
 
160
- def self.create(o)
161
- acct = from_hash(o)
157
+ def self.create(o,tmp_email=nil, tmp_api_key=nil)
158
+ acct = from_hash(o,tmp_email, tmp_api_key)
162
159
  acct.create
163
160
  end
164
161
 
@@ -168,13 +165,13 @@ module Megam
168
165
  end
169
166
 
170
167
 
171
- def self.show
172
- prede = self.new()
168
+ def self.show(tmp_email=nil, tmp_api_key=nil)
169
+ prede = self.new(tmp_email, tmp_api_key)
173
170
  prede.megam_rest.get_requests
174
171
  end
175
172
 
176
- def self.list(n_name)
177
- prede = self.new()
173
+ def self.list(n_name,tmp_email=nil, tmp_api_key=nil)
174
+ prede = self.new(tmp_email,tmp_api_key)
178
175
  prede.megam_rest.get_request(n_name)
179
176
  end
180
177
 
@@ -0,0 +1,48 @@
1
+ # Copyright:: Copyright (c) 2012, 2013 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
+
17
+ module Megam
18
+ # Basic HTTP client, with support for adding features via middleware
19
+ class ServerAPI
20
+
21
+
22
+ attr_reader :email
23
+ attr_reader :api_key
24
+
25
+
26
+ # Create a Megam REST object. The supplied email and api_key is used as the base for
27
+ # all subsequent requests. For example, when initialized with an email, api_key url
28
+ # https://api.megam.co, a call to +get+ with 'nodes' will make an
29
+ # HTTP GET request to http://api.megam.co/nodes using the email, api_key
30
+ def initialize(email=nil, api_key=nil)
31
+ @email = email
32
+ @api_key = api_key
33
+ end
34
+
35
+ # Build a megam api client
36
+ #
37
+ # === Parameters
38
+ # api:: The Megam::API client
39
+ def megam_rest
40
+ options = { :email =>email || Megam::Config[:email], :api_key => api_key || Megam::Config[:api_key]}
41
+ Megam::API.new(options)
42
+ end
43
+
44
+
45
+
46
+ end
47
+ end
48
+
data/megam_api.gemspec CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
- s.add_runtime_dependency 'excon', '~> 0'
20
- s.add_runtime_dependency 'highline', '~> 0'
21
- s.add_runtime_dependency 'yajl-ruby', '~> 0'
22
- s.add_runtime_dependency 'mixlib-config', '~> 2.0'
23
- s.add_runtime_dependency 'mixlib-log', '~> 1.0'
24
- s.add_development_dependency 'minitest', '~> 0'
25
- s.add_development_dependency 'rake', '~> 0'
19
+ s.add_runtime_dependency 'excon', '~> 0.31'
20
+ s.add_runtime_dependency 'highline', '~> 1.6'
21
+ s.add_runtime_dependency 'yajl-ruby', '~> 1.2'
22
+ s.add_runtime_dependency 'mixlib-config', '~> 2.1'
23
+ s.add_runtime_dependency 'mixlib-log', '~> 1.6'
24
+ s.add_development_dependency 'minitest', '~> 5.2'
25
+ s.add_development_dependency 'rake', '~> 10.1'
26
26
  end
@@ -4,15 +4,15 @@ class TestAccounts < MiniTest::Unit::TestCase
4
4
 
5
5
  $admin = "admin-tom"
6
6
  $normal = "normal-tom"
7
+ $tom_email = "tom@gomegam.com"
8
+ $bob_email = "bob@gomegam.com"
7
9
 
8
10
  def test_get_accounts_good
9
- #response =megams.get_accounts(sandbox_email)
10
- response =megams.get_accounts('a@b.com')
11
+ response =megams.get_accounts(sandbox_email)
11
12
  response.body.to_s
12
13
  assert_equal(200, response.status)
13
14
  end
14
15
 
15
- =begin
16
16
  def test_get_accounts_bad
17
17
  assert_raises(Megam::API::Errors::NotFound) do
18
18
  response =megams.get_accounts(sandbox_email+"_bad")
@@ -22,14 +22,14 @@ class TestAccounts < MiniTest::Unit::TestCase
22
22
 
23
23
  def test_post_accounts_admin
24
24
  response =megams.post_accounts(
25
- {:id => random_id, :email => sandbox_email, :api_key => sandbox_apikey, :authority => $admin})
25
+ {:id => random_id, :email => $tom_email, :api_key => sandbox_apikey, :authority => $admin})
26
26
  response.body.to_s
27
27
  assert_equal(201, response.status)
28
28
  end
29
29
 
30
30
  def test_post_accounts_normal
31
31
  response =megams.post_accounts(
32
- {:id => random_id, :email => sandbox_email, :api_key => sandbox_apikey, :authority => $normal})
32
+ {:id => random_id, :email => $bob_email, :api_key => sandbox_apikey, :authority => $normal})
33
33
  response.body.to_s
34
34
  assert_equal(201, response.status)
35
35
  end
@@ -42,6 +42,4 @@ class TestAccounts < MiniTest::Unit::TestCase
42
42
  response.body.to_s
43
43
  end
44
44
  end
45
- =end
46
- end
47
-
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kishorekumar Neelamegam, Thomas Alrin, Subash Sethurajan, Rajthilak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2014-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -16,98 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.31'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.31'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: highline
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yajl-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mixlib-config
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: '2.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '2.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mixlib-log
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.0'
75
+ version: '1.6'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: '1.6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: minitest
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '5.2'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '5.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '10.1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '10.1'
111
111
  description: Ruby Client for the Megam Cloud. Performs REST based HTTP calls to api.megam.co
112
112
  http://github.com/indykish/megam_play.git
113
113
  email:
@@ -177,6 +177,7 @@ files:
177
177
  - lib/megam/core/predefcloud_collection.rb
178
178
  - lib/megam/core/request.rb
179
179
  - lib/megam/core/request_collection.rb
180
+ - lib/megam/core/server_api.rb
180
181
  - lib/megam/core/stuff.rb
181
182
  - lib/megam/core/text.rb
182
183
  - lib/megam/core/text_formatter.rb