some 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Rakefile +1 -0
  2. data/TODO +5 -0
  3. data/VERSION +1 -1
  4. data/bin/some +3 -2
  5. data/lib/some.rb +9 -3
  6. metadata +19 -6
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ Jeweler::Tasks.new do |s|
12
12
  s.executables = %w(some)
13
13
  s.add_dependency "nifty-cloud-sdk", "1.11.beta1"
14
14
  s.add_dependency "thor"
15
+ s.add_dependency "net-ssh"
15
16
  end
16
17
 
17
18
  Jeweler::RubyforgeTasks.new
data/TODO ADDED
@@ -0,0 +1,5 @@
1
+ capistrano 連携
2
+
3
+
4
+
5
+ some sync コマンドで全サーバーに全サーバの ohai を撒くみたいなのいいかも
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/bin/some CHANGED
@@ -7,8 +7,9 @@ require 'thor'
7
7
 
8
8
  class CLI < Thor
9
9
  desc "launch [<role>]", "launch an instance as role, or omit to ssh to vanilla instance"
10
+ option :name, :type => :string, :aliases => '-n', :desc => 'instance name'
10
11
  def launch(role=nil)
11
- id = task("Launch instance") { some.launch }
12
+ id = task("Launch instance") { some.launch(options[:name]) }
12
13
  host = task("Acquire hostname") { some.wait_for_hostname(id) }
13
14
  task("Wait for ssh") { some.wait_for_ssh(host) }
14
15
 
@@ -76,7 +77,7 @@ class CLI < Thor
76
77
  def closefw(port)
77
78
  raise ArgumentError unless port
78
79
  some.close_firewall(port)
79
- puts "port #{port} scheduled for open"
80
+ puts "port #{port} scheduled for close"
80
81
  end
81
82
 
82
83
  desc "fwlist", "list firewall rules"
data/lib/some.rb CHANGED
@@ -2,9 +2,10 @@ require 'net/ssh'
2
2
  require 'NIFTY'
3
3
  require 'yaml'
4
4
  require 'socket'
5
+ require 'json'
5
6
 
6
7
  class Some
7
- def launch
8
+ def launch(name=nil)
8
9
  ami = config['ami']
9
10
  raise "No AMI selected" unless ami
10
11
 
@@ -15,6 +16,7 @@ class Some
15
16
  open_firewall(22)
16
17
 
17
18
  result = api.run_instances(
19
+ :instance_id => name,
18
20
  :image_id => ami,
19
21
  :instance_type => config['instance_size'] || 'mini',
20
22
  :key_name => 'something',
@@ -124,7 +126,9 @@ class Some
124
126
  instances << {
125
127
  :instance_id => item.instanceId,
126
128
  :status => item.instanceState.name,
127
- :hostname => item.dnsName
129
+ :hostname => item.dnsName,
130
+ :public_ip => item.ipAddress,
131
+ :private_ip => item.privateIpAddress
128
132
  }
129
133
  end
130
134
  end
@@ -225,8 +229,10 @@ class Some
225
229
  end
226
230
 
227
231
  def setup_role(hostname, role)
232
+ dna = JSON.parse(config['role'][role])
233
+ dna.update("some" => {"instances" => list})
228
234
  commands = [
229
- "echo \'#{config['role'][role]}\' > /etc/chef/dna.json",
235
+ "echo \'#{JSON.pretty_generate(dna)}\' > /etc/chef/dna.json",
230
236
  "chef-solo -r #{config['cookbooks_url']}"
231
237
  ]
232
238
  ssh(hostname, commands)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: some
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-07 00:00:00.000000000Z
12
+ date: 2013-04-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nifty-cloud-sdk
16
- requirement: &212713900 !ruby/object:Gem::Requirement
16
+ requirement: &75940320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.11.beta1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *212713900
24
+ version_requirements: *75940320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &212713320 !ruby/object:Gem::Requirement
27
+ requirement: &75939740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *212713320
35
+ version_requirements: *75939740
36
+ - !ruby/object:Gem::Dependency
37
+ name: net-ssh
38
+ requirement: &75939160 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *75939160
36
47
  description: sumo clone for NIFTY Cloud
37
48
  email: tidnlyam@gmail.com
38
49
  executables:
@@ -40,9 +51,11 @@ executables:
40
51
  extensions: []
41
52
  extra_rdoc_files:
42
53
  - README.md
54
+ - TODO
43
55
  files:
44
56
  - README.md
45
57
  - Rakefile
58
+ - TODO
46
59
  - VERSION
47
60
  - bin/some
48
61
  - lib/some.rb