megam_api 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68e28bd9b304d359aaa8274a0fa9fcc03f049c55
4
- data.tar.gz: 1c5990d18bbb16555b4153c69c4e0a13571e0c5f
3
+ metadata.gz: 893efefb13ab310b61656e14f59065bfb717c8cb
4
+ data.tar.gz: 4f579b3d2a53f7fc962e876b04d90abd361e80de
5
5
  SHA512:
6
- metadata.gz: 226448ce094c14f5374ed435cb1c91817110f930a7d88be9f1454efb7fa337f710c854b4188ba79635f491f2e3a0bf8674600b108741b48f2ad2767e6ea5f0eb
7
- data.tar.gz: cac68e95580f3200224f2629bf918f84a05c0a4f6a76670d629c32c4e6659db9890016c3eb009aa554936ada4434c294c13ec6691696e32da7fa811f52486dd5
6
+ metadata.gz: 2c69ced0eefd1ab8701a6d137417f407f4fe1eb594f5b3a853a0766a8d086213ba4949b96ff01b17cdce96f1f7f7d7b0b1f10e5a5119294b0cbfd1d60be61ed5
7
+ data.tar.gz: fc3d50c49330e5a5a9cc760355a8356e9763159f7300fa1df187f15faf41351733b183045fc90c076768cc1283d414445b30206f11fccd372c18e10a7a47151e
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
data/lib/megam/api.rb CHANGED
@@ -30,6 +30,7 @@ require "megam/core/config"
30
30
  require "megam/core/stuff"
31
31
  require "megam/core/text"
32
32
  require "megam/core/json_compat"
33
+ require "megam/builder/make_node"
33
34
  require "megam/core/auth"
34
35
  require "megam/core/error"
35
36
  require "megam/core/account"
@@ -0,0 +1,107 @@
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
+ 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)
21
+ end
22
+
23
+ def self.create(data, group, action, email)
24
+
25
+ make_command = self.new()
26
+ begin
27
+ pc_collection = make_command.megam_rest.get_predefclouds
28
+ ct_collection = make_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
+ return re
42
+ end
43
+
44
+
45
+ predef_cloud = pc_collection.data[:body].lookup("#{data[:predef_cloud_name]}")
46
+ tool = ct_collection.data[:body].lookup(data[:provider])
47
+ template = tool.cloudtemplates.lookup(predef_cloud.spec[:type_name])
48
+ cloud_instruction = template.lookup_by_instruction(group, action)
49
+ ci_command = cloud_instruction.command
50
+ ci_name = cloud_instruction.name
51
+
52
+ command_hash = {
53
+ "systemprovider" => {
54
+ "provider" => {
55
+ "prov" => "#{data[:provider]}"
56
+ }
57
+ },
58
+ "compute" => {
59
+ "cctype" => "#{predef_cloud.spec[:type_name]}",
60
+ "cc"=> {
61
+ "groups" => "#{predef_cloud.spec[:groups]}",
62
+ "image" => "#{predef_cloud.spec[:image]}",
63
+ "flavor" => "#{predef_cloud.spec[:flavor]}"
64
+ },
65
+ "access" => {
66
+ "ssh_key" => "#{predef_cloud.access[:ssh_key]}",
67
+ "identity_file" => email+"/"+"#{data[:predef_cloud_name]}"+"/"+"#{predef_cloud.access[:identity_file]}",
68
+ "ssh_user" => "#{predef_cloud.access[:ssh_user]}",
69
+ "vault_location" => "#{predef_cloud.access[:vault_location]}",
70
+ "sshpub_location" => "#{predef_cloud.access[:sshpub_location]}"
71
+ }
72
+ },
73
+ "cloudtool" => {
74
+ "chef" => {
75
+ "command" => "#{tool.cli}",
76
+ "plugin" => "#{template.cctype} #{ci_command}",
77
+ "run_list" => "'role[#{data[:provider_role]}]'",
78
+ "name" => "#{ci_name} #{data[:book_name]}"
79
+ }
80
+ }
81
+ }
82
+
83
+ node_hash = {
84
+ "node_name" => "#{data[:book_name]}#{data[:domain_name]}",
85
+ "node_type" => "#{data[:book_type]}",
86
+ "req_type" => "#{action}",
87
+ "noofinstances" => data[:no_of_instances],
88
+ "command" => command_hash,
89
+ "predefs" => {"name" => data[:predef_name], "scm" => "#{data[:deps_scm]}",
90
+ "db" => "postgres@postgresql1.megam.com/morning.megam.co", "war" => "#{data[:deps_war]}", "queue" => "queue@queue1", "runtime_exec" => data[:runtime_exec]},
91
+ "appdefns" => {"timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""},
92
+ "boltdefns" => {"username" => "", "apikey" => "", "store_name" => "", "url" => "", "prime" => "", "timetokill" => "", "metered" => "", "logging" => "", "runtime_exec" => ""},
93
+ "appreq" => {},
94
+ "boltreq" => {}
95
+ }
96
+
97
+ if data[:book_type] == "APP"
98
+ node_hash["appdefns"] = {"timetokill" => "#{data[:timetokill]}", "metered" => "#{data[:metered]}", "logging" => "#{data[:logging]}", "runtime_exec" => "#{data[:runtime_exec]}"}
99
+ end
100
+ if data[:book_type] == "BOLT"
101
+ 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
+
104
+ node_hash
105
+ end
106
+ end
107
+ end
data/test/test_nodes.rb CHANGED
@@ -21,7 +21,7 @@ class TestApps < MiniTest::Unit::TestCase
21
21
  "ssh_key" => "megam_ec2",
22
22
  "identity_file" => "~/.ssh/megam_ec2.pem",
23
23
  "ssh_user" => "ubuntu",
24
- "vault_location" => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
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
26
  }
27
27
  },
@@ -13,7 +13,7 @@ class TestApps < MiniTest::Unit::TestCase
13
13
  :ssh_key => "megam_ec2",
14
14
  :identity_file => "~/.ssh/megam_ec2.pem",
15
15
  :ssh_user => "ubuntu",
16
- :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
16
+ :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
17
17
  :sshpub_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
18
18
  },
19
19
  :ideal => "ror,redis,riak",
@@ -35,7 +35,7 @@ class TestApps < MiniTest::Unit::TestCase
35
35
  :ssh_key => "boo_flightssh",
36
36
  :identity_file => "https://boering.dropbox.closedloc/aorc.pem",
37
37
  :ssh_user => "ubuntu",
38
- :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
38
+ :vault_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default",
39
39
  :sshpub_location => "https://s3-ap-southeast-1.amazonaws.com/cloudkeys/sandy@megamsandbox.com/default"
40
40
  },
41
41
  :ideal => "play,redis,riak",
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.4.0
4
+ version: 0.5.0
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-11-29 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -141,6 +141,7 @@ files:
141
141
  - lib/megam/api/predefs.rb
142
142
  - lib/megam/api/requests.rb
143
143
  - lib/megam/api/version.rb
144
+ - lib/megam/builder/make_node.rb
144
145
  - lib/megam/core/account.rb
145
146
  - lib/megam/core/app_request.rb
146
147
  - lib/megam/core/app_request_collection.rb