awscli 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDhhZmFjMTRjYTY4Njk1MDgzYzI0YTZjZDk2MTQzNjZlM2Q2NGQzNA==
4
+ OTcyN2Y4NWIzYTAzYzliZjVkNmEzMWUyZmRlYTE2ZmI5YTdhMGYwOQ==
5
5
  data.tar.gz: !binary |-
6
- OTI5ZDJkOWE3OTYyNGJmNzA2ZjM1NzMzOTZkNzYyNzI0OGVmY2Q4NA==
6
+ MGI5NDViZmVmNzVlNjRhYTUxODE2YjI0MTk5ZDY0ZDI4MDhhMzlhMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzY5MTI3NmU3NmMyMDdmYTIzMzNlOTQ5NWM5Mjc2YWJkODE5YjNlMmYzOTdl
10
- OTI2NGI2NDdjMGU5YmFiNGM1ZTU4MjA2YjRlOTkzODUzNTllZjQ4ZDdkMDQ1
11
- MGE3ZmU0MmM2OTZhOGQyYTM0OWM1OGFmZDJlZDQ5MGRkNmYzZWQ=
9
+ YTMyMmRhY2M4ZDBhMTA5MzViNmU3MzA2ODkzZjA1NzEwZTZlODU0YjhiOTQ3
10
+ NjYzOWMzNTA0MWJkMmQzMjdlM2NiMWIwYWJhNzZjMDAyMjMwODM5MDhlZGMx
11
+ MGYzZDZiNGY2Y2JiODU0NGEwZDA1NGNlYmFkNWNkYTE5ZjUxNmQ=
12
12
  data.tar.gz: !binary |-
13
- N2NhYzE1ZWI4MTg4YmUzZDczYmI2NGFhMDYyYjZmYjk4Nzg4ODMwODdiZGUw
14
- MjA2OTNlOGUxODI0ZTA5YzNlY2NmZjQ4NGMxNzZhMWY1YmRlZDhkYTgzZTVk
15
- YmE0N2ZhMmJjYjM3ZTVjMWEzMTBlOGY5YzY4MTY4YzNkOWMzY2M=
13
+ OGFlNzQ3MGI2YjA1NmUwMjQ1NjUwNjIxYWEwYjdhYzJlN2QzMzU3MzU2MzA2
14
+ MTIxYWI1ZTM1YmIzZGNjNGM5MGFjN2RiMzIyZGU5MWQ0MDhjZDkzZTA1MDhh
15
+ NzYwY2RhMTM5MGRiMTQ3Y2Q5MjBkY2QyYTk0MTI4MDJlZDFhZDY=
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Ashrith Mekala
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ awscli
2
+ ======
3
+
4
+ Amazon Web Service Command Line Interface
5
+
6
+ Provides support for following interface:
7
+
8
+ - Elastic Cloud Compute (EC2)
9
+ - Auto Scaling Group (AS)
10
+ - Simple Storage Service (S3)
11
+
12
+ More interfaces are in development.
13
+
14
+
15
+ To Install Use:
16
+
17
+ `gem install awscli`
18
+
19
+ For help using cli:
20
+
21
+ `awscli help`
22
+
23
+ For help on individual Interfaces:
24
+
25
+ ```
26
+ $ awscli <interface> help
27
+ ```
28
+
29
+ Licence:
30
+
31
+ `awscli` is released under the terms of the MIT License, see the included LICENSE file.
@@ -4,19 +4,8 @@ module AwsCli
4
4
  require 'awscli/connection'
5
5
  require 'awscli/ec2'
6
6
  class Ec2 < Thor
7
-
8
7
  class_option :region, :type => :string, :desc => "region to connect to", :default => 'us-west-1'
9
8
 
10
- private
11
-
12
- def create_ec2_object
13
- puts "ec2 Establishing Connetion..."
14
- $ec2_conn = Awscli::Connection.new.request_ec2
15
- puts $ec2_conn
16
- puts "ec2 Establishing Connetion... OK"
17
- @ec2 = Awscli::EC2::EC2.new($ec2_conn)
18
- end
19
-
20
9
  AwsCli::Cli.register AwsCli::CLI::Ec2, :ec2, 'ec2 [COMMAND]', 'Elastic Cloud Compute Interface'
