megam_api 0.7.1 → 0.7.2

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: 61893bc0541b6eae92badc0a4973aa3dffd4f4c4
4
- data.tar.gz: 730924c194e9b92611f29232fda2c35b8378741b
3
+ metadata.gz: 18c65c1b5bad20bae3824e93dc24c97a5e78af5b
4
+ data.tar.gz: 549d74e7aa3e9c1319c55183409a84ce9417cd87
5
5
  SHA512:
6
- metadata.gz: 726681779468ca612c7fe69dcd970f2b6a23608998af628c8f2499af62ece774f9c0f78e8f746a97d6727f4c80db9b907df94efa708fa0fed09446f25f6cc9ab
7
- data.tar.gz: 5749d4401a773a3ca45bb00d8042ebcf8d41a8075d854fbf491bdd806a977b25eddbe18215efcab3d2ae80585742a3c4af6900793b81334e3b6eb4d4a6ade243
6
+ metadata.gz: aa1e94ce4b19cad03b9aa4d32caea27ab1607bb71ae3a6ab9b8bc57c170af6761bef0699ae5585e7c2e3c7aef8eb17d5b5d06db0d4caaa53992c906903b9fa3d
7
+ data.tar.gz: 9a7596daa4428473102a9ee50a1c3b8f25ad1dad16085f662cdb00774cbb5fc13e7b85da1bfd25f6d7761d51e1719d565699e359763461e2b37e2f1f1295cdc9
data/lib/megam/api.rb CHANGED
@@ -115,6 +115,7 @@ module Megam
115
115
  end
116
116
 
117
117
  def request(params,&block)
118
+ just_color_debug("#{@options[:path]}")
118
119
  start = Time.now
119
120
  Megam::Log.debug("START")
120
121
  params.each do |pkey, pvalue|
@@ -137,7 +138,7 @@ module Megam
137
138
  end
138
139
  reerror = klass.new(error.message, error.response)
139
140
  reerror.set_backtrace(error.backtrace)
140
- Megam::Log.error("#{reerror.response.body}")
141
+ Megam::Log.debug("#{reerror.response.body}")
141
142
  reerror.response.body = Megam::JSONCompat.from_json(reerror.response.body.chomp)
142
143
  Megam::Log.debug("RESPONSE ERR: Ruby Object")
143
144
  Megam::Log.debug("#{reerror.response.body}")
@@ -177,6 +178,10 @@ module Megam
177
178
 
178
179
  private
179
180
 
181
+ def just_color_debug(path)
182
+ text.msg "--> #{text.color("(#{path})", :cyan,:bold)}"
183
+ end
184
+
180
185
  #Make a lazy connection.
181
186
  def connection
182
187
  @options[:path] =API_VERSION1+ @options[:path]
@@ -10,6 +10,16 @@ module Megam
10
10
  :body => @options[:body]
11
11
  )
12
12
  end
13
+
14
+ def get_appdefn(node_name,defn_id)
15
+ @options = {:path => "/appdefns/#{node_name}/#{defn_id}",:body => ""}.merge(@options)
16
+
17
+ request(
18
+ :expects => 200,
19
+ :method => :get,
20
+ :body => @options[:body]
21
+ )
22
+ end
13
23
 
14
24
  def post_appdefn(new_appdefn)
