bbcloud 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/Gemfile +3 -0
- data/README +11 -1
- data/README.rdoc +11 -1
- data/Rakefile +12 -0
- data/bbcloud.gemspec +10 -10
- data/bin/brightbox-accounts +7 -2
- data/bin/brightbox-cloudips +7 -2
- data/bin/brightbox-config +7 -2
- data/bin/brightbox-images +7 -2
- data/bin/brightbox-lbs +7 -2
- data/bin/brightbox-servers +7 -2
- data/bin/brightbox-types +7 -2
- data/bin/brightbox-users +7 -2
- data/bin/brightbox-zones +7 -2
- data/lib/bbcloud.rb +43 -0
- data/lib/bbcloud/accounts.rb +5 -3
- data/lib/bbcloud/command_generator.rb +50 -0
- data/lib/bbcloud/commands/accounts-list.rb +13 -11
- data/lib/bbcloud/commands/accounts-reset-ftp-password.rb +26 -23
- data/lib/bbcloud/commands/accounts-show.rb +20 -16
- data/lib/bbcloud/commands/cloudips-create.rb +16 -14
- data/lib/bbcloud/commands/cloudips-destroy.rb +29 -26
- data/lib/bbcloud/commands/cloudips-list.rb +13 -11
- data/lib/bbcloud/commands/cloudips-map.rb +48 -46
- data/lib/bbcloud/commands/cloudips-show.rb +15 -12
- data/lib/bbcloud/commands/cloudips-unmap.rb +28 -25
- data/lib/bbcloud/commands/config-client-add.rb +33 -31
- data/lib/bbcloud/commands/config-client-default.rb +18 -16
- data/lib/bbcloud/commands/config-client-list.rb +19 -16
- data/lib/bbcloud/commands/config-client-remove.rb +18 -16
- data/lib/bbcloud/commands/images-destroy.rb +18 -16
- data/lib/bbcloud/commands/images-list.rb +20 -18
- data/lib/bbcloud/commands/images-register.rb +21 -19
- data/lib/bbcloud/commands/images-show.rb +17 -15
- data/lib/bbcloud/commands/lbs-add-nodes.rb +15 -13
- data/lib/bbcloud/commands/lbs-create.rb +65 -63
- data/lib/bbcloud/commands/lbs-destroy.rb +13 -11
- data/lib/bbcloud/commands/lbs-list.rb +13 -11
- data/lib/bbcloud/commands/lbs-remove-nodes.rb +15 -13
- data/lib/bbcloud/commands/lbs-show.rb +15 -13
- data/lib/bbcloud/commands/lbs-update.rb +59 -57
- data/lib/bbcloud/commands/servers-activate-cloud.rb +18 -16
- data/lib/bbcloud/commands/servers-create.rb +80 -77
- data/lib/bbcloud/commands/servers-destroy.rb +17 -15
- data/lib/bbcloud/commands/servers-list.rb +14 -14
- data/lib/bbcloud/commands/servers-show.rb +39 -37
- data/lib/bbcloud/commands/servers-shutdown.rb +14 -12
- data/lib/bbcloud/commands/servers-snapshot.rb +14 -12
- data/lib/bbcloud/commands/servers-start.rb +15 -13
- data/lib/bbcloud/commands/servers-stop.rb +14 -12
- data/lib/bbcloud/commands/types-list.rb +13 -11
- data/lib/bbcloud/commands/types-show.rb +18 -16
- data/lib/bbcloud/commands/users-list.rb +13 -11
- data/lib/bbcloud/commands/users-show.rb +17 -15
- data/lib/bbcloud/commands/users-update.rb +27 -25
- data/lib/bbcloud/commands/zones-list.rb +13 -11
- data/lib/bbcloud/config.rb +125 -111
- data/lib/bbcloud/error_parser.rb +34 -0
- data/lib/bbcloud/fog_extensions.rb +19 -0
- data/lib/bbcloud/gli_global_hooks.rb +56 -0
- data/lib/bbcloud/logging.rb +40 -0
- data/lib/bbcloud/ruby_core_ext.rb +9 -0
- data/lib/bbcloud/servers.rb +7 -2
- data/lib/bbcloud/tables.rb +78 -73
- data/lib/bbcloud/vendor/gli/.gitignore +10 -0
- data/lib/bbcloud/vendor/gli/.rvmrc +1 -0
- data/lib/bbcloud/vendor/gli/Gemfile +5 -0
- data/lib/bbcloud/vendor/gli/LICENSE.txt +201 -0
- data/lib/bbcloud/vendor/gli/README.rdoc +54 -0
- data/lib/bbcloud/vendor/gli/Rakefile +84 -0
- data/lib/bbcloud/vendor/gli/bin/gli +72 -0
- data/lib/bbcloud/vendor/gli/bin/report_on_rake_results +10 -0
- data/lib/bbcloud/vendor/gli/bin/test_all_rubies.sh +2 -0
- data/lib/bbcloud/vendor/gli/features/gli_executable.feature +88 -0
- data/lib/bbcloud/vendor/gli/features/gli_init.feature +122 -0
- data/lib/bbcloud/vendor/gli/features/step_definitions/gli_executable_steps.rb +12 -0
- data/lib/bbcloud/vendor/gli/features/step_definitions/gli_init_steps.rb +4 -0
- data/lib/bbcloud/vendor/gli/features/support/env.rb +21 -0
- data/lib/bbcloud/vendor/gli/gli.cheat +80 -0
- data/lib/bbcloud/vendor/gli/gli.gemspec +46 -0
- data/lib/bbcloud/vendor/gli/gli.rdoc +51 -0
- data/lib/bbcloud/vendor/gli/lib/gli.rb +560 -0
- data/lib/bbcloud/vendor/gli/lib/gli/command.rb +124 -0
- data/lib/bbcloud/vendor/gli/lib/gli/command_line_token.rb +58 -0
- data/lib/bbcloud/vendor/gli/lib/gli/copy_options_to_aliases.rb +33 -0
- data/lib/bbcloud/vendor/gli/lib/gli/exceptions.rb +45 -0
- data/lib/bbcloud/vendor/gli/lib/gli/flag.rb +67 -0
- data/lib/bbcloud/vendor/gli/lib/gli/options.rb +19 -0
- data/lib/bbcloud/vendor/gli/lib/gli/switch.rb +63 -0
- data/lib/bbcloud/vendor/gli/lib/gli/terminal.rb +79 -0
- data/lib/bbcloud/vendor/gli/lib/gli_version.rb +3 -0
- data/lib/bbcloud/vendor/gli/lib/support/help.rb +180 -0
- data/lib/bbcloud/vendor/gli/lib/support/initconfig.rb +34 -0
- data/lib/bbcloud/vendor/gli/lib/support/rdoc.rb +119 -0
- data/lib/bbcloud/vendor/gli/lib/support/scaffold.rb +284 -0
- data/lib/bbcloud/vendor/gli/test/config.yaml +9 -0
- data/lib/bbcloud/vendor/gli/test/gli.reek +116 -0
- data/lib/bbcloud/vendor/gli/test/roodi.yaml +9 -0
- data/lib/bbcloud/vendor/gli/test/tc_command.rb +329 -0
- data/lib/bbcloud/vendor/gli/test/tc_flag.rb +67 -0
- data/lib/bbcloud/vendor/gli/test/tc_gli.rb +429 -0
- data/lib/bbcloud/vendor/gli/test/tc_options.rb +31 -0
- data/lib/bbcloud/vendor/gli/test/tc_parsing.rb +279 -0
- data/lib/bbcloud/vendor/gli/test/tc_switch.rb +80 -0
- data/lib/bbcloud/vendor/gli/test/tc_terminal.rb +91 -0
- data/lib/bbcloud/version.rb +1 -1
- data/pkg/bbcloud-0.12.0.gem +0 -0
- data/spec/fixtures/vcr_cassettes/server_list.yml +117 -0
- data/spec/servers_spec.rb +36 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/common_helpers.rb +47 -0
- metadata +129 -135
- data/lib/bbcloud/cli.rb +0 -160
- data/lib/bbcloud/vendor/fog/lib/fog.rb +0 -14
- data/lib/bbcloud/vendor/fog/lib/fog/compute.rb +0 -43
- data/lib/bbcloud/vendor/fog/lib/fog/compute/brightbox.rb +0 -162
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/account.rb +0 -51
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ip.rb +0 -47
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ips.rb +0 -34
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavor.rb +0 -33
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavors.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/image.rb +0 -56
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/images.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancer.rb +0 -50
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancers.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/server.rb +0 -108
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/servers.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/user.rb +0 -39
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/users.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zone.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zones.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/activate_console_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_listeners_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_nodes_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_api_client.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_cloud_ip.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_image.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_load_balancer.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_server.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_api_client.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_image.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_account.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_api_client.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_image.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_interface.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server_type.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_user.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_zone.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_api_clients.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_cloud_ips.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_images.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_load_balancers.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_server_types.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_servers.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_users.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_zones.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/map_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_listeners_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_nodes_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/reset_ftp_password_account.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/resize_server.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/shutdown_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/snapshot_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/start_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/stop_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/unmap_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_account.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_api_client.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_image.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_load_balancer.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_server.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_user.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/core.rb +0 -32
- data/lib/bbcloud/vendor/fog/lib/fog/core/attributes.rb +0 -178
- data/lib/bbcloud/vendor/fog/lib/fog/core/collection.rb +0 -127
- data/lib/bbcloud/vendor/fog/lib/fog/core/connection.rb +0 -35
- data/lib/bbcloud/vendor/fog/lib/fog/core/credentials.rb +0 -92
- data/lib/bbcloud/vendor/fog/lib/fog/core/deprecation.rb +0 -23
- data/lib/bbcloud/vendor/fog/lib/fog/core/errors.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/core/hmac.rb +0 -48
- data/lib/bbcloud/vendor/fog/lib/fog/core/mock.rb +0 -68
- data/lib/bbcloud/vendor/fog/lib/fog/core/model.rb +0 -57
- data/lib/bbcloud/vendor/fog/lib/fog/core/parser.rb +0 -99
- data/lib/bbcloud/vendor/fog/lib/fog/core/provider.rb +0 -18
- data/lib/bbcloud/vendor/fog/lib/fog/core/scp.rb +0 -67
- data/lib/bbcloud/vendor/fog/lib/fog/core/service.rb +0 -175
- data/lib/bbcloud/vendor/fog/lib/fog/core/ssh.rb +0 -120
- data/lib/bbcloud/vendor/fog/lib/fog/core/time.rb +0 -27
- data/lib/bbcloud/vendor/fog/lib/fog/core/wait_for.rb +0 -17
- data/lib/bbcloud/vendor/fog/lib/fog/providers.rb +0 -9
- data/lib/bbcloud/vendor/fog/lib/fog/providers/brightbox.rb +0 -9
@@ -1,18 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'Destroy load balancers'
|
3
|
+
arg_name 'lb-id...'
|
4
|
+
command [:destroy] do |c|
|
4
5
|
|
5
|
-
|
6
|
+
c.action do |global_options, options, args|
|
6
7
|
|
7
|
-
|
8
|
+
raise "You must specify the load balancers to destroy" if args.empty?
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
lbs = LoadBalancer.find_or_call(args) do |id|
|
11
|
+
raise "Couldn't find load balancer #{id}"
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
lbs.each do |lb|
|
15
|
+
info "Destroying load balancer #{lb}"
|
16
|
+
lb.destroy
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,16 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'List load balancers'
|
3
|
+
arg_name '[lb-id...]'
|
4
|
+
command [:list] do |c|
|
5
|
+
c.action do |global_options,options,args|
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
if args.empty?
|
8
|
+
lbs = LoadBalancer.find(:all)
|
9
|
+
else
|
10
|
+
lbs = LoadBalancer.find_or_call(args) do |id|
|
11
|
+
warn "Couldn't find load balancer #{id}"
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
+
render_table(lbs, global_options)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'Remove nodes from a load balancer'
|
3
|
+
arg_name 'lb-id node-id...'
|
4
|
+
command [:remove_nodes] do |c|
|
4
5
|
|
5
|
-
|
6
|
+
c.action do |global_options, options, args|
|
6
7
|
|
7
|
-
|
8
|
+
raise "You must specify the load balancer and the node ids to remove" if args.size < 2
|
8
9
|
|
9
|
-
|
10
|
+
lb = LoadBalancer.find(args.shift)
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
# We don't want to check servers exist as you can remove deleted
|
13
|
+
# servers from a load balancer.
|
14
|
+
nodes = args.collect { |a| Server.new(a) }
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
info "Removing #{nodes.size} nodes from load balancer #{lb.id}"
|
17
|
+
lb.remove_nodes nodes
|
18
|
+
lb.reload
|
19
|
+
render_table([lb], global_options)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'Show detailed load balancer info'
|
3
|
+
arg_name 'lbs-id...'
|
4
|
+
command [:show] do |c|
|
4
5
|
|
5
|
-
|
6
|
+
c.action do |global_options,options,args|
|
6
7
|
|
7
|
-
|
8
|
+
raise "You must specify load balancers to show" if args.empty?
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
lbs = LoadBalancer.find_or_call(args) do |id|
|
11
|
+
raise "Couldn't find lb #{id}"
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
table_opts = global_options.merge({
|
15
|
+
:vertical => true,
|
16
|
+
:fields => [:id, :status, :name, "created_at", "deleted_at", :policy, :cloud_ips, :nodes, :listeners, :healthcheck]
|
17
|
+
})
|
17
18
|
|
18
|
-
|
19
|
+
render_table(lbs, table_opts)
|
19
20
|
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,85 +1,87 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'Update a load balancer'
|
3
|
+
long_desc "All intervals and timeouts are in milliseconds"
|
4
|
+
arg_name 'lba-id [node-id...]'
|
4
5
|
|
5
|
-
command [:update] do |c|
|
6
|
+
command [:update] do |c|
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
c.desc "Friendly name of load balancer"
|
9
|
+
c.flag [:n, :name]
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
c.desc "Load balancer policy"
|
12
|
+
c.flag [:p, :policy]
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
c.desc "Listeners (in-port:out-port:protocol. Comma separate multiple listeners)"
|
15
|
+
c.flag [:l, :listeners]
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
c.desc "Healthcheck port"
|
18
|
+
c.flag [:k, "hc-port"]
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
c.desc "Healthcheck type"
|
21
|
+
c.flag [:y, "hc-type"]
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
c.desc "Healthcheck timeout"
|
24
|
+
c.flag [:t, "hc-timeout"]
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
c.desc "Healthcheck request. When the type is 'http' this is the url to request."
|
27
|
+
c.flag [:s, "hc-request"]
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
c.desc "Healthcheck interval"
|
30
|
+
c.flag [:e, "hc-interval"]
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
c.desc "Healthcheck threshold up. Number of successful healthchecks for the node to be considered up."
|
33
|
+
c.flag [:u, "hc-up"]
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
c.desc "Healthcheck threshold down. Number of failed healthchecks for the node to be considered down."
|
36
|
+
c.flag [:d, "hc-down"]
|
36
37
|
|
37
|
-
|
38
|
+
c.action do |global_options, options, args|
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
lb_id = args.shift
|
41
|
+
raise "You must specify the load balancer to update as the first argument" unless lb_id =~ /^lba-/
|
41
42
|
|
42
|
-
|
43
|
+
lbopts = {}
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
unless args.empty?
|
46
|
+
lbopts[:nodes] = args.collect { |a| { :node => a } }
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
hc_arg_lookup = { :k => :port, :y => :type, :t => :timeout, :s =>
|
50
|
+
:request, :e => :interval, :u => :threshold_up, :d =>
|
51
|
+
:threshold_down }
|
51
52
|
|
52
|
-
|
53
|
+
healthcheck = {}
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
options.keys.each do |k|
|
56
|
+
if options[k] and hc_arg_lookup[k]
|
57
|
+
healthcheck[hc_arg_lookup[k]] = options[k]
|
58
|
+
end
|
57
59
|
end
|
58
|
-
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
unless healthcheck.keys.empty?
|
62
|
+
lbopts[:healthcheck] = healthcheck
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
if options[:l]
|
66
|
+
lbopts[:listeners] = options[:l].split(",").collect do |l|
|
67
|
+
inport, output, protocol = l.split ":"
|
68
|
+
{ :in => inport, :out => output, :protocol => protocol }
|
69
|
+
end
|
68
70
|
end
|
69
|
-
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
if options[:n]
|
73
|
+
lbopts[:name] = options[:n]
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
if options[:p]
|
77
|
+
lbopts[:policy] = options[:p]
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
+
lb = LoadBalancer.find lb_id
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
info "Updating load balancer #{lb}"
|
83
|
+
lb = lb.update(lbopts)
|
84
|
+
render_table([lb], global_options)
|
85
|
+
end
|
84
86
|
end
|
85
87
|
end
|
@@ -1,23 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'Activate the console service for one or more servers'
|
3
|
+
arg_name 'server-id...'
|
4
|
+
command [:activate_console] do |c|
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
c.action do |global_options,options,args|
|
7
|
+
|
8
|
+
raise "You must specify servers to activate the console for" if args.empty?
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
servers = Server.find_or_call(args) do |id|
|
11
|
+
raise "Couldn't find server #{id}"
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
+
consoles = []
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
servers.each do |s|
|
17
|
+
info "Activating console for server #{s}"
|
18
|
+
r = s.activate_console
|
19
|
+
consoles << { :url => r["console_url"], :token => r["console_token"], :expires => r["console_token_expires"] }
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
+
render_table(consoles, global_options.merge(:fields => [:url, :token, :expires]))
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
@@ -1,100 +1,103 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Brightbox
|
2
|
+
desc 'Create servers'
|
3
|
+
arg_name 'image_id'
|
4
|
+
command [:create] do |c|
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
c.desc "Number of servers to create"
|
7
|
+
c.default_value 1
|
8
|
+
c.flag [:i, "server-count"]
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
c.desc "Zone to create the servers in"
|
11
|
+
c.flag [:z, "zone"]
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
c.desc "Type of server to create"
|
14
|
+
c.default_value "nano"
|
15
|
+
c.flag [:t, :type]
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
c.desc "Friendly name of server"
|
18
|
+
c.flag [:n, :name]
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
c.desc "Specify user data"
|
21
|
+
c.flag [:m, "user-data"]
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
c.desc "Specify the user data from a local file"
|
24
|
+
c.flag [:f, "user-data-file"]
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
c.desc "Don't base64 encode the user data"
|
27
|
+
c.switch [:e, :no_base64]
|
27
28
|
|
28
|
-
|
29
|
+
c.action do |global_options, options, args|
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
if options[:i].to_s !~ /^[0-9]+$/
|
35
|
-
raise "server-count must be a number"
|
36
|
-
end
|
31
|
+
if args.empty?
|
32
|
+
raise "You must specify the image_id as the first argument"
|
33
|
+
end
|
37
34
|
|
38
|
-
|
35
|
+
if options[:i].to_s !~ /^[0-9]+$/
|
36
|
+
raise "server-count must be a number"
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
image = Image.find image_id
|
42
|
-
|
43
|
-
type_id = options[:t]
|
44
|
-
if type_id =~ /^typ\-/
|
45
|
-
type = Type.find type_id
|
46
|
-
else
|
47
|
-
type = Type.find_by_handle type_id
|
48
|
-
end
|
39
|
+
options[:i] = options[:i].to_i
|
49
40
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
41
|
+
image_id = args.shift
|
42
|
+
image = Image.find image_id
|
43
|
+
|
44
|
+
type_id = options[:t]
|
45
|
+
if type_id =~ /^typ\-/
|
46
|
+
type = Type.find type_id
|
54
47
|
else
|
55
|
-
|
48
|
+
type = Type.find_by_handle type_id
|
56
49
|
end
|
57
|
-
end
|
58
|
-
|
59
|
-
user_data = options[:m]
|
60
|
-
user_data_file = options[:f]
|
61
50
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
51
|
+
if options[:z]
|
52
|
+
zone = options[:z]
|
53
|
+
if zone =~ /^typ\-/
|
54
|
+
zone = Zone.find zone
|
55
|
+
else
|
56
|
+
zone = Zone.find_by_handle zone
|
57
|
+
end
|
68
58
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
|
60
|
+
user_data = options[:m]
|
61
|
+
user_data_file = options[:f]
|
62
|
+
|
63
|
+
if user_data_file
|
64
|
+
raise "Cannot specify user data on command line and in file at same time" if user_data
|
65
|
+
# Wot we use to read the data, be it from stdin or a file on disk
|
66
|
+
file_handler = lambda do |fh|
|
67
|
+
raise "User data file too big (>16k)" if fh.stat.size > 16 * 1024
|
68
|
+
user_data = fh.read
|
69
|
+
end
|
70
|
+
# Figure out how to invoke file_handler, and then invoke it
|
71
|
+
if user_data_file == "-"
|
72
|
+
file_handler[$stdin]
|
73
|
+
else
|
74
|
+
File.open user_data_file, "r", &file_handler
|
75
|
+
end
|
74
76
|
end
|
75
|
-
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
if user_data
|
79
|
+
unless options[:e]
|
80
|
+
require 'base64'
|
81
|
+
user_data = Base64.encode64(user_data)
|
82
|
+
end
|
83
|
+
raise "User data too big (>16k)" if user_data.size > 16 * 1024
|
81
84
|
end
|
82
|
-
raise "User data too big (>16k)" if user_data.size > 16 * 1024
|
83
|
-
end
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
86
|
+
msg = "Creating #{options[:i] > 1 ? options[:i] : 'a'} #{type.handle} (#{type.id})"
|
87
|
+
msg << " server#{options[:i] > 1 ? 's' : ''} with image #{image.name.strip} (#{image.id})"
|
88
|
+
msg << " in zone #{zone.handle} (#{zone})" if zone
|
89
|
+
msg << " with %.2fk of user data" % (user_data.size / 1024.0) if user_data
|
90
|
+
info msg
|
91
|
+
|
92
|
+
servers = Server.create_servers( options[:i], {
|
93
|
+
:image_id => image.id,
|
94
|
+
:flavor_id => type.id,
|
95
|
+
:zone_id => zone.to_s,
|
96
|
+
:name => options[:n],
|
97
|
+
:user_data => user_data
|
98
|
+
}
|
99
|
+
)
|
100
|
+
render_table(servers, global_options)
|
97
101
|
end
|
98
|
-
render_table(servers, global_options)
|
99
102
|
end
|
100
103
|
end
|