21
10
  end
22
11
  end
@@ -33,7 +33,11 @@ module AwsCli
33
33
 
34
34
  def create_ec2_object
35
35
  puts "ec2 Establishing Connetion..."
36
- $ec2_conn = Awscli::Connection.new.request_ec2
36
+ $ec2_conn = if parent_options[:region]
37
+ Awscli::Connection.new.request_ec2(parent_options[:region])
38
+ else
39
+ Awscli::Connection.new.request_ec2
40
+ end
37
41
  puts "ec2 Establishing Connetion... OK"
38
42
  @ec2 = Awscli::EC2::Ami.new($ec2_conn)
39
43
  end
@@ -46,6 +46,15 @@ module AwsCli
46
46
  @ec2.delete_volume options
47
47
  end
48
48
 
49
+ desc "delete_detached", "Delete all the volumes that are not in use"
50
+ def delete_detached
51
+ if agree("Are you sure want to delete all the all volumes that are not in use ? ")
52
+ puts
53
+ create_ec2_object
54
+ @ec2.delete_detached
55
+ end
56
+ end
57
+
49
58
  desc "create_snapshot", "Create a snapshot from volume"
50
59
  method_option :volume_id, :aliases => "-v", :banner => "VID", :required => true, :type => :string, :desc => "volume to make a snapshot from"
51
60
  def create_snapshot
@@ -72,7 +81,11 @@ module AwsCli
72
81
 
73
82
  def create_ec2_object
74
83
  puts "ec2 Establishing Connetion..."
75
- $ec2_conn = Awscli::Connection.new.request_ec2
84
+ $ec2_conn = if parent_options[:region]
85
+ Awscli::Connection.new.request_ec2(parent_options[:region])
86
+ else
87
+ Awscli::Connection.new.request_ec2
88
+ end
76
89
  puts "ec2 Establishing Connetion... OK"
77
90
  @ec2 = Awscli::EC2::Ebs.new($ec2_conn)
78
91
  end
@@ -43,7 +43,11 @@ module AwsCli
43
43
 
44
44
  def create_ec2_object
45
45
  puts "ec2 Establishing Connetion..."
46
- $ec2_conn = Awscli::Connection.new.request_ec2
46
+ $ec2_conn = if parent_options[:region]
47
+ Awscli::Connection.new.request_ec2(parent_options[:region])
48
+ else
49
+ Awscli::Connection.new.request_ec2
50
+ end
47
51
  puts "ec2 Establishing Connetion... OK"
48
52
  @ec2 = Awscli::EC2::Eip.new($ec2_conn)
49
53
  end
@@ -6,7 +6,7 @@ module AwsCli
6
6
 
7
7
  # default_task :list
8
8
 
9
- desc "list", "lise the instances"
9
+ desc "list", "list the instances"
10
10
  long_desc <<-LONGDESC
11
11
  List and describe your instances
12
12
  The INSTANCE parameter is the instance ID(s) to describe.
@@ -72,7 +72,7 @@ module AwsCli
72
72
  puts "Not yet Implemented"
73
73
  end
74
74
 
75
- desc "dins", "ec2_describe_instance_status"
75
+ desc "dins", "describe instance status"
76
76
  long_desc <<-LONGDESC
77
77
  Describe the status for one or more instances.
78
78
  Checks are performed on your instances to determine if they are
@@ -203,7 +203,11 @@ module AwsCli
203
203
 
204
204
  def create_ec2_object
205
205
  puts "ec2 Establishing Connetion..."
206
- $ec2_conn = Awscli::Connection.new.request_ec2
206
+ $ec2_conn = if parent_options[:region]
207
+ Awscli::Connection.new.request_ec2(parent_options[:region])
208
+ else
209
+ Awscli::Connection.new.request_ec2
210
+ end
207
211
  puts "ec2 Establishing Connetion... OK"
208
212
  @ec2 = Awscli::EC2::EC2.new($ec2_conn)
209
213
  end
