zaws 0.0.5 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,154 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'netaddr'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
module ZAWS
|
6
|
-
module EC2Services
|
7
|
-
class SecurityGroup
|
8
|
-
|
9
|
-
def initialize(shellout,aws)
|
10
|
-
@shellout=shellout
|
11
|
-
@aws=aws
|
12
|
-
end
|
13
|
-
|
14
|
-
def view(region,view,textout=nil,verbose=nil,vpcid=nil,groupname=nil,groupid=nil,perm_groupid=nil,perm_protocol=nil,perm_toport=nil,cidr=nil)
|
15
|
-
comline="aws --output #{view} --region #{region} ec2 describe-security-groups"
|
16
|
-
if vpcid || groupname
|
17
|
-
comline = comline + " --filter"
|
18
|
-
end
|
19
|
-
comline = comline + " 'Name=vpc-id,Values=#{vpcid}'" if vpcid
|
20
|
-
comline = comline + " 'Name=group-name,Values=#{groupname}'" if groupname
|
21
|
-
comline = comline + " 'Name=group-id,Values=#{groupid}'" if groupid
|
22
|
-
comline = comline + " 'Name=ip-permission.group-id,Values=#{perm_groupid}'" if perm_groupid
|
23
|
-
comline = comline + " 'Name=ip-permission.cidr,Values=#{cidr}'" if cidr
|
24
|
-
comline = comline + " 'Name=ip-permission.protocol,Values=#{perm_protocol}'" if perm_protocol
|
25
|
-
comline = comline + " 'Name=ip-permission.to-port,Values=#{perm_toport}'" if perm_toport
|
26
|
-
sgroups=@shellout.cli(comline,verbose)
|
27
|
-
textout.puts(sgroups) if textout
|
28
|
-
return sgroups
|
29
|
-
end
|
30
|
-
|
31
|
-
def exists(region,textout=nil,verbose=nil,vpcid,groupname)
|
32
|
-
sgroups=JSON.parse(view(region,'json',nil,verbose,vpcid,groupname))
|
33
|
-
val = (sgroups["SecurityGroups"].count == 1)
|
34
|
-
sgroupid = val ? sgroups["SecurityGroups"][0]["GroupId"] : nil
|
35
|
-
textout.puts val.to_s if textout
|
36
|
-
return val, sgroupid
|
37
|
-
end
|
38
|
-
|
39
|
-
def declare(region,vpcid,groupname,description,nagios,textout=nil,verbose=nil,ufile=nil)
|
40
|
-
if ufile
|
41
|
-
ZAWS::Helper::ZFile.prepend("zaws security_group delete #{groupname} --region #{region} --vpcid #{vpcid} $XTRA_OPTS",'#Delete security group',ufile)
|
42
|
-
end
|
43
|
-
sgroup_exists,sgroupid = exists(region,nil,verbose,vpcid,groupname)
|
44
|
-
return ZAWS::Helper::Output.binary_nagios_check(sgroup_exists,"OK: Security Group Exists.","CRITICAL: Security Group Does Not Exist.",textout) if nagios
|
45
|
-
if not sgroup_exists
|
46
|
-
comline="aws --output json --region #{region} ec2 create-security-group --vpc-id #{vpcid} --group-name #{groupname} --description '#{description}'"
|
47
|
-
sgroup=JSON.parse(@shellout.cli(comline,verbose))
|
48
|
-
textout.puts "Security Group Created." if sgroup["return"] == "true"
|
49
|
-
else
|
50
|
-
textout.puts "Security Group Exists Already. Skipping Creation."
|
51
|
-
end
|
52
|
-
return 0
|
53
|
-
end
|
54
|
-
|
55
|
-
def id_by_name(region,textout=nil,verbose=nil,vpcid,groupname)
|
56
|
-
sgroups=JSON.parse(view(region,'json',nil,verbose,vpcid,groupname))
|
57
|
-
group_id= sgroups["SecurityGroups"].count == 1 ? sgroups["SecurityGroups"][0]["GroupId"] : nil
|
58
|
-
raise "More than one security group found when looking up id by name." if sgroups["SecurityGroups"].count > 1
|
59
|
-
textout.puts group_id if textout
|
60
|
-
return group_id
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
def delete(region,textout=nil,verbose=nil,vpcid,groupname)
|
65
|
-
groupid=id_by_name(region,nil,nil,vpcid,groupname)
|
66
|
-
if groupid
|
67
|
-
comline="aws --region #{region} ec2 delete-security-group --group-id #{groupid}"
|
68
|
-
sgroup=JSON.parse(@shellout.cli(comline,verbose))
|
69
|
-
textout.puts "Security Group deleted." if sgroup["return"] == "true"
|
70
|
-
else
|
71
|
-
textout.puts "Security Group does not exist. Skipping deletion."
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def ingress_group_exists(region,vpcid,target,source,protocol,port,textout=nil,verbose=nil)
|
76
|
-
targetid=id_by_name(region,nil,nil,vpcid,target)
|
77
|
-
sourceid=id_by_name(region,nil,nil,vpcid,source)
|
78
|
-
if targetid && sourceid
|
79
|
-
sgroups=JSON.parse(view(region,'json',nil,verbose,vpcid,nil,targetid,sourceid,protocol,port))
|
80
|
-
val = (sgroups["SecurityGroups"].count > 0)
|
81
|
-
textout.puts val.to_s if textout
|
82
|
-
return val, targetid, sourceid
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def ingress_cidr_exists(region,vpcid,target,cidr,protocol,port,textout=nil,verbose=nil)
|
87
|
-
verbose=$stdout
|
88
|
-
targetid=id_by_name(region,nil,nil,vpcid,target)
|
89
|
-
if targetid
|
90
|
-
sgroups=JSON.parse(view(region,'json',nil,verbose,vpcid,nil,targetid,nil,protocol,port,cidr))
|
91
|
-
val = (sgroups["SecurityGroups"].count > 0)
|
92
|
-
textout.puts val.to_s if textout
|
93
|
-
return val, targetid
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def declare_ingress_group(region,vpcid,target,source,protocol,port,nagios,textout=nil,verbose=nil,ufile=nil)
|
98
|
-
if ufile
|
99
|
-
ZAWS::Helper::ZFile.prepend("zaws security_group delete_ingress_group #{target} #{source} #{protocol} #{port} --region #{region} --vpcid #{vpcid} $XTRA_OPTS",'#Delete security group ingress group rule',ufile)
|
100
|
-
end
|
101
|
-
ingress_exists,targetid,sourceid = ingress_group_exists(region,vpcid,target,source,protocol,port,nil,verbose)
|
102
|
-
return ZAWS::Helper::Output.binary_nagios_check(ingress_exists,"OK: Security group ingress group rule exists.","CRITICAL: Security group ingress group rule does not exist.",textout) if nagios
|
103
|
-
if not ingress_exists
|
104
|
-
comline="aws --region #{region} ec2 authorize-security-group-ingress --group-id #{targetid} --source-security-group-owner-id #{sourceid} --protocol #{protocol} --port #{port}"
|
105
|
-
ingressrule=JSON.parse(@shellout.cli(comline,verbose))
|
106
|
-
textout.puts "Ingress group rule created." if ingressrule["return"] == "true"
|
107
|
-
else
|
108
|
-
textout.puts "Ingress group rule not created. Exists already."
|
109
|
-
end
|
110
|
-
return 0
|
111
|
-
end
|
112
|
-
|
113
|
-
def declare_ingress_cidr(region,vpcid,target,cidr,protocol,port,nagios,textout=nil,verbose=nil,ufile=nil)
|
114
|
-
if ufile
|
115
|
-
ZAWS::Helper::ZFile.prepend("zaws security_group delete_ingress_cidr #{target} #{cidr} #{protocol} #{port} --region #{region} --vpcid #{vpcid} $XTRA_OPTS",'#Delete cidr ingress group rule',ufile)
|
116
|
-
end
|
117
|
-
ingress_exists,targetid = ingress_cidr_exists(region,vpcid,target,cidr,protocol,port,nil,verbose)
|
118
|
-
return ZAWS::Helper::Output.binary_nagios_check(ingress_exists,"OK: Security group ingress cidr rule exists.","CRITICAL: Security group ingress cidr rule does not exist.",textout) if nagios
|
119
|
-
if not ingress_exists
|
120
|
-
comline="aws --region #{region} ec2 authorize-security-group-ingress --group-id #{targetid} --cidr #{cidr} --protocol #{protocol} --port #{port}"
|
121
|
-
ingressrule=JSON.parse(@shellout.cli(comline,verbose))
|
122
|
-
textout.puts "Ingress cidr rule created." if ingressrule["return"] == "true"
|
123
|
-
else
|
124
|
-
textout.puts "Ingress cidr rule not created. Exists already."
|
125
|
-
end
|
126
|
-
return 0
|
127
|
-
end
|
128
|
-
|
129
|
-
def delete_ingress_group(region,vpcid,target,source,protocol,port,textout=nil,verbose=nil)
|
130
|
-
ingress_exists,targetid,sourceid = ingress_group_exists(region,vpcid,target,source,protocol,port,nil,verbose)
|
131
|
-
if ingress_exists
|
132
|
-
comline="aws --region #{region} ec2 revoke-security-group-ingress --group-id #{targetid} --source-security-group-owner-id #{sourceid} --protocol #{protocol} --port #{port}"
|
133
|
-
val=JSON.parse(@shellout.cli(comline,verbose))
|
134
|
-
textout.puts "Security group ingress group rule deleted." if val["return"] == "true"
|
135
|
-
else
|
136
|
-
textout.puts "Security group ingress group rule does not exist. Skipping deletion."
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def delete_ingress_cidr(region,vpcid,target,cidr,protocol,port,textout=nil,verbose=nil)
|
141
|
-
ingress_exists,targetid = ingress_cidr_exists(region,vpcid,target,cidr,protocol,port,nil,verbose)
|
142
|
-
if ingress_exists
|
143
|
-
comline="aws --region #{region} ec2 revoke-security-group-ingress --group-id #{targetid} --cidr #{cidr} --protocol #{protocol} --port #{port}"
|
144
|
-
val=JSON.parse(@shellout.cli(comline,verbose))
|
145
|
-
textout.puts "Security group ingress cidr rule deleted." if val["return"] == "true"
|
146
|
-
else
|
147
|
-
textout.puts "Security group ingress cidr rule does not exist. Skipping deletion."
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
data/lib/zaws/ec2/subnet.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'netaddr'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
module ZAWS
|
6
|
-
module EC2Services
|
7
|
-
class Subnet
|
8
|
-
|
9
|
-
def initialize(shellout,aws)
|
10
|
-
@shellout=shellout
|
11
|
-
@aws=aws
|
12
|
-
end
|
13
|
-
|
14
|
-
def view(region,view,textout=nil,verbose=nil,vpcid=nil,cidrblock=nil)
|
15
|
-
comline="aws --output #{view} --region #{region} ec2 describe-subnets"
|
16
|
-
if vpcid || cidrblock
|
17
|
-
comline = comline + " --filter"
|
18
|
-
end
|
19
|
-
comline = comline + " 'Name=vpc-id,Values=#{vpcid}'" if vpcid
|
20
|
-
comline = comline + " 'Name=cidr,Values=#{cidrblock}'" if cidrblock
|
21
|
-
subnets=@shellout.cli(comline,verbose)
|
22
|
-
textout.puts(subnets) if textout
|
23
|
-
return subnets
|
24
|
-
end
|
25
|
-
|
26
|
-
def id_by_ip(region,textout=nil,verbose=nil,vpcid,ip)
|
27
|
-
subnets=JSON.parse(view(region,'json',nil,verbose,vpcid))
|
28
|
-
subnet_id=nil
|
29
|
-
subnets["Subnets"].each { |x| subnet_id = x["SubnetId"] if (NetAddr::CIDR.create(x["CidrBlock"])).contains?(ip) }
|
30
|
-
textout.puts subnet_id if textout
|
31
|
-
return subnet_id
|
32
|
-
end
|
33
|
-
|
34
|
-
def id_by_cidrblock(region,textout=nil,verbose=nil,vpcid,cidrblock)
|
35
|
-
subnets=JSON.parse(view(region,'json',nil,verbose,vpcid,cidrblock))
|
36
|
-
subnet_id= subnets["Subnets"].count == 1 ? subnets["Subnets"][0]["SubnetId"] : nil
|
37
|
-
textout.puts subnet_id if textout
|
38
|
-
return subnet_id
|
39
|
-
end
|
40
|
-
|
41
|
-
def id_array_by_cidrblock_array(region,textout=nil,verbose=nil,vpcid,cidrblock_array)
|
42
|
-
return cidrblock_array.map {|x| id_by_cidrblock(region,nil,verbose,vpcid,x)}
|
43
|
-
end
|
44
|
-
|
45
|
-
def exists(region,textout=nil,verbose=nil,vpcid,cidrblock)
|
46
|
-
val = id_by_cidrblock(region,nil,verbose,vpcid,cidrblock) ? true : false
|
47
|
-
textout.puts val.to_s if textout
|
48
|
-
return val
|
49
|
-
end
|
50
|
-
|
51
|
-
def declare(region,vpcid,cidrblock,availabilityzone,statetimeout,textout=nil,verbose=nil,nagios=false,ufile=nil)
|
52
|
-
if ufile
|
53
|
-
ZAWS::Helper::ZFile.prepend("zaws subnet delete #{cidrblock} #{vpcid} --region #{region} $XTRA_OPTS",'#Delete subnet',ufile)
|
54
|
-
end
|
55
|
-
if not exists(region,nil,verbose,vpcid,cidrblock)
|
56
|
-
if nagios
|
57
|
-
textout.puts "CRITICAL: Subnet Does Not Exist."
|
58
|
-
return 2
|
59
|
-
end
|
60
|
-
comline="aws --output json --region #{region} ec2 create-subnet --vpc-id #{vpcid} --cidr-block #{cidrblock} --availability-zone #{availabilityzone}"
|
61
|
-
subnet=@shellout.cli(comline,verbose)
|
62
|
-
begin
|
63
|
-
Timeout.timeout(statetimeout) do
|
64
|
-
until available(subnet,verbose)
|
65
|
-
sleep(1)
|
66
|
-
subnet=view(region,'json',nil,verbose,vpcid,cidrblock)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
textout.puts "Subnet created."
|
70
|
-
rescue Timeout::Error
|
71
|
-
throw 'Timeout before Subnet made available.'
|
72
|
-
end
|
73
|
-
else
|
74
|
-
if nagios
|
75
|
-
textout.puts "OK: Subnet Exists."
|
76
|
-
return 0
|
77
|
-
end
|
78
|
-
textout.puts "No action needed. Subnet exists already."
|
79
|
-
end
|
80
|
-
return 0
|
81
|
-
end
|
82
|
-
|
83
|
-
def available(subnet,verbose)
|
84
|
-
#based on the structure of the return from create-subnet and describe-subnet determine if subnet is available
|
85
|
-
subnet_hash=JSON.parse(subnet)
|
86
|
-
if subnet_hash["Subnet"]
|
87
|
-
return (subnet_hash["Subnet"]["State"] == "available")
|
88
|
-
end
|
89
|
-
if subnet_hash["Subnets"] and subnet_hash["Subnets"].count == 1
|
90
|
-
return (subnet_hash["Subnets"][0]["State"] == "available")
|
91
|
-
end
|
92
|
-
return false
|
93
|
-
end
|
94
|
-
|
95
|
-
def delete(region,textout=nil,verbose=nil,vpcid,cidrblock)
|
96
|
-
subnetid=id_by_cidrblock(region,nil,verbose,vpcid,cidrblock)
|
97
|
-
if subnetid
|
98
|
-
comline="aws --region #{region} ec2 delete-subnet --subnet-id #{subnetid}"
|
99
|
-
val=JSON.parse(@shellout.cli(comline,verbose))
|
100
|
-
textout.puts "Subnet deleted." if val["return"] == "true"
|
101
|
-
else
|
102
|
-
textout.puts "Subnet does not exist. Skipping deletion."
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'netaddr'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
module ZAWS
|
6
|
-
module ELBServices
|
7
|
-
class LoadBalancer
|
8
|
-
|
9
|
-
def initialize(shellout,aws)
|
10
|
-
@shellout=shellout
|
11
|
-
@aws=aws
|
12
|
-
end
|
13
|
-
|
14
|
-
def view(region,view,textout=nil,verbose=nil)
|
15
|
-
comline="aws --output #{view} --region #{region} elb describe-load-balancers"
|
16
|
-
lbs=@shellout.cli(comline,verbose)
|
17
|
-
textout.puts(lbs) if textout
|
18
|
-
return lbs
|
19
|
-
end
|
20
|
-
|
21
|
-
def exists(region,lbname,textout=nil,verbose=nil)
|
22
|
-
lbs=JSON.parse(view(region,'json',nil,verbose))
|
23
|
-
val = lbs["LoadBalancerDescriptions"].any? { |x| x["LoadBalancerName"]=="#{lbname}" }
|
24
|
-
instances = val ? (lbs["LoadBalancerDescriptions"].select { |x| x["LoadBalancerName"]=="#{lbname}" })[0]["Instances"] : nil
|
25
|
-
ldescriptions = val ? (lbs["LoadBalancerDescriptions"].select { |x| x["LoadBalancerName"]=="#{lbname}" })[0]["ListenerDescriptions"] : nil
|
26
|
-
textout.puts(val) if textout
|
27
|
-
return val,instances,ldescriptions
|
28
|
-
end
|
29
|
-
|
30
|
-
def calculated_listener(lbprotocol,lbport,inprotocol,inport,sslcert=nil)
|
31
|
-
listeners = []
|
32
|
-
single_listener = {}
|
33
|
-
single_listener["Protocol"]="#{lbprotocol}"
|
34
|
-
single_listener["LoadBalancerPort"]=lbport.to_i
|
35
|
-
single_listener["InstanceProtocol"]="#{inprotocol}"
|
36
|
-
single_listener["InstancePort"]=inport.to_i
|
37
|
-
single_listener["SSLCertificateId"]="#{sslcert}" if sslcert
|
38
|
-
listeners << single_listener
|
39
|
-
return listeners.to_json
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_in_subnet(region,lbname,lbprotocol,lbport,inprotocol,inport,securitygroup,cidrblocks,vpcid,nagios=false,textout=nil,verbose=nil,ufile=nil)
|
43
|
-
if ufile
|
44
|
-
ZAWS::Helper::ZFile.prepend("zaws load_balancer delete #{lbname} --region #{region} $XTRA_OPTS",'#Delete load balancer',ufile)
|
45
|
-
end
|
46
|
-
lbexists,instances,ldescriptions=exists(region,lbname,nil,verbose)
|
47
|
-
return ZAWS::Helper::Output.binary_nagios_check(lbexists,"OK: Load Balancer Exists.","CRITICAL: Load Balancer does not exist.",textout) if nagios
|
48
|
-
if not lbexists
|
49
|
-
comline="aws --region #{region} elb create-load-balancer"
|
50
|
-
comline+=" --load-balancer-name #{lbname}"
|
51
|
-
comline+=" --listeners '#{calculated_listener(lbprotocol,lbport,inprotocol,inport)}'"
|
52
|
-
comline+=" --subnets #{@aws.ec2.subnet.id_array_by_cidrblock_array(region,nil,nil,vpcid,cidrblocks).join(" ")}"
|
53
|
-
sgroup_exists,sgroupid = @aws.ec2.security_group.exists(region,nil,nil,vpcid,securitygroup)
|
54
|
-
comline+=" --security-groups #{sgroupid}"
|
55
|
-
newlb=JSON.parse(@shellout.cli(comline,verbose))
|
56
|
-
textout.puts "Load balancer created." if newlb["DNSName"]
|
57
|
-
else
|
58
|
-
textout.puts "Load balancer already exists. Skipping creation."
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def delete(region,lbname,textout=nil,verbose=nil)
|
63
|
-
lbexists,instances,ldescriptions=exists(region,lbname,nil,verbose)
|
64
|
-
if lbexists
|
65
|
-
comline="aws --region #{region} elb delete-load-balancer"
|
66
|
-
comline+=" --load-balancer-name #{lbname}"
|
67
|
-
deletelb=JSON.parse(@shellout.cli(comline,verbose))
|
68
|
-
textout.puts "Load balancer deleted." if deletelb["return"] == "true"
|
69
|
-
else
|
70
|
-
textout.puts "Load balancer does not exist. Skipping deletion."
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def exists_instance(region,lbname,instance_external_id,vpcid,textout=nil,verbose=nil)
|
75
|
-
lbexists,instances,ldescriptions=exists(region,lbname,nil,verbose)
|
76
|
-
instance_exists,instance_id = @aws.ec2.compute.exists(region,nil,verbose,vpcid,instance_external_id)
|
77
|
-
val = (lbexists and instance_exists and (instances.any? { |x| x["InstanceId"]==instance_id }))
|
78
|
-
textout.puts(val) if textout
|
79
|
-
return val, instance_id
|
80
|
-
end
|
81
|
-
|
82
|
-
def register_instance(region,lbname,instance_external_id,vpcid,nagios=false,textout=nil,verbose=nil,ufile=nil)
|
83
|
-
if ufile
|
84
|
-
ZAWS::Helper::ZFile.prepend("zaws load_balancer deregister_instance #{lbname} #{instance_external_id} --region #{region} --vpcid my_vpc_id $XTRA_OPTS",'#Deregister instance',ufile)
|
85
|
-
end
|
86
|
-
instance_registered,instance_id = exists_instance(region,lbname,instance_external_id,vpcid,nil,verbose)
|
87
|
-
return ZAWS::Helper::Output.binary_nagios_check(instance_registered,"OK: Instance registerd.","CRITICAL: Instance not registered.",textout) if nagios
|
88
|
-
if not instance_registered
|
89
|
-
comline="aws --region #{region} elb register-instances-with-load-balancer"
|
90
|
-
comline+=" --load-balancer-name #{lbname}"
|
91
|
-
comline+=" --instances #{instance_id}"
|
92
|
-
newinstance=JSON.parse(@shellout.cli(comline,verbose))
|
93
|
-
verbose.puts "DEBUG: newinstance=#{newinstance} TODO: need to know if it is returning a json object with a return key." if verbose
|
94
|
-
textout.puts "New instance registered." if newinstance["return"] == "true"
|
95
|
-
else
|
96
|
-
textout.puts "Instance already registered. Skipping registration."
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def deregister_instance(region,lbname,instance_external_id,vpcid,textout=nil,verbose=nil)
|
101
|
-
instance_registered,instance_id = exists_instance(region,lbname,instance_external_id,vpcid,nil,verbose)
|
102
|
-
if instance_registered
|
103
|
-
comline="aws --region #{region} elb deregister-instances-with-load-balancer"
|
104
|
-
comline+=" --load-balancer-name #{lbname}"
|
105
|
-
comline+=" --instances #{instance_id}"
|
106
|
-
newinstance=JSON.parse(@shellout.cli(comline,verbose))
|
107
|
-
verbose.puts "DEBUG: newinstance=#{newinstance} TODO: need to know if it is returning a json object with a return key." if verbose
|
108
|
-
textout.puts "Instance deregistered." if newinstance["return"] == "true"
|
109
|
-
else
|
110
|
-
textout.puts "Instance not registered. Skipping deregistration."
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def exists_listener(region,lbname,lbprotocol,lbport,inprotocol,inport,textout=nil,verbose=nil)
|
115
|
-
lbexists,instances,ldescriptions=exists(region,lbname,nil,verbose)
|
116
|
-
verbose.puts ldescriptions if verbose
|
117
|
-
val = (lbexists and (ldescriptions.any? { |x| x["Listener"]["LoadBalancerPort"]==(lbport.to_i) && x["Listener"]["Protocol"]==lbprotocol && x["Listener"]["InstancePort"]==(inport.to_i) && x["Listener"]["InstanceProtocol"]==inprotocol }))
|
118
|
-
textout.puts(val) if textout
|
119
|
-
return val
|
120
|
-
end
|
121
|
-
|
122
|
-
def declare_listener(region,lbname,lbprotocol,lbport,inprotocol,inport,nagios=false,textout=nil,verbose=nil,ufile=nil)
|
123
|
-
if ufile
|
124
|
-
ZAWS::Helper::ZFile.prepend("zaws load_balancer delete_listener #{lbname} #{lbprotocol} #{lbport} #{inprotocol} #{inport} --region #{region} $XTRA_OPTS",'#Delete listener',ufile)
|
125
|
-
end
|
126
|
-
lexists=exists_listener(region,lbname,lbprotocol,lbport,inprotocol,inport,nil,verbose)
|
127
|
-
return ZAWS::Helper::Output.binary_nagios_check(lexists,"OK: Listerner exists.","CRITICAL: Listener does not exist.",textout) if nagios
|
128
|
-
if not lexists
|
129
|
-
comline="aws --region #{region} elb create-load-balancer-listeners"
|
130
|
-
comline+=" --load-balancer-name #{lbname}"
|
131
|
-
comline+=" --listeners '#{calculated_listener(lbprotocol,lbport,inprotocol,inport)}'"
|
132
|
-
newlistener=JSON.parse(@shellout.cli(comline,verbose))
|
133
|
-
verbose.puts "DEBUG: newinstance=#{newlistener} TODO: need to know if it is returning a json object with a return key." if verbose
|
134
|
-
textout.puts "Listener created." if newlistener["return"] == "true"
|
135
|
-
else
|
136
|
-
textout.puts "Listerner exists. Skipping creation."
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def delete_listener(region,lbname,lbprotocol,lbport,inprotocol,inport,textout=nil,verbose=nil)
|
141
|
-
lexists=exists_listener(region,lbname,lbprotocol,lbport,inprotocol,inport,nil,verbose)
|
142
|
-
if lexists
|
143
|
-
comline="aws --region #{region} elb delete-load-balancer-listeners"
|
144
|
-
comline+=" --load-balancer-name #{lbname}"
|
145
|
-
comline+=" --load-balancer-ports '#{lbport}'"
|
146
|
-
dellistener=JSON.parse(@shellout.cli(comline,verbose))
|
147
|
-
verbose.puts "DEBUG: newinstance=#{dellistener} TODO: need to know if it is returning a json object with a return key." if verbose
|
148
|
-
textout.puts "Listerner deleted." if dellistener["return"] == "true"
|
149
|
-
else
|
150
|
-
textout.puts "Listener does not exist. Skipping deletion."
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'netaddr'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
module ZAWS
|
6
|
-
module Route53Services
|
7
|
-
class HostedZone
|
8
|
-
|
9
|
-
def initialize(shellout,aws)
|
10
|
-
@shellout=shellout
|
11
|
-
@aws=aws
|
12
|
-
end
|
13
|
-
|
14
|
-
def view(viewtype,textout=nil,verbose=nil)
|
15
|
-
comline="aws --output #{viewtype} route53 list-hosted-zones"
|
16
|
-
zones=@shellout.cli(comline,verbose)
|
17
|
-
textout.puts(zones) if textout
|
18
|
-
return zones
|
19
|
-
end
|
20
|
-
|
21
|
-
def view_records(viewtype,textout=nil,verbose=nil,zonename)
|
22
|
-
zones=JSON.parse(view('json',nil,verbose))
|
23
|
-
zone_id=nil
|
24
|
-
zones["HostedZones"].each { |x| zone_id = ("#{x["Name"]}"=="#{zonename}") ? x["Id"] : nil }
|
25
|
-
if zone_id
|
26
|
-
comline="aws --output #{viewtype} route53 list-resource-record-sets --hosted-zone-id #{zone_id}"
|
27
|
-
records=@shellout.cli(comline,verbose)
|
28
|
-
textout.puts(records) if textout
|
29
|
-
return records
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|