zaws 0.0.5 → 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +9 -18
- data/Gemfile +0 -0
- data/Gemfile.lock +26 -35
- data/Gemfile.lock.linux +69 -0
- data/Gemfile.lock.mac +81 -0
- data/Gemfile.lock.windows +77 -0
- data/LICENSE +0 -0
- data/README.md +11 -0
- data/Rakefile +1 -7
- data/archive/cloud_trail/cloud_trail.feature +124 -0
- data/bin/win_zaws.bat +2 -0
- data/lib/zaws.rb +54 -41
- data/lib/zaws/command/ai.rb +34 -0
- data/lib/zaws/command/bucket.rb +35 -0
- data/lib/zaws/command/cloud_trail.rb +43 -0
- data/lib/zaws/command/compute.rb +152 -87
- data/lib/zaws/command/config.rb +42 -0
- data/lib/zaws/command/elasticip.rb +19 -9
- data/lib/zaws/command/hosted_zone.rb +31 -18
- data/lib/zaws/command/iam.rb +37 -0
- data/lib/zaws/command/load_balancer.rb +54 -51
- data/lib/zaws/command/nessus.rb +41 -0
- data/lib/zaws/command/newrelic.rb +30 -0
- data/lib/zaws/command/route_table.rb +135 -122
- data/lib/zaws/command/security_group.rb +95 -82
- data/lib/zaws/command/subnet.rb +58 -46
- data/lib/zaws/command/sumo.rb +34 -0
- data/lib/zaws/command/vpc.rb +53 -0
- data/lib/zaws/external/awscli/awscli.rb +65 -0
- data/lib/zaws/external/awscli/commands.rb +10 -0
- data/lib/zaws/external/awscli/commands/aws.rb +40 -0
- data/lib/zaws/external/awscli/commands/ec2.rb +74 -0
- data/lib/zaws/external/awscli/commands/ec2/allocate_address.rb +42 -0
- data/lib/zaws/external/awscli/commands/ec2/assign_private_ip_addresses.rb +49 -0
- data/lib/zaws/external/awscli/commands/ec2/associate_address.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/associate_route_table.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/authorize_security_group_ingress.rb +70 -0
- data/lib/zaws/external/awscli/commands/ec2/create_route.rb +60 -0
- data/lib/zaws/external/awscli/commands/ec2/create_route_table.rb +40 -0
- data/lib/zaws/external/awscli/commands/ec2/create_security_group.rb +58 -0
- data/lib/zaws/external/awscli/commands/ec2/create_subnet.rb +62 -0
- data/lib/zaws/external/awscli/commands/ec2/create_tags.rb +53 -0
- data/lib/zaws/external/awscli/commands/ec2/create_vpc.rb +21 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_route.rb +54 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_route_table.rb +46 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_security_group.rb +46 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_subnet.rb +46 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_addresses.rb +41 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_images.rb +58 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_instances.rb +56 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_route_tables.rb +44 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_security_groups.rb +50 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_subnets.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_vpc_peering_connections.rb +23 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_vpcs.rb +26 -0
- data/lib/zaws/external/awscli/commands/ec2/disable_vgw_route_propagation.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/disassociate-address.rb +42 -0
- data/lib/zaws/external/awscli/commands/ec2/disassociate_route_table.rb +41 -0
- data/lib/zaws/external/awscli/commands/ec2/enable_vgw_route_propagation.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/filter.rb +115 -0
- data/lib/zaws/external/awscli/commands/ec2/modify_instance_attribute.rb +62 -0
- data/lib/zaws/external/awscli/commands/ec2/network_interfaces.rb +63 -0
- data/lib/zaws/external/awscli/commands/ec2/release_address.rb +42 -0
- data/lib/zaws/external/awscli/commands/ec2/revoke_security_group_ingress.rb +70 -0
- data/lib/zaws/external/awscli/commands/ec2/run_instances.rb +21 -0
- data/lib/zaws/external/awscli/commands/ec2/stop_instances.rb +21 -0
- data/lib/zaws/external/awscli/commands/ec2/terminate_instances.rb +40 -0
- data/lib/zaws/external/awscli/commands/ec2/unassign_private_ip_addresses.rb +49 -0
- data/lib/zaws/external/awscli/commands/elb.rb +19 -0
- data/lib/zaws/external/awscli/commands/elb/create_load_balancer.rb +64 -0
- data/lib/zaws/external/awscli/commands/elb/create_load_balancer_listeners.rb +47 -0
- data/lib/zaws/external/awscli/commands/elb/delete_load_balancer.rb +40 -0
- data/lib/zaws/external/awscli/commands/elb/delete_load_balancer_listeners.rb +49 -0
- data/lib/zaws/external/awscli/commands/elb/deregister_instances_with_load_balancer.rb +49 -0
- data/lib/zaws/external/awscli/commands/elb/describe_load_balancers.rb +30 -0
- data/lib/zaws/external/awscli/commands/elb/register_instances_with_load_balancer.rb +49 -0
- data/lib/zaws/external/awscli/commands/iam.rb +31 -0
- data/lib/zaws/external/awscli/commands/iam/GetPolicy.rb +21 -0
- data/lib/zaws/external/awscli/commands/iam/GetPolicyVersion.rb +21 -0
- data/lib/zaws/external/awscli/commands/iam/GetRolePolicy.rb +21 -0
- data/lib/zaws/external/awscli/commands/route53.rb +19 -0
- data/lib/zaws/external/awscli/commands/route53/list_hosted_zones.rb +30 -0
- data/lib/zaws/external/awscli/commands/route53/list_resource_record_sets.rb +41 -0
- data/lib/zaws/external/awscli/commands/s3/ls.rb +34 -0
- data/lib/zaws/external/awscli/commands/s3/mb.rb +41 -0
- data/lib/zaws/external/awscli/commands/s3/sync.rb +48 -0
- data/lib/zaws/external/awscli/credentials.rb +22 -0
- data/lib/zaws/external/awscli/data.rb +10 -0
- data/lib/zaws/external/awscli/data/ec2.rb +33 -0
- data/lib/zaws/external/awscli/data/ec2/instance.rb +162 -0
- data/lib/zaws/external/awscli/data/ec2/security_group.rb +51 -0
- data/lib/zaws/external/awscli/data/ec2/subnet.rb +59 -0
- data/lib/zaws/external/awscli/data/ec2/vpc.rb +85 -0
- data/lib/zaws/external/awscli/data/iam.rb +34 -0
- data/lib/zaws/external/awscli/data/iam/policy.rb +42 -0
- data/lib/zaws/external/awscli/data/iam/policy_document.rb +52 -0
- data/lib/zaws/external/awscli/data/iam/policy_version.rb +42 -0
- data/lib/zaws/external/awscli/data/iam/role_policy.rb +52 -0
- data/lib/zaws/external/awscli/generators/result/ec2/addresses.rb +70 -0
- data/lib/zaws/external/awscli/generators/result/ec2/allocation_id.rb +39 -0
- data/lib/zaws/external/awscli/generators/result/ec2/association_id.rb +29 -0
- data/lib/zaws/external/awscli/generators/result/ec2/images.rb +46 -0
- data/lib/zaws/external/awscli/generators/result/ec2/instances.rb +57 -0
- data/lib/zaws/external/awscli/generators/result/ec2/ip_permissions.rb +70 -0
- data/lib/zaws/external/awscli/generators/result/ec2/network_interfaces.rb +53 -0
- data/lib/zaws/external/awscli/generators/result/ec2/private_ip_addresses.rb +41 -0
- data/lib/zaws/external/awscli/generators/result/ec2/route_tables.rb +80 -0
- data/lib/zaws/external/awscli/generators/result/ec2/routes.rb +58 -0
- data/lib/zaws/external/awscli/generators/result/ec2/security_groups.rb +73 -0
- data/lib/zaws/external/awscli/generators/result/ec2/subnets.rb +88 -0
- data/lib/zaws/external/awscli/generators/result/ec2/tags.rb +34 -0
- data/lib/zaws/external/awscli/generators/result/ec2/virtual_gateway.rb +32 -0
- data/lib/zaws/external/awscli/generators/result/elb/listeners.rb +65 -0
- data/lib/zaws/external/awscli/generators/result/elb/load_balancers.rb +61 -0
- data/lib/zaws/external/awscli/generators/result/route53/hosted_zones.rb +52 -0
- data/lib/zaws/external/awscli/regions.rb +13 -0
- data/lib/zaws/external/nessusapi/data/agents.rb +36 -0
- data/lib/zaws/external/nessusapi/data/scanners.rb +35 -0
- data/lib/zaws/external/nessusapi/nessusapi.rb +57 -0
- data/lib/zaws/external/nessusapi/reources.rb +10 -0
- data/lib/zaws/external/nessusapi/resources/agents.rb +18 -0
- data/lib/zaws/external/nessusapi/resources/agents/list.rb +20 -0
- data/lib/zaws/external/nessusapi/resources/scanners.rb +18 -0
- data/lib/zaws/external/nessusapi/resources/scanners/list.rb +20 -0
- data/lib/zaws/external/newrelicapi/data/servers.rb +36 -0
- data/lib/zaws/external/newrelicapi/newrelic_client.rb +64 -0
- data/lib/zaws/external/newrelicapi/newrelic_creds.rb +60 -0
- data/lib/zaws/external/newrelicapi/newrelicapi.rb +46 -0
- data/lib/zaws/external/newrelicapi/resources/servers.rb +18 -0
- data/lib/zaws/external/newrelicapi/resources/servers/list.rb +20 -0
- data/lib/zaws/external/sumoapi/data/collectors.rb +35 -0
- data/lib/zaws/external/sumoapi/data/sources.rb +35 -0
- data/lib/zaws/external/sumoapi/resources/collectors.rb +18 -0
- data/lib/zaws/external/sumoapi/resources/collectors/list.rb +20 -0
- data/lib/zaws/external/sumoapi/resources/sources.rb +18 -0
- data/lib/zaws/external/sumoapi/resources/sources/list.rb +20 -0
- data/lib/zaws/external/sumoapi/sumo_client.rb +63 -0
- data/lib/zaws/external/sumoapi/sumo_creds.rb +67 -0
- data/lib/zaws/external/sumoapi/sumoapi.rb +56 -0
- data/lib/zaws/helper/data_lattice.rb +22 -0
- data/lib/zaws/helper/filestore.rb +48 -0
- data/lib/zaws/helper/filter.rb +15 -0
- data/lib/zaws/helper/inifile.rb +632 -0
- data/lib/zaws/helper/nessus_client.rb +143 -0
- data/lib/zaws/helper/nessus_creds.rb +67 -0
- data/lib/zaws/helper/option.rb +14 -15
- data/lib/zaws/helper/output.rb +81 -29
- data/lib/zaws/helper/process_hash.rb +47 -0
- data/lib/zaws/helper/shell.rb +0 -0
- data/lib/zaws/helper/verbose.rb +15 -0
- data/lib/zaws/helper/zfile.rb +8 -8
- data/lib/zaws/services/ai.rb +35 -0
- data/lib/zaws/services/ai/query.rb +135 -0
- data/lib/zaws/services/aws.rb +41 -0
- data/lib/zaws/services/chef.rb +0 -0
- data/lib/zaws/services/cloud_trail.rb +76 -0
- data/lib/zaws/services/config.rb +31 -0
- data/lib/zaws/services/ec2.rb +47 -0
- data/lib/zaws/services/ec2/compute.rb +352 -0
- data/lib/zaws/services/ec2/elasticip.rb +82 -0
- data/lib/zaws/services/ec2/route_table.rb +210 -0
- data/lib/zaws/services/ec2/security_group.rb +186 -0
- data/lib/zaws/services/ec2/subnet.rb +111 -0
- data/lib/zaws/services/ec2/vpc.rb +69 -0
- data/lib/zaws/{elb.rb → services/elb.rb} +3 -2
- data/lib/zaws/services/elb/load_balancer.rb +160 -0
- data/lib/zaws/services/iam.rb +25 -0
- data/lib/zaws/services/iam/policy.rb +25 -0
- data/lib/zaws/services/iam/role.rb +23 -0
- data/lib/zaws/services/nessus.rb +24 -0
- data/lib/zaws/services/nessus/agents.rb +19 -0
- data/lib/zaws/services/nessus/scanners.rb +19 -0
- data/lib/zaws/services/newrelic.rb +21 -0
- data/lib/zaws/services/newrelic/servers.rb +19 -0
- data/lib/zaws/{route53.rb → services/route53.rb} +1 -1
- data/lib/zaws/services/route53/hosted_zone.rb +36 -0
- data/lib/zaws/services/s3.rb +15 -0
- data/lib/zaws/services/s3/bucket.rb +42 -0
- data/lib/zaws/services/sumo.rb +21 -0
- data/lib/zaws/services/sumo/collectors.rb +19 -0
- data/lib/zaws/services/vmware.rb +0 -0
- data/lib/zaws/version.rb +1 -1
- data/shove_all.sh +6 -0
- data/shove_all_mac.sh +6 -0
- data/shove_all_windows.sh +6 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/zaws/command/ec2/compute/assoc_security_group_spec.rb +135 -0
- data/spec/zaws/command/ec2/compute/compute_spec.rb +321 -0
- data/spec/zaws/command/ec2/compute/images_spec.rb +69 -0
- data/spec/zaws/command/ec2/compute/management_spec.rb +364 -0
- data/spec/zaws/command/ec2/compute/network_spec.rb +93 -0
- data/spec/zaws/command/ec2/compute/node_spec.rb +70 -0
- data/spec/zaws/command/ec2/compute/secondary_ip_spec.rb +212 -0
- data/spec/zaws/command/ec2/compute/storage_spec.rb +63 -0
- data/spec/zaws/command/ec2/elasticip_spec.rb +271 -0
- data/spec/zaws/command/ec2/route_table_spec.rb +844 -0
- data/spec/zaws/command/ec2/security_group_spec.rb +710 -0
- data/spec/zaws/command/ec2/subnet_spec.rb +273 -0
- data/spec/zaws/command/ec2/vpc_spec.rb +180 -0
- data/spec/zaws/command/elb/load_balancer_spec.rb +633 -0
- data/spec/zaws/command/iam/policy_spec.rb +101 -0
- data/spec/zaws/command/iam/role_policy_spec.rb +35 -0
- data/spec/zaws/command/route53/hosted_zone_spec.rb +100 -0
- data/spec/zaws/command/s3/bucket_spec.rb +70 -0
- data/spec/zaws/external/awscli/data/ec2/instance_spec.rb +90 -0
- data/spec/zaws/external/awscli/data/iam/policy_document_spec.rb +56 -0
- data/spec/zaws/external/awscli/data/iam/role_policy_spec.rb +54 -0
- data/spec/zaws/external/awscli/get_aws_version_spec.rb +18 -0
- data/spec/zaws/helper/option_spec.rb +54 -0
- data/spec/zaws/helper/output_spec.rb +144 -0
- data/spec/zaws/helper/process_hash_spec.rb +48 -0
- data/spec/zaws/helper/shell_spec.rb +56 -0
- data/spec/zaws/nessus/scanners.json +0 -0
- data/spec/zaws/version_spec.rb +18 -0
- data/zaws.gemspec +1 -3
- metadata +260 -189
- data/feature/compute/assoc_security_group.feature +0 -55
- data/feature/compute/compute.feature +0 -138
- data/feature/compute/secondary_ip.feature +0 -107
- data/feature/compute/view.feature +0 -23
- data/feature/compute/view_images.feature +0 -24
- data/feature/elasticip/elasticip.feature +0 -138
- data/feature/elasticip/view.feature +0 -18
- data/feature/hosted_zone/view.feature +0 -17
- data/feature/hosted_zone/view_record.feature +0 -29
- data/feature/load_balancer/instance_registration.feature +0 -120
- data/feature/load_balancer/listener.feature +0 -86
- data/feature/load_balancer/load_balancer.feature +0 -101
- data/feature/load_balancer/view.feature +0 -18
- data/feature/route_table/assoc_subnet.feature +0 -128
- data/feature/route_table/route_propagation.feature +0 -93
- data/feature/route_table/route_table.feature +0 -91
- data/feature/route_table/route_to_gateway.feature +0 -69
- data/feature/route_table/route_to_instance.feature +0 -115
- data/feature/route_table/view.feature +0 -25
- data/feature/security_group/ingress_cidr.feature +0 -144
- data/feature/security_group/ingress_group.feature +0 -184
- data/feature/security_group/security_group.feature +0 -107
- data/feature/security_group/view.feature +0 -23
- data/feature/subnet/subnet.feature +0 -94
- data/feature/subnet/view.feature +0 -24
- data/feature/support/env.rb +0 -14
- data/feature/version.feature +0 -6
- data/lib/zaws/aws.rb +0 -26
- data/lib/zaws/ec2.rb +0 -40
- data/lib/zaws/ec2/compute.rb +0 -247
- data/lib/zaws/ec2/elasticip.rb +0 -79
- data/lib/zaws/ec2/route_table.rb +0 -207
- data/lib/zaws/ec2/security_group.rb +0 -154
- data/lib/zaws/ec2/subnet.rb +0 -109
- data/lib/zaws/elb/load_balancer.rb +0 -157
- data/lib/zaws/route53/hosted_zone.rb +0 -36
- data/spec/zaws/ec2/compute/add_volume_spec.rb +0 -39
- data/spec/zaws/ec2/compute/block_device_mapping_spec.rb +0 -31
- data/spec/zaws/ec2/compute/instance_id_by_external_id_spec.rb +0 -23
- data/spec/zaws/ec2/compute/instance_ping_spec.rb +0 -34
- data/spec/zaws/ec2/compute/instance_running_spec.rb +0 -47
- data/spec/zaws/ec2/compute/network_interface_json_spec.rb +0 -57
- data/spec/zaws/ec2/compute/nosdcheck_spec.rb +0 -17
- data/spec/zaws/ec2/compute/tag_instance_spec.rb +0 -21
- data/spec/zaws/ec2/security_group/id_by_name_spec.rb +0 -32
- data/spec/zaws/ec2/subnet/available_spec.rb +0 -22
- data/spec/zaws/ec2/subnet/declare_spec.rb +0 -31
- data/spec/zaws/ec2/subnet/exists_spec.rb +0 -33
- data/spec/zaws/ec2/subnet/id_array_by_cidrblock_array_spec.rb +0 -48
- data/spec/zaws/ec2/subnet/id_by_cidrblock_spec.rb +0 -35
- data/spec/zaws/ec2/subnet/id_by_ip_spec.rb +0 -42
- data/spec/zaws/ec2/subnet/view_spec.rb +0 -34
- data/spec/zaws/elb/load_balancer/calculated_listener_spec.rb +0 -18
- data/spec/zaws/helper/option/absent_spec.rb +0 -14
- data/spec/zaws/helper/option/exclusive_spec.rb +0 -14
- data/spec/zaws/helper/option/exists_spec.rb +0 -18
- data/spec/zaws/helper/option/minimum_spec.rb +0 -14
- data/spec/zaws/helper/output/binary_nagios_check_spec.rb +0 -19
- data/spec/zaws/helper/output/colorize_spec.rb +0 -30
- data/spec/zaws/helper/output/opt_exclusive_spec.rb +0 -14
- data/spec/zaws/helper/output/opt_minimum_spec.rb +0 -15
- data/spec/zaws/helper/output/opt_required_spec.rb +0 -12
- data/spec/zaws/helper/shell/cli_spec.rb +0 -33
- data/spec/zaws/helper/shell/if_then_spec.rb +0 -24
@@ -2,91 +2,104 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module ZAWS
|
4
4
|
module Command
|
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
|
-
|
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
|
+
attr_accessor :aws
|
10
|
+
attr_accessor :out
|
11
|
+
attr_accessor :print_exit_code
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
shellout=ZAWS::Helper::Shell.new
|
16
|
+
awscli = ZAWS::AWSCLI.new(shellout)
|
17
|
+
@aws = ZAWS::AWS.new(shellout, awscli)
|
18
|
+
@out = $stdout
|
19
|
+
@print_exit_code = false
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "view", "View security groups."
|
23
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
24
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
25
|
+
option :unused, :desc => "Get all security groups unused by instances", :type => :boolean, :aliases => :u, :default => false
|
26
|
+
|
27
|
+
def view
|
28
|
+
@out.puts(@aws.ec2.security_group.view(options[:region], (options[:unused] ? 'json' : options[:viewtype]), (options[:verbose] ? @out : nil), options[:vpcid], nil, nil, nil, nil, nil, nil, options[:unused]))
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "exists_by_name GROUP_NAME", "Determine if a security group exists by name GROUP_NAME."
|
32
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
33
|
+
def exists_by_name(group_name)
|
34
|
+
val,sgroupid=@aws.ec2.security_group.exists(options[:region], (options[:verbose] ? @out : nil), options[:vpcid], group_name)
|
35
|
+
@out.puts(val.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "declare GROUP_NAME DESCRIPTION", "Declare a new security group GROUP_NAME, but skip creating it if it exists."
|
39
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
40
|
+
option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
|
41
|
+
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
42
|
+
|
43
|
+
def declare(group_name, description)
|
44
|
+
exitcode = @aws.ec2.security_group.declare(options[:region], options[:vpcid], group_name, description, options[:check], @out, (options[:verbose] ? @out : nil), options[:undofile])
|
31
45
|
exit exitcode
|
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
|
-
option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "delete GROUP_NAME", "Delete a new security group GROUP_NAME, but skip it if it does not exist."
|
49
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
50
|
+
def delete(group_name)
|
51
|
+
@out.puts(@aws.ec2.security_group.delete(options[:region],(options[:verbose] ? @out : nil), options[:vpcid], group_name))
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "ingress_group_exists TARGET_GROUP_NAME SOURCE_GROUP_NAME PROTOCOL PORT", "Determine if an ingress security group rule exists."
|
55
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
56
|
+
|
57
|
+
def ingress_group_exists(target, source, protocol, port)
|
58
|
+
@aws.ec2.security_group.ingress_group_exists(options[:region], options[:vpcid], target, source, protocol, port, @out, (options[:verbose] ? @out : nil))
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "ingress_cidr_exists TARGET_GROUP_NAME CIDR PROTOCOL PORT", "Determine if an ingress CIDR rule exists."
|
62
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
63
|
+
|
64
|
+
def ingress_cidr_exists(target, cidr, protocol, port)
|
65
|
+
@aws.ec2.security_group.ingress_cidr_exists(options[:region], options[:vpcid], target, cidr, protocol, port, @out, (options[:verbose] ? @out : nil))
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "declare_ingress_group TARGET_GROUP_NAME SOURCE_GROUP_NAME PROTOCOL PORT", "Declare an ingress security group rule."
|
69
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
70
|
+
option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
|
58
71
|
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
option :
|
72
|
+
|
73
|
+
def declare_ingress_group(target, source, protocol, port)
|
74
|
+
exitcode = @aws.ec2.security_group.declare_ingress_group(options[:region], options[:vpcid], target, source, protocol, port, options[:check], @out, (options[:verbose] ? @out : nil), options[:undofile])
|
75
|
+
exit exitcode
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "declare_ingress_cidr TARGET_GROUP_NAME CIDR PROTOCOL PORT", "Declare an ingress CIDR rule."
|
79
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
80
|
+
option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
|
68
81
|
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
|
83
|
+
def declare_ingress_cidr(target, cidr, protocol, port)
|
84
|
+
exitcode = @aws.ec2.security_group.declare_ingress_cidr(options[:region], options[:vpcid], target, cidr, protocol, port, options[:check], @out, (options[:verbose] ? @out : nil), options[:undofile])
|
85
|
+
exit exitcode
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "delete_ingress_group TARGET_GROUP_NAME SOURCE_GROUP_NAME PROTOCOL PORT", "Delete an ingress security group rule."
|
89
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
90
|
+
|
91
|
+
def delete_ingress_group(target, source, protocol, port)
|
92
|
+
@aws.ec2.security_group.delete_ingress_group(options[:region], options[:vpcid], target, source, protocol, port, @out, (options[:verbose] ? @out : nil))
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "delete_ingress_cidr TARGET_GROUP_NAME CIDR PROTOCOL PORT", "Delete an ingress security cidr rule."
|
96
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
97
|
+
|
98
|
+
def delete_ingress_cidr(target, cidr, protocol, port)
|
99
|
+
@aws.ec2.security_group.delete_ingress_cidr(options[:region], options[:vpcid], target, cidr, protocol, port, @out, (options[:verbose] ? @out : nil))
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
90
103
|
end
|
91
104
|
end
|
92
105
|
|
data/lib/zaws/command/subnet.rb
CHANGED
@@ -2,52 +2,64 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module ZAWS
|
4
4
|
module Command
|
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
|
-
|
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
|
+
attr_accessor :aws
|
10
|
+
attr_accessor :out
|
11
|
+
attr_accessor :print_exit_code
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
shellout=ZAWS::Helper::Shell.new
|
16
|
+
awscli = ZAWS::AWSCLI.new(shellout,false)
|
17
|
+
@aws = ZAWS::AWS.new(shellout, awscli)
|
18
|
+
@out = $stdout
|
19
|
+
@print_exit_code = false
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "view", "View subnets."
|
23
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
24
|
+
option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
|
25
|
+
def view
|
26
|
+
@out.puts(@aws.ec2.subnet.view(options[:region], options[:viewtype], (options[:verbose] ? @out : nil), options[:vpcid]))
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "id_by_ip PRIVATE_IP VPCID", "get subnet id by specifying PRIVATE_IP address in subnet"
|
30
|
+
|
31
|
+
def id_by_ip(privateip, vpcid)
|
32
|
+
@aws.ec2.subnet.id_by_ip(options[:region], @out, (options[:verbose] ? @out : nil), vpcid, privateip)
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "id_by_cidrblock CIDRBLOCK VPCID", "get subnet id by specifying CIDRBLOCK for subnet"
|
36
|
+
|
37
|
+
def id_by_cidrblock(cidrblock, vpcid)
|
38
|
+
@aws.ec2.subnet.id_by_cidrblock(options[:region], @out, (options[:verbose] ? @out : nil), vpcid, cidrblock)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "exists CIDRBLOCK VPCID", "Determine if a subnet exists by CIDRBLOCK."
|
42
|
+
|
43
|
+
def exists(cidrblock, vpcid)
|
44
|
+
@out.puts(@aws.ec2.subnet.exists(options[:region], (options[:verbose] ? @out : nil), vpcid, cidrblock).to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "declare CIDRBLOCK AVAILABILITY_ZONE VPCID", "Create a subnet if it does not exist already"
|
48
|
+
option :availabilitytimeout, :type => :numeric, :desc => "Timeout before exiting from waiting for state to change from pending to available.", :banner => "<azone>", :aliases => :t, :default => 30
|
49
|
+
option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
|
38
50
|
option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
|
39
|
-
|
40
|
-
aws
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
def declare(cidrblock, availabilityzone, vpcid)
|
52
|
+
exitcode=@aws.ec2.subnet.declare(options[:region], vpcid, cidrblock, availabilityzone, options[:availabilitytimeout], @out, (options[:verbose] ? @out : nil), options[:check], options[:undofile])
|
53
|
+
exit exitcode if not @print_exit_code
|
54
|
+
@out.puts(exitcode)
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "delete CIDRBLOCK VPCID", "Delete a subnet if it exists."
|
58
|
+
|
59
|
+
def delete(cidrblock, vpcid)
|
60
|
+
@aws.ec2.subnet.delete(options[:region], @out, (options[:verbose] ? @out : nil), vpcid, cidrblock)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
52
64
|
end
|
53
65
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Sumo < Thor
|
6
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
7
|
+
|
8
|
+
attr_accessor :sumo
|
9
|
+
attr_accessor :out
|
10
|
+
attr_accessor :print_exit_code
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
super
|
14
|
+
shellout=ZAWS::Helper::Shell.new
|
15
|
+
sumoapi = ZAWS::Sumoapi.new(shellout)
|
16
|
+
@sumo = ZAWS::Controllers::Sumo.new(shellout, sumoapi)
|
17
|
+
@out = $stdout
|
18
|
+
@print_exit_code = false
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "view_collectors", "View Collectors."
|
22
|
+
option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
|
23
|
+
def view_collectors
|
24
|
+
@sumo.view(options[:home], @out, (options[:verbose] ? @out : nil))
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "view_sources", "View Sources."
|
28
|
+
def view_sources(collector_name)
|
29
|
+
@out.puts(@sumo.view_sources(collector_name,options[:home], options[:verbose]))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
module Command
|
5
|
+
class Vpc < Thor
|
6
|
+
class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true, :default => "us-east-1"
|
7
|
+
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
|
8
|
+
|
9
|
+
attr_accessor :aws
|
10
|
+
attr_accessor :out
|
11
|
+
attr_accessor :print_exit_code
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
shellout=ZAWS::Helper::Shell.new
|
16
|
+
awscli = ZAWS::AWSCLI.new(shellout,false)
|
17
|
+
@aws = ZAWS::AWS.new(shellout, awscli)
|
18
|
+
@out = $stdout
|
19
|
+
@print_exit_code = false
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "view", "View compute instances."
|
23
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
24
|
+
def view
|
25
|
+
@aws.ec2.vpc.view(options[:region], options[:viewtype], @out, (options[:verbose] ? @out : nil))
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "check_management_data", "View data used to manage the vpc."
|
29
|
+
option :profile, :type => :string, :desc => "AWS profile to use.", :banner => "<profile>", :aliases => :w, :default => nil
|
30
|
+
def check_management_data
|
31
|
+
@aws.ec2.vpc.check_management_data(options[:region], @out, (options[:verbose] ? @out : nil), options[:profile])
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "declare CIDR EXTERNALID", "Declare a new vpc with a name and CIDR."
|
35
|
+
option :availabilitytimeout, :type => :numeric, :desc => "Timeout before exiting from waiting for state to change from pending to available.", :banner => "<azone>", :aliases => :t, :default => 30
|
36
|
+
option :profile, :type => :string, :desc => "AWS profile to use.", :banner => "<profile>", :aliases => :w, :default => nil
|
37
|
+
def declare(cidr,externalid)
|
38
|
+
exitcode= @aws.ec2.vpc.declare(options[:region],cidr, externalid,options[:availabilitytimeout], @out, (options[:verbose] ? @out : nil), options[:profile])
|
39
|
+
exit exitcode unless @print_exit_code
|
40
|
+
@out.puts(exitcode)
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "view_peering", "View peering connections between vpcs."
|
44
|
+
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
|
45
|
+
def view_peering
|
46
|
+
@aws.ec2.vpc.view_peering(options[:region], options[:viewtype], @out, (options[:verbose] ? @out : nil))
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module ZAWS
|
4
|
+
class AWSCLI
|
5
|
+
attr_accessor :home
|
6
|
+
|
7
|
+
def initialize(shellout,keep_filestore_empty=false)
|
8
|
+
@shellout=shellout
|
9
|
+
@keep_filestore_empty=keep_filestore_empty
|
10
|
+
end
|
11
|
+
|
12
|
+
def filestore
|
13
|
+
@filestore ||= ZAWS::Repository::Filestore.new(@keep_filestore_empty)
|
14
|
+
@filestore.timeout = 1800
|
15
|
+
return @filestore if @keep_filestore_empty
|
16
|
+
@home ||= ENV['HOME']
|
17
|
+
@filestore.location="#{@home}/.awsdata"
|
18
|
+
unless File.directory?(@filestore.location)
|
19
|
+
FileUtils.mkdir_p(@filestore.location)
|
20
|
+
end
|
21
|
+
return @filestore
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_creds
|
25
|
+
if File.directory?("#{@home}/.awsdata")
|
26
|
+
FileUtils.rmtree("#{@home}/.awsdata")
|
27
|
+
end
|
28
|
+
if File.exist?("#{@home}/.aws/credentials")
|
29
|
+
File.delete("#{@home}/.aws/credentials")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def version
|
34
|
+
if ! @version
|
35
|
+
info = @shellout.cli("aws --version",nil)
|
36
|
+
#aws-cli/1.2.13 Python/2.7.5 Linux/3.10.0-123.el7.x86_64
|
37
|
+
version_match = /(?<version>aws-cli\/[1-9\.]*)/.match(info)
|
38
|
+
@version ||= version_match[:version]
|
39
|
+
end
|
40
|
+
return @version
|
41
|
+
end
|
42
|
+
|
43
|
+
def command_ec2
|
44
|
+
@_command_ec2 ||= (ZAWS::AWSCLI::Commands::EC2.new(@shellout,self))
|
45
|
+
return @_command_ec2
|
46
|
+
end
|
47
|
+
|
48
|
+
def command_iam
|
49
|
+
@_command_iam ||= (ZAWS::AWSCLI::Commands::IAM.new(@shellout,self))
|
50
|
+
return @_command_iam
|
51
|
+
end
|
52
|
+
|
53
|
+
def data_ec2
|
54
|
+
@_data_ec2 ||= (ZAWS::AWSCLI::Data::EC2.new(@shellout,self))
|
55
|
+
return @_data_ec2
|
56
|
+
end
|
57
|
+
|
58
|
+
def data_iam
|
59
|
+
@_data_iam ||= (ZAWS::AWSCLI::Data::IAM.new(@shellout,self))
|
60
|
+
return @_data_iam
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|