vagrant-vrealize 0.0.4

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.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +16 -0
  3. data/LICENSE +55 -0
  4. data/README.md +132 -0
  5. data/Rakefile +29 -0
  6. data/example_box/README.md +13 -0
  7. data/example_box/Vagrantfile +7 -0
  8. data/example_box/metadata.json +3 -0
  9. data/example_box/mkbox.sh +3 -0
  10. data/example_box/vrealize.box +0 -0
  11. data/lib/vagrant-vrealize/action/connect_vrealize.rb +65 -0
  12. data/lib/vagrant-vrealize/action/is_created.rb +35 -0
  13. data/lib/vagrant-vrealize/action/is_stopped.rb +18 -0
  14. data/lib/vagrant-vrealize/action/message_already_created.rb +18 -0
  15. data/lib/vagrant-vrealize/action/message_not_created.rb +16 -0
  16. data/lib/vagrant-vrealize/action/message_will_not_destroy.rb +16 -0
  17. data/lib/vagrant-vrealize/action/read_ssh_info.rb +28 -0
  18. data/lib/vagrant-vrealize/action/read_state.rb +28 -0
  19. data/lib/vagrant-vrealize/action/run_instance.rb +111 -0
  20. data/lib/vagrant-vrealize/action/start_instance.rb +25 -0
  21. data/lib/vagrant-vrealize/action/stop_instance.rb +19 -0
  22. data/lib/vagrant-vrealize/action/terminate_instance.rb +23 -0
  23. data/lib/vagrant-vrealize/action/timed_provision.rb +21 -0
  24. data/lib/vagrant-vrealize/action/wait_for_state.rb +25 -0
  25. data/lib/vagrant-vrealize/action/warn_networks.rb +19 -0
  26. data/lib/vagrant-vrealize/action.rb +191 -0
  27. data/lib/vagrant-vrealize/config.rb +138 -0
  28. data/lib/vagrant-vrealize/errors.rb +32 -0
  29. data/lib/vagrant-vrealize/extra-entries.rb +46 -0
  30. data/lib/vagrant-vrealize/plugin.rb +73 -0
  31. data/lib/vagrant-vrealize/provider.rb +52 -0
  32. data/lib/vagrant-vrealize/util/timer.rb +17 -0
  33. data/lib/vagrant-vrealize/version.rb +5 -0
  34. data/lib/vagrant-vrealize/vra_client.rb +140 -0
  35. data/lib/vagrant-vrealize.rb +19 -0
  36. data/locales/en.yml +148 -0
  37. metadata +106 -0
