Class: Appfront::Command::Clusters
- Defined in:
- lib/appfront/command/clusters.rb
Class Method Summary collapse
- .create(args, opts) ⇒ Object
- .info(args, opts) ⇒ Object
- .list ⇒ Object
- .rm(args, opts) ⇒ Object
- .scale_down(args, opts) ⇒ Object
- .scale_up(args, opts) ⇒ Object
Class Method Details
.create(args, opts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/appfront/command/clusters.rb', line 25 def self.create(args, opts) exit 1 unless opts[:provider] exit 1 unless opts[:provider] == 'amazon' or opts[:provider] == 'digitalocean' or opts[:provider] == 'manual' if args.count == 3 name = args[0] type = args[1] region = args[2] elsif args.count == 2 type = args[0] region = args[1] elsif args.count == 1 name = args[0] type = 'manual' region = 'manual' end tier = opts[:provider] if type == 'manual' spinner "Creating new manual cluster ..." do @info = api.post "/provider/#{tier}/cluster/#{region}/#{type}" unless name @info = api.post "/provider/#{tier}/cluster/#{region}/#{type}", name: name if name end else spinner "Creating new cluster on region #{region}..." do @info = api.post "/provider/#{tier}/cluster/#{region}/#{type}" unless name @info = api.post "/provider/#{tier}/cluster/#{region}/#{type}", name: name if name end end print "\n" end |
.info(args, opts) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/appfront/command/clusters.rb', line 11 def self.info(args, opts) exit 1 unless args[0] uuid = args[0] exit 1 unless opts[:provider] exit 1 unless opts[:provider] == 'amazon' or opts[:provider] == 'digitalocean' or opts[:provider] == 'manual' c = api.get "/cluster/#{uuid}" puts "=== Cluster #{uuid}: \n" puts "\t === Name: #{c['name']}\n" puts "\t === Token: #{c['token']}\n" puts "\t === Region: #{c['region']}\n" puts "\t === Active Boxes: #{c['boxes']}\n" puts "\n" end |
.list ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/appfront/command/clusters.rb', line 3 def self.list clusters = api.get "/clusters" puts '=== Clusters List:' clusters.each do |cl| puts "Cluster #{cl['uuid']} ---> Name: #{cl['name']} \tProvider: #{cl['provider']}" end end |
.rm(args, opts) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/appfront/command/clusters.rb', line 57 def self.rm(args, opts) exit 1 unless args[0] uuid = args[0] exit 1 unless opts[:provider] exit 1 unless opts[:provider] == 'amazon' or opts[:provider] == 'digitalocean' or opts[:provider] == 'manual' tier = opts[:provider] spinner "Removing cluster #{uuid}..." do sleep 1 @info = api.delete "/provider/#{tier}/cluster/#{uuid}" end print "\n" end |
.scale_down(args, opts) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/appfront/command/clusters.rb', line 84 def self.scale_down(args, opts) uuid = args[0] exit 1 unless args[0] exit 1 unless opts[:provider] exit 1 unless opts[:provider] == 'amazon' or opts[:provider] == 'digitalocean' exit 1 unless args[0] spinner "Scaling DOWN cluster #{uuid}..." do api.put "/provider/cluster/#{uuid}/scale/down" end print "\n" end |
.scale_up(args, opts) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/appfront/command/clusters.rb', line 71 def self.scale_up(args, opts) exit 1 unless args[0] uuid = args[0] exit 1 unless opts[:provider] exit 1 unless opts[:provider] == 'amazon' or opts[:provider] == 'digitalocean' spinner "Scaling UP cluster #{uuid}..." do api.put "/provider/cluster/#{uuid}/scale/up" end print "\n" end |