nchosts 0.0.1
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.
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/nchosts +4 -0
- data/lib/nchosts/command.rb +52 -0
- data/lib/nchosts/templates/aliases.erb +3 -0
- data/lib/nchosts/templates/ssh_config.erb +4 -0
- data/lib/nchosts/version.rb +3 -0
- data/lib/nchosts.rb +12 -0
- data/nchosts.gemspec +30 -0
- metadata +187 -0
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            *.gem
         | 
| 2 | 
            +
            *.rbc
         | 
| 3 | 
            +
            .bundle
         | 
| 4 | 
            +
            .config
         | 
| 5 | 
            +
            .yardoc
         | 
| 6 | 
            +
            Gemfile.lock
         | 
| 7 | 
            +
            InstalledFiles
         | 
| 8 | 
            +
            _yardoc
         | 
| 9 | 
            +
            coverage
         | 
| 10 | 
            +
            doc/
         | 
| 11 | 
            +
            lib/bundler/man
         | 
| 12 | 
            +
            pkg
         | 
| 13 | 
            +
            rdoc
         | 
| 14 | 
            +
            spec/reports
         | 
| 15 | 
            +
            test/tmp
         | 
| 16 | 
            +
            test/version_tmp
         | 
| 17 | 
            +
            tmp
         | 
| 18 | 
            +
            *.bundle
         | 
| 19 | 
            +
            *.so
         | 
| 20 | 
            +
            *.o
         | 
| 21 | 
            +
            *.a
         | 