15
25
  @options = {:path => '/appdefns/content',
@@ -21,7 +21,6 @@ module Megam
21
21
  end
22
22
 
23
23
  def post_cloudtoolsetting(new_cloudtoolsetting)
24
- puts "entry"
25
24
  @options = {:path => '/cloudtoolsettings/content',
26
25
  :body => Megam::JSONCompat.to_json(new_cloudtoolsetting)}.merge(@options)
27
26
 
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.7.1"
3
+ VERSION = "0.7.2"
4
4
  end
5
5
  end
@@ -21,72 +21,71 @@ module Megam
21
21
  end
22
22
 
23
23
  def self.create(node_name, group, action)
24
-
25
- delete_command = self.new()
26
- begin
27
- node_collection = delete_command.megam_rest.get_node(node_name)
28
- ct_collection = delete_command.megam_rest.get_cloudtools
29
-
30
- rescue ArgumentError => ae
31
- hash = {"msg" => ae.message, "msg_type" => "error"}
32
- re = Megam::Error.from_hash(hash)
33
- return re
34
- rescue Megam::API::Errors::ErrorWithResponse => ewr
35
- hash = {"msg" => ewr.message, "msg_type" => "error"}
36
- re = Megam::Error.from_hash(hash)
37
- return re
38
- rescue StandardError => se
39
- hash = {"msg" => se.message, "msg_type" => "error"}
40
- re = Megam::Error.from_hash(hash)
24
+
25
+ delete_command = self.new()
26
+ begin
27
+ node_collection = delete_command.megam_rest.get_node(node_name)
28
+ ct_collection = delete_command.megam_rest.get_cloudtools
29
+
30
+ rescue ArgumentError => ae
31
+ hash = {"msg" => ae.message, "msg_type" => "error"}
32
+ re = Megam::Error.from_hash(hash)
33
+ return re
34
+ rescue Megam::API::Errors::ErrorWithResponse => ewr
35
+ hash = {"msg" => ewr.message, "msg_type" => "error"}
36
+ re = Megam::Error.from_hash(hash)
37
+ return re
38
+ rescue StandardError => se
39
+ hash = {"msg" => se.message, "msg_type" => "error"}
40
+ re = Megam::Error.from_hash(hash)
41
41
  return re
42
- end
43
-
44
-
45
- node = node_collection.data[:body].lookup(node_name)
46
- tool = ct_collection.data[:body].lookup(node.request[:command]['systemprovider']['provider']['prov'])
47
- template = tool.cloudtemplates.lookup(node.request[:command]['compute']['cctype'])
48
- cloud_instruction = template.lookup_by_instruction(group, action)
49
- ci_command = "#{cloud_instruction.command}"
50
- ci_command["<node_name>"] = "#{node_name}"
42
+ end
43
+
44
+ node = node_collection.data[:body].lookup(node_name)
45
+ tool = ct_collection.data[:body].lookup(node.request[:command]['systemprovider']['provider']['prov'])
46
+ template = tool.cloudtemplates.lookup(node.request[:command]['compute']['cctype'])
47
+ cloud_instruction = template.lookup_by_instruction(group, action)
48
+ ci_command = "#{cloud_instruction.command}"
49
+ ci_command["<node_name>"] = "#{node_name}"
51
50
 
52
- command_hash = {
53
- "systemprovider" => {
54
- "provider" => {
55
- "prov" => "#{node.request[:command]['systemprovider']['provider']['prov']}"
56
- }
57
- },
58
- "compute" => {
59
- "cctype" => "#{node.request[:command]['compute']['cctype']}",
60
- "cc" => {
61
- "groups" => "",
62
- "image" => "",
63
- "flavor" => ""
64
- },
65
- "access" => {
66
- "ssh_key" => "#{node.request[:command]['compute']['access']['ssh_key']}",
67
- "identity_file" => "#{node.request[:command]['compute']['access']['identity_file']}",
68
- "ssh_user" => "",
69
- "vault_location" => "#{node.request[:command]['compute']['access']['vault_location']}",
70
- "sshpub_location" => "#{node.request[:command]['compute']['access']['sshpub_location']}",
71
- "zone" => "#{node.request[:command]['compute']['access']['zone']}"
72
- }
73
- },
74
- "cloudtool" => {
75
- "chef" => {
76
- "command" => "#{node.request[:command]['cloudtool']['chef']['prov']}",
77
- "plugin" => "#{node.request[:command]['compute']['cctype']} #{ci_command}", #ec2 server delete or create
78
- "run_list" => "",
79
- "name" => "-N #{node_name}"
80
- }
81
- }
82
- }
51
+ command_hash = {
52
+ "systemprovider" => {
53
+ "provider" => {
54
+ "prov" => "#{node.request[:command]['systemprovider']['provider']['prov']}"
55
+ }
56
+ },
57
+ "compute" => {
58
+ "cctype" => "#{node.request[:command]['compute']['cctype']}",
59
+ "cc" => {
60
+ "groups" => "",
61
+ "image" => "",
62
+ "flavor" => ""
63
+ },
64
+ "access" => {
65
+ "ssh_key" => "#{node.request[:command]['compute']['access']['ssh_key']}",
66
+ "identity_file" => "#{node.request[:command]['compute']['access']['identity_file']}",
67
+ "ssh_user" => "",
68
+ "vault_location" => "#{node.request[:command]['compute']['access']['vault_location']}",
69
+ "sshpub_location" => "#{node.request[:command]['compute']['access']['sshpub_location']}",
70
+ "zone" => "#{node.request[:command]['compute']['access']['zone']}"
71
+ }
72
+ },
73
+ "cloudtool" => {
74
+ "chef" => {
75
+ "command" => "#{node.request[:command]['cloudtool']['chef']['prov']}",
76
+ "plugin" => "#{node.request[:command]['compute']['cctype']} #{ci_command}", #ec2 server delete or create
77
+ "run_list" => "",
78
+ "name" => "-N #{node_name}"
79
+ }
80
+ }
81
+ }
83
82
 
84
83
  node_hash = {
85
84
  "node_name" => "#{node_name}",
86
85
  "req_type" => "#{action}",
87
86
  "command" => command_hash
88
87
  }
89
- node_hash
88
+ node_hash
90
89
  end
91
90
  end
92
91
  end
@@ -26,6 +26,7 @@ module Megam
26
26
  begin
27
27
  pc_collection = make_command.megam_rest.get_predefclouds
28
28
  ct_collection = make_command.megam_rest.get_cloudtools
29
+ cts_collection = make_command.megam_rest.get_cloudtoolsettings
29
30
 
30
31
  rescue ArgumentError => ae
31
32
  hash = {"msg" => ae.message, "msg_type" => "error"}
@@ -45,7 +46,9 @@ predef_cloud = pc_collection.data[:body].lookup("#{data[:predef_cloud_name]}")
45
46
  tool = ct_collection.data[:body].lookup(data[:provider])
46
47
  template = tool.cloudtemplates.lookup(predef_cloud.spec[:type_name])
47
48
  cloud_instruction = template.lookup_by_instruction(group, action)
48
- ci_command = cloud_instruction.command
49
+ cts = cts_collection.data[:body].lookup(data[:repo])
50
+ ci_command = "#{cloud_instruction.command}"
51
+ ci_command["-c"] = "-c #{cts.conf_location}"
49
52
  ci_name = cloud_instruction.name
50
53
 
51
54
  command_hash = {
@@ -59,7 +62,8 @@ ci_name = cloud_instruction.name
59
62
  "cc"=> {
60
63
  "groups" => "#{predef_cloud.spec[:groups]}",
61
64
  "image" => "#{predef_cloud.spec[:image]}",
62
- "flavor" => "#{predef_cloud.spec[:flavor]}"
65
+ "flavor" => "#{predef_cloud.spec[:flavor]}",
66
+ "tenant_id" => "#{predef_cloud.spec[:tenant_id]}"
63
67
  },
64
68
  "access" => {
65
69
  "ssh_key" => "#{predef_cloud.access[:ssh_key]}",
@@ -67,7 +71,8 @@ ci_name = cloud_instruction.name
67
71
  "ssh_user" => "#{predef_cloud.access[:ssh_user]}",
68
72
  "vault_location" => "#{predef_cloud.access[:vault_location]}",
69
73
  "sshpub_location" => "#{predef_cloud.access[:sshpub_location]}",
70
- "zone" => "#{predef_cloud.access[:zone]}"
74
+ "zone" => "#{predef_cloud.access[:zone]}",
75
+ "region" => "#{predef_cloud.access[:region]}"
71
76
  }
72
77
  },
73
78
  "cloudtool" => {
@@ -99,8 +104,7 @@ ci_name = cloud_instruction.name
99
104
  end
100
105
  if data[:book_type] == "BOLT"
101
106
  node_hash["boltdefns"] = {"username" => "#{data['user_name']}", "apikey" => "#{data['password']}", "store_name" => "#{data['store_db_name']}", "url" => "#{data['url']}", "prime" => "#{data['prime']}", "timetokill" => "#{data['timetokill']}", "metered" => "#{data['monitoring']}", "logging" => "#{data['logging']}", "runtime_exec" => "#{data['runtime_exec']}" }
102
- end
103
-
107
+ end
104
108
  node_hash
105
109
  end
106
110
  end
@@ -17,13 +17,6 @@ module Megam
17
17
  class AppRequest
18
18
  # Each notify entry is a resource/action pair, modeled as an
19
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
20
 
28
21
  def initialize
29
22
  @id = nil
@@ -17,13 +17,6 @@ module Megam
17
17
  class Appdefns
18
18
  # Each notify entry is a resource/action pair, modeled as an
19
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
20
 
28
21
  def initialize
29
22
  @id = nil
@@ -33,6 +26,7 @@ module Megam
33
26
  @created_at = nil
34
27
  @some_msg = {}
35
28
  end
29
+
36
30
  def appdefns
37
31
  self
38
32
  end
@@ -74,7 +68,6 @@ module Megam
74
68
  end
75
69
  end
76
70
 
77
-
78
71
  def created_at(arg=nil)
79
72
  if arg != nil
80
73
  @created_at = arg
@@ -97,8 +90,6 @@ module Megam
97
90
 
98
91
  # Transform the ruby obj -> to a Hash
99
92
  def to_hash
100
- puts "===================> CLASS NAME ====================================="
101
- puts self.class.name
102
93
  index_hash = Hash.new
103
94
  index_hash["json_claz"] = self.class.name
104
95
  index_hash["id"] = id
@@ -127,25 +118,7 @@ puts self.class.name
127
118
  result
128
119
  end
129
120
 
130
- # Create a Megam::Node from NodeResult-JSON
131
- #
132
- #[{
133
- #"id":"NOD362212018897289216",
134
- #"accounts_id":"ACT362211962353876992",
135
- #"json_claz":"Megam::Node",
136
- #"request":{
137
- #"req_id":"NOD362212018897289216",
138
- #"command":"commands"
139
- #},
140
- #"predefs":{
141
- #"name":"",
142
- #"scm":"",
143
- #"war":"",
144
- #"db":"",
145
- #"queue":""
146
- #}
147
- #}]
148
- #
121
+
149
122
  def self.json_create(o)
150
123
  appdefns = new
151
124
  appdefns.id(o["id"]) if o.has_key?("id")
@@ -198,10 +171,15 @@ puts self.class.name
198
171
  appdefns = self.new()
199
172
  appdefns.megam_rest.get_appdefn(node_name)
200
173
  end
174
+
175
+ # Load a account by email_p
176
+ def self.show(node_name, id)
177
+ appdefns = self.new()
178
+ appdefns.megam_rest.get_appdefn(node_name,id)
179
+ end
201
180
 
202
181
  def to_s
203
182
  Megam::Stuff.styled_hash(to_hash)
204
- #"---> Megam::Account:[error=#{error?}]\n"+
205
183
  end
206
184
 
207
185
  end
@@ -19,13 +19,12 @@ module Megam
19
19
  # Each notify entry is a resource/action pair, modeled as an
20
20
  # Struct with a #resource and #action member
21
21
  =begin
22
- def self.hash_tree
23
- Hash.new do |hash, key|
24
- hash[key] = hash_tree
25
- end
26
- end
22
+ def self.hash_tree
23
+ Hash.new do |hash, key|
24
+ hash[key] = hash_tree
25
+ end
26
+ end
27
27
  =end
28
-
29
28
  def initialize
30
29
  @id = nil
31
30
  @node_id = nil
@@ -34,6 +33,7 @@ module Megam
34
33
  @created_at = nil
35
34
  @some_msg = {}
36
35
  end
36
+
37
37
  def boltdefns
38
38
  self
39
39
  end
@@ -75,7 +75,6 @@ module Megam
75
75
  end
76
76
  end
77
77
 
78
-
79
78
  def created_at(arg=nil)
80
79
  if arg != nil
81
80
  @created_at = arg
@@ -152,7 +151,6 @@ module Megam
152
151
  boltdefns.node_name(o["node_name"]) if o.has_key?("node_name")
153
152
  boltdefns.created_at(o["created_at"]) if o.has_key?("created_at")
154
153
 
155
-
156
154
  #APP DEFINITIONS
157
155
  op = o["boltdefns"]
158
156
  boltdefns.boltdefns[:username] = op["username"] if op && op.has_key?("username")
@@ -199,16 +197,20 @@ module Megam
199
197
  megam_rest.post_boltdefn(to_hash)
200
198
  end
201
199
 
202
- # Load a account by email_p
200
+ # Show all bolt defns by [node_name]/email
203
201
  def self.show(node_name)
204
202
  boltdefns = self.new()
205
203
  boltdefns.megam_rest.get_boltdefn(node_name)
204
+ end
206
205
 
206
+ # Show a bolt defn by [node_name, defn id] for an email
207
+ def self.show(node_name,id)
208
+ boltdefns = self.new()
209
+ boltdefns.megam_rest.get_boltdefn(node_name,id)
207
210
  end
208
211
 
209
212
  def to_s
210
213
  Megam::Stuff.styled_hash(to_hash)
211
- #"---> Megam::Account:[error=#{error?}]\n"+
212
214
  end
213
215
 
214
216
  end
@@ -1,4 +1,3 @@
1
-
2
1
  # Copyright:: Copyright (c) 2012, 2013 Megam Systems
3
2
  # License:: Apache License, Version 2.0
4
3
  #
@@ -19,11 +18,13 @@ module Megam
19
18
  # Each notify entry is a resource/action pair, modeled as an
20
19
  # Struct with a #resource and #action member
21
20
  def initialize
22
- @id = nil
21
+ @id = nil
23
22
  @accounts_id = nil
24
23
  @cloud_type = nil
24
+ @repo_name = nil
25
25
  @repo = nil
26
- @vault_location=nil
26
+ @vault_location=nil
27
+ @conf_location=nil
27
28
  @created_at = nil
28
29
  @some_msg = {}
29
30
  end
@@ -43,7 +44,7 @@ module Megam
43
44
  else
44
45
  @id
45
46
  end
46
- end
47
+ end
47
48
 
48
49
  def accounts_id(arg=nil)
49
50
  if arg != nil
@@ -61,6 +62,14 @@ module Megam
61
62
  end
62
63
  end
63
64
 
65
+ def repo_name(arg=nil)
66
+ if arg != nil
67
+ @repo_name = arg
68
+ else
69
+ @repo_name
70
+ end
71
+ end
72
+
64
73
  def repo(arg=nil)
65
74
  if arg != nil
66
75
  @repo = arg
@@ -75,7 +84,15 @@ module Megam
75
84
  else
76
85
  @vault_location
77
86
  end
78
- end
87
+ end
88
+
89
+ def conf_location(arg=nil)
90
+ if arg != nil
91
+ @conf_location= arg
92
+ else
93
+ @conf_location
94
+ end
95
+ end
79
96
 
80
97
  def created_at(arg=nil)
81
98
  if arg != nil
@@ -101,11 +118,13 @@ module Megam
101
118
  def to_hash
102
119
  index_hash = Hash.new
103
120
  index_hash["json_claz"] = self.class.name
104
- index_hash["id"] = id
121
+ index_hash["id"] = id
105
122
  index_hash["accounts_id"] = accounts_id
106
123
  index_hash["cloud_type"] = cloud_type
124
+ index_hash["repo_name"] = repo_name
107
125
  index_hash["repo"] = repo
108
- index_hash["vault_location"] = vault_location
126
+ index_hash["vault_location"] = vault_location
127
+ index_hash["conf_location"] = conf_location
109
128
  index_hash["created_at"] = created_at
110
129
  index_hash["some_msg"] = some_msg
111
130
  index_hash
@@ -119,11 +138,13 @@ module Megam
119
138
 
120
139
  def for_json
121
140
  result = {
122
- "id" => id,
141
+ "id" => id,
123
142
  "accounts_id" => accounts_id,
124
143
  "cloud_type" => cloud_type,
125
144
  "repo" => repo,
126
- "vault_location" => vault_location,
145
+ "repo_name" => repo_name,
146
+ "vault_location" => vault_location,
147
+ "conf_location" => conf_location,
127
148
  "created_at" => created_at
128
149
  }
129
150
  result
@@ -132,12 +153,14 @@ module Megam
132
153
  #
133
154
  def self.json_create(o)
134
155
  cts = new
135
- cts.id(o["id"]) if o.has_key?("id")
156
+ cts.id(o["id"]) if o.has_key?("id")
136
157
  cts.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
137
158
  cts.cloud_type(o["cloud_type"]) if o.has_key?("cloud_type")
159
+ cts.repo_name(o["repo_name"]) if o.has_key?("repo_name")
138
160
  cts.repo(o["repo"]) if o.has_key?("repo")
139
- cts.vault_location(o["vault_location"]) if o.has_key?("vault_location")
140
-
161
+ cts.vault_location(o["vault_location"]) if o.has_key?("vault_location")
162
+ cts.conf_location(o["conf_location"]) if o.has_key?("conf_location")
163
+
141
164
  cts.created_at(o["created_at"]) if o.has_key?("created_at")
142
165
  #success or error
143
166
  cts.some_msg[:code] = o["code"] if o.has_key?("code")
@@ -157,8 +180,10 @@ module Megam
157
180
  @id = o[:id] if o.has_key?(:id)
158
181
  @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
159
182
  @cloud_type = o[:cloud_type] if o.has_key?(:cloud_type)
183
+ @repo_name = o[:repo_name] if o.has_key?(:repo_name)
160
184
  @repo = o[:repo] if o.has_key?(:repo)
161
- @vault_location = o[:vault_location] if o.has_key?(:vault_location)
185
+ @vault_location = o[:vault_location] if o.has_key?(:vault_location)
186
+ @conf_location = o[:conf_location] if o.has_key?(:conf_location)
162
187
  @created_at = o[:created_at] if o.has_key?(:created_at)
163
188
  self
164
189
  end
@@ -177,14 +202,14 @@ module Megam
177
202
  # returns a cloudtoolsettingsCollection
178
203
  # don't return self. check if the Megam::cloudtoolsettingCollection is returned.
179
204
  def self.list
180
- cts = self.new()
205
+ cts = self.new()
181
206
  cts.megam_rest.get_cloudtoolsettings
182
207
  end
183
208
 
184
209
  # Show a particular cloudtoolsetting by name,
185
210
  # Megam::cloudtoolsetting
186
211
  def self.show(p_name)
187
- pre = self.new()
212
+ pre = self.new()
188
213
  pre.megam_rest.get_cloudtoolsetting(p_name)
189
214
  end
190
215
 
@@ -35,14 +35,14 @@ module Megam
35
35
  def []=(index, arg)
36
36
  is_megam_cloudtoolsettings(arg)
37
37
  @cloudtoolsettings[index] = arg
38
- @cloudtoolsettings_by_name[arg.name] = index
38
+ @cloudtoolsettings_by_name[arg.repo_name] = index
39
39
  end
40
40
 
41
41
  def <<(*args)
42
42
  args.flatten.each do |a|
43
43
  is_megam_cloudtoolsettings(a)
44
44
  @cloudtoolsettings << a
45
- @cloudtoolsettings_by_name[a.name] =@cloudtoolsettings.length - 1
45
+ @cloudtoolsettings_by_name[a.repo_name] =@cloudtoolsettings.length - 1
46
46
  end
47
47
  self
48
48
  end
@@ -61,11 +61,11 @@ module Megam
61
61
  @cloudtoolsettings_by_name.each_key do |key|
62
62
  @cloudtoolsettings_by_name[key] += 1 if@cloudtoolsettings_by_name[key] > @insert_after_idx
63
63
  end
64
- @cloudtoolsettings_by_name[cloudtoolsettings.cloud_type] = @insert_after_idx + 1
64
+ @cloudtoolsettings_by_name[cloudtoolsettings.repo_name] = @insert_after_idx + 1
65
65
  @insert_after_idx += 1
66
66
  else
67
67
  @cloudtoolsettings << cloudtoolsettings
68
- @cloudtoolsettings_by_name[cloudtoolsettings.cloud_type] =@cloudtoolsettings.length - 1
68
+ @cloudtoolsettings_by_name[cloudtoolsettings.repo_name] =@cloudtoolsettings.length - 1
69
69
  end
70
70
  end
71
71
 
@@ -88,7 +88,7 @@ module Megam
88
88
  def lookup(cloudtoolsettings)
89
89
  lookup_by = nil
90
90
  if cloudtoolsettings.kind_of?(Megam::CloudToolSetting)
91
- lookup_by = cloudtoolsettings.cloud_type
91
+ lookup_by = cloudtoolsettings.repo_name
92
92
  elsif cloudtoolsettings.kind_of?(String)
93
93
  lookup_by = cloudtoolsettings
94
94
  else
@@ -105,7 +105,7 @@ module Megam
105
105
  def to_hash
106
106
  index_hash = Hash.new
107
107
  self.each do |cloudtoolsettings|
108
- index_hash[cloudtoolsettings.cloud_type] = cloudtoolsettings.to_s
108
+ index_hash[cloudtoolsettings.repo_name] = cloudtoolsettings.to_s
109
109
  end
110
110
  index_hash
111
111
  end
@@ -161,6 +161,7 @@ module Megam
161
161
  predefcd.spec[:groups] = oq["groups"] if oq && oq.has_key?("groups")
162
162
  predefcd.spec[:image] = oq["image"] if oq && oq.has_key?("image")
163
163
  predefcd.spec[:flavor] = oq["flavor"] if oq && oq.has_key?("flavor")
164
+ predefcd.spec[:tenant_id] = oq["tenant_id"] if oq && oq.has_key?("tenant_id")
164
165
  #predef
165
166
  op = o["access"]
166
167
  predefcd.access[:ssh_key] = op["ssh_key"] if op && op.has_key?("ssh_key")
@@ -169,6 +170,7 @@ module Megam
169
170
  predefcd.access[:vault_location]= op["vault_location"] if op && op.has_key?("vault_location")
170
171
  predefcd.access[:sshpub_location]= op["sshpub_location"] if op && op.has_key?("sshpub_location")
171
172
  predefcd.access[:zone]= op["zone"] if op && op.has_key?("zone")
173
+ predefcd.access[:region]= op["region"] if op && op.has_key?("region")
172
174
  #access
173
175
  # predefcd.ideal(o["ideal"]) if o.has_key?("ideal")
174
176
  # predefcd.performance(o["performance"]) if o.has_key?("performance")
@@ -1,23 +1,23 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
-
5
4
  def test_post_appdefns
6
-
7
- tmp_hash = {
5
+ tmp_hash = {
8
6
  "node_name" => "black1.megam.co",
9
- "appdefns" => {"timetokill" => "test1", "metered" => "test1", "logging" => "test1", "runtime_exec" => "test"}
7
+ "appdefns" => {"timetokill" => "test1", "metered" => "test1", "logging" => "test1", "runtime_exec" => "test"}
10
8
  }
11
-
12
- puts "======================> POST APPDEFNS TEMP HASH <============================================= "
13
- puts tmp_hash
14
9
  response = megams.post_appdefn(tmp_hash)
15
10
  assert_equal(201, response.status)
16
11
  end
17
12
 
18
- def test_get_appdefns
13
+ def test_get_appdefns_node
19
14
  response = megams.get_appdefn("black1.megam.co")
20
15
  assert_equal(200, response.status)
21
16
  end
22
17
 
18
+ def test_get_appdefns
19
+ response = megams.get_appdefn("asphyxiated1.megam.co","ADF412857952341327872")
20
+ assert_equal(200, response.status)
21
+ end
22
+
23
23
  end
data/test/test_appreqs.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
-
5
4
  def test_post_appreqs
6
5
 
7
- tmp_hash = {
6
+ tmp_hash = {
8
7
  "req_type" => "NStart",
9
8
  "node_name" => "black1.megam.co",
10
9
  "appdefns_id" => "12455",
@@ -13,16 +12,14 @@ class TestApps < MiniTest::Unit::TestCase
13
12
  "lc_when" => "When"
14
13
  }
15
14
 
16
- puts "======================> POST APPREQS TEMP HASH <============================================= "
17
- puts tmp_hash
18
15
  response = megams.post_appreq(tmp_hash)
19
16
  assert_equal(201, response.status)
20
17
  end
21
- #=begin
18
+
22
19
  def test_get_appreqs
23
20
  response = megams.get_appreq("oceanographer1.megam.co")
24
21
  assert_equal(200, response.status)
25
22
  end
26
- #=end
23
+
27
24
 
28
25
  end
@@ -9,8 +9,6 @@ class TestApps < MiniTest::Unit::TestCase
9
9
  "boltdefns" => {"username" => "new", "apikey" => "new", "store_name" => "", "url" => "", "prime" => "", "timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""}
10
10
  }
11
11
 
12
- puts "======================> POST APPDEFNS TEMP HASH <============================================= "
13
- puts tmp_hash
14
12
  response = megams.post_boltdefn(tmp_hash)
15
13
  assert_equal(201, response.status)
16
14
  end
@@ -13,8 +13,6 @@ class TestApps < MiniTest::Unit::TestCase
13
13
  "lc_when" => "When"
14
14
  }
15
15
 
16
- puts "======================> POST BOLTREQS TEMP HASH <============================================= "
17
- puts tmp_hash
18
16
  response = megams.post_boltreq(tmp_hash)
19
17
  assert_equal(201, response.status)
20
18
  end
@@ -1,20 +1,23 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- =begin
4
+ #=begin
5
5
  def test_post_cloudtoolsetting1
6
6
  tmp_hash = { :cloud_type => "chef",
7
- :repo => "https://github.com"
8
- :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
7
+ :repo_name => "test_chef",
8
+ :repo => "https://github.com",
9
+ :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudrecipes/sandy@megamsandbox.com/chef",
10
+ :conf_location => "sandy@megamsandbox.com/chef/chef-repo/.chef/knife.rb"
9
11
  }
10
12
 
11
13
  response = megams.post_cloudtoolsetting(tmp_hash)
12
14
  assert_equal(201, response.status)
13
15
  end
14
- =end
16
+ #=end
15
17
  =begin
16
18
  def test_post_cloudtoolsetting2
17
- tmp_hash = { :cloud_type => "chef",
19
+ tmp_hash = { :cloud_type => "chef",
20
+ :repo_name => "test_chef",
18
21
  :repo => "https://github.com",
19
22
  :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
20
23
  }
@@ -22,12 +25,12 @@ class TestApps < MiniTest::Unit::TestCase
22
25
  assert_equal(201, response.status)
23
26
  end
24
27
  =end
25
- #=begin
28
+ =begin
26
29
  def test_get_cloudtoolsettings
27
30
  response = megams.get_cloudtoolsettings
28
31
  assert_equal(200, response.status)
29
32
  end
30
- #=end
33
+ =end
31
34
  =begin
32
35
  def test_get_cloudtoolsetting2
33
36
  response = megams.get_cloudtoolsetting("rkspce_sundown_play")
data/test/test_nodes.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- #=begin
4
+
5
5
  def test_post_node1
6
-
7
6
  @com = {
8
7
  "systemprovider" => {
9
8
  "provider" => {
@@ -15,7 +14,8 @@ class TestApps < MiniTest::Unit::TestCase
15
14
  "cc" => {
16
15
  "groups" => "megam",
17
16
  "image" => "ami-d783cd85",
18
- "flavor" => "t1.micro"
17
+ "flavor" => "t1.micro",
18
+ "tenant_id" => ""
19
19
  },
20
20
  "access" => {
21
21
  "ssh_key" => "megam_ec2",
@@ -23,13 +23,14 @@ class TestApps < MiniTest::Unit::TestCase
23
23
  "ssh_user" => "ubuntu",
24
24
  "vault_location" => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
25
25
  "sshpub_location" => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
26
- "zone" => ""
26
+ "zone" => "",
27
+ "region" => "region"
27
28
  }
28
29
  },
29
30
  "cloudtool" => {
30
31
  "chef" => {
31
32
  "command" => "knife",
32
- "plugin" => "ec2 server create", #ec2 server delete or create
33
+ "plugin" => "ec2 server create -c sandy@megamsandbox.com/default", #ec2 server delete or create
33
34
  "run_list" => "role[opendj]",
34
35
  "name" => "-N TestOverAll"
35
36
  }
@@ -50,55 +51,41 @@ class TestApps < MiniTest::Unit::TestCase
50
51
  "boltreq" => {}
51
52
  }
52
53
 
53
- puts "======================> TEMP HASH <============================================= "
54
- puts tmp_hash.class
55
- puts tmp_hash
56
54
  response = megams.post_node(tmp_hash)
57
55
  assert_equal(201, response.status)
58
56
  end
59
57
 
60
- #=end
61
- #=begin
62
- def test_post_node2
63
- tmp_hash = {
64
- "node_name" => "sundown.megam.co",
65
- "command" => "commands2",
66
- "predefs" => {"name" => "rails", "scm" => "https://github.com/awesome.git",
67
- "db" => "postgres@postgresql2.megam.com/morning.megam.co", "war" => "http://s3pub.com/0.1/orion.war", "queue" => "rabbit@queue1"}
68
- }
69
- response = megams.post_node(tmp_hash)
70
- assert_equal(201, response.status)
71
- end
72
- #=end
73
- def test_get_nodes
74
- response = megams.get_nodes
75
-
76
- puts "=================> GET NODES Response ========>"
77
- puts response.inspect
58
+ def test_post_node2
59
+ tmp_hash = {
60
+ "node_name" => "sundown.megam.co",
61
+ "command" => "commands2",
62
+ "predefs" => {"name" => "rails", "scm" => "https://github.com/awesome.git",
63
+ "db" => "postgres@postgresql2.megam.com/morning.megam.co", "war" => "http://s3pub.com/0.1/orion.war", "queue" => "rabbit@queue1"}
64
+ }
65
+ response = megams.post_node(tmp_hash)
66
+ assert_equal(201, response.status)
67
+ end
78
68
 
79
- assert_equal(200, response.status)
80
- end
69
+ def test_get_nodes
70
+ response = megams.get_nodes
71
+ assert_equal(200, response.status)
72
+ end
81
73
 
82
74
  def test_get_node0
83
75
  response = megams.get_node("black1.megam.co")
84
- puts "=================> Response ========>"
85
- puts response.inspect
86
76
  assert_equal(200, response.status)
87
77
  end
88
78
 
89
- #=end
90
- =begin
91
- def test_get_node1
92
- response = megams.get_node("night.megam.co")
93
- assert_equal(200, response.status)
94
- end
79
+ def test_get_node1
80
+ response = megams.get_node("night.megam.co")
81
+ assert_equal(200, response.status)
82
+ end
95
83
 
96
- def test_get_node_not_found
97
- assert_raises(Megam::API::Errors::NotFound) do
98
- megams.get_node("stupid.megam.co")
99
- end
100
- end
101
- =end
84
+ def test_get_node_not_found
85
+ assert_raises(Megam::API::Errors::NotFound) do
86
+ megams.get_node("stupid.megam.co")
87
+ end
88
+ end
102
89
 
103
90
  def test_delete_node1
104
91
 
@@ -113,7 +100,8 @@ end
113
100
  "cc" => {
114
101
  "groups" => "",
115
102
  "image" => "",
116
- "flavor" => ""
103
+ "flavor" => "",
104
+ "tenant_id" => ""
117
105
  },
118
106
  "access" => {
119
107
  "ssh_key" => "megam_ec2",
@@ -121,7 +109,8 @@ end
121
109
  "ssh_user" => "",
122
110
  "vault_location" => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
123
111
  "sshpub_location" => "",
124
- "zone" => ""
112
+ "zone" => "",
113
+ "region" => "region"
125
114
  }
126
115
  },
127
116
  "cloudtool" => {
@@ -140,12 +129,7 @@ end
140
129
  "command" => @com
141
130
  }
142
131
 
143
- puts "======================> TEMP HASH <============================================= "
144
- puts tmp_hash.class
145
- puts tmp_hash
146
132
  response = megams.post_request(tmp_hash)
147
133
  assert_equal(201, response.status)
148
134
  end
149
-
150
- end
151
-
135
+ end
@@ -7,7 +7,8 @@ class TestApps < MiniTest::Unit::TestCase
7
7
  :type_name => "aws-ec2",
8
8
  :groups => "megam",
9
9
  :image => "ami-d783cd85",
10
- :flavor => "m1.medium"
10
+ :flavor => "m1.medium",
11
+ :tenant_id => ""
11
12
  },
12
13
  :access => {
13
14
  :ssh_key => "megam_ec2",
@@ -15,7 +16,8 @@ class TestApps < MiniTest::Unit::TestCase
15
16
  :ssh_user => "ubuntu",
16
17
  :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
17
18
  :sshpub_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
18
- :zone => ""
19
+ :zone => "",
20
+ :region => "southeast"
19
21
  },
20
22
  #:ideal => "ror,redis,riak",
21
23
  #:performance => "10rpm"
@@ -30,7 +32,8 @@ class TestApps < MiniTest::Unit::TestCase
30
32
  :type_name => "rackspace",
31
33
  :groups => "staging_france_boeing",
32
34
  :image => "RCP000XERAOl",
33
- :flavor => "m1-miniscule"
35
+ :flavor => "m1-miniscule",
36
+ :tenant_id => ""
34
37
  },
35
38
  :access => {
36
39
  :ssh_key => "boo_flightssh",
@@ -38,7 +41,8 @@ class TestApps < MiniTest::Unit::TestCase
38
41
  :ssh_user => "ubuntu",
39
42
  :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
40
43
  :sshpub_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
41
- :zone => ""
44
+ :zone => "",
45
+ :region => ""
42
46
  },
43
47
  #:ideal => "play,redis,riak",
44
48
  #:performance => "10rpm"
@@ -1,8 +1,7 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
-
5
- #=begin
4
+ #=begin
6
5
  def test_get_requests
7
6
  response = megams.get_requests
8
7
  assert_equal(200, response.status)
@@ -13,15 +12,15 @@ class TestApps < MiniTest::Unit::TestCase
13
12
  response = megams.get_request("faulty")
14
13
  end
15
14
  end
16
- #=end
15
+
16
+ #=end
17
17
  def test_get_request_good
18
18
  response = megams.get_request("black1.megam.co")
19
19
  assert_equal(200, response.status)
20
20
  end
21
21
 
22
-
23
- #=begin
24
- @com = {
22
+ #=begin
23
+ @com = {
25
24
  "systemprovider" => {
26
25
  "provider" => {
27
26
  "prov" => "chef"
@@ -32,7 +31,8 @@ class TestApps < MiniTest::Unit::TestCase
32
31
  "cc" => {
33
32
  "groups" => "",
34
33
  "image" => "",
35
- "flavor" => ""
34
+ "flavor" => "",
35
+ "tenant_id" => ""
36
36
  },
37
37
  "access" => {
38
38
  "ssh_key" => "megam_ec2",
@@ -40,7 +40,8 @@ class TestApps < MiniTest::Unit::TestCase
40
40
  "ssh_user" => "",
41
41
  "vault_location" => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
42
42
  "sshpub_location" => "",
43
- "zone" => ""
43
+ "zone" => "",
44
+ "region" => ""
44
45
  }
45
46
  },
46
47
  "cloudtool" => {
@@ -53,23 +54,21 @@ class TestApps < MiniTest::Unit::TestCase
53
54
  }
54
55
  }
55
56
 
56
- @@tmp_hash = {
57
- "node_name" => "black1.megam.co",
58
- "node_type" => "APP", #APP or Bolt
59
- "req_type" => "delete",
60
- "noofinstances" => 0,
61
- "command" => @com,
62
- "predefs" => {"name" => "", "scm" => "", "db" => "", "war" => "", "queue" => ""},
63
- "appdefns" => {"timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""},
64
- "boltdefns" => {"username" => "", "apikey" => "", "store_name" => "", "url" => "", "prime" => "", "timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""},
65
- "appreq" => {},
66
- "boltreq" => {}
67
- }
57
+ @@tmp_hash = {
58
+ "node_name" => "black1.megam.co",
59
+ "node_type" => "APP", #APP or Bolt
60
+ "req_type" => "delete",
61
+ "noofinstances" => 0,
62
+ "command" => @com,
63
+ "predefs" => {"name" => "", "scm" => "", "db" => "", "war" => "", "queue" => ""},
64
+ "appdefns" => {"timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""},
65
+ "boltdefns" => {"username" => "", "apikey" => "", "store_name" => "", "url" => "", "prime" => "", "timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""},
66
+ "appreq" => {},
67
+ "boltreq" => {}
68
+ }
68
69
 
69
70
  def test_request_node_delete
70
71
 
71
- puts "======================> DELETE NODE Request TEMP HASH <============================================= "
72
- puts @@tmp_hash
73
72
  response = megams.post_request(@@tmp_hash)
74
73
  assert_equal(201, response.status)
75
74
  end
@@ -77,12 +76,9 @@ puts @@tmp_hash
77
76
  def test_request_node_stop
78
77
  @@tmp_hash["req_type"] = "stop"
79
78
  @@tmp_hash["command"]["cloudtool"]["chef"]["plugin"] = "ec2 server stop"
80
- puts "======================> STOP NODE Request TEMP HASH <============================================= "
81
- puts @@tmp_hash
82
-
83
79
  response = megams.post_request(@@tmp_hash)
84
80
  assert_equal(201, response.status)
85
81
  end
86
82
  #=end
87
-
83
+
88
84
  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.1
4
+ version: 0.7.2
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: 2013-12-12 00:00:00.000000000 Z
11
+ date: 2013-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon