megam_api 0.6.0 → 0.7.0

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: d950507a28a11ed7d8530a39b758486f768fa805
4
- data.tar.gz: 7b53215125dd516e7204205eb30238d8436af8e2
3
+ metadata.gz: 548de7ae29eb0c6f8a2a40ec1f9aa570775faea1
4
+ data.tar.gz: 5f1388d4b34ed0f335e44543ba4bbf4fb881e64b
5
5
  SHA512:
6
- metadata.gz: 4d8e708ce70d33be14c466189f70e224c4f1d70b372862c1ce1b41e20fb7b005c58d5386418297cf52811e6df296102ab6d775d83649825d4aa55baf28466c12
7
- data.tar.gz: e14ac29df68569f396f597cf4667d9e2452b5828d4822de39b9ce216a2dd91affb79e1e6700f42547f5f9d440bd6b9fb676bdf0b8aaa6be284cbe5c642c5ba21
6
+ metadata.gz: d7b0745b77f482a280247c1c2c3752cb9541dcfbd563269316e2afe41f8ae8e26d16afa8fd434484f7988e1e64193955826f58b6fb185cd29a429c7378b59021
7
+ data.tar.gz: 453b8c1d9040998d47853792087c746a10af674950d8c4b868699de49350455d47ec1fda6f953f55c3a32888a79bc6bd48ce8a797705ce21636340730bf21588
data/lib/megam/api.rb CHANGED
@@ -31,6 +31,7 @@ require "megam/core/stuff"
31
31
  require "megam/core/text"
32
32
  require "megam/core/json_compat"
33
33
  require "megam/builder/make_node"
34
+ require "megam/builder/delete_node"
34
35
  require "megam/core/auth"
35
36
  require "megam/core/error"
36
37
  require "megam/core/account"
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -0,0 +1,91 @@
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 DeleteNode
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(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)
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}"
51
+
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
+ }
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
+ }
82
+
83
+ node_hash = {
84
+ "node_name" => "#{node_name}",
85
+ "req_type" => "#{action}",
86
+ "command" => command_hash
87
+ }
88
+ node_hash
89
+ end
90
+ end
91
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kishorekumar Neelamegam, Thomas Alrin, Subash Sethurajan, Rajthilak
@@ -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/delete_node.rb
144
145
  - lib/megam/builder/make_node.rb
145
146
  - lib/megam/core/account.rb
146
147
  - lib/megam/core/app_request.rb