@@ -47,7 +47,11 @@ module AwsCli
47
47
 
48
48
  def create_ec2_object
49
49
  puts "ec2 Establishing Connetion..."
50
- $ec2_conn = Awscli::Connection.new.request_ec2
50
+ $ec2_conn = if parent_options[:region]
51
+ Awscli::Connection.new.request_ec2(parent_options[:region])
52
+ else
53
+ Awscli::Connection.new.request_ec2
54
+ end
51
55
  puts "ec2 Establishing Connetion... OK"
52
56
  @ec2 = Awscli::EC2::KeyPairs.new($ec2_conn)
53
57
  end
@@ -22,7 +22,11 @@ module AwsCli
22
22
 
23
23
  def create_ec2_object
24
24
  puts "ec2 Establishing Connetion..."
25
- $ec2_conn = Awscli::Connection.new.request_ec2
25
+ $ec2_conn = if parent_options[:region]
26
+ Awscli::Connection.new.request_ec2(parent_options[:region])
27
+ else
28
+ Awscli::Connection.new.request_ec2
29
+ end
26
30
  puts "ec2 Establishing Connetion... OK"
27
31
  @ec2 = Awscli::EC2::Monitoring.new($ec2_conn)
28
32
  end
@@ -29,7 +29,11 @@ module AwsCli
29
29
 
30
30
  def create_ec2_object
31
31
  puts "ec2 Establishing Connetion..."
32
- $ec2_conn = Awscli::Connection.new.request_ec2
32
+ $ec2_conn = if parent_options[:region]
33
+ Awscli::Connection.new.request_ec2(parent_options[:region])
34
+ else
35
+ Awscli::Connection.new.request_ec2
36
+ end
33
37
  puts "ec2 Establishing Connetion... OK"
34
38
  @ec2 = Awscli::EC2::Placement.new($ec2_conn)
35
39
  end
@@ -32,7 +32,11 @@ module AwsCli
32
32
 
33
33
  def create_ec2_object
34
34
  puts "ec2 Establishing Connetion..."
35
- $ec2_conn = Awscli::Connection.new.request_ec2
35
+ $ec2_conn = if parent_options[:region]
36
+ Awscli::Connection.new.request_ec2(parent_options[:region])
37
+ else
38
+ Awscli::Connection.new.request_ec2
39
+ end
36
40
  puts "ec2 Establishing Connetion... OK"
37
41
  @ec2 = Awscli::EC2::ReservedInstances.new($ec2_conn)
38
42
  end
@@ -53,7 +53,11 @@ module AwsCli
53
53
 
54
54
  def create_ec2_object
55
55
  puts "ec2 Establishing Connetion..."
56
- $ec2_conn = Awscli::Connection.new.request_ec2
56
+ $ec2_conn = if parent_options[:region]
57
+ Awscli::Connection.new.request_ec2(parent_options[:region])
58
+ else
59
+ Awscli::Connection.new.request_ec2
60
+ end
57
61
  puts "ec2 Establishing Connetion... OK"
58
62
  @ec2 = Awscli::EC2::SecGroups.new($ec2_conn)
59
63
  end
@@ -68,7 +68,11 @@ module AwsCli
68
68
 
69
69
  def create_ec2_object
70
70
  puts "ec2 Establishing Connetion..."
71
- $ec2_conn = Awscli::Connection.new.request_ec2
71
+ $ec2_conn = if parent_options[:region]
72
+ Awscli::Connection.new.request_ec2(parent_options[:region])
73
+ else
74
+ Awscli::Connection.new.request_ec2
75
+ end
72
76
  puts "ec2 Establishing Connetion... OK"
73
77
  @ec2 = Awscli::EC2::Spot.new($ec2_conn)
74
78
  end
@@ -30,7 +30,11 @@ module AwsCli
30
30
 
31
31
  def create_ec2_object
32
32
  puts "ec2 Establishing Connetion..."
33
- $ec2_conn = Awscli::Connection.new.request_ec2
33
+ $ec2_conn = if parent_options[:region]
34
+ Awscli::Connection.new.request_ec2(parent_options[:region])
35
+ else
36
+ Awscli::Connection.new.request_ec2
37
+ end
34
38
  puts "ec2 Establishing Connetion... OK"
