dev-lxc 0.4.1 → 0.5.0

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: bd80876c8a3bc57a8b947f054b16dff20ec26843
4
- data.tar.gz: 9fcab6eaf86c32e326474bfc8f8e28a3ff2e0a46
3
+ metadata.gz: 79fba00eb009b9b2fcf9065f5607c3fab54de07d
4
+ data.tar.gz: 7161cfde69c348d86e8d3e52756ed71ba28cb938
5
5
  SHA512:
6
- metadata.gz: a01dabcd2f3cbba5fe3fece181bf53d6fd36cdeb9810f9b02735fd5378bcf313630578355573785a804d82c700e15338f417bbd7544c67e862c89eb66beb9ec7
7
- data.tar.gz: 726b7161383db28d2bac0a5e1cb7faf152024fc3c6ac2b529dbd16ce6786e9d08573fa660e2273e3e31418c0e6628568f620af4fe06fcceef6a276fa6324f410
6
+ metadata.gz: 59ead33f36b39cb1c0ad90a0a98c89ac963da70354591157227d5b2094449c5a26f3e93fa74c9a5c50192bb489171e86ca90a9e936d73382c70b42c9dd82a030
7
+ data.tar.gz: 8d5aae0290ebe546c67af627aa271fa28acc3cebfd2c93d80bbb52a284e9081244b5d28fc0961b2230ab260fd41a85c2945ac6c6556c8f09c36ae285118f4a5b
data/README.md CHANGED
@@ -63,6 +63,18 @@ Run `gem update dev-lxc` inside the Vagrant VM platform to ensure you have the l
63
63
 
64
64
  ## Usage
65
65
 
66
+ ### Display Help
67
+
68
+ ```
69
+ dev-lxc help
70
+
71
+ dev-lxc -h
72
+
73
+ dev-lxc --help
74
+
75
+ dev-lxc help <subcommand>
76
+ ```
77
+
66
78
  ### Shorter Commands are Faster (to type that is :)
67
79
 
68
80
  The dev-lxc-platform's root user's `~/.bashrc` file has aliased `dl` to `dev-lxc` for ease of use but
@@ -73,23 +85,29 @@ You only have to type enough of a `dev-lxc` subcommand to make it unique.
73
85
  The following commands are equivalent:
74
86
 
75
87
  ```
76
- dev-lxc cluster init standalone > dev-lxc.yml
77
- dl cl i standalone > dev-lxc.yml
88
+ dev-lxc init standalone > dev-lxc.yml
89
+ dl i standalone > dev-lxc.yml
78
90
  ```
79
91
 
80
92
  ```
81
- dev-lxc cluster start
82
- dl cl start
93
+ dev-lxc start
94
+ dl start
95
+
96
+ # if no subcommand is given then `start` will be called by default
97
+ # and any arguments will be passed to the `start` subcommand
98
+ # so both of the following commands will start all servers
99
+ dev-lxc
100
+ dl
83
101
  ```
84
102
 
85
103
  ```
86
- dev-lxc cluster status
87
- dl cl stat
104
+ dev-lxc status
105
+ dl stat
88
106
  ```
89
107
 
90
108
  ```
91
- dev-lxc cluster destroy
92
- dl cl d
109
+ dev-lxc destroy
110
+ dl d
93
111
  ```
94
112
 
95
113
  ### Create and Manage a Cluster
