zaws 0.0.1
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.
- data/.gitignore +35 -0
- data/.travis.yml +20 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +78 -0
- data/LICENSE +204 -0
- data/README.md +17 -0
- data/Rakefile +26 -0
- data/bin/zaws +20 -0
- data/feature/compute/assoc_security_group.feature +55 -0
- data/feature/compute/compute.feature +138 -0
- data/feature/compute/secondary_ip.feature +107 -0
- data/feature/compute/view.feature +23 -0
- data/feature/compute/view_images.feature +24 -0
- data/feature/elasticip/elasticip.feature +138 -0
- data/feature/elasticip/view.feature +18 -0
- data/feature/hosted_zone/view.feature +17 -0
- data/feature/hosted_zone/view_record.feature +29 -0
- data/feature/load_balancer/instance_registration.feature +120 -0
- data/feature/load_balancer/listener.feature +86 -0
- data/feature/load_balancer/load_balancer.feature +101 -0
- data/feature/load_balancer/view.feature +18 -0
- data/feature/route_table/assoc_subnet.feature +128 -0
- data/feature/route_table/route_propagation.feature +93 -0
- data/feature/route_table/route_table.feature +91 -0
- data/feature/route_table/route_to_gateway.feature +69 -0
- data/feature/route_table/route_to_instance.feature +115 -0
- data/feature/route_table/view.feature +25 -0
- data/feature/security_group/ingress.feature +184 -0
- data/feature/security_group/security_group.feature +107 -0
- data/feature/security_group/view.feature +23 -0
- data/feature/subnet/subnet.feature +92 -0
- data/feature/subnet/view.feature +24 -0
- data/feature/support/env.rb +14 -0
- data/feature/version.feature +6 -0
- data/lib/zaws/aws.rb +26 -0
- data/lib/zaws/command/compute.rb +100 -0
- data/lib/zaws/command/elasticip.rb +47 -0
- data/lib/zaws/command/hosted_zone.rb +26 -0
- data/lib/zaws/command/load_balancer.rb +113 -0
- data/lib/zaws/command/route_table.rb +134 -0
- data/lib/zaws/command/security_group.rb +69 -0
- data/lib/zaws/command/subnet.rb +65 -0
- data/lib/zaws/ec2/compute.rb +247 -0
- data/lib/zaws/ec2/elasticip.rb +85 -0
- data/lib/zaws/ec2/route_table.rb +202 -0
- data/lib/zaws/ec2/security_group.rb +116 -0
- data/lib/zaws/ec2/subnet.rb +108 -0
- data/lib/zaws/ec2.rb +40 -0
- data/lib/zaws/elb/load_balancer.rb +157 -0
- data/lib/zaws/elb.rb +20 -0
- data/lib/zaws/helper/file.rb +23 -0
- data/lib/zaws/helper/option.rb +24 -0
- data/lib/zaws/helper/output.rb +46 -0
- data/lib/zaws/helper/shell.rb +25 -0
- data/lib/zaws/route53/hosted_zone.rb +36 -0
- data/lib/zaws/route53.rb +20 -0
- data/lib/zaws/version.rb +3 -0
- data/lib/zaws.rb +57 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/zaws/ec2/compute/add_volume_spec.rb +39 -0
- data/spec/zaws/ec2/compute/block_device_mapping_spec.rb +31 -0
- data/spec/zaws/ec2/compute/instance_id_by_external_id_spec.rb +23 -0
- data/spec/zaws/ec2/compute/instance_ping_spec.rb +34 -0
- data/spec/zaws/ec2/compute/instance_running_spec.rb +47 -0
- data/spec/zaws/ec2/compute/network_interface_json_spec.rb +57 -0
- data/spec/zaws/ec2/compute/nosdcheck_spec.rb +17 -0
- data/spec/zaws/ec2/compute/tag_instance_spec.rb +21 -0
- data/spec/zaws/ec2/security_group/id_by_name_spec.rb +32 -0
- data/spec/zaws/ec2/subnet/available_spec.rb +22 -0
- data/spec/zaws/ec2/subnet/declare_spec.rb +31 -0
- data/spec/zaws/ec2/subnet/exists_spec.rb +33 -0
- data/spec/zaws/ec2/subnet/id_array_by_cidrblock_array_spec.rb +48 -0
- data/spec/zaws/ec2/subnet/id_by_cidrblock_spec.rb +35 -0
- data/spec/zaws/ec2/subnet/id_by_ip_spec.rb +42 -0
- data/spec/zaws/ec2/subnet/view_spec.rb +34 -0
- data/spec/zaws/elb/load_balancer/calculated_listener_spec.rb +18 -0
- data/spec/zaws/helper/option/absent_spec.rb +14 -0
- data/spec/zaws/helper/option/exclusive_spec.rb +14 -0
- data/spec/zaws/helper/option/exists_spec.rb +18 -0
- data/spec/zaws/helper/option/minimum_spec.rb +14 -0
- data/spec/zaws/helper/output/binary_nagios_check_spec.rb +19 -0
- data/spec/zaws/helper/output/colorize_spec.rb +30 -0
- data/spec/zaws/helper/output/opt_exclusive_spec.rb +14 -0
- data/spec/zaws/helper/output/opt_minimum_spec.rb +15 -0
- data/spec/zaws/helper/output/opt_required_spec.rb +12 -0
- data/spec/zaws/helper/shell/cli_spec.rb +33 -0
- data/spec/zaws/helper/shell/if_then_spec.rb +24 -0
- data/zaws.gemspec +34 -0
- metadata +350 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Elasticip < Thor
|
6
|
+
class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
|
7
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
8
|
+
|
9
|
+
desc "view","View elastic ips."
|
10
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
11
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
12
|
+
def view
|
13
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
14
|
+
aws.ec2.elasticip.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "assoc_exists EXTERNAL_ID","Determine by an instance's EXTERNAL_ID if it has an elastic."
|
18
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
19
|
+
def assoc_exists(externalid)
|
20
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
21
|
+
val,instanceid,assoc,alloc,ip=aws.ec2.elasticip.assoc_exists(options[:region],externalid,$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
|
22
|
+
return val
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "declare EXTERNAL_ID","Declare an instance by its instance's EXTERNAL_ID should have an elastic ip."
|
26
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
27
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
28
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
29
|
+
def declare(externalid)
|
30
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
31
|
+
val=aws.ec2.elasticip.declare(options[:region],externalid,$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],options[:nagios],options[:undofile])
|
32
|
+
return val
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "release EXTERNAL_ID","Release an elastic ip address a specific instance. The instance's EXTERNAL_ID is required."
|
36
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
37
|
+
def release(externalid)
|
38
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
39
|
+
val=aws.ec2.elasticip.release(options[:region],externalid,$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
|
40
|
+
return val
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Hosted_Zone < Thor
|
6
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
7
|
+
|
8
|
+
desc "view","View hosted zones."
|
9
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
10
|
+
def view
|
11
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
12
|
+
aws.route53.hosted_zone.view(options[:viewtype],$stdout,(options[:verbose]?$stdout:nil))
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "view_records ZONE_NAME","View record sets for hosted ZONE_NAME."
|
16
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
17
|
+
def view_records(zonename)
|
18
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
19
|
+
aws.route53.hosted_zone.view_records(options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),zonename)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Load_Balancer < Thor
|
6
|
+
class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
|
7
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
8
|
+
|
9
|
+
desc "view","View load balancers."
|
10
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
11
|
+
def view
|
12
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
13
|
+
aws.elb.load_balancer.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil))
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "exists LOAD_BALANCER_NAME","Determine if a load balancer exists by its LOAD_BALANCER_NAME"
|
17
|
+
def exists(lbname)
|
18
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
19
|
+
val,instances=aws.elb.load_balancer.exists(options[:region],lbname,$stdout,(options[:verbose]?$stdout:nil))
|
20
|
+
return val
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "create_in_subnets","Create a new load balancer in the subnets specified by the option --cidrblocks."
|
24
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
25
|
+
option :cidrblocks,:type => :array, :desc => "subnet cidr blocks to attach to load balancer, one per avaialability zone.", :banner => "<cidrblocks>", :aliases => :u
|
26
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
27
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
28
|
+
def create_in_subnet(lbname,lbprotocol,lbport,inprotocol,inport,securitygroup)
|
29
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
30
|
+
exitcode = aws.elb.load_balancer.create_in_subnet(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,securitygroup,options[:cidrblocks],options[:vpcid],options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
|
31
|
+
exit exitcode
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "delete LOAD_BALANCER_NAME","Delete load balancer identified by LOAD_BALANCER_NAME if it exists."
|
35
|
+
def delete(lbname)
|
36
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
37
|
+
aws.elb.load_balancer.delete(options[:region],lbname,$stdout,(options[:verbose]?$stdout:nil))
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "exists_instance LOAD_BALANCER_NAME INSTANCE_EXTERNAL_ID","Determine if an instance identified by the INSTANCE_EXTERNAL_ID is registered with load balancer identified by LOAD_BALANCER_NAME."
|
41
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
42
|
+
def exists_instance(lbname,instance_external_id)
|
43
|
+
$stdout.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
|
44
|
+
$stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
|
45
|
+
$stdout.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
|
46
|
+
$stdout.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
|
47
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
48
|
+
aws.elb.load_balancer.exists_instance(options[:region],lbname,instance_external_id,options[:vpcid],$stdout,(options[:verbose]?$stdout:nil))
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "register_instance LOAD_BALANCER_NAME INSTANCE_EXTERNAL_ID","Register an instance identified by the INSTANCE_EXTERNAL_ID is registered with load balancer identified by LOAD_BALANCER_NAME."
|
52
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
53
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
54
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
55
|
+
def register_instance(lbname,instance_external_id)
|
56
|
+
$stdout.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
|
57
|
+
$stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
|
58
|
+
$stdout.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
|
59
|
+
$stdout.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
|
60
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
61
|
+
aws.elb.load_balancer.register_instance(options[:region],lbname,instance_external_id,options[:vpcid],options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "deregister_instance LOAD_BALANCER_NAME INSTANCE_EXTERNAL_ID","Deregister an instance identified by the INSTANCE_EXTERNAL_ID is registered with load balancer identified by LOAD_BALANCER_NAME."
|
65
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
66
|
+
def deregister_instance(lbname,instance_external_id)
|
67
|
+
$stdout.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
|
68
|
+
$stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
|
69
|
+
$stdout.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
|
70
|
+
$stdout.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
|
71
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
72
|
+
aws.elb.load_balancer.deregister_instance(options[:region],lbname,instance_external_id,options[:vpcid],$stdout,(options[:verbose]?$stdout:nil))
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "exists_listener LOAD_BALANCER_NAME LBPROTOCOL LBPORT INPROTOCOL INPORT","Determine if a listener is registered with load balancer."
|
76
|
+
def exists_listener(lbname,lbprotocol,lbport,inprotocol,inport)
|
77
|
+
$stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
|
78
|
+
$stdout.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
|
79
|
+
$stdout.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
|
80
|
+
$stdout.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
|
81
|
+
$stdout.puts "DEBUG: inport=#{inport}" if options[:verbose]
|
82
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
83
|
+
aws.elb.load_balancer.exists_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,$stdout,(options[:verbose]?$stdout:nil))
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "declare_listener LOAD_BALANCER_NAME LBPROTOCOL LBPORT INPROTOCOL INPORT","Create a new listener."
|
87
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
88
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
89
|
+
def declare_listener(lbname,lbprotocol,lbport,inprotocol,inport)
|
90
|
+
$stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
|
91
|
+
$stdout.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
|
92
|
+
$stdout.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
|
93
|
+
$stdout.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
|
94
|
+
$stdout.puts "DEBUG: inport=#{inport}" if options[:verbose]
|
95
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
96
|
+
aws.elb.load_balancer.declare_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "delete_listener LOAD_BALANCER_NAME LBPROTOCOL LBPORT INPROTOCOL INPORT","Delete listener."
|
100
|
+
def delete_listener(lbname,lbprotocol,lbport,inprotocol,inport)
|
101
|
+
$stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
|
102
|
+
$stdout.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
|
103
|
+
$stdout.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
|
104
|
+
$stdout.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
|
105
|
+
$stdout.puts "DEBUG: inport=#{inport}" if options[:verbose]
|
106
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
107
|
+
aws.elb.load_balancer.delete_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,$stdout,(options[:verbose]?$stdout:nil))
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Route_Table < Thor
|
6
|
+
class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
|
7
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
8
|
+
|
9
|
+
desc "view","View route tables."
|
10
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
11
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
12
|
+
def view
|
13
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
14
|
+
aws.ec2.route_table.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "exists_by_external_id EXTERNAL_ID","Determine if a route table exists by EXTERNAL_ID."
|
18
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
19
|
+
def exists_by_external_id(externalid)
|
20
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
21
|
+
aws.ec2.route_table.exists(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],externalid)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "declare EXTERNAL_ID","Declare a new route table by EXTERNAL_ID, but skip creating it if it exists."
|
25
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
26
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
27
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
28
|
+
def declare(externalid)
|
29
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
30
|
+
exitcode = aws.ec2.route_table.declare(options[:region],options[:vpcid],externalid,options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
|
31
|
+
exit exitcode
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "delete EXTERNAL_ID","Delete route table by its EXTERNAL_ID."
|
35
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
36
|
+
def delete(externalid)
|
37
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
38
|
+
aws.ec2.route_table.delete(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],externalid)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "route_exists_by_instance ROUTE_TABLE CIDR_BLOCK INSTANCE_EXTERNAL_ID","Determine if a route exists for CIDR_BLOCK in ROUTE_TABLE to an instance INSTANCE_EXTERNAL_ID."
|
42
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
43
|
+
def route_exists_by_instance(routetable,cidrblock,externalid)
|
44
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
45
|
+
aws.ec2.route_table.route_exists_by_instance(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,externalid)
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "declare_route ROUTE_TABLE CIDR_BLOCK INSTANCE_EXTERNAL_ID","Declare a new route to instance INSTANCE_EXTERNAL_ID for CIDR_BLOCK in ROUTE_TABLE, but skip creating it if it exists."
|
49
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
50
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
51
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
52
|
+
def declare_route(routetable,cidrblock,externalid)
|
53
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
54
|
+
exitcode = aws.ec2.route_table.declare_route(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,externalid,options[:nagios],options[:undofile])
|
55
|
+
exit exitcode
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "delete_route ROUTE_TABLE CIDR_BLOCK","Delete a route to CIDR_BLOCK in ROUTE_TABLE, but skip deletion if it doesn't exist."
|
59
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
60
|
+
def delete_route(routetable,cidrblock)
|
61
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
62
|
+
aws.ec2.route_table.delete_route(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock)
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "route_exists_by_gatewayid ROUTE_TABLE CIDR_BLOCK GATEWAY_ID","Determine if a route exists for CIDR_BLOCK in ROUTE_TABLE to GATEWAY_ID."
|
66
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
67
|
+
def route_exists_by_gatewayid(routetable,cidrblock,gatewayid)
|
68
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
69
|
+
aws.ec2.route_table.route_exists_by_gatewayid(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,gatewayid)
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "declare_route ROUTE_TABLE CIDR_BLOCK GATEWAY_ID","Declare a new route to GATEWAY_ID, but skip creating it if it exists."
|
73
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
74
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
75
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
76
|
+
def declare_route_to_gateway(routetable,cidrblock,gatewayid)
|
77
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
78
|
+
exitcode = aws.ec2.route_table.declare_route_to_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,gatewayid,options[:nagios],options[:undofile])
|
79
|
+
exit exitcode
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "subnet_assoc_exists ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK","Determine if a route table is associated to a subnet."
|
83
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
84
|
+
def subnet_assoc_exists(rtable_externalid,cidrblock)
|
85
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
86
|
+
aws.ec2.route_table.subnet_assoc_exists(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,cidrblock)
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "assoc_subnet ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK","Associate a route table to a subnet."
|
90
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
91
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
92
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
93
|
+
def assoc_subnet(rtable_externalid,cidrblock)
|
94
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
95
|
+
exitcode = aws.ec2.route_table.assoc_subnet(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,cidrblock,options[:nagios],options[:undofile])
|
96
|
+
exit exitcode
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "delete_assoc_subnet ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK","Delete association of route table to subnet."
|
100
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
101
|
+
def delete_assoc_subnet(rtable_externalid,cidrblock)
|
102
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
103
|
+
aws.ec2.route_table.delete_assoc_subnet(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,cidrblock)
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "propagation_exists_from_gateway ROUTE_TABLE_EXTERNAL_ID VIRTUAL_GATEWAY_ID","Determine if route propagation from a gateway exists."
|
107
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
108
|
+
def propagation_exists_from_gateway(rtable_externalid,vgatewayid)
|
109
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
110
|
+
aws.ec2.route_table.propagation_exists_from_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,vgatewayid)
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "declare_propagation_from_gateway ROUTE_TABLE_EXTERNAL_ID VIRTUAL_GATEWAY_ID","Propagate routes to the routing tables from a virtual gateway."
|
114
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
115
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
116
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
117
|
+
def declare_propagation_from_gateway(rtable_externalid,vgatewayid)
|
118
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
119
|
+
exitcode = aws.ec2.route_table.declare_propagation_from_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,vgatewayid,options[:nagios],options[:undofile])
|
120
|
+
exit exitcode
|
121
|
+
end
|
122
|
+
|
123
|
+
desc "delete_propagation_from_gateway ROUTE_TABLE_EXTERNAL_ID GATEWAY_ID","Delete route propagation from virtual gateway."
|
124
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
125
|
+
def delete_propagation_from_gateway(rtable_externalid,vgatewayid)
|
126
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
127
|
+
aws.ec2.route_table.delete_propagation_from_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,vgatewayid)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Security_Group < Thor
|
6
|
+
class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
|
7
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
8
|
+
|
9
|
+
desc "view","View security groups."
|
10
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
11
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
12
|
+
def view
|
13
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
14
|
+
aws.ec2.security_group.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "exists_by_name GROUP_NAME","Determine if a security group exists by name GROUP_NAME."
|
18
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
19
|
+
def exists_by_name(group_name)
|
20
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
21
|
+
aws.ec2.security_group.exists(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],group_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "declare GROUP_NAME DESCRIPTION","Declare a new security group GROUP_NAME, but skip creating it if it exists."
|
25
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
26
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
27
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
28
|
+
def declare(group_name,description)
|
29
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
30
|
+
exitcode = aws.ec2.security_group.declare(options[:region],options[:vpcid],group_name,description,options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
|
31
|
+
exit exitcode
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "delete GROUP_NAME","Delete a new security group GROUP_NAME, but skip it if it does not exist."
|
35
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
36
|
+
def delete(group_name)
|
37
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
38
|
+
aws.ec2.security_group.delete(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],group_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "ingress_group_exists TARGET_GROUP_NAME SOURCE_GROUP_NAME PROTOCOL PORT","Determine if an ingress security group rule exists."
|
42
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
43
|
+
def ingress_group_exists(target,source,protocol,port)
|
44
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
45
|
+
aws.ec2.security_group.ingress_group_exists(options[:region],options[:vpcid],target,source,protocol,port,$stdout,(options[:verbose]?$stdout:nil))
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "declare_ingress_group TARGET_GROUP_NAME SOURCE_GROUP_NAME PROTOCOL PORT","Declare an ingress security group rule."
|
49
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
50
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
51
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
52
|
+
def declare_ingress_group(target,source,protocol,port)
|
53
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
54
|
+
exitcode = aws.ec2.security_group.declare_ingress_group(options[:region],options[:vpcid],target,source,protocol,port,options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
|
55
|
+
exit exitcode
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "delete_ingress_group TARGET_GROUP_NAME SOURCE_GROUP_NAME PROTOCOL PORT","Delete an ingress security group rule."
|
59
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
60
|
+
def delete_ingress_group(target,source,protocol,port)
|
61
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
62
|
+
aws.ec2.security_group.delete_ingress_group(options[:region],options[:vpcid],target,source,protocol,port,$stdout,(options[:verbose]?$stdout:nil))
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Subnet < Thor
|
6
|
+
class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
|
7
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
8
|
+
|
9
|
+
desc "view","View subnets."
|
10
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
11
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
12
|
+
def view
|
13
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
14
|
+
aws.ec2.subnet.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "id_subnet_by_ip","get subnet id by specifying ip address in subnet"
|
18
|
+
option :privateip, :type => :string, :desc => "ip addresses", :banner => "<privateip>", :aliases => :p, :required => true
|
19
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :required => true
|
20
|
+
def id_by_ip
|
21
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
22
|
+
aws.ec2.subnet.id_by_ip(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],options[:privateip])
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "id_subnet_by_cidrblock","get subnet id by specifying cidrblock for subnet"
|
26
|
+
option :cidrblock, :type => :string, :desc => "cidrblock", :banner => "<cidrblock>", :aliases => :c, :required => true
|
27
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :required => true
|
28
|
+
def id_by_cidrblock
|
29
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
30
|
+
aws.ec2.subnet.id_by_cidrblock(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],options[:cidrblock])
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "exists","determine if a subnet exists."
|
34
|
+
option :cidrblock, :type => :string, :desc => "cidrblock", :banner => "<cidrblock>", :aliases => :c, :required => true
|
35
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :required => true
|
36
|
+
def exists
|
37
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
38
|
+
aws.ec2.subnet.exists(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],options[:cidrblock])
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "declare","create a subnet if it does not exist already"
|
42
|
+
option :cidrblock, :type => :string, :desc => "cidrblock", :banner => "<cidrblock>", :aliases => :c, :required => true
|
43
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :required => true
|
44
|
+
option :availabilityzone, :type => :string, :desc => "AWS availability zone (eg us-west-1,us-west-2,...)", :banner => "<azone>", :aliases => :a, :required => true
|
45
|
+
option :availabilitytimeout, :type => :numeric, :desc => "AWS availability zone (eg us-west-1,us-west-2,...)", :banner => "<azone>", :aliases => :t, :default => 30
|
46
|
+
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
47
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
48
|
+
def declare
|
49
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
50
|
+
exitcode=aws.ec2.subnet.declare(options[:region],options[:vpcid],options[:cidrblock],options[:availabilityzone],options[:availabilitytimeout],$stdout,(options[:verbose]?$stdout:nil),options[:nagios],options[:undofile])
|
51
|
+
exit exitcode
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "delete","delete a subnet if it exists already"
|
55
|
+
option :cidrblock, :type => :string, :desc => "cidrblock", :banner => "<cidrblock>", :aliases => :c, :required => true
|
56
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :required => true
|
57
|
+
def delete
|
58
|
+
aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
|
59
|
+
aws.ec2.subnet.delete(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],options[:cidrblock])
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|