35
39
  @ec2 = Awscli::EC2::Subnet.new($ec2_conn)
36
40
  end
@@ -32,7 +32,11 @@ module AwsCli
32
32
 
33
33
  def create_ec2_object
34
34
  puts "ec2 Establishing Connetion..."
35
- $ec2_conn = Awscli::Connection.new.request_ec2
35
+ $ec2_conn = if parent_options[:region]
36
+ Awscli::Connection.new.request_ec2(parent_options[:region])
37
+ else
38
+ Awscli::Connection.new.request_ec2
39
+ end
36
40
  puts "ec2 Establishing Connetion... OK"
37
41
  @ec2 = Awscli::EC2::Tags.new($ec2_conn)
38
42
  end
@@ -29,7 +29,11 @@ module AwsCli
29
29
 
30
30
  def create_ec2_object
31
31
  puts "ec2 Establishing Connetion..."
32
- $ec2_conn = Awscli::Connection.new.request_ec2
32
+ $ec2_conn = if parent_options[:region]
33
+ Awscli::Connection.new.request_ec2(parent_options[:region])
34
+ else
35
+ Awscli::Connection.new.request_ec2
36
+ end
33
37
  puts "ec2 Establishing Connetion... OK"
34
38
  @ec2 = Awscli::EC2::Vpc.new($ec2_conn)
35
39
  end
@@ -37,7 +37,11 @@ module AwsCli
37
37
 
38
38
  def create_ec2_object
39
39
  puts "ec2 Establishing Connetion..."
40
- $ec2_conn = Awscli::Connection.new.request_ec2
40
+ $ec2_conn = if parent_options[:region]
41
+ Awscli::Connection.new.request_ec2(parent_options[:region])
42
+ else
43
+ Awscli::Connection.new.request_ec2
44
+ end
41
45
  puts "ec2 Establishing Connetion... OK"
42
46
  @ec2 = Awscli::EC2::Dhcp.new($ec2_conn)
43
47
  end
@@ -44,7 +44,11 @@ module AwsCli
44
44
 
45
45
  def create_ec2_object
46
46
  puts "ec2 Establishing Connetion..."
47
- $ec2_conn = Awscli::Connection.new.request_ec2
47
+ $ec2_conn = if parent_options[:region]
48
+ Awscli::Connection.new.request_ec2(parent_options[:region])
49
+ else
50
+ Awscli::Connection.new.request_ec2
51
+ end
48
52
  puts "ec2 Establishing Connetion... OK"
49
53
  @ec2 = Awscli::EC2::InternetGateways.new($ec2_conn)
50
54
  end
@@ -61,7 +61,11 @@ module AwsCli
61
61
 
62
62
  def create_ec2_object
63
63
  puts "ec2 Establishing Connetion..."
64
- $ec2_conn = Awscli::Connection.new.request_ec2
64
+ $ec2_conn = if parent_options[:region]
65
+ Awscli::Connection.new.request_ec2(parent_options[:region])
66
+ else
67
+ Awscli::Connection.new.request_ec2
68
+ end
65
69
  puts "ec2 Establishing Connetion... OK"
66
70
  @ec2 = Awscli::EC2::NetworkInterfaces.new($ec2_conn)
67
71
  end
@@ -15,7 +15,11 @@ module AwsCli
15
15
 
16
16
  def create_ec2_object
17
17
  puts "ec2 Establishing Connetion..."
18
- $ec2_conn = Awscli::Connection.new.request_ec2
18
+ $ec2_conn = if parent_options[:region]
19
+ Awscli::Connection.new.request_ec2(parent_options[:region])
20
+ else
21
+ Awscli::Connection.new.request_ec2
22
+ end
19
23
  puts "ec2 Establishing Connetion... OK"
20
24
  @ec2 = Awscli::EC2::NetworkAcl.new($ec2_conn)
21
25
  end
@@ -36,7 +36,6 @@ module AwsCli
36
36
  @s3.delete_file options[:bucket_name], options[:file_name]
