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
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "add volume to instance" do
|
6
|
-
|
7
|
-
volumes = <<-eos
|
8
|
-
{ "VolumeId": "vol-1234abcd" }
|
9
|
-
eos
|
10
|
-
|
11
|
-
attachvolume = <<-eos
|
12
|
-
{
|
13
|
-
"AttachTime": "YYYY-MM-DDTHH:MM:SS.000Z",
|
14
|
-
"InstanceId": "id-X",
|
15
|
-
"VolumeId": "vol-1234abcd",
|
16
|
-
"State": "attaching",
|
17
|
-
"Device": "/dev/sda" }
|
18
|
-
eos
|
19
|
-
|
20
|
-
tag_created = <<-eos
|
21
|
-
{ "return":"true" }
|
22
|
-
eos
|
23
|
-
|
24
|
-
textout=double('outout')
|
25
|
-
shellout=double('ZAWS::Helper::Shell')
|
26
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 create-volume --availability-zone us-west-1a --size 70",nil).and_return(volumes)
|
27
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 create-tags --resources vol-1234abcd --tags Key=externalid,Value=extername",nil).and_return(tag_created)
|
28
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 create-tags --resources vol-1234abcd --tags Key=Name,Value=extername",nil).and_return(tag_created)
|
29
|
-
expect(shellout).to receive(:cli).with('ping -q -c 2 0.0.0.0',nil).and_return(true)
|
30
|
-
expect(shellout).to receive(:cli).with("aws --output json ec2 attach-volume --region us-west-1 --volume-id vol-1234abcd --instance-id id-X --device /dev/sda",nil).and_return(attachvolume)
|
31
|
-
aws=ZAWS::AWS.new(shellout)
|
32
|
-
bdm = aws.ec2.compute.add_volume('us-west-1','id-X','extername','0.0.0.0','/dev/sda','us-west-1a',70,nil)
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "provides a block device mapping overriding the root size" do
|
6
|
-
|
7
|
-
images = <<-eos
|
8
|
-
{ "Images": [
|
9
|
-
{ "RootDeviceName": "/dev/sda1",
|
10
|
-
"BlockDeviceMappings": [
|
11
|
-
{ "DeviceName": "/dev/sda1",
|
12
|
-
"Ebs": {
|
13
|
-
"DeleteOnTermination": true,
|
14
|
-
"SnapshotId": "snap-XXX",
|
15
|
-
"VolumeSize": 7,
|
16
|
-
"VolumeType": "standard" } } ] } ] }
|
17
|
-
eos
|
18
|
-
|
19
|
-
textout=double('outout')
|
20
|
-
shellout=double('ZAWS::Helper::Shell')
|
21
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-images --owner me --image-ids X",nil).and_return(images)
|
22
|
-
aws=ZAWS::AWS.new(shellout)
|
23
|
-
bdm = aws.ec2.compute.block_device_mapping('us-west-1','me',nil,70,'X')
|
24
|
-
expect(bdm).to eq('[{"DeviceName":"/dev/sda1","Ebs":{"DeleteOnTermination":true,"SnapshotId":"snap-XXX","VolumeSize":70,"VolumeType":"standard"}}]')
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "provides an instance id when you give it a external id" do
|
6
|
-
|
7
|
-
compute_instances = <<-eos
|
8
|
-
{ "Reservations": [
|
9
|
-
{ "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] }
|
10
|
-
] }
|
11
|
-
eos
|
12
|
-
|
13
|
-
textout=double('outout')
|
14
|
-
shellout=double('ZAWS::Helper::Shell')
|
15
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'",nil).and_return(compute_instances)
|
16
|
-
aws=ZAWS::AWS.new(shellout)
|
17
|
-
instanceid = aws.ec2.compute.instance_id_by_external_id('us-west-1','my_instance','my_vpc_id',nil,nil)
|
18
|
-
expect(instanceid).to eq("i-XXXXXXX")
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "determines an instance is reachable over the network with ping" do
|
6
|
-
|
7
|
-
shellout=double('ZAWS::Helper::Shell')
|
8
|
-
comline ='ping -q -c 2 0.0.0.0'
|
9
|
-
times_called = 0
|
10
|
-
shellout.stub(:cli).with(comline,nil).and_return do
|
11
|
-
times_called += 1
|
12
|
-
raise Mixlib::ShellOut::ShellCommandFailed if times_called == 2
|
13
|
-
end
|
14
|
-
aws=ZAWS::AWS.new(shellout)
|
15
|
-
aws.ec2.compute.instance_ping?('0.0.0.0',10,1)
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
it "determines an instance is not reachable over the network with ping" do
|
20
|
-
|
21
|
-
shellout=double('ZAWS::Helper::Shell')
|
22
|
-
comline ='ping -q -c 2 0.0.0.0'
|
23
|
-
times_called = 0
|
24
|
-
shellout.stub(:cli).with(comline,nil).and_return do
|
25
|
-
times_called += 1
|
26
|
-
raise Mixlib::ShellOut::ShellCommandFailed if times_called < 4
|
27
|
-
end
|
28
|
-
aws=ZAWS::AWS.new(shellout)
|
29
|
-
expect {aws.ec2.compute.instance_ping?('0.0.0.0',2,1)}.to raise_error(StandardError, 'Timeout before instance responded to ping.')
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "determines an instance is running" do
|
6
|
-
|
7
|
-
compute_instances_without = <<-eos
|
8
|
-
{ "Reservations": [
|
9
|
-
{ "Instances" : [ {"InstanceId": "i-XXXXXXX","State": { "Code":0 }, "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] }
|
10
|
-
] }
|
11
|
-
eos
|
12
|
-
|
13
|
-
compute_instances = <<-eos
|
14
|
-
{ "Reservations": [
|
15
|
-
{ "Instances" : [ {"InstanceId": "i-XXXXXXX","State": { "Code":16 }, "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] }
|
16
|
-
] }
|
17
|
-
eos
|
18
|
-
|
19
|
-
textout=double('outout')
|
20
|
-
shellout=double('ZAWS::Helper::Shell')
|
21
|
-
comline="aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'"
|
22
|
-
expect(shellout).to receive(:cli).with(comline,nil).and_return(compute_instances_without,compute_instances)
|
23
|
-
aws=ZAWS::AWS.new(shellout)
|
24
|
-
aws.ec2.compute.instance_running?('us-west-1','my_vpc_id','my_instance',3,1,nil)
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
it "determines an instance is not running" do
|
29
|
-
|
30
|
-
compute_instances_without = <<-eos
|
31
|
-
{ "Reservations": [
|
32
|
-
{ "Instances" : [ {"InstanceId": "i-XXXXXXX","State": { "Code":0 }, "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] }
|
33
|
-
] }
|
34
|
-
eos
|
35
|
-
|
36
|
-
textout=double('outout')
|
37
|
-
shellout=double('ZAWS::Helper::Shell')
|
38
|
-
comline="aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'"
|
39
|
-
expect(shellout).to receive(:cli).with(comline,nil).and_return(compute_instances_without,compute_instances_without)
|
40
|
-
aws=ZAWS::AWS.new(shellout)
|
41
|
-
expect {aws.ec2.compute.instance_running?('us-west-1','my_vpc_id','my_instance',5,2,nil)}.to raise_error(StandardError, 'Timeout before instance state code set to running(16).')
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "provides a network interface structure" do
|
6
|
-
|
7
|
-
subnets = <<-eos
|
8
|
-
{ "Subnets": [
|
9
|
-
{
|
10
|
-
"VpcId": "vpc-XXXXXX",
|
11
|
-
"CidrBlock": "10.0.1.0/24",
|
12
|
-
"MapPublicIpOnLaunch": false,
|
13
|
-
"DefaultForAz": false,
|
14
|
-
"State": "available",
|
15
|
-
"SubnetId": "subnet-XXXXXX",
|
16
|
-
"AvailableIpAddressCount": 251
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"VpcId": "vpc-XXXXXX",
|
20
|
-
"CidrBlock": "10.0.0.0/24",
|
21
|
-
"MapPublicIpOnLaunch": false,
|
22
|
-
"DefaultForAz": false,
|
23
|
-
"State": "available",
|
24
|
-
"SubnetId": "subnet-YYYYYY",
|
25
|
-
"AvailableIpAddressCount": 251
|
26
|
-
}
|
27
|
-
]
|
28
|
-
}
|
29
|
-
eos
|
30
|
-
|
31
|
-
sgroups = <<-eos
|
32
|
-
{
|
33
|
-
"SecurityGroups": [
|
34
|
-
{
|
35
|
-
"Description": "My security group",
|
36
|
-
"GroupName": "my_security_group_name",
|
37
|
-
"OwnerId": "123456789012",
|
38
|
-
"GroupId": "sg-903004f8"
|
39
|
-
}
|
40
|
-
]
|
41
|
-
}
|
42
|
-
eos
|
43
|
-
|
44
|
-
textout=double('outout')
|
45
|
-
shellout=double('ZAWS::Helper::Shell')
|
46
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id'",nil).and_return(subnets)
|
47
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-security-groups --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=group-name,Values=my_security_group_name'",nil).and_return(sgroups)
|
48
|
-
aws=ZAWS::AWS.new(shellout)
|
49
|
-
bdm = aws.ec2.compute.network_interface_json('us-west-1',nil,'my_vpc_id','10.0.0.6','my_security_group_name')
|
50
|
-
expect(bdm).to eq('[{"Groups":["sg-903004f8"],"PrivateIpAddress":"10.0.0.6","DeviceIndex":0,"SubnetId":"subnet-YYYYYY"}]')
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "sets no source/destination check for instances intended to be NAT instances" do
|
6
|
-
nosd_check_result = <<-eos
|
7
|
-
{ "return":"true" }
|
8
|
-
eos
|
9
|
-
textout=double('outout')
|
10
|
-
shellout=double('ZAWS::Helper::Shell')
|
11
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 modify-instance-attribute --instance-id=id-X --no-source-dest-check",nil).and_return(nosd_check_result)
|
12
|
-
aws=ZAWS::AWS.new(shellout)
|
13
|
-
aws.ec2.compute.nosdcheck('us-west-1','id-X')
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Compute do
|
4
|
-
|
5
|
-
it "tags an instance when created" do
|
6
|
-
tag_created = <<-eos
|
7
|
-
{ "return":"true" }
|
8
|
-
eos
|
9
|
-
textout=double('outout')
|
10
|
-
shellout=double('ZAWS::Helper::Shell')
|
11
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 create-tags --resources id-X --tags Key=externalid,Value=extername",nil).and_return(tag_created)
|
12
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 create-tags --resources id-X --tags Key=Name,Value=extername",nil).and_return(tag_created)
|
13
|
-
aws=ZAWS::AWS.new(shellout)
|
14
|
-
aws.ec2.compute.tag_resource('us-west-1','id-X','extername')
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2 do
|
4
|
-
|
5
|
-
it "security group id by group name" do
|
6
|
-
|
7
|
-
sgroups = <<-eos
|
8
|
-
{
|
9
|
-
"SecurityGroups": [
|
10
|
-
{
|
11
|
-
"Description": "My security group",
|
12
|
-
"GroupName": "my_security_group_name",
|
13
|
-
"OwnerId": "123456789012",
|
14
|
-
"GroupId": "sg-abcd1234"
|
15
|
-
}
|
16
|
-
]
|
17
|
-
}
|
18
|
-
eos
|
19
|
-
|
20
|
-
textout=double('outout')
|
21
|
-
shellout=double('ZAWS::Helper::Shell')
|
22
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-security-groups --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=group-name,Values=my_security_group_name'",nil).and_return(sgroups)
|
23
|
-
expect(textout).to receive(:puts).with('sg-abcd1234')
|
24
|
-
aws=ZAWS::AWS.new(shellout)
|
25
|
-
aws.ec2.security_group.id_by_name('us-west-1',textout,nil,'my_vpc_id','my_security_group_name')
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2 do
|
4
|
-
|
5
|
-
it "determine subnet is available by return json from create-subnet" do
|
6
|
-
|
7
|
-
# example output for: aws ec2 escribe-subnets
|
8
|
-
subnet = <<-eos
|
9
|
-
{ "Subnet": {
|
10
|
-
"State": "available"
|
11
|
-
}
|
12
|
-
}
|
13
|
-
eos
|
14
|
-
|
15
|
-
shellout=double('ZAWS::Helper::Shell')
|
16
|
-
aws=ZAWS::AWS.new(shellout)
|
17
|
-
expect(aws.ec2.subnet.available(subnet,nil)).to be true
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2 do
|
4
|
-
|
5
|
-
it "declare subnet " do
|
6
|
-
|
7
|
-
empty_subnets = <<-eos
|
8
|
-
{ "Subnets": [] }
|
9
|
-
eos
|
10
|
-
|
11
|
-
create_subnet_return = <<-eos
|
12
|
-
{ "Subnet": { "State": "pending" } }
|
13
|
-
eos
|
14
|
-
|
15
|
-
# example output for: aws ec2 escribe-subnets
|
16
|
-
describe_subnets = <<-eos
|
17
|
-
{ "Subnets": [ { "State": "available" } ] }
|
18
|
-
eos
|
19
|
-
|
20
|
-
textout=double('outout')
|
21
|
-
shellout=double('ZAWS::Helper::Shell')
|
22
|
-
shellout.stub(:cli).with(anything(),anything()).and_return(empty_subnets,create_subnet_return,describe_subnets)
|
23
|
-
expect(textout).to receive(:puts).with('Subnet created.')
|
24
|
-
aws=ZAWS::AWS.new(shellout)
|
25
|
-
aws.ec2.subnet.declare('us-west-1','vpc-XXXXXX','10.0.0.0/24','us-west-1a',30,textout)
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2 do
|
4
|
-
|
5
|
-
it "subnet exists" do
|
6
|
-
|
7
|
-
# example output for: aws ec2 escribe-subnets
|
8
|
-
subnets = <<-eos
|
9
|
-
{ "Subnets": [
|
10
|
-
{
|
11
|
-
"VpcId": "vpc-XXXXXX",
|
12
|
-
"CidrBlock": "10.0.0.0/24",
|
13
|
-
"MapPublicIpOnLaunch": false,
|
14
|
-
"DefaultForAz": false,
|
15
|
-
"State": "available",
|
16
|
-
"SubnetId": "subnet-YYYYYY",
|
17
|
-
"AvailableIpAddressCount": 251
|
18
|
-
}
|
19
|
-
]
|
20
|
-
}
|
21
|
-
eos
|
22
|
-
|
23
|
-
textout=double('outout')
|
24
|
-
shellout=double('ZAWS::Helper::Shell')
|
25
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=vpc-XXXXXX' 'Name=cidr,Values=10.0.0.0/24'",nil).and_return(subnets)
|
26
|
-
expect(textout).to receive(:puts).with('true')
|
27
|
-
aws=ZAWS::AWS.new(shellout)
|
28
|
-
aws.ec2.subnet.exists('us-west-1',textout,nil,'vpc-XXXXXX','10.0.0.0/24')
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ZAWS::EC2Services::Subnet do
|
4
|
-
|
5
|
-
it "Provides an array of subnet ids if given an array of subnet cidr blocks" do
|
6
|
-
|
7
|
-
# example output for: aws ec2 escribe-subnets
|
8
|
-
subnets_10_0_0_0_24 = <<-eos
|
9
|
-
{ "Subnets": [
|
10
|
-
{
|
11
|
-
"VpcId": "vpc-XXXXXX",
|
12
|
-
"CidrBlock": "10.0.0.0/24",
|
13
|
-
"MapPublicIpOnLaunch": false,
|
14
|
-
"DefaultForAz": false,
|
15
|
-
"State": "available",
|
16
|
-
"SubnetId": "subnet-YYYYYYYY",
|
17
|
-
"AvailableIpAddressCount": 251
|
18
|
-
}
|
19
|
-
]
|
20
|
-
}
|
21
|
-
eos
|
22
|
-
|
23
|
-
subnets_10_0_1_0_24 = <<-eos
|
24
|
-
{ "Subnets": [
|
25
|
-
{
|
26
|
-
"VpcId": "vpc-XXXXXX",
|
27
|
-
"CidrBlock": "10.0.1.0/24",
|
28
|
-
"MapPublicIpOnLaunch": false,
|
29
|
-
"DefaultForAz": false,
|
30
|
-
"State": "available",
|
31
|
-
"SubnetId": "subnet-ZZZZZZZZ",
|
32
|
-
"AvailableIpAddressCount": 251
|
33
|
-
}
|
34
|
-
]
|
35
|
-
}
|
36
|
-
eos
|
37
|
-
|
38
|
-
shellout=double('ZAWS::Helper::Shell')
|
39
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=vpc-XXXXXX' 'Name=cidr,Values=10.0.0.0/24'",nil).and_return(subnets_10_0_0_0_24)
|
40
|
-
expect(shellout).to receive(:cli).with("aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=vpc-XXXXXX' 'Name=cidr,Values=10.0.1.0/24'",nil).and_return(subnets_10_0_1_0_24)
|
41
|
-
aws=ZAWS::AWS.new(shellout)
|
42
|
-
expect(aws.ec2.subnet.id_array_by_cidrblock_array('us-west-1',nil,nil,'vpc-XXXXXX',["10.0.0.0/24","10.0.1.0/24"])).to eql(["subnet-YYYYYYYY","subnet-ZZZZZZZZ"])
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|