pec 0.7.1 → 0.7.2

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: bff0038d6e2313f1e3b8b039dfae6a5c07766c7f
4
- data.tar.gz: cc9ebdecf5f4d785c8bcbe296ee3b94c022201e4
3
+ metadata.gz: 5e8eba0965d155a9f519d921295e942b6b106775
4
+ data.tar.gz: fa6a457c9dd23058705d20369890c3b772a251ee
5
5
  SHA512:
6
- metadata.gz: 9250a610cd7bc60cdf757b4ff067f78640b8954eba8d746de3ad36b18457770cadb86199099f6c017c7e207a611a6199faa129ea7579144b611a2e94a78ec5d1
7
- data.tar.gz: 78dfab706b07339bbcc385593127141c2084af477233d9ca448c8c39aada1e9f349a660f2749d153b25ceca54e914aa4f22c79faa8345366838250ee83141102
6
+ metadata.gz: 2f3e85aa04e43cc5f40f8dda96e5b7aa00455741ab24ebcd19a5c04c9861b952e6162cdd2ed37e49f29077cf2d24209a477d1408d270abcfe51c8b3722eff3ff
7
+ data.tar.gz: 0ba33459b7b1528d83f9cb10320240cc62eb8e91b940965d134596ec0a7f8bf6a14d53a69b4d193ce07c4a0347bce83be21894ae4aeea8861f692c2ba3a48046
data/README.md CHANGED
@@ -18,13 +18,13 @@ create - /Pec.yaml
18
18
  create - /user_data/web_server.yaml.sample
19
19
  ```
20
20
 
21
- $ pec up <hostname>
21
+ $ pec up <hostname_regex> <hostname_regex>...
22
22
 
23
- $ pec destroy <hostname>
23
+ $ pec destroy <hostname_regex> <hostname_regex>...
24
24
 
25
- $ pec status <hostname>
25
+ $ pec status <hostname_regex> <hostname_regex>...
26
26
 
27
- $ pec config
27
+ $ pec config <hostname_regex> <hostname_regex>...
28
28
 
29
29
  ### Configure
30
30
  #### Pec.yaml
data/lib/pec.rb CHANGED
@@ -39,15 +39,16 @@ module Pec
39
39
  @_configure
40
40
  end
41
41
 
42
- def self.servers(host_name)
43
- self.configure.each do |host|
44
- next if host_name && host.name != host_name
45
- Pec.init_yao(host.tenant)
46
- server = Yao::Server.list_detail.find {|s|s.name == host.name}
47
- yield(server, host)
42
+ def self.servers(hosts)
43
+ self.configure.each do |config|
44
+ next if hosts && hosts.none? {|name| config.name.match(/^#{name}/)}
45
+ Pec.init_yao(config.tenant)
46
+ server = Yao::Server.list_detail.find {|s|s.name == config.name}
47
+ yield(server, config)
48
48
  end
49
49
  end
50
50
 
51
+
51
52
  def self.check_env
52
53
  %w(
53
54
  OS_AUTH_URL
@@ -4,28 +4,33 @@ module Pec
4
4
 
5
5
  desc 'init', 'create sample config'
6
6
  def init
7
- _sub_command(host_name, options)
7
+ _sub_command(nil, options)
8
8
  end
9
9
 
10
10
  desc 'up', 'create vm by Pec.yaml'
11
- def up(host_name = nil)
12
- _sub_command(host_name, options)
11
+ def up(*hosts)
12
+ _sub_command(hosts, options)
13
13
  end
14
14
 
15
15
  option :force , type: :boolean, aliases: "-f"
16
16
  desc "destroy", "delete vm"
17
- def destroy(host_name = nil)
18
- _sub_command(host_name, options)
17
+ def destroy(*hosts)
18
+ _sub_command(hosts, options)
19
19
  end
20
20
 
21
21
  desc "status", "vm status"
22
- def status(host_name = nil)
23
- _sub_command(host_name, options)
22
+ def status(*hosts)
23
+ _sub_command(hosts, options)
24
+ end
25
+
26
+ desc "list", "vm list"
27
+ def list
28
+ _sub_command(nil, options)
24
29
  end
25
30
 
26
31
  desc "config", "show configure"
27
- def config
28
- _sub_command(host_name, options)
32
+ def config(*hosts)
33
+ _sub_command(hosts, options)
29
34
  end
30
35
 
31
36
  map %w[--version -v] => :__print_version
@@ -35,8 +40,8 @@ module Pec
35
40
  end
36
41
 
37
42
  no_commands do
38
- def _sub_command(host_name, options)
39
- Object.const_get("Pec::Command::#{caller[0][/`([^']*)'/, 1].capitalize}").run(host_name, options)
43
+ def _sub_command(hosts, options)
44
+ Object.const_get("Pec::Command::#{caller[0][/`([^']*)'/, 1].capitalize}").run(hosts, options)
40
45
  end
41
46
  end
42
47
  end
@@ -6,5 +6,6 @@ module Pec
6
6
  autoload :Status, "pec/command/status"
7
7
  autoload :Config, "pec/command/config"
8
8
  autoload :Init, "pec/command/init"
9
+ autoload :List, "pec/command/list"
9
10
  end
10
11
  end
@@ -1,8 +1,10 @@
1
1
  module Pec::Command
2
2
  class Config < Base
3
- def self.run(host_name, options)
3
+ def self.run(hosts, options)
4
4
  puts YAML.dump(
5
- YAML.load_file("Pec.yaml").to_hash.reject {|c| c[0].to_s.match(/^_/)}
5
+ YAML.load_file("Pec.yaml").to_hash.reject {|c|
6
+ c[0].to_s.match(/^_/) || (hosts && hosts.none? {|name| c.match(/^#{name}/)})
7
+ }
6
8
  )
7
9
  rescue => e
8
10
  print_exception(e)
@@ -0,0 +1,13 @@
1
+ module Pec::Command
2
+ class List < Base
3
+ def self.run(host_name, options)
4
+ Thor.new.say("vm list:", :yellow)
5
+ Pec.configure.each do |host|
6
+ puts sprintf(
7
+ " %-35s",
8
+ host.name,
9
+ )
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,15 +1,16 @@
1
1
  module Pec::Command
2
2
  class Status < Base
3
3
  def self.task(host_name, options, server, config)
4
- Thor.new.say("Current machine stasus:", :yellow)
4
+ Thor.new.say("Current machine status:", :yellow)
5
5
  if server
6
6
  puts sprintf(
7
- " %-35s %-10s %-10s %-10s %-10s %-35s %-48s",
7
+ " %-35s %-10s %-10s %-10s %-10s %-10s %-35s %-48s",
8
8
  config.name,
9
9
  server.status,
10
10
  tenant_name(server),
11
11
  flavor_name(server),
12
12
  server.availability_zone,
13
+ server.key_name,
13
14
  server.ext_srv_attr_host,
14
15
  ip_addresses(server)
15
16
  )
@@ -1,3 +1,3 @@
1
1
  module Pec
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kazuhiko yamashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -147,6 +147,7 @@ files:
147
147
  - lib/pec/command/config.rb
148
148
  - lib/pec/command/destroy.rb
149
149
  - lib/pec/command/init.rb
150
+ - lib/pec/command/list.rb
150
151
  - lib/pec/command/status.rb
151
152
  - lib/pec/command/up.rb
152
153
  - lib/pec/config_error.rb