37
37
  end
38
38
 
39
- # s3.directories.get('arun123').files.get('block_9091299035346850259').copy('ashrithtst', 'testfile')
40
39
  desc "copy", "copy object from one bucket to another"
41
40
  method_option :source_bucket, :aliases => "-s", :required => true, :desc => "source bucket name from where to copy the file"
42
41
  method_option :source_file, :aliases => "-f", :required => true, :desc => "source file name to copy"
@@ -22,11 +22,18 @@ module Awscli
22
22
  end
23
23
  end
24
24
 
25
- def request_ec2
25
+ def request_ec2 region=nil
26
26
  # => returns AWS Compute connection object
27
27
  @@config.merge!(:provider => 'AWS')
28
- if @@config['region']
29
- Awscli::Errors.invalid_region unless Awscli::Instances::REGIONS.include?(@@config['region'])
28
+ if region
29
+ #if user passes a region optionally
30
+ Awscli::Errors.invalid_region unless Awscli::Instances::REGIONS.include?(region)
31
+ @@config.reject!{ |k| k == 'region' } if @@config['region']
32
+ @@config.merge!(:region => region)
33
+ else
34
+ if @@config['region']
35
+ Awscli::Errors.invalid_region unless Awscli::Instances::REGIONS.include?(@@config['region'])
36
+ end
30
37
  end
31
38
  Fog::Compute.new(@@config)
32
39
  end
@@ -482,6 +482,18 @@ module Awscli
482
482
  puts "Deleted volume: #{options[:volume_id]}"
483
483
  end
484
484
 
485
+ def delete_detached
486
+ vols = @@conn.volumes.all('status' => 'available')
487
+ unless vols.empty?
488
+ puts "Deleting all volumes which are not in use ..."
489
+ vols.each do |vol|
490
+ vol.destroy
491
+ end
492
+ else
493
+ puts "No volumes found, that are not in use found"
494
+ end
495
+ end
496
+
485
497
  def create_snapshot options
486
498
  abort "Cannot find volume: #{options[:volume_id]}" unless @@conn.volumes.get(options[:volume_id])
487
499
  @@conn.snapshots.create(options)
@@ -20,7 +20,7 @@ module Awscli
20
20
  def self.missing_environment_variable
21
21
  message = <<-ERRMSG1.gsub(/^ {8}/, '')
22
22
  Missing AWSCLI_CONFIG_FILE environment variable
23
- Please export the variable 'export AWSCLI_CONFIG_FILE="~/awscli_config.yml'
23
+ Please export the variable 'export AWSCLI_CONFIG_FILE="~/awscli_config.yml"'
24
24
  Contents of the file should be:
25
25
  #########################################
26
26
  #Aws Credentials
@@ -63,7 +63,7 @@ module Awscli
63
63
  end
64
64
 
65
65
  def self.invalid_region
66
- message = "Invalid region found in config file , Available Regions #{Awscli::Instances::REGIONS}"
66
+ message = "Invalid region found in config file (or) passed as an option , Available Regions are #{Awscli::Instances::REGIONS}"
67
67
  raise(Awscli::Errors::LoadError.new(message))
68
68
  end
69
69
 
@@ -1,3 +1,3 @@
1
1
  module Awscli
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awscli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashrith
@@ -147,14 +147,16 @@ files:
147
147
  - lib/awscli.rb
148
148
  - test/default_test.rb
149
149
  - test/test_helper.rb
150
- - README.rdoc
150
+ - README.md
151
+ - LICENSE
151
152
  - features/awscli.feature
152
153
  - features/step_definitions/awscli_steps.rb
153
154
  - features/support/env.rb
154
155
  homepage: http://github.com/ashrithr/awscli
155
- licenses: []
156
+ licenses:
157
+ - MIT
156
158
  metadata: {}
157
- post_install_message:
159
+ post_install_message: Thanks for installing!, This gem is still in development.
158
160
  rdoc_options:
159
161
  - --title
160
162
  - awscli
@@ -1,5 +0,0 @@
1
- = awscli
2
-
3
- Amazon Web Service Command Line Interface
4
-
5
- WIP