@@ -0,0 +1,140 @@
1
+ require 'vra'
2
+
3
+ module VagrantPlugins
4
+ module Vrealize
5
+
6
+ class VraClient
7
+
8
+ def self.build(vra_params)
9
+ pagination_bugfix_params = {page_size: 100}.merge(vra_params)
10
+ new(Vra::Client.new(pagination_bugfix_params))
11
+ end
12
+
13
+
14
+ def initialize(client)
15
+ @client = client
16
+ end
17
+
18
+
19
+ def authorize!
20
+ @client.authorize!
21
+ end
22
+
23
+
24
+ def resources
25
+ @client.resources
26
+ end
27
+
28
+
29
+ def entitled_catalog_items
30
+ @client.catalog.entitled_items
31
+ end
32
+
33
+ def request(catalog_item_id,params)
34
+ req = @client.catalog.request(catalog_item_id, params)
35
+ yield req if block_given?
36
+ req.submit
37
+ end
38
+
39
+ def ssh_info(machine_id)
40
+ resource = @client.resources.by_id(machine_id)
41
+ host = resource.ip_addresses.first
42
+
43
+ {host: host, port: 22}
44
+ end
45
+
46
+ def destroy(machine_id)
47
+ resource = @client.resources.by_id(machine_id)
48
+ if resource
49
+ resource.destroy
50
+ end
51
+ end
52
+
53
+
54
+ end # class VraClient
55
+
56
+
57
+ class EntitledItemsCollection
58
+ def self.fetch(vra)
59
+ new(vra, vra.entitled_catalog_items)
60
+ end
61
+
62
+ def initialize(vra, entitled_items)
63
+ @vra = vra
64
+ @entitled_items = entitled_items
65
+ end
66
+
67
+ def find(&blk)
68
+ found_item = @entitled_items.find(&blk)
69
+ raise "No catalog item was found." unless found_item
70
+ CatalogRequest.new(@vra, found_item.id)
71
+ end
72
+
73
+ def find_by_name(name)
74
+ find{|item| item.name == name}
75
+ end
76
+
77
+ def find_by_id(id)
78
+ find{|item| item.id == id}
79
+ end
80
+ end
81
+
82
+ class CatalogRequest
83
+ def initialize(vra, catalog_item_id)
84
+ @vra = vra
85
+ @catalog_item_id = catalog_item_id
86
+ end
87
+
88
+ def request(params, &blk)
89
+ new_item_request = @vra.request(@catalog_item_id, params) { |cat_req|
90
+ yield cat_req if blk
91
+ }
92
+ SubmittedItemRequest.new(@vra, new_item_request)
93
+ end
94
+ end
95
+
96
+ class SubmittedItemRequest
97
+ def initialize(vra, request)
98
+ @vra = vra
99
+ @request = request
100
+ end
101
+
102
+ def machine
103
+ if done?
104
+ @request.resources.first
105
+ end
106
+ end
107
+
108
+ def join
109
+ while !done?
110
+ fail "Creating the machine failed: #{@request.status}" if failed?
111
+ sleep 5
112
+ end
113
+ self
114
+ end
115
+
116
+ OkStates = %w{
117
+ SUCCESSFUL
118
+ IN_PROGRESS
119
+ PENDING_PRE_APPROVAL
120
+ PENDING_POST_APPROVAL
121
+ }
122
+
123
+ private
124
+ def done?
125
+ begin
126
+ @request.refresh # TODO - this can except if Service Temporarily Unavailable
127
+ @request.status == "SUCCESSFUL"
128
+ end
129
+ end
130
+
131
+ def failed?
132
+ @request.refresh
133
+ !OkStates.include?(@request.status)
134
+ end
135
+
136
+ end
137
+
138
+
139
+ end
140
+ end
@@ -0,0 +1,19 @@
1
+ require "pathname"
2
+
3
+ require 'vagrant-vrealize/plugin'
4
+
5
+ module VagrantPlugins
6
+ module Vrealize
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-vrealize", __FILE__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
+ end
17
+
18
+ end
19
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,148 @@
1
+ en:
2
+ vagrant_vrealize:
3
+ already_status: |-
4
+ The machine is already %{status}.
5
+ burning_ami: |-
6
+ Waiting for the AMI '%{ami_id}' to burn...
7
+ elb:
8
+ adjusting: |-
9
+ Adjusting availability zones of ELB %{elb_name}...
10
+ registering: |-
11
+ Registering %{instance_id} at ELB %{elb_name}...
12
+ deregistering: |-
13
+ Deregistering %{instance_id} from ELB %{elb_name}...
14
+ ok: |-
15
+ ok
16
+ skipped: |-
17
+ skipped
18
+
19
+ launching_instance: |-
20
+ Launching an instance with the following settings...
21
+ launch_no_keypair: |-
22
+ Warning! You didn't specify a keypair to launch your instance with.
23
+ This can sometimes result in not being able to access your instance.
24
+ launch_vpc_warning: |-
25
+ Warning! You're launching this instance into a VPC without an
26
+ elastic IP. Please verify you're properly connected to a VPN so
27
+ you can access this machine, otherwise Vagrant will not be able
28
+ to SSH into it.
29
+ not_created: |-
30
+ Instance is not created. Please run `vagrant up` first.
31
+ packaging_instance: |-
32
+ Burning instance %{instance_id} into an ami
33
+ packaging_instance_complete: |-
34
+ Burn was successful in %{time_seconds}s
35
+ ready: |-
36
+ Machine is booted and ready for use!
37
+ rsync_not_found_warning: |-
38
+ Warning! Folder sync disabled because the rsync binary is missing in the %{side}.
39
+ Make sure rsync is installed and the binary can be found in the PATH.
40
+ rsync_folder: |-
41
+ Rsyncing folder: %{hostpath} => %{guestpath}
42
+ source_dest_checks_no_vpc: |-
43
+ Warning! Ignoring source_dest_checks flag as it can only be configured on
44
+ a VPC instance.
45
+ starting: |-
46
+ Starting the instance...
47
+ stopping: |-
48
+ Stopping the instance...
49
+ terminating: |-
50
+ Terminating the instance...
51
+ waiting_for_ready: |-
52
+ Waiting for instance to become "ready"...
53
+ waiting_for_ssh: |-
54
+ Waiting for SSH to become available...
55
+ warn_networks: |-
56
+ Warning! The VRealize provider doesn't support any of the Vagrant
57
+ high-level network configurations (`config.vm.network`). They
58
+ will be silently ignored.
59
+ warn_ssh_access: |-
60
+ Warning! Vagrant might not be able to SSH into the instance.
61
+ Please check your security groups settings.
62
+ will_not_destroy: |-
63
+ The instance '%{name}' will not be destroyed, since the confirmation
64
+ was declined.
65
+
66
+ config:
67
+ access_key_id_required: |-
68
+ An access key ID must be specified via "access_key_id"
69
+ ami_required: |-
70
+ An AMI must be configured via "ami" (region: #{region})
71
+ private_key_missing: |-
72
+ The specified private key for AWS could not be found
73
+ region_required: |-
74
+ A region must be specified via "region"
75
+ secret_access_key_required: |-
76
+ A secret access key is required via "secret_access_key"
77
+ subnet_id_required_with_public_ip: |-
78
+ If you assign a public IP address to an instance in a VPC, a subnet must be specifed via "subnet_id"
79
+ aws_info_required: |-
80
+ One or more of the needed AWS credentials are missing. No environment variables
81
+ are set nor profile '%{profile}' exists at '%{location}'
82
+
83
+ errors:
84
+ instance_ready_timeout: |-
85
+ The instance never became "ready" in AWS. The timeout currently
86
+ set waiting for the instance to become ready is %{timeout} seconds.
87
+ Please verify that the machine properly boots. If you need more time
88
+ set the `instance_ready_timeout` configuration on the AWS provider.
89
+ instance_package_error: |-
90
+ There was an error packaging the instance. See details below for more info.
91
+
92
+ AMI Id: %{ami_id}
93
+ Error: %{err}
94
+ instance_package_timeout: |-
95
+ The AMI failed to become "ready" in AWS. The timeout currently
96
+ set waiting for the instance to become ready is %{timeout} seconds. For
97
+ larger instances AMI burning may take long periods of time. Please
98
+ ensure the timeout is set high enough, it can be changed by adjusting
99
+ the `instance_package_timeout` configuration on the AWS provider.
100
+ rsync_error: |-
101
+ There was an error when attempting to rsync a shared folder.
102
+ Please inspect the error message below for more info.
103
+
104
+ Host path: %{hostpath}
105
+ Guest path: %{guestpath}
106
+ Error: %{stderr}
107
+ mkdir_error: |-
108
+ There was an error when attempting to create a shared host folder.
109
+ Please inspect the error message below for more info.
110
+
111
+ Host path: %{hostpath}
112
+ Error: %{err}
113
+ elb_does_not_exist: |-
114
+ ELB configured for the instance does not exist
115
+
116
+ states:
117
+ short_not_created: |-
118
+ not created
119
+ long_not_created: |-
120
+ The EC2 instance is not created. Run `vagrant up` to create it.
121
+
122
+ short_stopped: |-
123
+ stopped
124
+ long_stopped: |-
125
+ The EC2 instance is stopped. Run `vagrant up` to start it.
126
+
127
+ short_stopping: |-
128
+ stopping
129
+ long_stopping: |-
130
+ The EC2 instance is stopping. Wait until is completely stopped to
131
+ run `vagrant up` and start it.
132
+
133
+ short_pending: |-
134
+ pending
135
+ long_pending: |-
136
+ The EC2 instance is pending a start (i.e. this is a transition state).
137
+
138
+ short_running: |-
139
+ running
140
+ long_running: |-
141
+ The EC2 instance is running. To stop this machine, you can run
142
+ `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
143
+
144
+ short_pending: |-
145
+ pending
146
+ long_pending: |-
147
+ The EC2 instance is still being initialized. To destroy this machine,
148
+ you can run `vagrant destroy`.
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-vrealize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Alex Young
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vmware-vra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Enables Vagrant to manage machines in VMware VRealize.
42
+ email: Alexander.Young@sky.uk
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CONTRIBUTING.md
48
+ - LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - example_box/README.md
52
+ - example_box/Vagrantfile
53
+ - example_box/metadata.json
54
+ - example_box/mkbox.sh
55
+ - example_box/vrealize.box
56
+ - lib/vagrant-vrealize.rb
57
+ - lib/vagrant-vrealize/action.rb
58
+ - lib/vagrant-vrealize/action/connect_vrealize.rb
59
+ - lib/vagrant-vrealize/action/is_created.rb
60
+ - lib/vagrant-vrealize/action/is_stopped.rb
61
+ - lib/vagrant-vrealize/action/message_already_created.rb
62
+ - lib/vagrant-vrealize/action/message_not_created.rb
63
+ - lib/vagrant-vrealize/action/message_will_not_destroy.rb
64
+ - lib/vagrant-vrealize/action/read_ssh_info.rb
65
+ - lib/vagrant-vrealize/action/read_state.rb
66
+ - lib/vagrant-vrealize/action/run_instance.rb
67
+ - lib/vagrant-vrealize/action/start_instance.rb
68
+ - lib/vagrant-vrealize/action/stop_instance.rb
69
+ - lib/vagrant-vrealize/action/terminate_instance.rb
70
+ - lib/vagrant-vrealize/action/timed_provision.rb
71
+ - lib/vagrant-vrealize/action/wait_for_state.rb
72
+ - lib/vagrant-vrealize/action/warn_networks.rb
73
+ - lib/vagrant-vrealize/config.rb
74
+ - lib/vagrant-vrealize/errors.rb
75
+ - lib/vagrant-vrealize/extra-entries.rb
76
+ - lib/vagrant-vrealize/plugin.rb
77
+ - lib/vagrant-vrealize/provider.rb
78
+ - lib/vagrant-vrealize/util/timer.rb
79
+ - lib/vagrant-vrealize/version.rb
80
+ - lib/vagrant-vrealize/vra_client.rb
81
+ - locales/en.yml
82
+ homepage: https://github.com/sky-uk/vagrant-vrealize
83
+ licenses:
84
+ - BSD-3-Clause
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.3.6
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.4.5.1
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Enables Vagrant to manage machines in VMware VRealize.
106
+ test_files: []