@@ -107,7 +125,7 @@ Be sure you configure the
107
125
  [mounts and packages entries](https://github.com/jeremiahsnapp/dev-lxc#cluster-config-files)
108
126
  appropriately.
109
127
 
110
- dev-lxc cluster init tier > dev-lxc.yml
128
+ dev-lxc init tier > dev-lxc.yml
111
129
 
112
130
  Uncomment the Analytics server section in `dev-lxc.yml` if you want it to be built.
113
131
 
@@ -118,7 +136,7 @@ Starting the cluster the first time takes awhile since it has a lot to build.
118
136
  The tool automatically creates snapshot clones at appropriate times so future
119
137
  creation of the cluster's servers is very quick.
120
138
 
121
- dev-lxc cluster start
139
+ dev-lxc start
122
140
 
123
141
  A test org, user, knife.rb and keys are automatically created in
124
142
  the bootstrap backend server in `/root/chef-repo/.chef` for testing purposes.
@@ -131,16 +149,16 @@ org and user.
131
149
 
132
150
  Run the following command to see the status of the cluster.
133
151
 
134
- dev-lxc cluster status
152
+ dev-lxc status
135
153
 
136
154
  This is an example of the output.
137
155
 
138
156
  ```
139
157
  Cluster is available at https://chef.lxc
140
158
  Analytics is available at https://analytics.lxc
141
- be-tier.lxc running 10.0.3.203
142
- fe1-tier.lxc running 10.0.3.204
143
- analytics-tier.lxc running 10.0.3.206
159
+ tier-be.lxc running 10.0.3.203
160
+ tier-fe1.lxc running 10.0.3.204
161
+ tier-analytics.lxc running 10.0.3.206
144
162
  ```
145
163
 
146
164
  [https://chef.lxc](https://chef.lxc) resolves to the frontend.
@@ -149,7 +167,7 @@ Analytics is available at https://analytics.lxc
149
167
 
150
168
  Create a local chef-repo with appropriate knife.rb and pem files.
151
169
 
152
- dev-lxc cluster chef-repo
170
+ dev-lxc chef-repo
153
171
 
154
172
  Now you can easily use knife to access the cluster.
155
173
 
@@ -163,68 +181,78 @@ Clones of the servers as they existed immediately after initial installation, co
163
181
  test org and user creation are available so you can destroy the cluster and "rebuild" it within
164
182
  seconds effectively starting with a clean slate very easily.
165
183
 
166
- dev-lxc cluster destroy
167
- dev-lxc cluster start
184
+ dev-lxc destroy
185
+ dev-lxc start
168
186
 
169
187
  #### Stop and start the cluster
170
188
 
171
- dev-lxc cluster stop
172
- dev-lxc cluster start
189
+ dev-lxc stop
190
+ dev-lxc start
173
191
 
174
192
  #### Backdoor access to each server's filesystem
175
193
 
176
194
  The abspath subcommand can be used to prepend each server's rootfs path to a particular file.
177
195
 
178
- When using `dev-lxc cluster abspath` only results for actual Chef Servers will be returned.
179
- If an Analytics server is described in `dev-lcx.yml` it will be ignored.
180
-
181
- For example, you can use the following command to edit each server's chef-server.rb file without
182
- logging into the containers.
196
+ For example, you can use the following command to edit the backend and frontend servers' chef-server.rb
197
+ file without logging into the containers.
183
198
 
184
- emacs $(dev-lxc cluster abspath /etc/opscode/chef-server.rb)
199
+ emacs $(dev-lxc abspath 'be|fe' /etc/opscode/chef-server.rb)
185
200
 
186
201
  #### Run arbitrary commands in each server
187
202
 
188
- After modifying the chef-server.rb you could use the run_command subcommand to tell each server
189
- to run `chef-server-ctl reconfigure`.
203
+ After modifying the chef-server.rb you could use the run_command subcommand to tell the backend and
204
+ frontend servers to run `chef-server-ctl reconfigure`.
190
205
 
191
- When using `dev-lxc cluster run_command` the command will only be run in actual Chef Servers.
192
- If an Analytics server is described in `dev-lcx.yml` it will be ignored.
193
-
194
- dev-lxc cluster run_command 'chef-server-ctl reconfigure'
206
+ dev-lxc run_command 'be|fe' 'chef-server-ctl reconfigure'
195
207
 
196
208
  #### Destroy cluster
197
209
 
198
210
  Use the following command to destroy the cluster's servers and also destroy their unique and shared
199
211
  base containers if you want to build them from scratch.
200
212
 
201
- dev-lxc cluster destroy -u -s
213
+ dev-lxc destroy -u -s
202
214
 
203
215
  #### Use commands against a specific server
204
- You can also run most of these commands against individual servers by using the server subcommand.
216
+ You can also run most of these commands against a set of servers by specifying a pattern that matches
217
+ a set of server names.
218
+
219
+ dev-lxc <subcommand> [pattern]
205
220
 
206
- dev-lxc server ...
221
+ For example, to only start the backend and frontend servers named `tier-be.lxc` and `tier-fe1.lxc`
222
+ you can run the following command.
223
+
224
+ dev-lxc start 'be|fe'
207
225
 
208
226
  ### Using the dev-lxc library
209
227
 
210
- dev-lxc can also be used as a library.
228
+ dev-lxc cli interface can be used as a library.
229
+
230
+ require 'dev-lxc/cli'
231
+
232
+ ARGV = [ 'start' ] # start all servers
233
+ DevLXC::CLI::DevLXC.start
234
+
235
+ ARGV = [ 'status' ] # show status of all servers
236
+ DevLXC::CLI::DevLXC.start
237
+
238
+ ARGV = [ 'run_command', 'uptime' ] # run `uptime` in all servers
239
+ DevLXC::CLI::DevLXC.start
240
+
241
+ ARGV = [ 'destroy' ] # destroy all servers
242
+ DevLXC::CLI::DevLXC.start
243
+
244
+ dev-lxc itself can also be used as a library
211
245
 
212
246
  require 'yaml'
213
247
  require 'dev-lxc'
214
- config = YAML.load(IO.read('dev-lxc.yml'))
215
- cluster = DevLXC::ChefCluster.new(config)
216
- cluster.start
217
- cluster.status
218
- cluster.run_command("uptime")
219
- server = DevLXC::ChefServer.new("fe1-tier.lxc", config)
220
- server.stop
221
- server.status
222
- cluster.status
223
- server.start
224
- cluster.status
225
- server.run_command("chef-server-ctl reconfigure")
226
- cluster.destroy
227
- cluster.status
248
+
249
+ config = YAML.load(IO.read('dev-lxc.yml'))
250
+ server = DevLXC::ChefServer.new("tier-fe1.lxc", config)
251
+
252
+ server.start # start tier-fe1.lxc
253
+ server.status # show status of tier-fe1.lxc
254
+ server.run_command("chef-server-ctl reconfigure") # run command in tier-fe1.lxc
255
+ server.stop # stop tier-fe1.lxc
228
256
 
229
257
  ## Cluster Config Files
230
258
 
@@ -232,9 +260,9 @@ dev-lxc uses a YAML configuration file named `dev-lxc.yml` to define a cluster.
232
260
 
233
261
  The following command generates sample config files for various cluster topologies.
234
262
 
235
- dev-lxc cluster init
263
+ dev-lxc init
236
264
 
237
- `dev-lxc cluster init tier > dev-lxc.yml` creates a `dev-lxc.yml` file with the following content:
265
+ `dev-lxc init tier > dev-lxc.yml` creates a `dev-lxc.yml` file with the following content:
238
266
 
239
267
  platform_container: p-ubuntu-1404
240
268
  topology: tier
@@ -249,17 +277,17 @@ The following command generates sample config files for various cluster topologi
249
277
  # push-jobs-server: /dev-shared/chef-packages/push-jobs-server/opscode-push-jobs-server_1.1.6-1_amd64.deb
250
278
  # analytics: /dev-shared/chef-packages/analytics/opscode-analytics_1.1.1-1_amd64.deb
251
279
  servers:
252
- be-tier.lxc:
280
+ tier-be.lxc:
253
281
  role: backend
254
282
  ipaddress: 10.0.3.203
255
283
  bootstrap: true
256
- fe1-tier.lxc:
284
+ tier-fe1.lxc:
257
285
  role: frontend
258
286
  ipaddress: 10.0.3.204
259
- # fe2-tier.lxc:
287
+ # tier-fe2.lxc:
260
288
  # role: frontend
261
289
  # ipaddress: 10.0.3.205
262
- # analytics-tier.lxc:
290
+ # tier-analytics.lxc:
263
291
  # role: analytics
264
292
  # ipaddress: 10.0.3.206
265
293
 
@@ -298,10 +326,10 @@ The following is an example of managing multiple clusters while still avoiding s
298
326
  each cluster's config file.
299
327
 
300
328
  mkdir -p ~/clusters/{clusterA,clusterB}
301
- dev-lxc cluster init tier > ~/clusters/clusterA/dev-lxc.yml
302
- dev-lxc cluster init standalone > ~/clusters/clusterB/dev-lxc.yml
303
- cd ~/clusters/clusterA && dev-lxc cluster start # starts clusterA
304
- cd ~/clusters/clusterB && dev-lxc cluster start # starts clusterB
329
+ dev-lxc init tier > ~/clusters/clusterA/dev-lxc.yml
330
+ dev-lxc init standalone > ~/clusters/clusterB/dev-lxc.yml
331
+ cd ~/clusters/clusterA && dev-lxc start # starts clusterA
332
+ cd ~/clusters/clusterB && dev-lxc start # starts clusterB
305
333
 
306
334
  ### Maintain Uniqueness Across Multiple Clusters
307
335
 
@@ -320,10 +348,10 @@ more clusters you have to maintain uniqueness across the YAML config files for t
320
348
  If cluster B is started with the same `api_fqdn` as an already running cluster A, then cluster B
321
349
  will overwrite cluster A's DNS resolution of `api_fqdn`.
322
350
 
323
- It is easy to provide uniqueness. For example, you can use the following command to replace `-tier`
324
- with `-1234` in a tier cluster's config.
351
+ It is easy to provide uniqueness. For example, you can use the following command to replace `.lxc`
352
+ with `-1234.lxc` in a cluster's config.
325
353
 
326
- sed -i 's/-tier/-1234/' dev-lxc.yml
354
+ sed -i 's/\.lxc/-1234.lxc/' dev-lxc.yml
327
355
 
328
356
  * IP Addresses
329
357
 
@@ -373,7 +401,7 @@ During a cluster build process the base containers that get created fall into th
373
401
 
374
402
  `DevLXC::ChefServer#create_base_server` controls the creation of a shared base container.
375
403
 
376
- Chef packages that are common to all servers in a Chef cluster, such as Chef server,
404
+ Chef packages that are common to all servers in a Chef cluster, such as chef-server-core,
377
405
  opscode-reporting and opscode-push-jobs-server are installed using `dpkg` or `rpm`.
378
406
 
379
407
  Note the manage package will not be installed at this point since it is not common to all
@@ -407,15 +435,12 @@ During a cluster build process the base containers that get created fall into th
407
435
 
408
436
  ### Destroying Base Containers
409
437
 
410
- When using `dev-lxc cluster destroy` to destroy an entire Chef cluster or `dev-lxc server destroy [NAME]`
411
- to destroy a single Chef server you have the option to also destroy any or all of the three types
412
- of base containers associated with the cluster or server.
413
-
414
- Either of the following commands will list the options available.
438
+ When using `dev-lxc destroy` to destroy servers you have the option to also destroy any or all of
439
+ the three types of base containers associated with the servers.
415
440
 
416
- dev-lxc cluster help destroy
441
+ The following command will list the options available.
417
442
 
418
- dev-lxc server help destroy
443
+ dev-lxc help destroy
419
444
 
420
445
  Of course, you can also just use the standard LXC commands to destroy any container.
421
446
 
@@ -35,18 +35,6 @@ module DevLXC
35
35
  chef_servers
36
36
  end
37
37
 
38
- def status
39
- puts "Cluster is available at https://#{@api_fqdn}"
40
- puts "Analytics is available at https://#{@analytics_fqdn}" if @analytics_fqdn
41
- chef_servers.each { |cs| cs.status }
42
- end
43
-
44
- def abspath(rootfs_path)
45
- abspath = Array.new
46
- chef_servers.each { |cs| abspath << cs.abspath(rootfs_path) unless cs.role == 'analytics' }
47
- abspath.compact
48
- end
49
-
50
38
  def chef_repo
51
39
  if @topology == "open-source"
52
40
  puts "Unable to create a chef-repo for an Open Source Chef Server"
@@ -81,29 +69,6 @@ knife[:chef_repo_path] = Dir.pwd
81
69
  end
82
70
  end
83
71
 
84
- def run_command(command)
85
- chef_servers.each { |cs| cs.run_command(command) unless cs.role == 'analytics' }
86
- end
87
-
88
- def start
89
- puts "Starting cluster"
90
- chef_servers.each { |cs| cs.start }
91
- end
92
-
93
- def stop
94
- puts "Stopping cluster"
95
- chef_servers.reverse_each { |cs| cs.stop }
96
- end
97
-
98
- def destroy
99
- puts "Destroying cluster"
100
- chef_servers.reverse_each { |cs| cs.destroy }
101
- end
102
-
103
- def destroy_container(type)
104
- chef_servers.each { |cs| cs.destroy_container(type) }
105
- end
106
-
107
72
  def chef_server_config
108
73
  chef_server_config = %Q(api_fqdn "#{@api_fqdn}"\n)
109
74
  if @topology == 'tier'
data/lib/dev-lxc/cli.rb CHANGED
@@ -3,7 +3,8 @@ require 'dev-lxc'
3
3
  require 'thor'
4
4
 
5
5
  module DevLXC::CLI
6
- class Cluster < Thor
6
+ class DevLXC < Thor
7
+
7
8
  no_commands{
8
9
  def get_cluster(config_option)
9
10
  config = "dev-lxc.yaml" if File.exists?("dev-lxc.yaml")
@@ -12,8 +13,24 @@ module DevLXC::CLI
12
13
  raise "A cluster config file must be provided" if config.nil?
13
14
  ::DevLXC::ChefCluster.new(YAML.load(IO.read(config)))
14
15
  end
16
+
17
+ def match_pattern(pattern)
18
+ get_cluster(options[:config]).chef_servers.select { |cs| cs.server.name =~ /#{pattern}/ }
19
+ end
15
20
  }
16
21
 
22
+ desc "create [PLATFORM_CONTAINER_NAME]", "Create a platform container"
23
+ def create(platform_container_name=nil)
24
+ platform_container_names = %w(p-ubuntu-1204 p-ubuntu-1404 p-centos-5 p-centos-6)
25
+ if platform_container_name.nil? || ! platform_container_names.include?(platform_container_name)
26
+ platform_container_names_with_index = platform_container_names.map.with_index{ |a, i| [i+1, *a]}
27
+ print_table platform_container_names_with_index
28
+ selection = ask("Which platform container do you want to create?", :limited_to => platform_container_names_with_index.map{|c| c[0].to_s})
29
+ platform_container_name = platform_container_names[selection.to_i - 1]
30
+ end
31
+ ::DevLXC.create_platform_container(platform_container_name)
32
+ end
33
+
17
34
  desc "init [TOPOLOGY]", "Provide a cluster config file"
18
35
  def init(topology=nil)
19
36
  topologies = %w(open-source standalone tier)
@@ -26,16 +43,26 @@ module DevLXC::CLI
26
43
  puts IO.read("#{File.dirname(__FILE__)}/../../files/configs/#{topology}.yml")
27
44
  end
28
45
 
29
- desc "status", "Show status of all servers"
46
+ desc "status", "Show status of servers"
30
47
  option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
31
- def status
32
- get_cluster(options[:config]).status
48
+ def status(pattern=nil)
49
+ config = "dev-lxc.yaml" if File.exists?("dev-lxc.yaml")
50
+ config = "dev-lxc.yml" if File.exists?("dev-lxc.yml")
51
+ config = options[:config] unless options[:config].nil?
52
+ raise "A cluster config file must be provided" if config.nil?
53
+ cluster_config = YAML.load(IO.read(config))
54
+
55
+ puts "Cluster is available at https://#{cluster_config['api_fqdn']}"
56
+ puts "Analytics is available at https://#{cluster_config['analytics_fqdn']}" if cluster_config['analytics_fqdn']
57
+ match_pattern(pattern).each { |cs| cs.status }
33
58
  end
34
59
 
35
- desc "abspath [ROOTFS_PATH]", "Returns the absolute path to a file in each Chef Server (not in an Analytics server)"
60
+ desc "abspath [ROOTFS_PATH]", "Returns the absolute path to a file in each server"
36
61
  option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
37
- def abspath(rootfs_path)
38
- puts get_cluster(options[:config]).abspath(rootfs_path).join(" ")
62
+ def abspath(pattern=nil, rootfs_path)
63
+ abspath = Array.new
64
+ match_pattern(pattern).map { |cs| abspath << cs.abspath(rootfs_path) }
65
+ puts abspath.compact.join(" ")
39
66
  end
40
67
 
41
68
  desc "chef-repo", "Creates a chef-repo in the current directory using files from the cluster's backend /root/chef-repo"
@@ -44,110 +71,44 @@ module DevLXC::CLI
44
71
  get_cluster(options[:config]).chef_repo
45
72
  end
46
73
 
47
- desc "run_command [COMMAND]", "Runs a command in each Chef Server (not in an Analytics server)"
74
+ desc "run_command [COMMAND]", "Runs a command in each server"
48
75
  option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
49
- def run_command(command)
50
- get_cluster(options[:config]).run_command(command)
76
+ def run_command(pattern=nil, command)
77
+ match_pattern(pattern).each { |cs| cs.run_command(command) }
51
78
  end
52
79
 
53
- desc "start", "Start all servers"
80
+ desc "start", "Start servers"
54
81
  option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
55
- def start
56
- get_cluster(options[:config]).start
82
+ def start(pattern=nil)
83
+ match_pattern(pattern).each { |cs| cs.start }
57
84
  end
58
85
 
59
- desc "stop", "Stop all servers"
60
- option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
61
- def stop
62
- get_cluster(options[:config]).stop
86
+ # make `start` the default subcommand and pass any arguments to it
87
+ default_task :start
88
+ def method_missing(method, *args)
89
+ args = ["start", method.to_s] + args
90
+ DevLXC.start(args)
63
91
  end
64
92
 
65
- desc "destroy", "Destroy all servers"
93
+ desc "stop", "Stop servers"
66
94
  option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
67
- option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the unique containers"
68
- option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the shared container"
69
- option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the platform container"
70
- def destroy
71
- cluster = get_cluster(options[:config])
72
- cluster.destroy
73
- cluster.destroy_container(:unique) if options[:unique]
74
- cluster.destroy_container(:shared) if options[:shared]
75
- cluster.destroy_container(:platform) if options[:platform]
95
+ def stop(pattern=nil)
96
+ match_pattern(pattern).reverse_each { |cs| cs.stop }
76
97
  end
77
- end
78
98
 
79
- class Server < Thor
80
- no_commands{
81
- def get_server(name, config_option)
82
- config = "dev-lxc.yaml" if File.exists?("dev-lxc.yaml")
83
- config = "dev-lxc.yml" if File.exists?("dev-lxc.yml")
84
- config = config_option unless config_option.nil?
85
- raise "A cluster config file must be provided" if config.nil?
86
- ::DevLXC::ChefServer.new(name, YAML.load(IO.read(config)))
87
- end
88
- }
89
-
90
- desc "status [NAME]", "Show status of a server"
99
+ desc "destroy", "Destroy servers"
91
100
  option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
92
- def status(name)
93
- get_server(name, options[:config]).status
94
- end
95
-
96
- desc "abspath [NAME] [ROOTFS_PATH]", "Returns the absolute path to a file in a server"
97
- option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
98
- def abspath(name, rootfs_path)
99
- puts get_server(name, options[:config]).abspath(rootfs_path)
100
- end
101
-
102
- desc "run_command [NAME] [COMMAND]", "Runs a command in a server"
103
- option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
104
- def run_command(name, command)
105
- get_server(name, options[:config]).run_command(command)
106
- end
107
-
108
- desc "start [NAME]", "Start a server"
109
- option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
110
- def start(name)
111
- get_server(name, options[:config]).start
112
- end
113
-
114
- desc "stop [NAME]", "Stop a server"
115
- option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
116
- def stop(name)
117
- get_server(name, options[:config]).stop
118
- end
119
-
120
- desc "destroy [NAME]", "Destroy a server"
121
- option :config, :aliases => "-c", :desc => "Specify a cluster's YAML config file. ./dev-lxc.yml will be used by default"
122
- option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the unique container"
101
+ option :unique, :aliases => "-u", :type => :boolean, :desc => "Also destroy the unique containers"
123
102
  option :shared, :aliases => "-s", :type => :boolean, :desc => "Also destroy the shared container"
124
103
  option :platform, :aliases => "-p", :type => :boolean, :desc => "Also destroy the platform container"
125
- def destroy(name)
126
- server = get_server(name, options[:config])
127
- server.destroy
128
- server.destroy_container(:unique) if options[:unique]
129
- server.destroy_container(:shared) if options[:shared]
130
- server.destroy_container(:platform) if options[:platform]
131
- end
132
- end
133
-
134
- class DevLXC < Thor
135
- desc "create [PLATFORM_CONTAINER_NAME]", "Create a platform container"
136
- def create(platform_container_name=nil)
137
- platform_container_names = %w(p-ubuntu-1204 p-ubuntu-1404 p-centos-5 p-centos-6)
138
- if platform_container_name.nil? || ! platform_container_names.include?(platform_container_name)
139
- platform_container_names_with_index = platform_container_names.map.with_index{ |a, i| [i+1, *a]}
140
- print_table platform_container_names_with_index
141
- selection = ask("Which platform container do you want to create?", :limited_to => platform_container_names_with_index.map{|c| c[0].to_s})
142
- platform_container_name = platform_container_names[selection.to_i - 1]
104
+ def destroy(pattern=nil)
105
+ match_pattern(pattern).reverse_each do |cs|
106
+ cs.destroy
107
+ cs.destroy_container(:unique) if options[:unique]
108
+ cs.destroy_container(:shared) if options[:shared]
109
+ cs.destroy_container(:platform) if options[:platform]
143
110
  end
144
- ::DevLXC.create_platform_container(platform_container_name)
145
111
  end
146
112
 
147
- desc "cluster SUBCOMMAND ...ARGS", "Manage cluster"
148
- subcommand "cluster", Cluster
149
-
150
- desc "server SUBCOMMAND ...ARGS", "Manage server"
151
- subcommand "server", Server
152
113
  end
153
114
  end
@@ -1,3 +1,3 @@
1
1
  module DevLXC
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev-lxc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremiah Snapp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler