houcho 0.0.2 → 0.0.3
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 +8 -8
- data/README.md +47 -84
- data/bin/houcho +114 -133
- data/lib/houcho.rb +41 -2
- data/lib/{CI.rb → houcho/ci.rb} +6 -2
- data/lib/houcho/cloudforecast.rb +59 -0
- data/lib/houcho/cloudforecast/host.rb +23 -0
- data/lib/houcho/cloudforecast/role.rb +24 -0
- data/lib/houcho/element.rb +74 -0
- data/lib/houcho/host.rb +22 -0
- data/lib/houcho/initialize.rb +15 -0
- data/lib/houcho/role.rb +121 -0
- data/lib/houcho/spec.rb +6 -0
- data/lib/houcho/spec/runner.rb +116 -0
- data/lib/houcho/version.rb +1 -1
- data/lib/houcho/yamlhandle.rb +27 -0
- data/templates/conf/houcho.conf +10 -0
- data/templates/conf/kk.rb +14 -0
- data/templates/conf/rspec.conf +1 -0
- data/templates/master +94 -0
- data/templates/role/cf_roles.yaml +0 -0
- data/templates/role/cloudforecast.yaml +0 -0
- data/templates/role/hosts.yaml +0 -0
- data/templates/role/hosts_ignored.yaml +0 -0
- data/templates/role/roles.yaml +0 -0
- data/templates/role/specs.yaml +0 -0
- data/templates/spec/sample_spec.rb +13 -0
- data/templates/spec/spec_helper.rb +29 -0
- metadata +25 -5
- data/lib/Conductor.rb +0 -619
- data/lib/RoleHandle.rb +0 -155
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTA0ZGY2OTllZjYyMGQ1Y2FiZTVmMDkzYzkwMzMxNGNkOTRiNTg0Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjIwNWRmMjljNWRlZTIxMjhiMjhkOWM2ZjM4MmMzMjhjOWNjNjRmNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjMwMWI2NGNkMDE0OWRlNDViYjEwNjc2Y2E4MjhkZTc1OGM3NWFmMDVkZWUx
|
10
|
+
NTUwZjRmNjk3MDBkMzg2YjFiN2YxNmJkMGEwYzFhZTUyYWVlYjM1MTVjNjRh
|
11
|
+
ZjFkYjc2N2E2ZTJiNWY3NTQ4YmU3ZmRhZmE0OGU1NTgwMzA5OGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2IyNTQ4ZmZmYTY4MThlN2YwMzM1MDhhZDMzOThlNTgzNDc3NjJjYmQwZDI5
|
14
|
+
YzNlZTBiZDJhYjJjMzcxNzZhNzFlMWRhYzFlNGNhZmY3NzViMTVmMTE0MjBk
|
15
|
+
MzZhNTYxNTkwN2M5NTg1MDNhM2E4OWNhYjFiYjNjOGNmYjViOWU=
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Houcho
|
2
2
|
- wrapping to execute serverspec
|
3
|
+
- depends on ruby 1.9 later.
|
3
4
|
|
4
5
|
## Install and Initialize
|
5
6
|
- install houcho from ruby gems
|
@@ -9,9 +10,8 @@
|
|
9
10
|
```
|
10
11
|
|
11
12
|
- make working directory and initialize.
|
12
|
-
-
|
13
|
-
|
14
|
-
|
13
|
+
- when `houcho init` then `git init`
|
14
|
+
|
15
15
|
```sh
|
16
16
|
$ mkdir houcho-repo
|
17
17
|
$ cd houcho-repo
|
@@ -22,15 +22,15 @@ $ houcho init
|
|
22
22
|
- example of the most simplest use case
|
23
23
|
|
24
24
|
```sh
|
25
|
-
$ houcho spec exec
|
25
|
+
$ houcho spec exec houcho_sample --hosts test.studio3104.com
|
26
26
|
```
|
27
27
|
|
28
|
-
- run `houcho_sample_spec.rb`
|
29
|
-
- arguments
|
30
|
-
- argument of
|
28
|
+
- run `houcho_sample_spec.rb` to `test.studio3104.com`
|
29
|
+
- arguments are able to specify multiple space-delimited.
|
30
|
+
- argument of `spec exec` is able to specify exception of `_spec.rb`, and relative path from `spec/` under working directory.
|
31
31
|
|
32
32
|
## Create Role, Run Role
|
33
|
-
|
33
|
+
Houcho is able to define role of combination to be used well.
|
34
34
|
|
35
35
|
- create role at first.
|
36
36
|
|
@@ -38,104 +38,92 @@ $ houcho init
|
|
38
38
|
$ houcho role create studio3104::www
|
39
39
|
```
|
40
40
|
|
41
|
-
- attach
|
41
|
+
- attach hosts to role just created.
|
42
42
|
|
43
43
|
```sh
|
44
|
-
$ houcho host attach www01.studio3104.com studio3104::www
|
45
|
-
$ houcho host attach www02.studio3104.com studio3104::www
|
44
|
+
$ houcho host attach www01.studio3104.com www02.studio3104.com --roles studio3104::www
|
46
45
|
```
|
47
46
|
|
48
|
-
- attach
|
47
|
+
- attach specs to role.
|
49
48
|
- argument is able to specify exception of `_spec.rb`, and relative path from `spec/` under working directory same as simple usage.
|
50
49
|
|
51
50
|
```sh
|
52
|
-
$ houcho spec attach houcho_sample studio3104::www
|
51
|
+
$ houcho spec attach houcho_sample houcho_sample2 --roles studio3104::www
|
53
52
|
```
|
54
53
|
|
55
54
|
- show details of a role just created.
|
56
55
|
|
57
56
|
```sh
|
58
57
|
$ houcho role details studio3104::www
|
59
|
-
studio3104::www
|
60
|
-
|
61
|
-
[host]
|
58
|
+
[studio3104::www]
|
59
|
+
host
|
62
60
|
├─ www01.studio3104.com
|
63
61
|
└─ www02.studio3104.com
|
64
62
|
|
65
|
-
|
66
|
-
|
63
|
+
spec
|
64
|
+
├─ houcho_sample
|
65
|
+
└─ houcho_sample2
|
67
66
|
```
|
68
67
|
|
69
68
|
- execute role.
|
70
69
|
- it can specify multiple space-delimited.
|
71
70
|
|
72
71
|
```sh
|
73
|
-
$ houcho
|
72
|
+
$ houcho role exec studio3104::www
|
74
73
|
```
|
75
74
|
|
76
75
|
- it is also possible to use regular expressions.
|
77
76
|
|
78
77
|
```sh
|
79
|
-
$ houcho
|
78
|
+
$ houcho role exec studio3104.+
|
80
79
|
```
|
81
80
|
|
82
81
|
|
83
82
|
## Include CloudForecast's yaml file
|
84
|
-
|
83
|
+
Houcho is able to load yaml of CloudForecast, and attach to the role defined.
|
85
84
|
|
86
85
|
- install yaml of CloudForecast to `role/cloudforecast/` under working directory.
|
87
|
-
-
|
86
|
+
- extension have to be yaml.
|
88
87
|
|
89
|
-
- cloudforecast
|
90
|
-
- yaml
|
88
|
+
- load cloudforecast's yaml.
|
89
|
+
- run each time you replace the yaml. do not need to run every time.
|
91
90
|
|
92
91
|
```sh
|
93
|
-
$ houcho
|
94
|
-
$ houcho
|
92
|
+
$ houcho cf load
|
93
|
+
$ houcho cf show
|
95
94
|
houcho::author::studio3104
|
96
|
-
$ houcho
|
97
|
-
[
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
studio3107.test
|
102
|
-
studio3108.test
|
103
|
-
studio3109.test
|
104
|
-
studio3110.test
|
95
|
+
$ houcho cf details houcho::author::studio3104
|
96
|
+
[houcho::author::studio3104]
|
97
|
+
host
|
98
|
+
├─ studio3104.test
|
99
|
+
└─ studio3105.test
|
105
100
|
```
|
106
101
|
|
107
|
-
-
|
108
|
-
- TODO: 複数指定出来るようにする。
|
102
|
+
- attach to the original role defined, the role read from cloudforecast.
|
109
103
|
|
110
104
|
```sh
|
111
|
-
$ houcho
|
105
|
+
$ houcho cf attach houcho::author::studio3104 --roles studio3104::www
|
112
106
|
$ houcho role details studio3104::www
|
113
|
-
studio3104::www
|
114
|
-
|
115
|
-
[host]
|
107
|
+
[studio3104::www]
|
108
|
+
host
|
116
109
|
├─ www01.studio3104.com
|
117
110
|
└─ www02.studio3104.com
|
118
111
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
112
|
+
spec
|
113
|
+
├─ houcho_sample
|
114
|
+
└─ houcho_sample2
|
115
|
+
|
116
|
+
cf
|
123
117
|
houcho::author::studio3104
|
124
|
-
|
118
|
+
host
|
125
119
|
├─ studio3104.test
|
126
|
-
|
127
|
-
├─ studio3106.test
|
128
|
-
├─ studio3107.test
|
129
|
-
├─ studio3108.test
|
130
|
-
├─ studio3109.test
|
131
|
-
└─ studio3110.test
|
120
|
+
└─ studio3105.test
|
132
121
|
```
|
133
122
|
|
134
123
|
## Applied Usage
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
- simple usageと同じように、作業ディレクトリの`spec/`からの相対パスで、`_spec.rb`を除いて指定します。
|
124
|
+
- at modified specs, run specs by sampling appropriately host.
|
125
|
+
- `--sample-host-count` can specifies the number of samples(default: 5)
|
126
|
+
- argument is able to specify exception of `_spec.rb`, and relative path from `spec/` under working directory same as simple usage.
|
139
127
|
|
140
128
|
```sh
|
141
129
|
$ houcho spec check houcho_sample hogehogechan
|
@@ -147,36 +135,11 @@ $ houcho spec check houcho_sample hogehogechan
|
|
147
135
|
hogehogechan has not attached to any roles
|
148
136
|
```
|
149
137
|
|
150
|
-
- cloudforecast
|
138
|
+
- Run exclude from the target some hosts that are included in the role of cloudforecast.
|
151
139
|
|
152
140
|
```sh
|
153
|
-
$ houcho
|
154
|
-
$ houcho role details studio3104::www
|
155
|
-
studio3104::www
|
156
|
-
|
157
|
-
[host]
|
158
|
-
├─ www01.studio3104.com
|
159
|
-
└─ www02.studio3104.com
|
160
|
-
|
161
|
-
[spec]
|
162
|
-
└─ houcho_sample
|
163
|
-
|
164
|
-
[cloudforecast's]
|
165
|
-
houcho::author::studio3104
|
166
|
-
[host]
|
167
|
-
├─ <ignored>studio3109.test</ignored>
|
168
|
-
├─ studio3104.test
|
169
|
-
├─ studio3105.test
|
170
|
-
├─ studio3106.test
|
171
|
-
├─ studio3107.test
|
172
|
-
├─ studio3108.test
|
173
|
-
└─ studio3110.test
|
141
|
+
$ houcho role exec studio3104::www --exclude-hosts studio3104.test
|
174
142
|
```
|
175
143
|
|
176
144
|
## TODO
|
177
|
-
-
|
178
|
-
- attach|detachの引数を複数取れるようにする
|
179
|
-
- host ignore|disignoreはなにやら変なので他のやりかた考える
|
180
|
-
- 引数を複数取れるようにもする
|
181
|
-
- disignoreって英語として変
|
182
|
-
- include|excludeにすれば実装はそのままでいいかな・・・
|
145
|
+
- there is no tests…
|
data/bin/houcho
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- encoding: utf-8 -*-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
3
4
|
|
4
|
-
app_dir = File.expand_path("#{File.dirname(__FILE__)}/..")
|
5
5
|
require 'rubygems'
|
6
6
|
require 'thor'
|
7
|
-
require
|
7
|
+
require 'houcho'
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
include Houcho
|
10
|
+
|
11
|
+
module Helper
|
12
|
+
module_function
|
13
|
+
|
14
|
+
def empty_args(klass, chell, mesod)
|
15
|
+
klass.class.task_help(chell, mesod)
|
16
|
+
exit
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
class Thor::MyHelper < Thor
|
@@ -29,57 +36,51 @@ class Thor::MyHelper < Thor
|
|
29
36
|
end
|
30
37
|
|
31
38
|
|
32
|
-
class
|
39
|
+
class SpecConduct < Thor::MyHelper
|
33
40
|
namespace :spec
|
34
41
|
|
35
|
-
desc 'details [
|
36
|
-
def details(
|
37
|
-
|
42
|
+
desc 'details [spec1 spec2 spec3...]', 'show details about spec'
|
43
|
+
def details(*args)
|
44
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
45
|
+
puts_details(Spec.details(args))
|
38
46
|
end
|
39
47
|
|
40
48
|
desc 'show', 'show all of specs'
|
41
49
|
def show
|
42
|
-
|
50
|
+
puts Spec.elements.sort.join("\n")
|
43
51
|
end
|
44
52
|
|
45
|
-
desc 'attach [
|
46
|
-
|
47
|
-
|
53
|
+
desc 'attach [spec1 spec2 spec3...] --roles [role1 role2...]', 'attach spec to role'
|
54
|
+
option :roles, :type => :array, :required => true, :desc => 'specify the roles separated by spaces.'
|
55
|
+
def attach(*args)
|
56
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
57
|
+
Spec.attach(args, options[:roles])
|
48
58
|
end
|
49
59
|
|
50
|
-
desc 'detach [
|
51
|
-
|
52
|
-
|
60
|
+
desc 'detach [spec1 spec2 spec3...] --roles [role1 role2...]', 'detach spec from spec'
|
61
|
+
option :roles, :type => :array, :required => true, :desc => 'specify the roles separated by spaces.'
|
62
|
+
def detach(*args)
|
63
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
64
|
+
Spec.detach(args, options[:roles])
|
53
65
|
end
|
54
66
|
|
55
|
-
desc 'check [options]', '
|
56
|
-
option :sample_host_count, :type => :numeric, :default => 5, :desc => '
|
67
|
+
desc 'check [options]', 'run the spec sampled appropriately to the associated host'
|
68
|
+
option :sample_host_count, :type => :numeric, :default => 5, :desc => 'number of sample hosts'
|
57
69
|
def check(*args)
|
58
|
-
if args.empty?
|
59
|
-
|
60
|
-
exit
|
61
|
-
end
|
62
|
-
conduct.check_specs(options[:sample_host_count], args)
|
70
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
71
|
+
Spec::Runner.check(args, options[:sample_host_count])
|
63
72
|
end
|
64
73
|
|
65
|
-
desc 'exec [options]', 'run serverspec'
|
66
|
-
option :hosts, :type => :array, :desc => 'hosts
|
67
|
-
option :specs, :type => :array, :desc => 'run specs (requied: --hosts)'
|
68
|
-
option :roles, :type => :array, :desc => 'runspecs by role'
|
74
|
+
desc 'exec (spec1 spec2..) [options]', 'run serverspec manually'
|
75
|
+
option :hosts, :type => :array, :desc => '--hosts host1 host2 host3...', :required => true
|
69
76
|
option :ukigumo, :type => :boolean, :desc => 'post results to UkigumoServer'
|
70
77
|
option :ikachan, :type => :boolean, :desc => 'post fail results to Ikachan'
|
71
78
|
option :dry_run, :type => :boolean, :desc => 'show commands that may exexute'
|
72
|
-
def exec
|
73
|
-
|
74
|
-
(options[:hosts]||[]), (options[:specs]||[]), (options[:roles]||[])
|
75
|
-
|
76
|
-
if (hosts + specs + roles).empty? || (hosts.empty? && ! specs.empty?) || (! hosts.empty? && specs.empty?)
|
77
|
-
self.class.task_help(shell, __method__)
|
78
|
-
exit
|
79
|
-
end
|
79
|
+
def exec(*args)
|
80
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
80
81
|
|
81
|
-
|
82
|
-
|
82
|
+
Spec::Runner.exec(
|
83
|
+
[], [], options[:hosts], args,
|
83
84
|
{
|
84
85
|
ukigumo: options[:ukigumo],
|
85
86
|
ikachan: options[:ikachan],
|
@@ -90,152 +91,132 @@ class Spec < Thor::MyHelper
|
|
90
91
|
end
|
91
92
|
|
92
93
|
|
93
|
-
class
|
94
|
+
class HostConduct < Thor::MyHelper
|
94
95
|
namespace :host
|
95
96
|
|
96
|
-
desc 'details [
|
97
|
-
def details(
|
98
|
-
|
97
|
+
desc 'details [host1 host2 host3...]', 'show details about host'
|
98
|
+
def details(*args)
|
99
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
100
|
+
puts_details(Host.details(args))
|
99
101
|
end
|
100
102
|
|
101
103
|
desc 'show', 'show all of hosts'
|
102
104
|
def show
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
desc 'attach [host] [role]', 'attach a host to a role'
|
107
|
-
def attach(host, role)
|
108
|
-
conduct.attach_host_to_role(host, role)
|
109
|
-
end
|
110
|
-
|
111
|
-
desc 'detach [host] [role]', 'detach a host from a role'
|
112
|
-
def detach(host, role)
|
113
|
-
conduct.detach_host_from_role(host, role)
|
105
|
+
puts (Host.elements + CloudForecast::Host.all).join("\n")
|
114
106
|
end
|
115
107
|
|
116
|
-
desc
|
117
|
-
|
118
|
-
|
108
|
+
desc 'attach [host1 host2 host3...] --roles [role1 role2...]', 'attach host to role'
|
109
|
+
option :roles, :type => :array, :required => true, :desc => 'specify the roles separated by spaces.'
|
110
|
+
def attach(*args)
|
111
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
112
|
+
Host.attach(args, options[:roles])
|
119
113
|
end
|
120
114
|
|
121
|
-
desc
|
122
|
-
|
123
|
-
|
115
|
+
desc 'detach [host1 host2 host3...] --roles [role1 role2...]', 'detach host from role'
|
116
|
+
option :roles, :type => :array, :required => true, :desc => 'specify the roles separated by spaces.'
|
117
|
+
def detach(*args)
|
118
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
119
|
+
Host.detach(args, options[:roles])
|
124
120
|
end
|
125
121
|
end
|
126
122
|
|
127
123
|
|
128
|
-
class
|
124
|
+
class RoleConduct < Thor::MyHelper
|
129
125
|
namespace :role
|
130
126
|
|
131
|
-
desc 'create [
|
132
|
-
def create(
|
133
|
-
|
127
|
+
desc 'create [role1 role2 role3...]', 'cretate role'
|
128
|
+
def create(*args)
|
129
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
130
|
+
Role.create(args)
|
134
131
|
end
|
135
132
|
|
136
|
-
desc 'delete [
|
137
|
-
def delete(
|
138
|
-
|
133
|
+
desc 'delete [role1 role2 role3...]', 'delete a role'
|
134
|
+
def delete(*args)
|
135
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
136
|
+
Role.delete(args)
|
139
137
|
end
|
140
138
|
|
141
139
|
desc 'rename [exist role] [name]', 'rename a role'
|
142
140
|
def rename(role, rename)
|
143
|
-
|
141
|
+
Role.rename(role, rename)
|
144
142
|
end
|
145
143
|
|
146
|
-
desc 'details [
|
147
|
-
def details(
|
148
|
-
|
144
|
+
desc 'details [role1 role2...]', 'show details about role'
|
145
|
+
def details(*args)
|
146
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
147
|
+
puts_details(Role.details(args))
|
149
148
|
end
|
150
149
|
|
151
150
|
desc 'show', 'show all of roles'
|
152
151
|
def show
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
|
-
class CloudForecast < Thor::MyHelper
|
159
|
-
namespace :cfrole
|
160
|
-
|
161
|
-
desc "details [cfrole]", "show details about a cf's role"
|
162
|
-
def details(cf_role)
|
163
|
-
conduct.show_cf_role_details(cf_role)
|
152
|
+
puts Role.all.join("\n")
|
164
153
|
end
|
165
154
|
|
166
|
-
desc '
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
conduct.attach_cfrole_to_role(cf_role, role)
|
174
|
-
end
|
175
|
-
|
176
|
-
desc 'detach [cfrole] [role]', 'detach a cf role from a role'
|
177
|
-
def detach(cf_role, role)
|
178
|
-
conduct.detach_cfrole_from_role(cf_role, role)
|
179
|
-
end
|
155
|
+
desc 'exec (role1 role2..) [options]', 'run role'
|
156
|
+
option :exclude_hosts, :type => :array, :desc => '--exclude-hosts host1 host2 host3...'
|
157
|
+
option :ukigumo, :type => :boolean, :desc => 'post results to UkigumoServer'
|
158
|
+
option :ikachan, :type => :boolean, :desc => 'post fail results to Ikachan'
|
159
|
+
option :dry_run, :type => :boolean, :desc => 'show commands that may exexute'
|
160
|
+
def exec(*args)
|
161
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
180
162
|
|
181
|
-
|
182
|
-
|
183
|
-
|
163
|
+
Spec::Runner.exec(
|
164
|
+
args, (options[:exclude_hosts]||[]), [], [],
|
165
|
+
{
|
166
|
+
ukigumo: options[:ukigumo],
|
167
|
+
ikachan: options[:ikachan],
|
168
|
+
},
|
169
|
+
options[:dry_run],
|
170
|
+
)
|
184
171
|
end
|
185
|
-
|
186
172
|
end
|
187
173
|
|
188
174
|
|
189
|
-
class
|
190
|
-
namespace :
|
191
|
-
|
192
|
-
desc 'create [runlist]', 'cretate a runlist'
|
193
|
-
def create(runlist)
|
194
|
-
conduct.create_runlist(runlist)
|
195
|
-
end
|
175
|
+
class CFConduct < Thor::MyHelper
|
176
|
+
namespace :cf
|
196
177
|
|
197
|
-
desc
|
198
|
-
def
|
199
|
-
|
178
|
+
desc "details [cf1 cf2 cf3...]", "show details about cloudforecast's role"
|
179
|
+
def details(*args)
|
180
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
181
|
+
puts_details(CloudForecast::Role.details(args))
|
200
182
|
end
|
201
183
|
|
202
|
-
desc '
|
203
|
-
def
|
204
|
-
|
205
|
-
end
|
206
|
-
|
207
|
-
desc 'exclude [role] [runlist]', 'exclude a role from a runlist'
|
208
|
-
def exclude(role, runlist)
|
209
|
-
conduct.exclude_role_from_runlist(role, runlist)
|
184
|
+
desc 'show', "show all of cloudforecast's roles"
|
185
|
+
def show
|
186
|
+
puts CloudForecast::Role.all.sort.join("\n")
|
210
187
|
end
|
211
188
|
|
212
|
-
desc '
|
213
|
-
|
214
|
-
|
189
|
+
desc 'attach [cf1 cf2 cf3...] --roles [role1 role2...]', "attach cloudforecast's role to role"
|
190
|
+
option :roles, :type => :array, :required => true, :desc => 'specify the roles separated by spaces.'
|
191
|
+
def attach(*args)
|
192
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
193
|
+
CloudForecast::Role.attach(args, options[:roles])
|
215
194
|
end
|
216
195
|
|
217
|
-
desc '
|
218
|
-
|
219
|
-
|
196
|
+
desc 'detach [cf1 cf2 cf3...] --roles [role1 role2...]', "detach cloudforecast's role from role"
|
197
|
+
option :roles, :type => :array, :required => true, :desc => 'specify the roles separated by spaces.'
|
198
|
+
def detach(*args)
|
199
|
+
Helper.empty_args(self, shell, __method__) if args.empty?
|
200
|
+
CloudForecast::Role.detach(args, options[:roles])
|
220
201
|
end
|
221
202
|
|
222
|
-
desc '
|
223
|
-
def
|
224
|
-
|
203
|
+
desc 'load', '(re)loading yamls of cloudforecast'
|
204
|
+
def load
|
205
|
+
CloudForecast.load_yaml
|
225
206
|
end
|
226
207
|
end
|
227
208
|
|
228
209
|
|
229
|
-
class
|
230
|
-
register(
|
231
|
-
register(
|
232
|
-
register(
|
233
|
-
register(
|
210
|
+
class Main < Thor
|
211
|
+
register(CFConduct, 'cf', 'cf [attach|detach|show|details|load]', 'operate relevant to CloudForecast')
|
212
|
+
register(RoleConduct, 'role', 'role [create|delete|rename|show|details|exec]', 'operate roles')
|
213
|
+
register(HostConduct, 'host', 'host [attach|detach|show|details]', 'operate hosts')
|
214
|
+
register(SpecConduct, 'spec', 'spec [attach|detach|show|details|exec|check]', 'operate specs')
|
234
215
|
|
235
216
|
class_option :help, :type => :boolean, :aliases => '-h', :desc => 'Help message.'
|
236
217
|
no_tasks do
|
237
218
|
def invoke_task(task, *args)
|
238
|
-
if options[:help] && ! %w{role host spec
|
219
|
+
if options[:help] && ! %w{role host spec cf help}.include?(task.name)
|
239
220
|
Houcho.task_help(shell, task.name)
|
240
221
|
else
|
241
222
|
super
|
@@ -245,10 +226,10 @@ class Houcho < Thor
|
|
245
226
|
|
246
227
|
desc 'init', 'set houcho repository on current directory'
|
247
228
|
def init
|
248
|
-
|
229
|
+
Initialize
|
249
230
|
end
|
250
231
|
|
251
232
|
end
|
252
233
|
|
253
|
-
|
254
|
-
exit! if $
|
234
|
+
Main.start
|
235
|
+
exit! if $houcho_fail
|