awscli 0.0.4 → 0.0.5
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 +8 -8
- data/README.rdoc +5 -0
- data/Rakefile +44 -0
- data/bin/awscli +32 -0
- data/features/awscli.feature +8 -0
- data/features/step_definitions/awscli_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/lib/awscli.rb +51 -0
- data/lib/awscli/as.rb +289 -0
- data/lib/awscli/cli.rb +21 -0
- data/lib/awscli/cli/as.rb +12 -0
- data/lib/awscli/cli/as/activities.rb +28 -0
- data/lib/awscli/cli/as/configurations.rb +50 -0
- data/lib/awscli/cli/as/groups.rb +97 -0
- data/lib/awscli/cli/as/instances.rb +34 -0
- data/lib/awscli/cli/as/policies.rb +45 -0
- data/lib/awscli/cli/ec2.rb +23 -0
- data/lib/awscli/cli/ec2/ami.rb +46 -0
- data/lib/awscli/cli/ec2/ebs.rb +85 -0
- data/lib/awscli/cli/ec2/eip.rb +56 -0
- data/lib/awscli/cli/ec2/instances.rb +216 -0
- data/lib/awscli/cli/ec2/keypairs.rb +60 -0
- data/lib/awscli/cli/ec2/monitoring.rb +35 -0
- data/lib/awscli/cli/ec2/placement.rb +42 -0
- data/lib/awscli/cli/ec2/reservedinstmng.rb +45 -0
- data/lib/awscli/cli/ec2/secgroups.rb +66 -0
- data/lib/awscli/cli/ec2/spot.rb +81 -0
- data/lib/awscli/cli/ec2/subnet.rb +43 -0
- data/lib/awscli/cli/ec2/tags.rb +45 -0
- data/lib/awscli/cli/ec2/vmmng.rb +17 -0
- data/lib/awscli/cli/ec2/vpc.rb +42 -0
- data/lib/awscli/cli/ec2/vpc/connections.rb +0 -0
- data/lib/awscli/cli/ec2/vpc/cust_gateways.rb +0 -0
- data/lib/awscli/cli/ec2/vpc/dhcp.rb +51 -0
- data/lib/awscli/cli/ec2/vpc/internet_gateways.rb +58 -0
- data/lib/awscli/cli/ec2/vpc/net_interfaces.rb +75 -0
- data/lib/awscli/cli/ec2/vpc/network_acls.rb +29 -0
- data/lib/awscli/cli/ec2/vpc/priv_gatewats.rb +0 -0
- data/lib/awscli/cli/ec2/vpc/route_tables.rb +0 -0
- data/lib/awscli/cli/s3.rb +12 -0
- data/lib/awscli/cli/s3/directories.rb +82 -0
- data/lib/awscli/cli/s3/files.rb +77 -0
- data/lib/awscli/connection.rb +55 -0
- data/lib/awscli/ec2.rb +821 -0
- data/lib/awscli/errors.rb +64 -0
- data/lib/awscli/helper.rb +8 -0
- data/lib/awscli/s3.rb +108 -0
- data/lib/awscli/version.rb +3 -0
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +59 -4
@@ -0,0 +1,56 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class Eip < Thor
|
6
|
+
|
7
|
+
desc "list", "List Elastic IPs"
|
8
|
+
def list
|
9
|
+
puts "Listing EIPs"
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.list
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "create", "Create Elastic IP"
|
15
|
+
def create
|
16
|
+
create_ec2_object
|
17
|
+
@ec2.create
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "delete", "Delete Elastic IP"
|
21
|
+
method_option :eip, :aliases => "-e", :required => true, :banner => "IP", :type => :string, :desc => "Elastic IP to delete"
|
22
|
+
def delete
|
23
|
+
create_ec2_object
|
24
|
+
@ec2.delete options
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "associate", "Associate EIP with an Instance"
|
28
|
+
method_option :eip, :aliases => "-e", :required => true, :banner => "IP", :type => :string, :desc => "Elastic IP to associate"
|
29
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :type => :string, :desc => "Instance ID to which to associate EIP"
|
30
|
+
def associate
|
31
|
+
create_ec2_object
|
32
|
+
@ec2.associate options
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "disassociate", "Disassociate EIP from an instance"
|
36
|
+
method_option :eip, :aliases => "-e", :required => true, :banner => "IP", :type => :string, :desc => "Elastic IP to disassociate"
|
37
|
+
def disassociate
|
38
|
+
create_ec2_object
|
39
|
+
@ec2.disassociate options
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def create_ec2_object
|
45
|
+
puts "ec2 Establishing Connetion..."
|
46
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
47
|
+
puts "ec2 Establishing Connetion... OK"
|
48
|
+
@ec2 = Awscli::EC2::Eip.new($ec2_conn)
|
49
|
+
end
|
50
|
+
|
51
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Eip, :eip, 'eip [COMMAND]', 'EC2 EIP Management'
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class Instances < Thor
|
6
|
+
|
7
|
+
# default_task :list
|
8
|
+
|
9
|
+
desc "list", "ec2_describe_instances"
|
10
|
+
long_desc <<-LONGDESC
|
11
|
+
List and describe your instances
|
12
|
+
The INSTANCE parameter is the instance ID(s) to describe.
|
13
|
+
If unspecified all your instances will be returned.
|
14
|
+
LONGDESC
|
15
|
+
def list
|
16
|
+
puts "Listing Instances"
|
17
|
+
create_ec2_object
|
18
|
+
# puts parent_options #access awscli/cli/ec2.rb class options
|
19
|
+
@ec2.list_instances
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "diatt", "ec2_describe_instance_attribute"
|
23
|
+
long_desc <<-LONGDESC
|
24
|
+
Describes the specified attribute of the specified instance. You can specify only one attribute at a time.
|
25
|
+
\x5
|
26
|
+
Available Attributes to Request:
|
27
|
+
architecture ami_launch_index availability_zone block_device_mapping network_interfaces client_token
|
28
|
+
dns_name ebs_optimized groups flavor_id iam_instance_profile image_id instance_initiated_shutdown_behavior
|
29
|
+
kernel_id key_name created_at monitoring placement_group platform private_dns_name private_ip_address
|
30
|
+
public_ip_address ramdisk_id root_device_name root_device_type security_group_ids state state_reason subnet_id
|
31
|
+
tenancy tags user_data vpc_id volumes username
|
32
|
+
LONGDESC
|
33
|
+
method_option :id, :aliases => "-i", :banner => "INSTANCEID", :type => :string, :desc => "Id of an instance to modify attribute", :required => true
|
34
|
+
method_option :attr, :aliases => "-a", :banner => "ATTR", :type => :string, :desc => "Attribute to modify", :required => true
|
35
|
+
def diatt
|
36
|
+
create_ec2_object
|
37
|
+
@ec2.describe_instance_attribute(options[:id], options[:attr])
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
desc "miatt", "ec2_modify_instance_attribute"
|
42
|
+
long_desc <<-LONGDESC
|
43
|
+
Modifies an instance attribute. Only one attribute can be specified per call.
|
44
|
+
LONGDESC
|
45
|
+
method_option :id, :aliases => "-i", :banner => "INSTANCEID", :type => :string, :desc => "Id of an instance to modify attribute", :required => true
|
46
|
+
method_option :isize, :aliases => "-t", :banner => "VALUE", :type => :string, :desc => "Changes the instance type to the specified value."
|
47
|
+
method_option :kernel, :aliases => "-k", :banner => "VALUE", :type => :string, :desc => "Changes the instance's kernel to the specified value"
|
48
|
+
method_option :ramdisk, :aliases => "-r", :banner => "VALUE", :type => :string, :desc => "Changes the instance's RAM disk to the specified value"
|
49
|
+
method_option :userdata, :aliases => "-u", :banner => "VALUE", :type => :string, :desc => "Changes the instance's user data to the specified value"
|
50
|
+
method_option :disable_api_term, :aliases => "-d", :banner => "true|false" , :type => :string, :desc => "Changes the instance's DisableApiTermination flag to the specified value. Setting this flag means you can't terminate the instance using the API"
|
51
|
+
method_option :inst_shutdown_beh, :aliases => "-s", :banner => "stop|terminate", :type => :string, :desc => "Changes the instance's InstanceInitiatedShutdownBehavior flag to the specified value."
|
52
|
+
method_option :source_dest_check, :aliases => "-c", :banner => "true|false" , :type => :string, :desc => "This attribute exists to enable a Network Address Translation (NAT) instance in a VPC to perform NAT. The attribute controls whether source/destination checking is enabled on the instance. A value of true means checking is enabled, and false means checking is disabled"
|
53
|
+
method_option :group_id, :aliases => "-g", :banner => "G1, G2, ..", :type => :array, :desc => "This attribute is applicable only to instances running in a VPC. Use this parameter when you want to change the security groups that an instance is in."
|
54
|
+
def miatt
|
55
|
+
create_ec2_object
|
56
|
+
opts = Marshal.load(Marshal.dump(options)) #create a copy of options, as original options hash cannot be modified
|
57
|
+
opts.reject!{ |k| k == 'id' } #remove id from opts
|
58
|
+
abort "Please pass an attribute by setting respective option" unless opts
|
59
|
+
abort "You can only pass one attribute at a time" if opts.size != 1
|
60
|
+
opts.each do |k,v|
|
61
|
+
puts "calling modify_instance_attribute with: #{options[:id]}, #{k}, #{opts[k]}"
|
62
|
+
@ec2.modify_instance_attribute(options[:id], k, opts[k])
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "riatt", "ec2_reset_instance_attribute"
|
68
|
+
long_desc <<-LONGDESC
|
69
|
+
Resets an instance attribute to its initial value. Only one attribute can be specified per call.
|
70
|
+
LONGDESC
|
71
|
+
def riatt
|
72
|
+
puts "Not yet Implemented"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "dins", "ec2_describe_instance_status"
|
76
|
+
long_desc <<-LONGDESC
|
77
|
+
Describe the status for one or more instances.
|
78
|
+
Checks are performed on your instances to determine if they are
|
79
|
+
in running order or not. Use this command to see the result of these
|
80
|
+
instance checks so that you can take remedial action if possible.
|
81
|
+
|
82
|
+
There are two types of checks performed: INSTANCE and SYSTEM.
|
83
|
+
INSTANCE checks examine the health and reachability of the
|
84
|
+
application environment. SYSTEM checks examine the health of
|
85
|
+
the infrastructure surrounding your instance.
|
86
|
+
LONGDESC
|
87
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
|
88
|
+
def dins
|
89
|
+
create_ec2_object
|
90
|
+
@ec2.describe_instance_status options[:instance_id]
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "import", "ec2_import_instance"
|
94
|
+
long_desc <<-LONGDESC
|
95
|
+
Create an import instance task to import a virtual machine into EC2
|
96
|
+
using meta_data from the given disk image. The volume size for the
|
97
|
+
imported disk_image will be calculated automatically, unless specified.
|
98
|
+
LONGDESC
|
99
|
+
def import
|
100
|
+
puts "Cannot find it in the *FOG*"
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "reboot", "ec2_reboot_instances"
|
104
|
+
long_desc <<-LONGDESC
|
105
|
+
Reboot selected running instances.
|
106
|
+
The INSTANCE parameter is an instance ID to reboot.
|
107
|
+
LONGDESC
|
108
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
|
109
|
+
def reboot
|
110
|
+
create_ec2_object
|
111
|
+
@ec2.reboot_instance options[:instance_id]
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "create", "ec2_run_instances"
|
115
|
+
long_desc <<-LONGDESC
|
116
|
+
Launch an instance of a specified AMI.
|
117
|
+
|
118
|
+
Usage Examples:
|
119
|
+
|
120
|
+
`awscli ec2 instances create -i ami-b63210f3 -k ruby-sample-1363113606 -b "/dev/sdb=ephemeral10" "/dev/sdc=snap-xxxxx::false::"`
|
121
|
+
|
122
|
+
`awscli ec2 instances create -i ami-b63210f3 -k ruby-sample-1363113606 -b "/dev/sdb=ephemeral10" "/dev/sdc=:10:false::"`
|
123
|
+
|
124
|
+
Block Device Mapping Format:
|
125
|
+
This argument is passed in the form of <devicename>=<blockdevice>. The devicename is the device name of the physical device on the instance to map. The blockdevice can be one of the following values:
|
126
|
+
|
127
|
+
none - supportsesses an existing mapping of the device from the AMI used to launch the instance. For example: "/dev/sdc=none"
|
128
|
+
|
129
|
+
ephemeral[0..3] - An instance store volume to be mapped to the device. For example: "/dev/sdc=ephemeral0"
|
130
|
+
|
131
|
+
[snapshot-id]:[volume-size]:[true|false]:[standard|io1[:iops]] - An EBS volume to be mapped to the device.
|
132
|
+
[snapshot-id] To create a volume from a snapshot, specify the snapshot ID.
|
133
|
+
[volume-size] To create an empty EBS volume, omit the snapshot ID and specify a volume size instead.
|
134
|
+
For example: "/dev/sdh=:20".
|
135
|
+
[delete-on-termination] To prevent the volume from being deleted on termination of the instance, specify false.
|
136
|
+
The default is true.
|
137
|
+
[volume-type] To create a Provisioned IOPS volume, specify io1. The default volume type is standard.
|
138
|
+
If the volume type is io1, you can also provision the number of IOPS that the volume supports.
|
139
|
+
For example, "/dev/sdh=snap-7eb96d16::false:io1:500"
|
140
|
+
LONGDESC
|
141
|
+
method_option :image_id, :aliases => "-i", :required => true, :banner => "AMIID", :type => :string, :desc => "Id of machine image to load on instances"
|
142
|
+
method_option :availability_zone, :banner => "ZONE", :type => :string, :desc => "Placement constraint for instances"
|
143
|
+
method_option :placement_group, :banner => "GROUP", :type => :string, :desc => "Name of existing placement group to launch instance into"
|
144
|
+
method_option :tenancy, :banner => "TENANCY", :type => :string, :desc => "Tenancy option in ['dedicated', 'default'], defaults to 'default'"
|
145
|
+
method_option :block_device_mapping, :aliases => "-b", :type => :array , :desc => "<devicename>=<blockdeveice>, see help for how to pass values"
|
146
|
+
method_option :client_token, :type => :string, :desc => "unique case-sensitive token for ensuring idempotency"
|
147
|
+
method_option :groups, :aliases => "-g", :banner => "SG1 SG2 SG3",:type => :array, :default => ["default"], :desc => "Name of security group(s) for instances (not supported for VPC). Default: 'default'"
|
148
|
+
method_option :flavor_id, :aliases => "-t",:type => :string, :default => "m1.small", :desc => "Type of instance to boot."
|
149
|
+
method_option :kernel_id, :type => :string, :desc => "Id of kernel with which to launch"
|
150
|
+
method_option :key_name, :aliases => "-k", :required => true, :type => :string, :desc => "Name of a keypair to add to booting instances"
|
151
|
+
method_option :monitoring, :type => :boolean, :default => false, :desc => "Enables monitoring, defaults to false"
|
152
|
+
method_option :ramdisk_id, :type => :string, :desc => "Id of ramdisk with which to launch"
|
153
|
+
method_option :subnet_id, :type => :string, :desc => "VPC option to specify subnet to launch instance into"
|
154
|
+
method_option :user_data, :type => :string, :desc => "Additional data to provide to booting instances"
|
155
|
+
method_option :ebs_optimized, :type => :boolean, :default => false, :desc => "Whether the instance is optimized for EBS I/O"
|
156
|
+
method_option :vpc_id, :type => :string, :desc => "VPC to connect to"
|
157
|
+
method_option :tags, :type => :hash, :default => {'Name' => "awscli-#{Time.now.to_i}"}, :desc => "Tags to identify server"
|
158
|
+
method_option :private_ip_address, :banner => "IP",:type => :string, :desc => "VPC option to specify ip address within subnet"
|
159
|
+
method_option :wait_for, :aliases => "-w", :type => :boolean, :default => false, :desc => "wait for the server to get created and return public_dns"
|
160
|
+
def create
|
161
|
+
create_ec2_object
|
162
|
+
@ec2.create_instance options
|
163
|
+
end
|
164
|
+
|
165
|
+
desc "start", "ec2_start_instances"
|
166
|
+
long_desc <<-LONGDESC
|
167
|
+
Start selected running instances.
|
168
|
+
LONGDESC
|
169
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
|
170
|
+
def start
|
171
|
+
create_ec2_object
|
172
|
+
@ec2.start_instance options[:instance_id]
|
173
|
+
end
|
174
|
+
|
175
|
+
desc "stop", "ec2_stop_instances"
|
176
|
+
long_desc <<-LONGDESC
|
177
|
+
Stop selected running instances.
|
178
|
+
LONGDESC
|
179
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
|
180
|
+
def stop
|
181
|
+
create_ec2_object
|
182
|
+
@ec2.stop_instance options[:instance_id]
|
183
|
+
end
|
184
|
+
|
185
|
+
desc "kill", "ec2_terminate_instances"
|
186
|
+
long_desc <<-LONGDESC
|
187
|
+
Terminate selected running instances
|
188
|
+
LONGDESC
|
189
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
|
190
|
+
def terminate
|
191
|
+
create_ec2_object
|
192
|
+
@ec2.terminate_instance options[:instance_id]
|
193
|
+
end
|
194
|
+
|
195
|
+
desc "console_output", "Retrieve console output for specified instance"
|
196
|
+
method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id to get console output from"
|
197
|
+
def console_output
|
198
|
+
create_ec2_object
|
199
|
+
@ec2.get_console_output options[:instance_id]
|
200
|
+
end
|
201
|
+
|
202
|
+
private
|
203
|
+
|
204
|
+
def create_ec2_object
|
205
|
+
puts "ec2 Establishing Connetion..."
|
206
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
207
|
+
puts "ec2 Establishing Connetion... OK"
|
208
|
+
@ec2 = Awscli::EC2::EC2.new($ec2_conn)
|
209
|
+
end
|
210
|
+
|
211
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Instances, :instances, 'instances [COMMAND]', 'EC2 Instance Management'
|
212
|
+
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class KeyPairs < Thor
|
6
|
+
|
7
|
+
desc "list", "List Key Pairs"
|
8
|
+
def list
|
9
|
+
puts "Listing Key Pairs"
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.list_keypairs
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "create", "Create Key Pair"
|
15
|
+
method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to create"
|
16
|
+
method_option :fingerprint, :type => :string, :desc => "Fingerprint for the key(optional)"
|
17
|
+
method_option :private_key, :type => :string, :desc => "Private Key for the key(optional)"
|
18
|
+
def create
|
19
|
+
create_ec2_object
|
20
|
+
@ec2.create_keypair options
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "delete", "Delete Key Pair"
|
24
|
+
method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to delete"
|
25
|
+
def delete
|
26
|
+
create_ec2_object
|
27
|
+
@ec2.delete_keypair options[:name]
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "fingerprint", "Describe Key Fingerprint"
|
31
|
+
method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to delete"
|
32
|
+
def fingerprint
|
33
|
+
create_ec2_object
|
34
|
+
@ec2.fingerprint options[:name]
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "import", "Imports an Key Pair"
|
38
|
+
method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to import"
|
39
|
+
method_option :private_key_path, :aliases => "-p", :banner => "PATH", :type => :string, :desc => "Optionally pass private key path, by default tries to retrieve from user ~/.ssh dir"
|
40
|
+
method_option :public_key_path, :aliases => "-k", :banner => "PATH", :type => :string, :desc => "Optionally pass public key path, by default tries to retrieve from user ~/.ssh dir"
|
41
|
+
def import
|
42
|
+
create_ec2_object
|
43
|
+
@ec2.import_keypair options
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def create_ec2_object
|
49
|
+
puts "ec2 Establishing Connetion..."
|
50
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
51
|
+
puts "ec2 Establishing Connetion... OK"
|
52
|
+
@ec2 = Awscli::EC2::KeyPairs.new($ec2_conn)
|
53
|
+
end
|
54
|
+
|
55
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::KeyPairs, :kp, 'kp [COMMAND]', 'EC2 Key Pair Management'
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class MonitoringInstances < Thor
|
6
|
+
|
7
|
+
desc "monitor", "Monitor specified instance(s)"
|
8
|
+
method_option :instance_ids, :aliases => "-i", :type => :array, :required => true, :desc => "Instances Ids to monitor"
|
9
|
+
def monitor
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.monitor options
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "unmonitor", "UnMonitor specified instance(s)"
|
15
|
+
method_option :instance_ids, :aliases => "-i", :type => :array, :required => true, :desc => "Instances Ids to monitor"
|
16
|
+
def unmonitor
|
17
|
+
create_ec2_object
|
18
|
+
@ec2.unmonitor options
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def create_ec2_object
|
24
|
+
puts "ec2 Establishing Connetion..."
|
25
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
26
|
+
puts "ec2 Establishing Connetion... OK"
|
27
|
+
@ec2 = Awscli::EC2::Monitoring.new($ec2_conn)
|
28
|
+
end
|
29
|
+
|
30
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::MonitoringInstances, :mont, 'mont [COMMAND]', 'EC2 Instances Monitoring Management'
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class Placement < Thor
|
6
|
+
|
7
|
+
desc "list", "List Placement Groups"
|
8
|
+
def list
|
9
|
+
create_ec2_object
|
10
|
+
@ec2.list
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "create", "Create a new placement group"
|
14
|
+
method_option :name, :aliases => "-n", :required => true, :type => :string, :desc => "Name of the placement group"
|
15
|
+
method_option :strategy, :aliases => "-s", :type => :string, :default => "cluster", :desc => "Placement group strategy. Valid options in ['cluster']"
|
16
|
+
def create
|
17
|
+
create_ec2_object
|
18
|
+
@ec2.create options
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "delete", "Delete a placement group that you own"
|
22
|
+
method_option :name, :aliases => "-n", :required => true, :type => :string, :desc => "Name of the placement group"
|
23
|
+
def delete
|
24
|
+
create_ec2_object
|
25
|
+
@ec2.delete options
|
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::Placement.new($ec2_conn)
|
35
|
+
end
|
36
|
+
|
37
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Placement, :place, 'place [COMMAND]', 'EC2 Placement Management'
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class ReservedInstances < Thor
|
6
|
+
|
7
|
+
desc "list", "List ReservedInstances"
|
8
|
+
#TODO add filters
|
9
|
+
method_option :filters, :aliases => "-f", :type => :hash, :desc => "List of filters to limit results with"
|
10
|
+
method_option :offerings, :aliases => "-o", :type => :boolean, :default => false, :desc => "Describe all or specified reserved instances offerings"
|
11
|
+
method_option :list_filters, :aliases => "-l", :type => :boolean, :default => false, :desc => "List availble filters that you can be used to limit results"
|
12
|
+
def list
|
13
|
+
create_ec2_object
|
14
|
+
if options[:offerings]
|
15
|
+
@ec2.list_offerings options[:filters]
|
16
|
+
elsif options[:list_filters]
|
17
|
+
@ec2.list_filters
|
18
|
+
else
|
19
|
+
@ec2.list options[:filters]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "purchase", "Purchases a Reserved Instance for use with your account"
|
24
|
+
method_option :reserved_instances_offering_id, :aliases => "-i", :type => :string, :desc => "ID of the Reserved Instance offering you want to purchase"
|
25
|
+
method_option :instance_count, :aliases => "-c", :type => :numeric, :default => 1, :desc => "The number of Reserved Instances to purchase"
|
26
|
+
def purchase
|
27
|
+
create_ec2_object
|
28
|
+
@ec2.purchase 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::ReservedInstances.new($ec2_conn)
|
38
|
+
end
|
39
|
+
|
40
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::ReservedInstances, :resv, 'resv [COMMAND]', 'EC2 ReservedInstances Management'
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|