forked from concord-consortium/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud.thor
88 lines (75 loc) · 2.42 KB
/
cloud.thor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require './script/setup.rb'
require './script/aws-lab-server'
class Cloud < Thor
desc "list", "list existing servers"
def list
aws = AwsLabServer.new
aws.list
end
desc "list_targets", "list existing deploy targets"
def list_targets
targets = CONFIG[:deploy][:targets]
format_string = " %-24s%-30s%-30s"
puts
puts " Deploy Targets"
puts sprintf(format_string, *targets[0].keys)
puts "-" * 90
targets.each do |target|
puts sprintf(format_string, *target.values)
end
puts
end
desc "setup", "setup capistrano deploy tasks and littlechef nodes using targets in config/config.yml"
def setup
aws = AwsLabServer.new
aws.setup_capistrano_deploy_scripts
aws.setup_littlechef_nodes
aws.setup_ssh
end
desc "create hostname", "create a new server instance using this hostname"
def create(hostname)
aws = AwsLabServer.new
aws.create(hostname)
end
desc "recreate hostname", "recreate a new server instance for this hostname by destroying and rebuilding an existing server"
def recreate(hostname)
aws = AwsLabServer.new
aws.recreate(hostname)
end
desc "delete hostname", "delete an existing server instance running at this hostname"
def delete(hostname)
aws = AwsLabServer.new
aws.delete(hostname)
end
desc "stop reference", "stop a running existing server instance at this hostname or ec2-id"
def stop(reference)
aws = AwsLabServer.new
aws.stop(reference)
end
desc "start ec2_id", "start a stopped existing server instance using the ec2-id"
def start(ec2_id)
aws = AwsLabServer.new
aws.start(ec2_id)
end
desc "update reference", "update server <ec2_id|hostname> provisioning with littlechef 'lab-server' role"
def update(reference)
aws = AwsLabServer.new
aws.update(reference)
end
desc "find_dns_record hostname", "find dns record for hostname"
def find_dns_record(hostname)
aws = AwsLabServer.new
record = aws.find_dns_record(hostname)
puts "\n*** Record: #{record.inspect}"
end
desc "update_dns_record hostname ipaddress", "updating IP address for DNS record hostname to ipaddress"
def update_dns_record(hostname, ipaddress)
aws = AwsLabServer.new
record = aws.update_dns_record(hostname, ipaddress)
end
desc "setup_ssh hostname", "setup ssh configuration for communication to hostname"
def setup_ssh(hostname)
aws = AwsLabServer.new
aws.setup_ssh(hostname)
end
end