central-cli 0.6.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 +7 -0
- data/.dockerignore +3 -0
- data/.gitignore +15 -0
- data/.rspec +6 -0
- data/.rubocop.yml +5 -0
- data/Dockerfile +15 -0
- data/Gemfile +10 -0
- data/LICENSE +191 -0
- data/README.md +39 -0
- data/Rakefile +9 -0
- data/VERSION +1 -0
- data/bin/cm +85 -0
- data/central-cli.gemspec +35 -0
- data/central-docker.sh +6 -0
- data/lib/central/cli/app_command.rb +29 -0
- data/lib/central/cli/apps/build_command.rb +24 -0
- data/lib/central/cli/apps/central_yml_generator.rb +88 -0
- data/lib/central/cli/apps/common.rb +166 -0
- data/lib/central/cli/apps/deploy_command.rb +191 -0
- data/lib/central/cli/apps/docker_compose_generator.rb +48 -0
- data/lib/central/cli/apps/docker_helper.rb +85 -0
- data/lib/central/cli/apps/dockerfile_generator.rb +15 -0
- data/lib/central/cli/apps/init_command.rb +91 -0
- data/lib/central/cli/apps/list_command.rb +68 -0
- data/lib/central/cli/apps/logs_command.rb +76 -0
- data/lib/central/cli/apps/monitor_command.rb +93 -0
- data/lib/central/cli/apps/remove_command.rb +80 -0
- data/lib/central/cli/apps/restart_command.rb +38 -0
- data/lib/central/cli/apps/scale_command.rb +31 -0
- data/lib/central/cli/apps/show_command.rb +23 -0
- data/lib/central/cli/apps/start_command.rb +39 -0
- data/lib/central/cli/apps/stop_command.rb +39 -0
- data/lib/central/cli/auth/aws/create_command.rb +34 -0
- data/lib/central/cli/auth/aws_command.rb +7 -0
- data/lib/central/cli/auth/list_command.rb +28 -0
- data/lib/central/cli/auth_command.rb +9 -0
- data/lib/central/cli/bytes_helper.rb +38 -0
- data/lib/central/cli/common.rb +148 -0
- data/lib/central/cli/container_command.rb +10 -0
- data/lib/central/cli/containers/exec_command.rb +21 -0
- data/lib/central/cli/containers/inspect_command.rb +22 -0
- data/lib/central/cli/etcd/common.rb +7 -0
- data/lib/central/cli/etcd/get_command.rb +26 -0
- data/lib/central/cli/etcd/list_command.rb +31 -0
- data/lib/central/cli/etcd/mkdir_command.rb +21 -0
- data/lib/central/cli/etcd/remove_command.rb +25 -0
- data/lib/central/cli/etcd/set_command.rb +22 -0
- data/lib/central/cli/etcd_command.rb +16 -0
- data/lib/central/cli/external_registries/add_command.rb +21 -0
- data/lib/central/cli/external_registries/delete_command.rb +15 -0
- data/lib/central/cli/external_registries/list_command.rb +27 -0
- data/lib/central/cli/external_registries/remove_command.rb +13 -0
- data/lib/central/cli/external_registry_command.rb +14 -0
- data/lib/central/cli/login_command.rb +121 -0
- data/lib/central/cli/logout_command.rb +7 -0
- data/lib/central/cli/master/aws/create_command.rb +41 -0
- data/lib/central/cli/master/aws_command.rb +7 -0
- data/lib/central/cli/master/azure/create_command.rb +39 -0
- data/lib/central/cli/master/azure_command.rb +11 -0
- data/lib/central/cli/master/digital_ocean/create_command.rb +35 -0
- data/lib/central/cli/master/digital_ocean_command.rb +11 -0
- data/lib/central/cli/master/list_command.rb +28 -0
- data/lib/central/cli/master/use_command.rb +34 -0
- data/lib/central/cli/master/users/add_role_command.rb +26 -0
- data/lib/central/cli/master/users/invite_command.rb +24 -0
- data/lib/central/cli/master/users/list_command.rb +18 -0
- data/lib/central/cli/master/users/remove_command.rb +22 -0
- data/lib/central/cli/master/users/remove_role_command.rb +25 -0
- data/lib/central/cli/master/users_command.rb +15 -0
- data/lib/central/cli/master/vagrant/create_command.rb +25 -0
- data/lib/central/cli/master/vagrant/restart_command.rb +20 -0
- data/lib/central/cli/master/vagrant/ssh_command.rb +15 -0
- data/lib/central/cli/master/vagrant/start_command.rb +20 -0
- data/lib/central/cli/master/vagrant/stop_command.rb +20 -0
- data/lib/central/cli/master/vagrant/terminate_command.rb +13 -0
- data/lib/central/cli/master/vagrant_command.rb +21 -0
- data/lib/central/cli/master_command.rb +19 -0
- data/lib/central/cli/node_command.rb +30 -0
- data/lib/central/cli/nodes/add_label_command.rb +19 -0
- data/lib/central/cli/nodes/aws/create_command.rb +40 -0
- data/lib/central/cli/nodes/aws/restart_command.rb +29 -0
- data/lib/central/cli/nodes/aws/terminate_command.rb +21 -0
- data/lib/central/cli/nodes/aws_command.rb +14 -0
- data/lib/central/cli/nodes/azure/create_command.rb +40 -0
- data/lib/central/cli/nodes/azure/restart_command.rb +31 -0
- data/lib/central/cli/nodes/azure/terminate_command.rb +21 -0
- data/lib/central/cli/nodes/azure_command.rb +14 -0
- data/lib/central/cli/nodes/digital_ocean/create_command.rb +32 -0
- data/lib/central/cli/nodes/digital_ocean/restart_command.rb +27 -0
- data/lib/central/cli/nodes/digital_ocean/terminate_command.rb +19 -0
- data/lib/central/cli/nodes/digital_ocean_command.rb +14 -0
- data/lib/central/cli/nodes/label_command.rb +12 -0
- data/lib/central/cli/nodes/labels/add_command.rb +19 -0
- data/lib/central/cli/nodes/labels/remove_command.rb +23 -0
- data/lib/central/cli/nodes/list_command.rb +62 -0
- data/lib/central/cli/nodes/remove_command.rb +16 -0
- data/lib/central/cli/nodes/remove_label_command.rb +23 -0
- data/lib/central/cli/nodes/show_command.rb +49 -0
- data/lib/central/cli/nodes/ssh_command.rb +31 -0
- data/lib/central/cli/nodes/update_command.rb +20 -0
- data/lib/central/cli/nodes/vagrant/create_command.rb +27 -0
- data/lib/central/cli/nodes/vagrant/restart_command.rb +26 -0
- data/lib/central/cli/nodes/vagrant/ssh_command.rb +21 -0
- data/lib/central/cli/nodes/vagrant/start_command.rb +26 -0
- data/lib/central/cli/nodes/vagrant/stop_command.rb +26 -0
- data/lib/central/cli/nodes/vagrant/terminate_command.rb +17 -0
- data/lib/central/cli/nodes/vagrant_command.rb +20 -0
- data/lib/central/cli/register_command.rb +21 -0
- data/lib/central/cli/registry/create_command.rb +144 -0
- data/lib/central/cli/registry/delete_command.rb +22 -0
- data/lib/central/cli/registry/remove_command.rb +19 -0
- data/lib/central/cli/registry_command.rb +11 -0
- data/lib/central/cli/service_command.rb +49 -0
- data/lib/central/cli/services/add_env_command.rb +19 -0
- data/lib/central/cli/services/add_secret_command.rb +24 -0
- data/lib/central/cli/services/container_command.rb +8 -0
- data/lib/central/cli/services/containers_command.rb +32 -0
- data/lib/central/cli/services/create_command.rb +90 -0
- data/lib/central/cli/services/delete_command.rb +19 -0
- data/lib/central/cli/services/deploy_command.rb +21 -0
- data/lib/central/cli/services/env_command.rb +11 -0
- data/lib/central/cli/services/envs/add_command.rb +19 -0
- data/lib/central/cli/services/envs/list_command.rb +20 -0
- data/lib/central/cli/services/envs/remove_command.rb +18 -0
- data/lib/central/cli/services/envs_command.rb +20 -0
- data/lib/central/cli/services/link_command.rb +26 -0
- data/lib/central/cli/services/list_command.rb +42 -0
- data/lib/central/cli/services/logs_command.rb +57 -0
- data/lib/central/cli/services/monitor_command.rb +58 -0
- data/lib/central/cli/services/remove_command.rb +17 -0
- data/lib/central/cli/services/remove_env_command.rb +18 -0
- data/lib/central/cli/services/remove_secret_command.rb +28 -0
- data/lib/central/cli/services/restart_command.rb +17 -0
- data/lib/central/cli/services/scale_command.rb +17 -0
- data/lib/central/cli/services/secret_command.rb +9 -0
- data/lib/central/cli/services/secrets/link_command.rb +24 -0
- data/lib/central/cli/services/secrets/unlink_command.rb +28 -0
- data/lib/central/cli/services/services_helper.rb +360 -0
- data/lib/central/cli/services/show_command.rb +18 -0
- data/lib/central/cli/services/start_command.rb +17 -0
- data/lib/central/cli/services/stats_command.rb +74 -0
- data/lib/central/cli/services/stop_command.rb +17 -0
- data/lib/central/cli/services/unlink_command.rb +25 -0
- data/lib/central/cli/services/update_command.rb +78 -0
- data/lib/central/cli/stack_command.rb +32 -0
- data/lib/central/cli/stack_options.rb +11 -0
- data/lib/central/cli/stacks/add_user_command.rb +18 -0
- data/lib/central/cli/stacks/audit_log_command.rb +21 -0
- data/lib/central/cli/stacks/cloud_config_command.rb +41 -0
- data/lib/central/cli/stacks/common.rb +95 -0
- data/lib/central/cli/stacks/create_command.rb +26 -0
- data/lib/central/cli/stacks/current_command.rb +25 -0
- data/lib/central/cli/stacks/env_command.rb +32 -0
- data/lib/central/cli/stacks/list_command.rb +35 -0
- data/lib/central/cli/stacks/list_users_command.rb +26 -0
- data/lib/central/cli/stacks/logs_command.rb +81 -0
- data/lib/central/cli/stacks/remove_command.rb +26 -0
- data/lib/central/cli/stacks/remove_user_command.rb +17 -0
- data/lib/central/cli/stacks/show_command.rb +19 -0
- data/lib/central/cli/stacks/trusted_subnets/add_command.rb +16 -0
- data/lib/central/cli/stacks/trusted_subnets/list_command.rb +17 -0
- data/lib/central/cli/stacks/trusted_subnets/remove_command.rb +20 -0
- data/lib/central/cli/stacks/update_command.rb +27 -0
- data/lib/central/cli/stacks/use_command.rb +21 -0
- data/lib/central/cli/stacks/user_command.rb +11 -0
- data/lib/central/cli/stacks/users/add_command.rb +18 -0
- data/lib/central/cli/stacks/users/list_command.rb +18 -0
- data/lib/central/cli/stacks/users/remove_command.rb +17 -0
- data/lib/central/cli/user/forgot_password_command.rb +16 -0
- data/lib/central/cli/user/reset_password_command.rb +21 -0
- data/lib/central/cli/user/verify_command.rb +22 -0
- data/lib/central/cli/user_command.rb +12 -0
- data/lib/central/cli/vault/list_command.rb +25 -0
- data/lib/central/cli/vault/read_command.rb +17 -0
- data/lib/central/cli/vault/remove_command.rb +14 -0
- data/lib/central/cli/vault/update_command.rb +18 -0
- data/lib/central/cli/vault/write_command.rb +22 -0
- data/lib/central/cli/vault_command.rb +16 -0
- data/lib/central/cli/version.rb +5 -0
- data/lib/central/cli/version_command.rb +22 -0
- data/lib/central/cli/vpn/config_command.rb +25 -0
- data/lib/central/cli/vpn/create_command.rb +71 -0
- data/lib/central/cli/vpn/delete_command.rb +21 -0
- data/lib/central/cli/vpn/remove_command.rb +19 -0
- data/lib/central/cli/vpn_command.rb +13 -0
- data/lib/central/cli/whoami_command.rb +20 -0
- data/lib/central/client.rb +208 -0
- data/lib/central/errors.rb +10 -0
- data/lib/central/machine/aws.rb +14 -0
- data/lib/central/machine/aws/auth_provisioner.rb +161 -0
- data/lib/central/machine/aws/cloudinit.yml +71 -0
- data/lib/central/machine/aws/cloudinit_master.yml +118 -0
- data/lib/central/machine/aws/cloudinit_oauth.yml +76 -0
- data/lib/central/machine/aws/common.rb +31 -0
- data/lib/central/machine/aws/master_provisioner.rb +171 -0
- data/lib/central/machine/aws/node_destroyer.rb +46 -0
- data/lib/central/machine/aws/node_provisioner.rb +214 -0
- data/lib/central/machine/azure.rb +13 -0
- data/lib/central/machine/azure/cloudinit.yml +64 -0
- data/lib/central/machine/azure/cloudinit_master.yml +106 -0
- data/lib/central/machine/azure/logger.rb +26 -0
- data/lib/central/machine/azure/master_provisioner.rb +125 -0
- data/lib/central/machine/azure/node_destroyer.rb +52 -0
- data/lib/central/machine/azure/node_provisioner.rb +126 -0
- data/lib/central/machine/cert_helper.rb +39 -0
- data/lib/central/machine/cloud_config/cloudinit.yml +70 -0
- data/lib/central/machine/cloud_config/node_generator.rb +27 -0
- data/lib/central/machine/common.rb +16 -0
- data/lib/central/machine/digital_ocean.rb +13 -0
- data/lib/central/machine/digital_ocean/cloudinit.yml +64 -0
- data/lib/central/machine/digital_ocean/cloudinit_master.yml +118 -0
- data/lib/central/machine/digital_ocean/master_provisioner.rb +99 -0
- data/lib/central/machine/digital_ocean/node_destroyer.rb +40 -0
- data/lib/central/machine/digital_ocean/node_provisioner.rb +81 -0
- data/lib/central/machine/random_name.rb +39 -0
- data/lib/central/machine/vagrant.rb +12 -0
- data/lib/central/machine/vagrant/Vagrantfile.master.rb.erb +116 -0
- data/lib/central/machine/vagrant/Vagrantfile.node.rb.erb +32 -0
- data/lib/central/machine/vagrant/cloudinit.yml +73 -0
- data/lib/central/machine/vagrant/master_destroyer.rb +34 -0
- data/lib/central/machine/vagrant/master_provisioner.rb +79 -0
- data/lib/central/machine/vagrant/node_destroyer.rb +38 -0
- data/lib/central/machine/vagrant/node_provisioner.rb +68 -0
- data/lib/central/scripts/completer +157 -0
- data/lib/central/scripts/init +11 -0
- data/spec/central/cli/app/common_spec.rb +150 -0
- data/spec/central/cli/app/deploy_command_spec.rb +598 -0
- data/spec/central/cli/app/docker_helper_spec.rb +102 -0
- data/spec/central/cli/app/scale_spec.rb +49 -0
- data/spec/central/cli/common_spec.rb +117 -0
- data/spec/central/cli/login_command_spec.rb +31 -0
- data/spec/central/cli/master/current_command_spec.rb +55 -0
- data/spec/central/cli/master/use_command_spec.rb +37 -0
- data/spec/central/cli/master/users/invite_command_spec.rb +34 -0
- data/spec/central/cli/master/users/remove_command_spec.rb +26 -0
- data/spec/central/cli/master/users/roles/add_command_spec.rb +34 -0
- data/spec/central/cli/master/users/roles/remove_command_spec.rb +34 -0
- data/spec/central/cli/register_command_spec.rb +56 -0
- data/spec/central/cli/services/containers_command_spec.rb +40 -0
- data/spec/central/cli/services/link_command_spec.rb +38 -0
- data/spec/central/cli/services/restart_command_spec.rb +27 -0
- data/spec/central/cli/services/secrets/link_command_spec.rb +59 -0
- data/spec/central/cli/services/secrets/unlink_command_spec.rb +48 -0
- data/spec/central/cli/services/services_helper_spec.rb +170 -0
- data/spec/central/cli/services/unlink_command_spec.rb +38 -0
- data/spec/central/cli/stacks/trusted_subnets/add_command_spec.rb +37 -0
- data/spec/central/cli/stacks/trusted_subnets/list_command_spec.rb +30 -0
- data/spec/central/cli/stacks/trusted_subnets/remove_command_spec.rb +37 -0
- data/spec/central/cli/version_command_spec.rb +16 -0
- data/spec/fixtures/central.yml +17 -0
- data/spec/fixtures/docker-compose.yml +8 -0
- data/spec/fixtures/mysql.yml +3 -0
- data/spec/fixtures/wordpress-scaled.yml +3 -0
- data/spec/fixtures/wordpress.yml +2 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/client_helpers.rb +30 -0
- data/spec/support/fixtures_helpers.rb +7 -0
- data/tasks/rspec.rake +5 -0
- metadata +463 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Central::Cli::Master::Vagrant
|
|
2
|
+
class TerminateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
|
|
5
|
+
def execute
|
|
6
|
+
require_api_url
|
|
7
|
+
|
|
8
|
+
require 'central/machine/vagrant'
|
|
9
|
+
destroyer = Central::Machine::Vagrant::MasterDestroyer.new(client(require_token))
|
|
10
|
+
destroyer.run!
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
module Central::Cli::Master
|
|
3
|
+
require_relative 'vagrant/create_command'
|
|
4
|
+
require_relative 'vagrant/start_command'
|
|
5
|
+
require_relative 'vagrant/stop_command'
|
|
6
|
+
require_relative 'vagrant/restart_command'
|
|
7
|
+
require_relative 'vagrant/ssh_command'
|
|
8
|
+
require_relative 'vagrant/terminate_command'
|
|
9
|
+
|
|
10
|
+
class VagrantCommand < Clamp::Command
|
|
11
|
+
subcommand 'create', 'Create a new Vagrant master', Vagrant::CreateCommand
|
|
12
|
+
subcommand 'ssh', 'SSH into Vagrant master', Vagrant::SshCommand
|
|
13
|
+
subcommand 'start', 'Start Vagrant master', Vagrant::StartCommand
|
|
14
|
+
subcommand 'stop', 'Stop Vagrant master', Vagrant::StopCommand
|
|
15
|
+
subcommand 'restart', 'Restart Vagrant master', Vagrant::RestartCommand
|
|
16
|
+
subcommand 'terminate', 'Terminate Vagrant master', Vagrant::TerminateCommand
|
|
17
|
+
|
|
18
|
+
def execute
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative 'master/vagrant_command'
|
|
2
|
+
require_relative 'master/aws_command'
|
|
3
|
+
require_relative 'master/digital_ocean_command'
|
|
4
|
+
require_relative 'master/azure_command'
|
|
5
|
+
require_relative 'master/use_command'
|
|
6
|
+
require_relative 'master/list_command'
|
|
7
|
+
require_relative 'master/users_command'
|
|
8
|
+
|
|
9
|
+
class Central::Cli::MasterCommand < Clamp::Command
|
|
10
|
+
subcommand 'vagrant', 'Vagrant specific commands', Central::Cli::Master::VagrantCommand
|
|
11
|
+
subcommand 'aws', 'AWS specific commands', Central::Cli::Master::AwsCommand
|
|
12
|
+
subcommand 'digitalocean', 'DigitalOcean specific commands', Central::Cli::Master::DigitalOceanCommand
|
|
13
|
+
subcommand 'azure', 'Azure specific commands', Central::Cli::Master::AzureCommand
|
|
14
|
+
subcommand %w(list ls), 'List masters where client has logged in', Central::Cli::Master::ListCommand
|
|
15
|
+
subcommand 'use', 'Switch to use selected master', Central::Cli::Master::UseCommand
|
|
16
|
+
subcommand 'users', 'Users specific commands', Central::Cli::Master::UsersCommand
|
|
17
|
+
def execute
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require_relative 'nodes/list_command'
|
|
2
|
+
require_relative 'nodes/remove_command'
|
|
3
|
+
require_relative 'nodes/show_command'
|
|
4
|
+
require_relative 'nodes/update_command'
|
|
5
|
+
require_relative 'nodes/ssh_command'
|
|
6
|
+
|
|
7
|
+
require_relative 'nodes/label_command'
|
|
8
|
+
|
|
9
|
+
require_relative 'nodes/vagrant_command'
|
|
10
|
+
require_relative 'nodes/digital_ocean_command'
|
|
11
|
+
require_relative 'nodes/aws_command'
|
|
12
|
+
require_relative 'nodes/azure_command'
|
|
13
|
+
|
|
14
|
+
class Central::Cli::NodeCommand < Clamp::Command
|
|
15
|
+
subcommand %w(list ls), 'List stack nodes', Central::Cli::Nodes::ListCommand
|
|
16
|
+
subcommand 'show', 'Show node', Central::Cli::Nodes::ShowCommand
|
|
17
|
+
subcommand 'ssh', 'Ssh into node', Central::Cli::Nodes::SshCommand
|
|
18
|
+
subcommand 'update', 'Update node', Central::Cli::Nodes::UpdateCommand
|
|
19
|
+
subcommand %w(remove rm), 'Remove node', Central::Cli::Nodes::RemoveCommand
|
|
20
|
+
|
|
21
|
+
subcommand 'label', 'Node label specific commands', Central::Cli::Nodes::LabelCommand
|
|
22
|
+
|
|
23
|
+
subcommand 'vagrant', 'Vagrant specific commands', Central::Cli::Nodes::VagrantCommand
|
|
24
|
+
subcommand 'digitalocean', 'DigitalOcean specific commands', Central::Cli::Nodes::DigitalOceanCommand
|
|
25
|
+
subcommand 'aws', 'AWS specific commands', Central::Cli::Nodes::AwsCommand
|
|
26
|
+
subcommand 'azure', 'Azure specific commands', Central::Cli::Nodes::AzureCommand
|
|
27
|
+
|
|
28
|
+
def execute
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Central::Cli::Nodes
|
|
2
|
+
class AddLabelCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
|
|
5
|
+
parameter 'NODE_ID', 'Node id'
|
|
6
|
+
parameter 'LABEL', 'Label'
|
|
7
|
+
|
|
8
|
+
def execute
|
|
9
|
+
require_api_url
|
|
10
|
+
require_current_stack
|
|
11
|
+
token = require_token
|
|
12
|
+
|
|
13
|
+
node = client(token).get("stacks/#{current_stack}/nodes/#{node_id}")
|
|
14
|
+
data = {}
|
|
15
|
+
data[:labels] = node['labels'].to_a | [label]
|
|
16
|
+
client.put("nodes/#{node['id']}", data, {}, 'Central-Stack-Token' => node['stack']['token'])
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Aws
|
|
2
|
+
class CreateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter '[NAME]', 'Node name'
|
|
7
|
+
option '--access-key', 'ACCESS_KEY', 'AWS access key ID', environment_variable: 'AWS_ACCESS_KEY_ID', required: true
|
|
8
|
+
option '--secret-key', 'SECRET_KEY', 'AWS secret key', environment_variable: 'AWS_SECRET_ACCESS_KEY', required: true
|
|
9
|
+
option '--key-pair', 'KEY_PAIR', 'EC2 Key Pair', required: true
|
|
10
|
+
option '--region', 'REGION', 'EC2 Region', default: 'us-west-2'
|
|
11
|
+
option '--zone', 'ZONE', 'EC2 Availability Zone', default: 'a'
|
|
12
|
+
option '--vpc-id', 'VPC ID', 'Virtual Private Cloud (VPC) ID (default: default vpc)'
|
|
13
|
+
option '--subnet-id', 'SUBNET ID', 'VPC option to specify subnet to launch instance into (default: first subnet in vpc/az)'
|
|
14
|
+
option '--type', 'SIZE', 'Instance type', default: 't2.small'
|
|
15
|
+
option '--storage', 'STORAGE', 'Storage size (GiB)', default: '30'
|
|
16
|
+
option '--version', 'VERSION', 'Define installed Central version', default: 'latest'
|
|
17
|
+
|
|
18
|
+
def execute
|
|
19
|
+
require_api_url
|
|
20
|
+
require_current_stack
|
|
21
|
+
|
|
22
|
+
require 'central/machine/aws'
|
|
23
|
+
stack = client(require_token).get("stacks/#{current_stack}")
|
|
24
|
+
provisioner = Central::Machine::Aws::NodeProvisioner.new(client(require_token), access_key, secret_key, region)
|
|
25
|
+
provisioner.run!(
|
|
26
|
+
master_uri: api_url,
|
|
27
|
+
stack_token: stack['token'],
|
|
28
|
+
stack: current_stack,
|
|
29
|
+
name: name,
|
|
30
|
+
type: type,
|
|
31
|
+
vpc: vpc_id,
|
|
32
|
+
zone: zone,
|
|
33
|
+
subnet: subnet_id,
|
|
34
|
+
storage: storage,
|
|
35
|
+
version: version,
|
|
36
|
+
key_pair: key_pair
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Aws
|
|
2
|
+
class RestartCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter 'NAME', 'Node name'
|
|
7
|
+
option '--access-key', 'ACCESS_KEY', 'AWS access key ID', environment_variable: 'AWS_ACCESS_KEY_ID', required: true
|
|
8
|
+
option '--secret-key', 'SECRET_KEY', 'AWS secret key', environment_variable: 'AWS_SECRET_ACCESS_KEY', required: true
|
|
9
|
+
option '--region', 'REGION', 'EC2 Region', required: true
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
require_api_url
|
|
13
|
+
require_current_stack
|
|
14
|
+
|
|
15
|
+
require 'central/machine/aws'
|
|
16
|
+
|
|
17
|
+
client = Fog::Compute.new(provider: 'AWS', aws_access_key_id: access_key, aws_secret_access_key: secret_key, region: region)
|
|
18
|
+
instance = client.servers.all('tag:central_name' => name).first
|
|
19
|
+
if instance
|
|
20
|
+
instance.reboot
|
|
21
|
+
ShellSpinner "Restarting AWS instance #{name.colorize(:cyan)} " do
|
|
22
|
+
instance.wait_for { ready? }
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
abort "Cannot find instance #{name.colorize(:cyan)} in AWS"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Aws
|
|
2
|
+
class TerminateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter 'NAME', 'Node name'
|
|
7
|
+
option '--access-key', 'ACCESS_KEY', 'AWS access key ID', environment_variable: 'AWS_ACCESS_KEY_ID', required: true
|
|
8
|
+
option '--secret-key', 'SECRET_KEY', 'AWS secret key', environment_variable: 'AWS_SECRET_ACCESS_KEY', required: true
|
|
9
|
+
option '--region', 'REGION', 'EC2 Region', default: 'us-west-2'
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
require_api_url
|
|
13
|
+
require_current_stack
|
|
14
|
+
|
|
15
|
+
require 'central/machine/aws'
|
|
16
|
+
stack = client(require_token).get("stacks/#{current_stack}")
|
|
17
|
+
destroyer = Central::Machine::Aws::NodeDestroyer.new(client(require_token), access_key, secret_key, region)
|
|
18
|
+
destroyer.run!(stack, name)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_relative 'aws/create_command'
|
|
2
|
+
require_relative 'aws/terminate_command'
|
|
3
|
+
require_relative 'aws/restart_command'
|
|
4
|
+
|
|
5
|
+
module Central::Cli::Nodes
|
|
6
|
+
class AwsCommand < Clamp::Command
|
|
7
|
+
subcommand 'create', 'Create a new AWS node', Aws::CreateCommand
|
|
8
|
+
subcommand 'terminate', 'Terminate AWS node', Aws::TerminateCommand
|
|
9
|
+
subcommand 'restart', 'Restart AWS node', Aws::RestartCommand
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Azure
|
|
2
|
+
class CreateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
option '--subscription-id', 'SUBSCRIPTION ID', 'Azure subscription id', required: true
|
|
7
|
+
option '--subscription-cert', 'CERTIFICATE', 'Path to Azure management certificate', attribute_name: :certificate, required: true
|
|
8
|
+
option '--size', 'SIZE', 'SIZE', default: 'Small'
|
|
9
|
+
option '--network', 'NETWORK', 'Virtual Network name'
|
|
10
|
+
option '--subnet', 'SUBNET', 'Subnet name'
|
|
11
|
+
option '--ssh-key', 'SSH KEY', 'SSH private key file', required: true
|
|
12
|
+
option '--password', 'PASSWORD', 'Password'
|
|
13
|
+
option '--location', 'LOCATION', 'Location', default: 'West Europe'
|
|
14
|
+
option '--version', 'VERSION', 'Define installed Central version', default: 'latest'
|
|
15
|
+
|
|
16
|
+
parameter '[NAME]', 'Node name'
|
|
17
|
+
|
|
18
|
+
def execute
|
|
19
|
+
require_api_url
|
|
20
|
+
require_current_stack
|
|
21
|
+
|
|
22
|
+
require 'central/machine/azure'
|
|
23
|
+
stack = client(require_token).get("stacks/#{current_stack}")
|
|
24
|
+
provisioner = Central::Machine::Azure::NodeProvisioner.new(client(require_token), subscription_id, certificate)
|
|
25
|
+
provisioner.run!(
|
|
26
|
+
master_uri: api_url,
|
|
27
|
+
stack_token: stack['token'],
|
|
28
|
+
stack: current_stack,
|
|
29
|
+
password: password,
|
|
30
|
+
ssh_key: ssh_key,
|
|
31
|
+
name: name,
|
|
32
|
+
size: size,
|
|
33
|
+
virtual_network: network,
|
|
34
|
+
subnet: subnet,
|
|
35
|
+
location: location,
|
|
36
|
+
version: version
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Azure
|
|
2
|
+
class RestartCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter 'NAME', 'Node name'
|
|
7
|
+
option '--subscription-id', 'SUBSCRIPTION ID', 'Azure subscription id', required: true
|
|
8
|
+
option '--subscription-cert', 'CERTIFICATE', 'Path to Azure management certificate', attribute_name: :certificate, required: true
|
|
9
|
+
|
|
10
|
+
def execute
|
|
11
|
+
require_api_url
|
|
12
|
+
require_current_stack
|
|
13
|
+
|
|
14
|
+
require 'central/machine/azure'
|
|
15
|
+
|
|
16
|
+
client = ::Azure
|
|
17
|
+
client.management_certificate = certificate
|
|
18
|
+
client.subscription_id = subscription_id
|
|
19
|
+
|
|
20
|
+
client.vm_management.initialize_external_logger(Central::Machine::Azure::Logger.new) # We don't want all the output
|
|
21
|
+
ShellSpinner "Restarting Azure VM #{name.colorize(:cyan)} " do
|
|
22
|
+
vm = client.vm_management.get_virtual_machine(name, "central-#{current_stack}-#{name}")
|
|
23
|
+
if vm
|
|
24
|
+
client.vm_management.restart_virtual_machine(name, "central-#{current_stack}-#{name}")
|
|
25
|
+
else
|
|
26
|
+
abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Azure
|
|
2
|
+
class TerminateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter 'NAME', 'Node name'
|
|
7
|
+
option '--subscription-id', 'SUBSCRIPTION ID', 'Azure subscription id', required: true
|
|
8
|
+
option '--subscription-cert', 'CERTIFICATE', 'Path to Azure management certificate', attribute_name: :certificate, required: true
|
|
9
|
+
|
|
10
|
+
def execute
|
|
11
|
+
require_api_url
|
|
12
|
+
require_current_stack
|
|
13
|
+
|
|
14
|
+
require 'central/machine/azure'
|
|
15
|
+
|
|
16
|
+
stack = client(require_token).get("stacks/#{current_stack}")
|
|
17
|
+
destroyer = Central::Machine::Azure::NodeDestroyer.new(client(require_token), subscription_id, certificate)
|
|
18
|
+
destroyer.run!(stack, name)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_relative 'azure/create_command'
|
|
2
|
+
require_relative 'azure/restart_command'
|
|
3
|
+
require_relative 'azure/terminate_command'
|
|
4
|
+
|
|
5
|
+
module Central::Cli::Nodes
|
|
6
|
+
class AzureCommand < Clamp::Command
|
|
7
|
+
subcommand 'create', 'Create a new Azure node', Azure::CreateCommand
|
|
8
|
+
subcommand 'restart', 'Restart Azure node', Azure::RestartCommand
|
|
9
|
+
subcommand 'terminate', 'Terminate Azure node', Azure::TerminateCommand
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Central::Cli::Nodes::DigitalOcean
|
|
2
|
+
class CreateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter '[NAME]', 'Node name'
|
|
7
|
+
option '--token', 'TOKEN', 'DigitalOcean API token', required: true
|
|
8
|
+
option '--ssh-key', 'SSH_KEY', 'Path to ssh public key', required: true
|
|
9
|
+
option '--size', 'SIZE', 'Droplet size', default: '1gb'
|
|
10
|
+
option '--region', 'REGION', 'Region', default: 'ams2'
|
|
11
|
+
option '--version', 'VERSION', 'Define installed Central version', default: 'latest'
|
|
12
|
+
|
|
13
|
+
def execute
|
|
14
|
+
require_api_url
|
|
15
|
+
require_current_stack
|
|
16
|
+
|
|
17
|
+
require 'central/machine/digital_ocean'
|
|
18
|
+
stack = client(require_token).get("stacks/#{current_stack}")
|
|
19
|
+
provisioner = Central::Machine::DigitalOcean::NodeProvisioner.new(client(require_token), token)
|
|
20
|
+
provisioner.run!(
|
|
21
|
+
master_uri: api_url,
|
|
22
|
+
stack_token: stack['token'],
|
|
23
|
+
stack: current_stack,
|
|
24
|
+
ssh_key: ssh_key,
|
|
25
|
+
name: name,
|
|
26
|
+
size: size,
|
|
27
|
+
region: region,
|
|
28
|
+
version: version
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Central::Cli::Nodes::DigitalOcean
|
|
2
|
+
class RestartCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter 'NAME', 'Node name'
|
|
7
|
+
option '--token', 'TOKEN', 'DigitalOcean API token', required: true
|
|
8
|
+
|
|
9
|
+
def execute
|
|
10
|
+
require_api_url
|
|
11
|
+
require_current_stack
|
|
12
|
+
|
|
13
|
+
require 'central/machine/digital_ocean'
|
|
14
|
+
|
|
15
|
+
client = DropletKit::Client.new(access_token: token)
|
|
16
|
+
droplet = client.droplets.all.find { |d| d.name == name }
|
|
17
|
+
if droplet
|
|
18
|
+
ShellSpinner "Restarting DigitalOcean droplet #{name.colorize(:cyan)} " do
|
|
19
|
+
client.droplet_actions.reboot(droplet_id: droplet.id)
|
|
20
|
+
sleep 5 until client.droplets.find(id: droplet.id).status == 'active'
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
abort "Cannot find droplet #{name.colorize(:cyan)} in DigitalOcean"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Central::Cli::Nodes::DigitalOcean
|
|
2
|
+
class TerminateCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
include Central::Cli::StackOptions
|
|
5
|
+
|
|
6
|
+
parameter 'NAME', 'Node name'
|
|
7
|
+
option '--token', 'TOKEN', 'DigitalOcean API token', required: true
|
|
8
|
+
|
|
9
|
+
def execute
|
|
10
|
+
require_api_url
|
|
11
|
+
require_current_stack
|
|
12
|
+
|
|
13
|
+
require 'central/machine/digital_ocean'
|
|
14
|
+
stack = client(require_token).get("stacks/#{current_stack}")
|
|
15
|
+
destroyer = Central::Machine::DigitalOcean::NodeDestroyer.new(client(require_token), token)
|
|
16
|
+
destroyer.run!(stack, name)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_relative 'digital_ocean/create_command'
|
|
2
|
+
require_relative 'digital_ocean/restart_command'
|
|
3
|
+
require_relative 'digital_ocean/terminate_command'
|
|
4
|
+
|
|
5
|
+
module Central::Cli::Nodes
|
|
6
|
+
class DigitalOceanCommand < Clamp::Command
|
|
7
|
+
subcommand 'create', 'Create a new DigitalOcean node', DigitalOcean::CreateCommand
|
|
8
|
+
subcommand 'restart', 'Restart DigitalOcean node', DigitalOcean::RestartCommand
|
|
9
|
+
subcommand 'terminate', 'Terminate DigitalOcean node', DigitalOcean::TerminateCommand
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Central::Cli::Nodes
|
|
2
|
+
require_relative 'labels/add_command'
|
|
3
|
+
require_relative 'labels/remove_command'
|
|
4
|
+
|
|
5
|
+
class LabelCommand < Clamp::Command
|
|
6
|
+
subcommand 'add', 'Add label to node', Labels::AddCommand
|
|
7
|
+
subcommand %w(remove rm), 'Remove label from node', Labels::RemoveCommand
|
|
8
|
+
|
|
9
|
+
def execute
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Central::Cli::Nodes::Labels
|
|
2
|
+
class AddCommand < Clamp::Command
|
|
3
|
+
include Central::Cli::Common
|
|
4
|
+
|
|
5
|
+
parameter 'NODE_ID', 'Node id'
|
|
6
|
+
parameter 'LABEL', 'Label'
|
|
7
|
+
|
|
8
|
+
def execute
|
|
9
|
+
require_api_url
|
|
10
|
+
require_current_stack
|
|
11
|
+
token = require_token
|
|
12
|
+
|
|
13
|
+
node = client(token).get("stacks/#{current_stack}/nodes/#{node_id}")
|
|
14
|
+
data = {}
|
|
15
|
+
data[:labels] = node['labels'].to_a | [label]
|
|
16
|
+
client.put("nodes/#{node['id']}", data, {}, 'Central-Stack-Token' => node['stack']['token'])
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|