| 22 | 
            +
            mkmf.log
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 tily
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            # Nchosts
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            TODO: Write a gem description
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                gem 'nchosts'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            And then execute:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                $ bundle
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Or install it yourself as:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ gem install nchosts
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## Usage
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            TODO: Write usage instructions here
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            * ヒント: 安全に利用するため閲覧権限の API キーを利用することが推奨です
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ## Contributing
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            1. Fork it ( https://github.com/[my-github-username]/nchosts/fork )
         | 
| 28 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 29 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 30 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 31 | 
            +
            5. Create a new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/nchosts
    ADDED
    
    
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            module Nchosts
         | 
| 2 | 
            +
            	class Command < Thor
         | 
| 3 | 
            +
            		desc 'version', 'show version info'
         | 
| 4 | 
            +
            		def version
         | 
| 5 | 
            +
            			puts "v#{Nchosts::VERSION}"
         | 
| 6 | 
            +
            		end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            		desc 'collect', 'collect hosts info from nifty cloud api'
         | 
| 9 | 
            +
            		option :config, :aliases => :c
         | 
| 10 | 
            +
            		option :output_path, :aliases => :o
         | 
| 11 | 
            +
            		def collect
         | 
| 12 | 
            +
            			instances = []
         | 
| 13 | 
            +
            			json = JSON.parse File.read(options[:config])
         | 
| 14 | 
            +
            			json['accounts'].each do |account|
         | 
| 15 | 
            +
            				client = AceClient::Niftycloud::Computing.build_client(
         | 
| 16 | 
            +
            					endpoint: 'cp.cloud.nifty.com',
         | 
| 17 | 
            +
            					path: '/api',
         | 
| 18 | 
            +
            					access_key_id: account['access_key_id'],
         | 
| 19 | 
            +
            					secret_access_key: account['secret_access_key']
         | 
| 20 | 
            +
            				)
         | 
| 21 | 
            +
            				client.regions.each do |region|
         | 
| 22 | 
            +
            					client.endpoint = region['regionEndpoint']
         | 
| 23 | 
            +
            					client.instances.each do |instance|
         | 
| 24 | 
            +
            						instance['region'] = region
         | 
| 25 | 
            +
            						instance['account'] = account
         | 
| 26 | 
            +
            						p instance
         | 
| 27 | 
            +
            						instances << instance
         | 
| 28 | 
            +
            					end
         | 
| 29 | 
            +
            				end
         | 
| 30 | 
            +
            			end
         | 
| 31 | 
            +
            			File.write options[:output_path], instances.to_json
         | 
| 32 | 
            +
            		end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            		desc 'generate', 'generate'
         | 
| 35 | 
            +
            		option :format, :aliases => :f # hosts, capistrano, ssh_config
         | 
| 36 | 
            +
            		option :include # host name regexp
         | 
| 37 | 
            +
            		option :exclude # host name regexp
         | 
| 38 | 
            +
            		option :template, :aliases => :t
         | 
| 39 | 
            +
            		option :input_path, :aliases => :i
         | 
| 40 | 
            +
            		def generate
         | 
| 41 | 
            +
            			template = template(options[:template])
         | 
| 42 | 
            +
            			instances = JSON.parse File.read options[:input_path]
         | 
| 43 | 
            +
            			puts Erubis::Eruby.new(template).result(:instances => instances)
         | 
| 44 | 
            +
            		end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            		no_commands do
         | 
| 47 | 
            +
            			def template(name)
         | 
| 48 | 
            +
            				File.read File.join(File.dirname(__FILE__), "templates/#{name}.erb")
         | 
| 49 | 
            +
            			end
         | 
| 50 | 
            +
            		end
         | 
| 51 | 
            +
            	end
         | 
| 52 | 
            +
            end
         | 
    
        data/lib/nchosts.rb
    ADDED
    
    
    
        data/nchosts.gemspec
    ADDED
    
    | @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'nchosts/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "nchosts"
         | 
| 8 | 
            +
              spec.version       = Nchosts::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["tily"]
         | 
| 10 | 
            +
              spec.email         = ["tily05@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = %q{command to collect hosts info}
         | 
| 12 | 
            +
              spec.description   = %q{command to collect hosts info}
         | 
| 13 | 
            +
              spec.homepage      = ""
         | 
| 14 | 
            +
              spec.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_development_dependency "bundler", "~> 1.6"
         | 
| 22 | 
            +
              spec.add_development_dependency "rake"
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              spec.add_dependency "thor"
         | 
| 25 | 
            +
              spec.add_dependency "ace-client"
         | 
| 26 | 
            +
              spec.add_dependency "ace-client-ext"
         | 
| 27 | 
            +
              spec.add_dependency "builder"
         | 
| 28 | 
            +
              spec.add_dependency "json"
         | 
| 29 | 
            +
              spec.add_dependency "erubis"
         | 
| 30 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,187 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: nchosts
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - tily
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2015-03-06 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: bundler
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ~>
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '1.6'
         | 
| 22 | 
            +
              type: :development
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ~>
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '1.6'
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: rake
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ! '>='
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: '0'
         | 
| 38 | 
            +
              type: :development
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '0'
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: thor
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ! '>='
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '0'
         | 
| 54 | 
            +
              type: :runtime
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: ace-client
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ! '>='
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '0'
         | 
| 70 | 
            +
              type: :runtime
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '0'
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: ace-client-ext
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 83 | 
            +
                - - ! '>='
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: '0'
         | 
| 86 | 
            +
              type: :runtime
         | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ! '>='
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '0'
         | 
| 94 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 95 | 
            +
              name: builder
         | 
| 96 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 97 | 
            +
                none: false
         | 
| 98 | 
            +
                requirements:
         | 
| 99 | 
            +
                - - ! '>='
         | 
| 100 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                    version: '0'
         | 
| 102 | 
            +
              type: :runtime
         | 
| 103 | 
            +
              prerelease: false
         | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                none: false
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - ! '>='
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: '0'
         | 
| 110 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            +
              name: json
         | 
| 112 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 113 | 
            +
                none: false
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ! '>='
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                none: false
         | 
| 122 | 
            +
                requirements:
         | 
| 123 | 
            +
                - - ! '>='
         | 
| 124 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                    version: '0'
         | 
| 126 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 127 | 
            +
              name: erubis
         | 
| 128 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 129 | 
            +
                none: false
         | 
| 130 | 
            +
                requirements:
         | 
| 131 | 
            +
                - - ! '>='
         | 
| 132 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 133 | 
            +
                    version: '0'
         | 
| 134 | 
            +
              type: :runtime
         | 
| 135 | 
            +
              prerelease: false
         | 
| 136 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 137 | 
            +
                none: false
         | 
| 138 | 
            +
                requirements:
         | 
| 139 | 
            +
                - - ! '>='
         | 
| 140 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 141 | 
            +
                    version: '0'
         | 
| 142 | 
            +
            description: command to collect hosts info
         | 
| 143 | 
            +
            email:
         | 
| 144 | 
            +
            - tily05@gmail.com
         | 
| 145 | 
            +
            executables:
         | 
| 146 | 
            +
            - nchosts
         | 
| 147 | 
            +
            extensions: []
         | 
| 148 | 
            +
            extra_rdoc_files: []
         | 
| 149 | 
            +
            files:
         | 
| 150 | 
            +
            - .gitignore
         | 
| 151 | 
            +
            - Gemfile
         | 
| 152 | 
            +
            - LICENSE.txt
         | 
| 153 | 
            +
            - README.md
         | 
| 154 | 
            +
            - Rakefile
         | 
| 155 | 
            +
            - bin/nchosts
         | 
| 156 | 
            +
            - lib/nchosts.rb
         | 
| 157 | 
            +
            - lib/nchosts/command.rb
         | 
| 158 | 
            +
            - lib/nchosts/templates/aliases.erb
         | 
| 159 | 
            +
            - lib/nchosts/templates/ssh_config.erb
         | 
| 160 | 
            +
            - lib/nchosts/version.rb
         | 
| 161 | 
            +
            - nchosts.gemspec
         | 
| 162 | 
            +
            homepage: ''
         | 
| 163 | 
            +
            licenses:
         | 
| 164 | 
            +
            - MIT
         | 
| 165 | 
            +
            post_install_message: 
         | 
| 166 | 
            +
            rdoc_options: []
         | 
| 167 | 
            +
            require_paths:
         | 
| 168 | 
            +
            - lib
         | 
| 169 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 170 | 
            +
              none: false
         | 
| 171 | 
            +
              requirements:
         | 
| 172 | 
            +
              - - ! '>='
         | 
| 173 | 
            +
                - !ruby/object:Gem::Version
         | 
| 174 | 
            +
                  version: '0'
         | 
| 175 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 176 | 
            +
              none: false
         | 
| 177 | 
            +
              requirements:
         | 
| 178 | 
            +
              - - ! '>='
         | 
| 179 | 
            +
                - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                  version: '0'
         | 
| 181 | 
            +
            requirements: []
         | 
| 182 | 
            +
            rubyforge_project: 
         | 
| 183 | 
            +
            rubygems_version: 1.8.24
         | 
| 184 | 
            +
            signing_key: 
         | 
| 185 | 
            +
            specification_version: 3
         | 
| 186 | 
            +
            summary: command to collect hosts info
         | 
| 187 | 
            +
            test_files: []
         |