vagrant-awsinfo 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTYyOGEwNDE1NzZmMGVmZTJkYjQ3ZjJhZTg5NDU4Y2UxNmUwNmUxMA==
5
+ data.tar.gz: !binary |-
6
+ NDNkNDQ2ODI3MmE2ZTM5YTE3ODUzZTI0MzVhMDc3OGI2Mjg3ZmRlZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MzYxMTE5MDcyMDYwNDFlMjZhMWYyZDM1YWYyNWI1Yzc4ZDRiMzZmODY0Yzk3
10
+ M2QxZjc3MzU0ZWY0ZGY3YzYyZTM2NDIwZWZhMmZhMzEwMTEwMmY2ODRjNGIy
11
+ ZWE5ZWNjYTIyOGFhMWE1ZGQzZmU0MmI1OThjM2U2ZmRlNzQzZDY=
12
+ data.tar.gz: !binary |-
13
+ YjE0ZTIzODBkN2U1NTQ4NjdmZmMwN2NiNzE4MDRhMmFkNTg2ZWMwNzE5NTA2
14
+ ODQ2NDhmYTQ4MDE4OWFhOTAxYjQxNDQ5MTdkZDI1ZmZiYzJlZDczM2QwYTlh
15
+ YzZhYTQwYzcwOTEyM2E5ZTE3N2M2ZjBmNzFjZDAwYWQxODI3MjY=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  # 0.0.1
2
3
  * Initial Release
3
4
 
@@ -11,3 +12,8 @@
11
12
  # 0.0.4
12
13
 
13
14
  * Supports returning only a single value, such as "host", "instance_id", ect
15
+
16
+ # 0.0.5
17
+
18
+ * Much more meta data from running instance
19
+ * Pretty print mode
data/README.md CHANGED
@@ -25,6 +25,29 @@ ec2-174-129-128-49.compute-1.amazonaws.com
25
25
 
26
26
  % vagrant awsinfo -k host -m default
27
27
  ec2-174-129-128-49.compute-1.amazonaws.com
