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 +4 -4
 - data/lib/megam/api.rb +1 -0
 - data/lib/megam/api/version.rb +1 -1
 - data/lib/megam/builder/delete_node.rb +91 -0
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 548de7ae29eb0c6f8a2a40ec1f9aa570775faea1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5f1388d4b34ed0f335e44543ba4bbf4fb881e64b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d7b0745b77f482a280247c1c2c3752cb9541dcfbd563269316e2afe41f8ae8e26d16afa8fd434484f7988e1e64193955826f58b6fb185cd29a429c7378b59021
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 453b8c1d9040998d47853792087c746a10af674950d8c4b868699de49350455d47ec1fda6f953f55c3a32888a79bc6bd48ce8a797705ce21636340730bf21588
         
     | 
    
        data/lib/megam/api.rb
    CHANGED
    
    
    
        data/lib/megam/api/version.rb
    CHANGED
    
    
| 
         @@ -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. 
     | 
| 
      
 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
         
     |