awscli 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +8 -8
  2. data/README.rdoc +5 -0
  3. data/Rakefile +44 -0
  4. data/bin/awscli +32 -0
  5. data/features/awscli.feature +8 -0
  6. data/features/step_definitions/awscli_steps.rb +6 -0
  7. data/features/support/env.rb +15 -0
  8. data/lib/awscli.rb +51 -0
  9. data/lib/awscli/as.rb +289 -0
  10. data/lib/awscli/cli.rb +21 -0
  11. data/lib/awscli/cli/as.rb +12 -0
  12. data/lib/awscli/cli/as/activities.rb +28 -0
  13. data/lib/awscli/cli/as/configurations.rb +50 -0
  14. data/lib/awscli/cli/as/groups.rb +97 -0
  15. data/lib/awscli/cli/as/instances.rb +34 -0
  16. data/lib/awscli/cli/as/policies.rb +45 -0
  17. data/lib/awscli/cli/ec2.rb +23 -0
  18. data/lib/awscli/cli/ec2/ami.rb +46 -0
  19. data/lib/awscli/cli/ec2/ebs.rb +85 -0
  20. data/lib/awscli/cli/ec2/eip.rb +56 -0
  21. data/lib/awscli/cli/ec2/instances.rb +216 -0
  22. data/lib/awscli/cli/ec2/keypairs.rb +60 -0
  23. data/lib/awscli/cli/ec2/monitoring.rb +35 -0
  24. data/lib/awscli/cli/ec2/placement.rb +42 -0
  25. data/lib/awscli/cli/ec2/reservedinstmng.rb +45 -0
  26. data/lib/awscli/cli/ec2/secgroups.rb +66 -0
  27. data/lib/awscli/cli/ec2/spot.rb +81 -0
  28. data/lib/awscli/cli/ec2/subnet.rb +43 -0
  29. data/lib/awscli/cli/ec2/tags.rb +45 -0
  30. data/lib/awscli/cli/ec2/vmmng.rb +17 -0
  31. data/lib/awscli/cli/ec2/vpc.rb +42 -0
  32. data/lib/awscli/cli/ec2/vpc/connections.rb +0 -0
  33. data/lib/awscli/cli/ec2/vpc/cust_gateways.rb +0 -0
  34. data/lib/awscli/cli/ec2/vpc/dhcp.rb +51 -0
  35. data/lib/awscli/cli/ec2/vpc/internet_gateways.rb +58 -0
  36. data/lib/awscli/cli/ec2/vpc/net_interfaces.rb +75 -0
  37. data/lib/awscli/cli/ec2/vpc/network_acls.rb +29 -0
  38. data/lib/awscli/cli/ec2/vpc/priv_gatewats.rb +0 -0
  39. data/lib/awscli/cli/ec2/vpc/route_tables.rb +0 -0
  40. data/lib/awscli/cli/s3.rb +12 -0
  41. data/lib/awscli/cli/s3/directories.rb +82 -0
  42. data/lib/awscli/cli/s3/files.rb +77 -0
  43. data/lib/awscli/connection.rb +55 -0
  44. data/lib/awscli/ec2.rb +821 -0
  45. data/lib/awscli/errors.rb +64 -0
  46. data/lib/awscli/helper.rb +8 -0
  47. data/lib/awscli/s3.rb +108 -0
  48. data/lib/awscli/version.rb +3 -0
  49. data/test/default_test.rb +14 -0
  50. data/test/test_helper.rb +9 -0
  51. metadata +59 -4