28
+
29
+ % vagrant awsinfo -k host -m default -p
30
+ {
31
+ "availability_zone": "us-east-1c",
32
+ "created_at": "2013-04-20T20:51:10Z",
33
+ "flavor": "m1.medium",
34
+ "host": "ec2-50-16-48-88.compute-1.amazonaws.com",
35
+ "public_ip": "50.16.48.88",
36
+ "private_ip": "10.151.111.73",
37
+ "private_dns_name": "ip-10-151-111-73.ec2.internal",
38
+ "tags": {
39
+ "Name": "Vagrant-PhonoGateway",
40
+ "OwnerHostname": "dyer.local",
41
+ "CreatedAt": "2013-04-20T 4:46:37",
42
+ "OwnerUsername": "jdyer"
43
+ },
44
+ "groups": [
45
+ "everything_open"
46
+ ],
47
+ "ssh_port": 22,
48
+ "instance_id": "i-28f14e43",
49
+ "state": "running"
50
+ }
28
51
  ```
29
52
 
30
53
  ## Contributing
@@ -1,8 +1,7 @@
1
1
  module VagrantAwsInfo
2
2
 
3
3
  class Command < Vagrant.plugin(2, :command)
4
-
5
- Settings = Struct.new(:machines,:keys)
4
+ Settings = Struct.new(:machines,:keys, :pretty)
6
5
 
7
6
  def execute
8
7
 
@@ -20,6 +19,10 @@ module VagrantAwsInfo
20
19
  o.on("-k KEY", "single value to return.") do |value|
21
20
  settings.keys = value
22
21
  end
22
+
23
+ o.on("-p", "Pretty print values.") do |value|
24
+ settings.pretty = true
25
+ end
23
26
  end
24
27
 
25
28
  settings.machines = ["default"] if settings.machines.empty?
@@ -36,25 +39,69 @@ module VagrantAwsInfo
36
39
  return 1
37
40
  end
38
41
  else
39
- @env.ui.info instance_info.to_json
42
+ if settings.pretty
43
+ jj instance_info
44
+ else
45
+ @env.ui.info instance_info.to_json
46
+ end
40
47
  end
41
48
 
42
49
  end
43
50
 
44
51
  private
45
52
 
53
+ def get_instance(machine)
54
+ env = machine.action("read_ssh_info")
55
+ region = env[:machine].provider_config.region
56
+
57
+ # Get the configs
58
+ region_config = env[:machine].provider_config.get_region_config(region)
59
+
60
+ # Build the fog config
61
+ fog_config = {
62
+ :provider => :aws,
63
+ :region => region
64
+ }
65
+
66
+ if region_config.use_iam_profile
67
+ fog_config[:use_iam_profile] = True
68
+ else
69
+ fog_config[:aws_access_key_id] = region_config.access_key_id
70
+ fog_config[:aws_secret_access_key] = region_config.secret_access_key
71
+ end
72
+
73
+ fog_config[:endpoint] = region_config.endpoint if region_config.endpoint
74
+ fog_config[:version] = region_config.version if region_config.version
75
+ env[:aws_compute] = Fog::Compute.new(fog_config)
76
+ return env
77
+ end
78
+
46
79
  def get_info(machine)
47
80
  with_target_vms(machine) do |machine|
48
81
  if machine.provider_name == :aws
49
- ssh_info = machine.provider.ssh_info
82
+ env = get_instance(machine)
83
+ instance = env[:aws_compute].servers.get(machine.id)
50
84
  r = {
51
- host: ssh_info[:host],
52
- ssh_port: ssh_info[:port],
53
- username: ssh_info[:username],
85
+ availability_zone: instance.availability_zone,
86
+ created_at: instance.created_at,
87
+ flavor: instance.flavor_id,
88
+ host: instance.dns_name,
89
+ public_ip: instance.public_ip_address,
90
+ private_ip: instance.private_ip_address,
91
+ private_dns_name: instance.private_dns_name,
92
+ tags: instance.tags,
93
+ security_groups: instance.groups,
94
+ ssh_port: env[:machine_ssh_info][:port],
54
95
  instance_id: machine.id,
55
- state: machine.provider.state.short_description,
96
+ image_id: instance.image_id,
97
+ state: machine.provider.state.short_description
56
98
  }
57
- return r
99
+
100
+ r.merge!(network_interfaces: instance.network_interfaces) unless instance.network_interfaces.empty?
101
+ r.merge!(subnet_id: instance.subnet_id) if instance.subnet_id
102
+ r.merge!(vpc_id: instance.vpc_id) if instance.vpc_id
103
+ return r
104
+
58
105
  else
59
106
  @env.ui.error "[WARNING] - Sorry this plugin currently only supports machines using the AWS provider"
60
107
  exit 1
@@ -1,3 +1,3 @@
1
1
  module VagrantAwsInfo
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["johntdyer@gmail.com"]
11
11
  spec.description = 'vagrant aws info querying plugin'
12
12
  spec.summary = spec.description
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/johntdyer/vagrant-awsinfo"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-awsinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Dyer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-17 00:00:00.000000000 Z
11
+ date: 2013-04-21 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: vagrant aws info querying plugin
15
14
  email:
@@ -29,29 +28,28 @@ files:
29
28
  - lib/vagrant-awsinfo/plugin.rb
30
29
  - lib/vagrant-awsinfo/version.rb
31
30
  - vagrant-awsinfo.gemspec
32
- homepage: ''
31
+ homepage: https://github.com/johntdyer/vagrant-awsinfo
33
32
  licenses:
34
33
  - MIT
34
+ metadata: {}
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
40
  requirements:
42
41
  - - ! '>='
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
44
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
45
  requirements:
48
46
  - - ! '>='
49
47
  - !ruby/object:Gem::Version
50
48
  version: '0'
51
49
  requirements: []
52
50
  rubyforge_project:
53
- rubygems_version: 1.8.23
51
+ rubygems_version: 2.0.3
54
52
  signing_key:
55
- specification_version: 3
53
+ specification_version: 4
56
54
  summary: vagrant aws info querying plugin
57
55
  test_files: []