@@ -0,0 +1,66 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class SecGroups < Thor
6
+
7
+ desc "list", "List Security Groups"
8
+ method_option :show_ip_permissions, :aliases => "-p", :type => :boolean, :default => false, :desc => "Enabling this flag will show ip permissions as well"
9
+ def list
10
+ create_ec2_object
11
+ @ec2.list_secgroups options
12
+ end
13
+
14
+ desc "create", "Create New Security Group"
15
+ method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the security group to create"
16
+ method_option :description, :aliases => "-d", :banner => "DESC", :type => :string, :desc => "Description of the group"
17
+ method_option :vpc_id, :aliases => "-v", :banner => "VPCID", :type => :string, :desc => "VPC ID to attach the security group to"
18
+ def create
19
+ create_ec2_object
20
+ @ec2.create_securitygroup options
21
+ end
22
+
23
+ desc "authorize", "Add a rule to existing Security Group"
24
+ method_option :group_id, :aliases => "-g", :required => true, :banner => "SGID", :type => :string, :desc => "ID of the security group to add a rule to"
25
+ method_option :protocol_type, :aliases => "-t", :required => true, :required => true, :banner => "TCP|UDP|ICMP", :type => :string, :desc => "Protocol Type to use for the rule"
26
+ method_option :start_port, :aliases => "-s", :required => true, :banner => "NUM", :type => :numeric, :desc => "Start of port range (or -1 for ICMP wildcard)"
27
+ method_option :end_port, :aliases => "-e", :required => true, :banner => "NUM", :type => :numeric, :desc => "End of port range (or -1 for ICMP wildcard)"
28
+ method_option :cidr, :aliases => "-c", :type => :string, :default => "0.0.0.0/0", :desc => "CIDR range"
29
+ def authorize
30
+ create_ec2_object
31
+ @ec2.authorize_securitygroup options
32
+ end
33
+
34
+ desc "revoke", "Remove a rule from security group"
35
+ method_option :group_id, :aliases => "-g", :required => true, :banner => "SGID", :type => :string, :desc => "ID of the security group to add a rule to"
36
+ method_option :protocol_type, :aliases => "-t", :required => true, :required => true, :banner => "TCP|UDP|ICMP", :type => :string, :desc => "Protocol Type to use for the rule"
37
+ method_option :start_port, :aliases => "-s", :required => true, :banner => "NUM", :type => :numeric, :desc => "Start of port range (or -1 for ICMP wildcard)"
38
+ method_option :end_port, :aliases => "-e", :required => true, :banner => "NUM", :type => :numeric, :desc => "End of port range (or -1 for ICMP wildcard)"
39
+ method_option :cidr, :aliases => "-c", :type => :string, :default => "0.0.0.0/0", :desc => "CIDR range"
40
+ def revoke
41
+ create_ec2_object
42
+ @ec2.revoke_securitygroup options
43
+ end
44
+
45
+ desc "delete", "Delete existing security group"
46
+ method_option :group_id, :aliases => "-g", :required => true, :banner => "SGID", :type => :string, :desc => "ID of the security group to add a rule to"
47
+ def delete
48
+ create_ec2_object
49
+ @ec2.delete_securitygroup options
50
+ end
51
+
52
+ private
53
+
54
+ def create_ec2_object
55
+ puts "ec2 Establishing Connetion..."
56
+ $ec2_conn = Awscli::Connection.new.request_ec2
57
+ puts "ec2 Establishing Connetion... OK"
58
+ @ec2 = Awscli::EC2::SecGroups.new($ec2_conn)
59
+ end
60
+
61
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::SecGroups, :sg, 'sg [COMMAND]', 'EC2 Security Groups Management'
62
+
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,81 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class SpotInstancesManagement < Thor
6
+
7
+ desc "list", "List spot requests or spot data feed subscription"
8
+ method_option :describe_spot_datafeed_subscription, :aliases => "-s", :type => :boolean, :default => false, :desc => "Describe spot data feed subscription"
9
+ method_option :price_history, :aliases => "-p", :type => :boolean, :default => false, :desc => "Describe spot price history"
10
+ method_option :filters, :aliases => "-f", :type => :hash, :desc => "List of filters to limit results with"
11
+ method_option :list_filters, :aliases => "-l", :type => :boolean, :default => false, :desc => "List the available filters"
12
+ def list
13
+ create_ec2_object
14
+ if options[:describe_spot_datafeed_subscription]
15
+ @ec2.describe_spot_datafeed_subscription
16
+ elsif options[:price_history]
17
+ @ec2.describe_spot_price_history options[:filters]
18
+ elsif options[:list_filters]
19
+ @ec2.list_filters
20
+ else
21
+ @ec2.describe_spot_requests
22
+ end
23
+ end
24
+
25
+ desc "create_spot_datafeed", "Create a spot datafeed subscription"
26
+ method_option :bucket, :aliases => "-b", :type => :string, :required => true, :desc => "bucket name to store datafeed in"
27
+ method_option :prefix, :aliases => "-p", :type => :string, :required => true, :desc => "prefix to store data with"
28
+ def create_spot_datafeed
29
+ create_ec2_object
30
+ @ec2.create_spot_datafeed_subsription options[:bucket], options[:prefix]
31
+ end
32
+
33
+ desc "delete_spot_datafeed", "Delete a spot datafeed subscription"
34
+ def delete_spot_datafeed
35
+ create_ec2_object
36
+ @ec2.delete_spot_datafeed_subsription
37
+ end
38
+
39
+ desc "create", "Request spot instances"
40
+ method_option :price, :aliases => "-p", :type => :string, :required => true, :desc => "The maximum hourly price for any Spot Instance launched to fulfill the request"
41
+ method_option :image_id, :aliases => "-a", :type => :string, :required => true, :desc => "ami id to use"
42
+ method_option :flavor_id, :aliases => "-t", :type => :string, :required => true, :desc => "type of the instance to use"
43
+ method_option :key_name, :aliases => "-k", :type => :string, :required => true, :desc => "The name of the key pair"
44
+ method_option :instance_count, :aliases => "-c", :type => :numeric, :default => 1, :desc => "The maximum number of Spot Instances to launch"
45
+ method_option :request_type, :type => :string, :desc => "The Spot Instance request type, Valid Values:one-time | persistent"
46
+ method_option :valid_from, :type => :string, :banner => "DATETIME", :desc => "Start date of the request" #If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.
47
+ method_option :valid_until, :type => :string, :banner => "DATETIME", :desc => "End date of the request" #If this is a one-time request, the request remains active until all instances launch, the request is canceled, or this date is reached. If the request is persistent, it remains active until it is canceled or this date and time is reached
48
+ method_option :launch_group, :type => :string, :default => "awscli_spot_group_#{Time.now.to_i}",:desc => "The instance launch group. Launch groups are Spot Instances that launch together and terminate together"
49
+ method_option :availability_zone_group, :type => :string, :desc => "The Availability Zone group. If you specify the same Availability Zone group for all Spot Instance requests, all Spot Instances are launched in the same Availability Zone"
50
+ method_option :groups, :type => :array, :default => ["default"], :desc => "Name of the security group"
51
+ method_option :user_data, :type => :string, :desc => "MIME, Base64-encoded user data to make available to the instances"
52
+ method_option :availability_zone, :type => :string, :desc => "The placement constraints (Availability Zone) for launching the instances"
53
+ method_option :block_device_mapping, :type => :string, :desc => "ebs mappings"
54
+ method_option :subnet_id, :type => :string, :desc => "subnet id use if vpc"
55
+ method_option :ebs_optimized, :type => :boolean, :desc => "whether to enable ebs optimization"
56
+ method_option :monitoring, :type => :boolean, :deafult => false, :desc => "Enables monitoring for the instance"
57
+ method_option :tags, :type => :string, :desc => "tags for the instances"
58
+ def create
59
+ create_ec2_object
60
+ @ec2.request_spot_instances options
61
+ end
62
+
63
+ desc "cancel", "Cancel spot instance requests"
64
+ def cancel
65
+ end
66
+
67
+ private
68
+
69
+ def create_ec2_object
70
+ puts "ec2 Establishing Connetion..."
71
+ $ec2_conn = Awscli::Connection.new.request_ec2
72
+ puts "ec2 Establishing Connetion... OK"
73
+ @ec2 = Awscli::EC2::Spot.new($ec2_conn)
74
+ end
75
+
76
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::SpotInstancesManagement, :spot, 'spot [COMMAND]', 'EC2 Spot Instances Management'
77
+
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,43 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class Subnet < Thor
6
+
7
+ desc "list", "List VPCs"
8
+ def list
9
+ create_ec2_object
10
+ @ec2.list
11
+ end
12
+
13
+ desc "create", "Create a subnet in an existing VPC, You can create up to 20 subnets in a VPC."
14
+ method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "The ID of the VPC where you want to create the subnet"
15
+ method_option :cidr_block, :aliases => "-c", :type => :string, :required => true, :desc => "The CIDR block you want the subnet to cover (e.g., 10.0.0.0/24)"
16
+ method_option :availability_zone, :aliases => "-z", :type => :string, :desc => "The Availability Zone you want the subnet in. Default: AWS selects a zone for you (recommended)"
17
+ def create
18
+ create_ec2_object
19
+ @ec2.create options
20
+ end
21
+
22
+ desc "delete", "Delete a subnet"
23
+ method_option :subnet_id, :aliases => "-s", :type => :string, :required => true, :desc => "The ID of the subnet you want to delete"
24
+ def delete
25
+ create_ec2_object
26
+ @ec2.delete options[:subnet_id]
27
+ end
28
+
29
+ private
30
+
31
+ def create_ec2_object
32
+ puts "ec2 Establishing Connetion..."
33
+ $ec2_conn = Awscli::Connection.new.request_ec2
34
+ puts "ec2 Establishing Connetion... OK"
35
+ @ec2 = Awscli::EC2::Subnet.new($ec2_conn)
36
+ end
37
+
38
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Subnet, :subnet, 'subnet [COMMAND]', 'EC2 Subnet Management'
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,45 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class Tags < Thor
6
+
7
+ desc "list", "List tags"
8
+ def list
9
+ create_ec2_object
10
+ @ec2.list
11
+ end
12
+
13
+ desc "create", "Create tag"
14
+ method_option :key, :aliases => "-k", :required => true, :type => :string, :desc => "key for the tag"
15
+ method_option :resource_id, :aliases => "-r", :required => true, :banner => "RID", :type => :string, :desc => "ID of a resource to tag. For example, ami-1a2b3c4d"
16
+ method_option :value, :aliases => "-v", :required => true, :type => :string, :desc => "Value for a tag. If you don't want the tag to have a value, specify the parameter with no value"
17
+ def create
18
+ create_ec2_object
19
+ @ec2.create options
20
+ end
21
+
22
+ desc "delete", "Deletes a specific set of tags from a specific set of resources"
23
+ method_option :key, :aliases => "-k", :required => true, :type => :string, :desc => "key for the tag"
24
+ method_option :resource_id, :aliases => "-r", :required => true, :banner => "RID", :type => :string, :desc => "ID of a resource to tag. For example, ami-1a2b3c4d"
25
+ method_option :value, :aliases => "-v", :required => true, :type => :string, :desc => "Value for a tag. If you don't want the tag to have a value, specify the parameter with no value"
26
+ def delete
27
+ create_ec2_object
28
+ @ec2.delete options
29
+ end
30
+
31
+ private
32
+
33
+ def create_ec2_object
34
+ puts "ec2 Establishing Connetion..."
35
+ $ec2_conn = Awscli::Connection.new.request_ec2
36
+ puts "ec2 Establishing Connetion... OK"
37
+ @ec2 = Awscli::EC2::Tags.new($ec2_conn)
38
+ end
39
+
40
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Tags, :tags, 'tags [COMMAND]', 'EC2 Tags Management'
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class VmManagement < Thor
6
+
7
+ desc "list", "List Images"
8
+ def list
9
+ puts "Listing Images"
10
+ end
11
+
12
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::VmManagement, :vm, 'vm [COMMAND]', 'EC2 VM Management'
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,42 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class Vpc < Thor
6
+
7
+ desc "list", "List VPCs"
8
+ def list
9
+ create_ec2_object
10
+ @ec2.list
11
+ end
12
+
13
+ desc "create", "Create a VPC with the CIDR block you specify"
14
+ method_option :cidr_block, :aliases => "-c", :type => :string, :required => true, :desc => "The CIDR block you want the VPC to cover (e.g., 10.0.0.0/16), You can't change the size of a VPC after you create it"
15
+ method_option :tenancy, :type => :string, :default => "default", :desc => "The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means instances must be launched with tenancy as dedicated"
16
+ def create
17
+ create_ec2_object
18
+ @ec2.create options
19
+ end
20
+
21
+ desc "delete", "Deletes a VPC. You must detach or delete all gateways or other objects that are dependent on the VPC first"
22
+ method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "The ID of the VPC you want to delete"
23
+ def delete
24
+ create_ec2_object
25
+ @ec2.delete options[:vpc_id]
26
+ end
27
+
28
+ private
29
+
30
+ def create_ec2_object
31
+ puts "ec2 Establishing Connetion..."
32
+ $ec2_conn = Awscli::Connection.new.request_ec2
33
+ puts "ec2 Establishing Connetion... OK"
34
+ @ec2 = Awscli::EC2::Vpc.new($ec2_conn)
35
+ end
36
+
37
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Vpc, :vpc, 'vpc [COMMAND]', 'EC2 VPC Management'
38
+
39
+ end
40
+ end
41
+ end
42
+ end
File without changes
@@ -0,0 +1,51 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ module VPC
5
+ require 'awscli/cli/ec2/vpc'
6
+ class Dhcp < Thor
7
+
8
+ desc "list", "List Dhcp Options"
9
+ def list
10
+ create_ec2_object
11
+ @ec2.list
12
+ end
13
+
14
+ desc "create", "Creates a set of DHCP options for your VPC"
15
+ method_option :dhcp_configuration_options, :aliases => "-o", :type => :hash, :required => true, :desc => "hash of key value dhcp options(domain-name, domain-name-servers, ntp-servers, netbios-name-servers, netbios-node-type) to assign"
16
+ def create
17
+ create_ec2_object
18
+ @ec2.create options[:dhcp_configuration_options]
19
+ end
20
+
21
+ desc "delete", "Deletes a set of DHCP options that you specify"
22
+ method_option :dhcp_options_id, :aliases => "-d", :type => :string, :required => true, :desc => "The ID of the DHCP options set you want to delete"
23
+ def delete
24
+ create_ec2_object
25
+ @ec2.delete options[:dhcp_options_id]
26
+ end
27
+
28
+ desc "associate", "Associates a set of DHCP options (that you've previously created) with the specified VPC. Or, associates no DHCP options with the VPC"
29
+ method_option :dhcp_options_id, :aliases => "-d", :type => :string, :required => true, :desc => "The ID of the DHCP options you want to associate with the VPC"
30
+ method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "The ID of the VPC you want to associate the DHCP options with"
31
+ def associate
32
+ create_ec2_object
33
+ @ec2.associate options[:dhcp_options_id], options[:vpc_id]
34
+ end
35
+
36
+ private
37
+
38
+ def create_ec2_object
39
+ puts "ec2 Establishing Connetion..."
40
+ $ec2_conn = Awscli::Connection.new.request_ec2
41
+ puts "ec2 Establishing Connetion... OK"
42
+ @ec2 = Awscli::EC2::Dhcp.new($ec2_conn)
43
+ end
44
+
45
+ AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::Dhcp, :dhcp, 'dhcp [COMMAND]', 'VPC DHCP Management'
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,58 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ module VPC
5
+ require 'awscli/cli/ec2/vpc'
6
+ class InternetGateways < Thor
7
+
8
+ desc "list", "List Internet Gateways"
9
+ def list
10
+ create_ec2_object
11
+ @ec2.list
12
+ end
13
+
14
+ desc "create", "Create Internet Gateway"
15
+ def create
16
+ create_ec2_object
17
+ @ec2.create
18
+ end
19
+
20
+ desc "delete", "Delete Internet Gateway"
21
+ method_option :internet_gateway_id, :aliases => "-i", :type => :string, :required => true, :desc => "id of the internet gateway to delete"
22
+ def delete
23
+ create_ec2_object
24
+ @ec2.delete options[:internet_gateway_id]
25
+ end
26
+
27
+ desc "attach", "Attach Internet Gateway"
28
+ method_option :internet_gateway_id, :aliases => "-i", :type => :string, :required => true, :desc => "id of the internet gateway to attach"
29
+ method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "id vpc to attach to"
30
+ def attach
31
+ create_ec2_object
32
+ @ec2.attach options[:internet_gateway_id], options[:vpc_id]
33
+ end
34
+
35
+ desc "deattach", "Deattach Internet Gateway"
36
+ method_option :internet_gateway_id, :aliases => "-i", :type => :string, :required => true, :desc => "id of the internet gateway to attach"
37
+ method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "id vpc to attach to"
38
+ def deattach
39
+ create_ec2_object
40
+ @ec2.deattach options[:internet_gateway_id], options[:vpc_id]
41
+ end
42
+
43
+ private
44
+
45
+ def create_ec2_object
46
+ puts "ec2 Establishing Connetion..."
47
+ $ec2_conn = Awscli::Connection.new.request_ec2
48
+ puts "ec2 Establishing Connetion... OK"
49
+ @ec2 = Awscli::EC2::InternetGateways.new($ec2_conn)
50
+ end
51
+
52
+ AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::InternetGateways, :internetgateways, 'internetgateways [COMMAND]', 'VPC Network Internet Gateway Management'
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,75 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ module VPC
5
+ require 'awscli/cli/ec2/vpc'
6
+ class NetworkInterfaces < Thor
7
+
8
+ desc "list", "List Network Interfaces"
9
+ def list
10
+ create_ec2_object
11
+ @ec2.list
12
+ end
13
+
14
+ desc "create", "Creates a network interface in the specified subnet. This command is supported only in EC2-VPC"
15
+ method_option :subnet_id, :aliases => "-s", :type => :string, :required => true, :desc => "subnet id"
16
+ method_option :description, :aliases => "-d", :type => :string, :desc => "Set the description of the network interface"
17
+ method_option :private_ip_address, :aliases => "-p", :type => :string, :desc => "The primary private IP address of the network interface. If an IP address is not specified, one will be auto-assigned to the interface"
18
+ method_option :group_set, :aliases => "-g", :type => :array, :desc => "A security group to add to the network interface"
19
+ def create
20
+ create_ec2_object
21
+ @ec2.create options
22
+ end
23
+
24
+ desc "delete", "Deletes a network interface. Network interfaces must be detached from an instance before they can be deleted."
25
+ method_option :network_interface_id, :aliases => "-n", :type => :string, :required => true, :desc => "Id of the network interface to delete"
26
+ def delete
27
+ create_ec2_object
28
+ @ec2.delete options[:network_interface_id]
29
+ end
30
+
31
+ desc "attach", "Attaches a network interface to an instance"
32
+ method_option :network_interface_id, :aliases => "-n", :type => :string, :required => true, :desc => "ID of the network interface to attach"
33
+ method_option :instance_id, :aliases => "-i", :type => :string, :required => true, :desc => "ID of the instance that will be attached to the network interface"
34
+ method_option :device_index, :aliases => "-d", :type => :numeric, :required => true, :desc => "index of the device for the network interface attachment on the instance"
35
+ def attach
36
+ create_ec2_object
37
+ @ec2.attach options[:network_interface_id], options[:instance_id], options[:device_index]
38
+ end
39
+
40
+ desc "deattach", "Detaches a network interface"
41
+ method_option :attachment_id, :aliases => "-a", :type => :string, :required => true, :desc => "ID of the attachment to detach"
42
+ method_option :force, :aliases => "-f", :type => :boolean, :default => false, :desc => "Set to true to force a detachment"
43
+ def deattach
44
+ create_ec2_object
45
+ @ec2.deattach options[:attachment_id], options[:force]
46
+ end
47
+
48
+ desc "modify_attribute", "Modifies a network interface attribute. You can specify only one attribute at a time"
49
+ method_option :network_interface_id, :aliases => "-n", :type => :string, :required => true, :desc => "The ID of the network interface you want to modify an attribute of"
50
+ method_option :attribute, :aliases => "-a", :type => :string, :required => true, :desc => "The attribute to modify, must be one of 'description', 'groupSet', 'sourceDestCheck' or 'attachment'"
51
+ method_option :description, :aliases => "-d", :type => :string, :desc => "New value of attribute - description"
52
+ method_option :group_set, :aliases => "-g", :type => :array, :desc => "New value of attribute - a list of group id's"
53
+ method_option :source_dest_check, :aliases => "-s", :type => :boolean, :desc => "New value of attribute - a boolean value"
54
+ method_option :attachment, :aliases => "-t", :type => :hash, :desc => "a hash with: attachmentid - the attachment to change & deleteOnTermination - a boolean"
55
+ def modify_attribute
56
+ create_ec2_object
57
+ @ec2.modify_attribute options
58
+ end
59
+
60
+ private
61
+
62
+ def create_ec2_object
63
+ puts "ec2 Establishing Connetion..."
64
+ $ec2_conn = Awscli::Connection.new.request_ec2
65
+ puts "ec2 Establishing Connetion... OK"
66
+ @ec2 = Awscli::EC2::NetworkInterfaces.new($ec2_conn)
67
+ end
68
+
69
+ AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::NetworkInterfaces, :netinterfaces, 'netinterfaces [COMMAND]', 'VPC Network Acl Management'
70
+
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end