vagrant-1cloud 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +3 -46
- data/Gemfile +0 -8
- data/LICENSE +0 -373
- data/README.md +0 -117
- data/Rakefile +0 -21
- data/build.sh +0 -32
- data/lib/vagrant-1cloud.rb +0 -20
- data/lib/vagrant-1cloud/actions.rb +0 -183
- data/lib/vagrant-1cloud/actions/check_state.rb +0 -19
- data/lib/vagrant-1cloud/actions/create.rb +0 -93
- data/lib/vagrant-1cloud/actions/destroy.rb +0 -31
- data/lib/vagrant-1cloud/actions/modify_provision_path.rb +0 -38
- data/lib/vagrant-1cloud/actions/power_off.rb +0 -35
- data/lib/vagrant-1cloud/actions/power_on.rb +0 -45
- data/lib/vagrant-1cloud/actions/private_network.rb +0 -108
- data/lib/vagrant-1cloud/actions/rebuild.rb +0 -78
- data/lib/vagrant-1cloud/actions/reload.rb +0 -42
- data/lib/vagrant-1cloud/actions/setup_key.rb +0 -60
- data/lib/vagrant-1cloud/actions/setup_sudo.rb +0 -43
- data/lib/vagrant-1cloud/actions/setup_user.rb +0 -58
- data/lib/vagrant-1cloud/actions/shut_down.rb +0 -35
- data/lib/vagrant-1cloud/commands/add_network.rb +0 -59
- data/lib/vagrant-1cloud/commands/create_network.rb +0 -135
- data/lib/vagrant-1cloud/commands/rebuild.rb +0 -29
- data/lib/vagrant-1cloud/config.rb +0 -62
- data/lib/vagrant-1cloud/errors.rb +0 -33
- data/lib/vagrant-1cloud/helpers/client.rb +0 -181
- data/lib/vagrant-1cloud/helpers/result.rb +0 -40
- data/lib/vagrant-1cloud/plugin.rb +0 -36
- data/lib/vagrant-1cloud/provider.rb +0 -106
- data/lib/vagrant-1cloud/version.rb +0 -5
- data/locales/en.yml +0 -90
- data/pom.xml +0 -59
- data/test/Vagrantfile +0 -14
- data/test/scripts/provision.sh +0 -3
- data/test/test.sh +0 -11
- data/test/test_id_rsa +0 -27
- data/test/test_id_rsa.pub +0 -1
- data/vagrant-1cloud.gemspec +0 -21
data/README.md
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
1cloud Vagrant Provider
|
2
|
-
==============================
|
3
|
-
|
4
|
-
[![Gem](https://img.shields.io/gem/v/vagrant-1cloud.svg)](https://rubygems.org/gems/vagrant-1cloud)
|
5
|
-
|
6
|
-
`vagrant-1cloud` is a Vagrant provider plugin that supports the management of [1cloud](https://1cloud.ru) VPS.
|
7
|
-
|
8
|
-
Features include:
|
9
|
-
- Create and destroy VPS
|
10
|
-
- Power on and off VPS
|
11
|
-
- Provision a VPS with shell
|
12
|
-
- Setup a SSH public key for authentication
|
13
|
-
- Create a new user account during VPS creation
|
14
|
-
- Create private network
|
15
|
-
- Add VPS to private network
|
16
|
-
- Rebuild VPS
|
17
|
-
|
18
|
-
|
19
|
-
Install
|
20
|
-
-------
|
21
|
-
Install the provider plugin using the Vagrant command-line interface:
|
22
|
-
|
23
|
-
`vagrant plugin install vagrant-1cloud`
|
24
|
-
|
25
|
-
|
26
|
-
Configure
|
27
|
-
---------
|
28
|
-
Once the provider has been installed, you will need to configure your project to use it. See the following example for a basic multi-machine `Vagrantfile` implementation that manages two 1cloud VPS:
|
29
|
-
|
30
|
-
```ruby
|
31
|
-
Vagrant.configure('2') do |config|
|
32
|
-
|
33
|
-
config.vm.define "vps1" do |config|
|
34
|
-
config.vm.provider :onecloud do |provider, override|
|
35
|
-
override.ssh.private_key_path = '~/.ssh/id_rsa'
|
36
|
-
override.vm.box = 'onecloud'
|
37
|
-
provider.token = 'YOUR TOKEN'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
config.vm.define "vps2" do |config|
|
42
|
-
config.vm.provider :onecloud do |provider, override|
|
43
|
-
override.ssh.private_key_path = '~/.ssh/id_rsa'
|
44
|
-
override.vm.box = 'onecloud'
|
45
|
-
provider.token = 'YOUR TOKEN'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
```
|
51
|
-
|
52
|
-
**Configuration Requirements**
|
53
|
-
- You *must* specify the `override.ssh.private_key_path` to enable authentication with the VPS.
|
54
|
-
- You *must* specify your 1cloud Personal Access Token at `provider.token`.
|
55
|
-
|
56
|
-
**Supported Configuration Attributes**
|
57
|
-
The following attributes are available to further configure the provider:
|
58
|
-
- `provider.image`
|
59
|
-
* A string representing the image ID to use when creating a new VPS. It defaults to `7` (ubuntu-14-04-x64).
|
60
|
-
- `provider.region`
|
61
|
-
* A string representing the region to create the new VPS in. It defaults to `SdnSpb`.
|
62
|
-
- `provider.hdd`
|
63
|
-
* A number representing the disk space (in GB) to use when creating a new VPS (e.g. 50). It defaults to 10.
|
64
|
-
- `provider.hdd_type`
|
65
|
-
* A string representing the disk type to use when creating a new VPS (e.g. `SSD`). It defaults to `SAS`.
|
66
|
-
- `provider.cpu`
|
67
|
-
* A number representing the amount of cores to use when creating a new VPS (e.g. 2). It defaults to 1.
|
68
|
-
- `provider.ram`
|
69
|
-
* A number representing the RAM (in MB) to use when creating a new VPS (e.g. 1024). It defaults to 512.
|
70
|
-
- `provider.hi_perf`
|
71
|
-
* A boolean flag indicating whether to use high performance pool or not. It defaults to `false`.
|
72
|
-
- `provider.private_net`
|
73
|
-
* A hash representing the pair that indicates the private network name and IP address of a new VPS (e.g. {"testnet" => "192.168.1.10"} or {"testnet" => nil} to set IP address automatically). VPS isn't added to private network by default.
|
74
|
-
- `config.vm.synced_folder`
|
75
|
-
* Supports both rsync__args and rsync__exclude, see the [Vagrant Docs](http://docs.vagrantup.com/v2/synced-folders/rsync.html) for more information. rsync__args default to `["--verbose", "--archive", "--delete", "-z", "--copy-links"]` and rsync__exclude defaults to `[".vagrant/"]`.
|
76
|
-
|
77
|
-
The provider will create a new user account with the specified SSH key for authorization if `config.ssh.username` is set.
|
78
|
-
|
79
|
-
|
80
|
-
Run
|
81
|
-
---
|
82
|
-
After creating your project's `Vagrantfile` with the required configuration
|
83
|
-
attributes described above, you may create a new VPS with the following
|
84
|
-
command:
|
85
|
-
|
86
|
-
$ vagrant up --provider=onecloud
|
87
|
-
|
88
|
-
This command will create a new VPS, setup your SSH key for authentication,
|
89
|
-
create a new user account, and run the provisioners you have configured.
|
90
|
-
|
91
|
-
**Supported Commands**
|
92
|
-
|
93
|
-
The provider supports the following Vagrant sub-commands:
|
94
|
-
- `vagrant destroy` - Destroys the VPS instance.
|
95
|
-
- `vagrant ssh` - Logs into the VPS instance using the configured user account.
|
96
|
-
- `vagrant halt` - Powers off the VPS instance.
|
97
|
-
- `vagrant provision` - Runs the configured provisioners and rsyncs any specified `config.vm.synced_folder`.
|
98
|
-
- `vagrant reload` - Reboots the VPS instance.
|
99
|
-
- `vagrant status` - Outputs the status (active, off, not created) for the VPS instance.
|
100
|
-
- `vagrant create-network` - Creates private network.
|
101
|
-
- `vagrant add-network` - Adds VPS to specified private network.
|
102
|
-
- `vagrant rebuild` - Rebuilds the VPS.
|
103
|
-
|
104
|
-
Troubleshooting
|
105
|
-
---------------
|
106
|
-
Before submitting a GitHub issue, please ensure both Vagrant and vagrant-onecloud are fully up-to-date.
|
107
|
-
* For the latest Vagrant version, please visit the [Vagrant](https://www.vagrantup.com/) website
|
108
|
-
* To update Vagrant plugins, run the following command: `vagrant plugin update`
|
109
|
-
|
110
|
-
* `vagrant plugin install vagrant-onecloud`
|
111
|
-
* Installation on OS X may not working due to a SSL certificate problem, and you may need to specify a certificate path explicitly. To do so, run `ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE"`. Then, add the following environment variable to your `.bash_profile` script and `source` it: `export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem`.
|
112
|
-
|
113
|
-
|
114
|
-
FAQ
|
115
|
-
---
|
116
|
-
|
117
|
-
* The Chef provisioner is no longer supported by default. Please use the `vagrant-omnibus` plugin to install Chef on Vagrant-managed machines. This plugin provides control over the specific version of Chef to install.
|
data/Rakefile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'bundler/gem_helper'
|
2
|
-
|
3
|
-
namespace :gem do
|
4
|
-
Bundler::GemHelper.install_tasks
|
5
|
-
end
|
6
|
-
|
7
|
-
task :test do
|
8
|
-
result = sh 'bash test/test.sh'
|
9
|
-
if result
|
10
|
-
puts 'Success!'
|
11
|
-
else
|
12
|
-
puts 'Failure!'
|
13
|
-
exit 1
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def env
|
18
|
-
['OC_CLIENT_ID', 'OC_API_KEY', 'VAGRANT_LOG'].inject('') do |acc, key|
|
19
|
-
acc += "#{key}=#{ENV[key] || 'error'} "
|
20
|
-
end
|
21
|
-
end
|
data/build.sh
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
4
|
-
PLUGIN_NAME="vagrant-1cloud"
|
5
|
-
PLUGIN_VERSION=$(cat ${DIR}/lib/${PLUGIN_NAME}/version.rb | grep VERSION | awk -F= '{gsub(" ","");gsub("'\''","");print $2}')
|
6
|
-
|
7
|
-
docker stop $(docker ps -a -q --filter label=${PLUGIN_NAME})
|
8
|
-
|
9
|
-
docker pull docker.avtodoria.dev:5043/test/vagrant
|
10
|
-
BUILDER_ID=$(docker run -it -d --rm --label ${PLUGIN_NAME} docker.avtodoria.dev:5043/test/vagrant)
|
11
|
-
|
12
|
-
docker cp ${DIR}/../${PLUGIN_NAME} ${BUILDER_ID}:/tmp/
|
13
|
-
|
14
|
-
docker exec -i ${BUILDER_ID} bash -c "cd /tmp/${PLUGIN_NAME} && \
|
15
|
-
git init && \
|
16
|
-
bundle config git.allow_insecure true && \
|
17
|
-
bundle install && \
|
18
|
-
bundle exec rake gem:build && \
|
19
|
-
bundle exec rake gem:install && \
|
20
|
-
bundle exec rake test"
|
21
|
-
if [ $? -ne 0 ]; then
|
22
|
-
echo "${PLUGIN_NAME} plugin was not built successfully!"
|
23
|
-
docker stop $(docker ps -a -q --filter label=${PLUGIN_NAME})
|
24
|
-
exit 1
|
25
|
-
fi
|
26
|
-
|
27
|
-
mkdir -p ${DIR}/package
|
28
|
-
docker cp ${BUILDER_ID}:/tmp/${PLUGIN_NAME}/pkg/${PLUGIN_NAME}-${PLUGIN_VERSION}.gem ${DIR}/package/${PLUGIN_NAME}.gem
|
29
|
-
|
30
|
-
echo "${PLUGIN_NAME} plugin was built successfully."
|
31
|
-
docker stop $(docker ps -a -q --filter label=${PLUGIN_NAME})
|
32
|
-
exit 0
|
data/lib/vagrant-1cloud.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'vagrant-1cloud/version'
|
2
|
-
require 'vagrant-1cloud/plugin'
|
3
|
-
require 'vagrant-1cloud/errors'
|
4
|
-
|
5
|
-
module VagrantPlugins
|
6
|
-
module OneCloud
|
7
|
-
def self.source_root
|
8
|
-
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.public_key(private_key_path)
|
12
|
-
File.read("#{private_key_path}.pub")
|
13
|
-
rescue
|
14
|
-
raise Errors::PublicKeyError, :path => "#{private_key_path}.pub"
|
15
|
-
end
|
16
|
-
|
17
|
-
I18n.load_path << File.expand_path('locales/en.yml', source_root)
|
18
|
-
I18n.reload!
|
19
|
-
end
|
20
|
-
end
|
@@ -1,183 +0,0 @@
|
|
1
|
-
require 'vagrant-1cloud/actions/check_state'
|
2
|
-
require 'vagrant-1cloud/actions/create'
|
3
|
-
require 'vagrant-1cloud/actions/destroy'
|
4
|
-
require 'vagrant-1cloud/actions/shut_down'
|
5
|
-
require 'vagrant-1cloud/actions/power_off'
|
6
|
-
require 'vagrant-1cloud/actions/power_on'
|
7
|
-
require 'vagrant-1cloud/actions/reload'
|
8
|
-
require 'vagrant-1cloud/actions/setup_user'
|
9
|
-
require 'vagrant-1cloud/actions/modify_provision_path'
|
10
|
-
require 'vagrant-1cloud/actions/private_network'
|
11
|
-
require 'vagrant-1cloud/actions/rebuild'
|
12
|
-
require 'vagrant-1cloud/actions/setup_sudo'
|
13
|
-
require 'vagrant-1cloud/actions/setup_key'
|
14
|
-
|
15
|
-
module VagrantPlugins
|
16
|
-
module OneCloud
|
17
|
-
module Actions
|
18
|
-
include Vagrant::Action::Builtin
|
19
|
-
|
20
|
-
def self.destroy
|
21
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
22
|
-
builder.use ConfigValidate
|
23
|
-
builder.use Call, CheckState do |env, b|
|
24
|
-
case env[:machine_state]
|
25
|
-
when :not_created
|
26
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
27
|
-
else
|
28
|
-
b.use Call, DestroyConfirm do |env2, b2|
|
29
|
-
if env2[:result]
|
30
|
-
b2.use Destroy
|
31
|
-
b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.ssh
|
40
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
41
|
-
builder.use ConfigValidate
|
42
|
-
builder.use Call, CheckState do |env, b|
|
43
|
-
case env[:machine_state]
|
44
|
-
when :Active
|
45
|
-
b.use SSHExec
|
46
|
-
when :off
|
47
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.off')
|
48
|
-
when :not_created
|
49
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.ssh_run
|
56
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
57
|
-
builder.use ConfigValidate
|
58
|
-
builder.use Call, CheckState do |env, b|
|
59
|
-
case env[:machine_state]
|
60
|
-
when :Active
|
61
|
-
b.use SSHRun
|
62
|
-
when :off
|
63
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.off')
|
64
|
-
when :not_created
|
65
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.provision
|
72
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
73
|
-
builder.use ConfigValidate
|
74
|
-
builder.use Call, CheckState do |env, b|
|
75
|
-
case env[:machine_state]
|
76
|
-
when :Active
|
77
|
-
b.use Provision
|
78
|
-
b.use ModifyProvisionPath
|
79
|
-
b.use SyncedFolders
|
80
|
-
when :off
|
81
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.off')
|
82
|
-
when :not_created
|
83
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.addnet
|
90
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
91
|
-
builder.use ConfigValidate
|
92
|
-
builder.use Call, CheckState do |env, b|
|
93
|
-
case env[:machine_state]
|
94
|
-
when :Active
|
95
|
-
b.use PrivateNetwork
|
96
|
-
when :off
|
97
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.off')
|
98
|
-
when :not_created
|
99
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.up
|
106
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
107
|
-
builder.use ConfigValidate
|
108
|
-
builder.use Call, CheckState do |env, b|
|
109
|
-
case env[:machine_state]
|
110
|
-
when :Active
|
111
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.already_active')
|
112
|
-
when :off
|
113
|
-
b.use PowerOn
|
114
|
-
b.use provision
|
115
|
-
when :not_created
|
116
|
-
b.use SetupKey
|
117
|
-
b.use Create
|
118
|
-
b.use PrivateNetwork
|
119
|
-
b.use SetupSudo
|
120
|
-
b.use SetupUser
|
121
|
-
b.use provision
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.halt
|
128
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
129
|
-
builder.use ConfigValidate
|
130
|
-
builder.use Call, CheckState do |env, b|
|
131
|
-
case env[:machine_state]
|
132
|
-
when :Active
|
133
|
-
if env[:force_halt]
|
134
|
-
b.use PowerOff
|
135
|
-
else
|
136
|
-
b.use ShutDown
|
137
|
-
end
|
138
|
-
when :off
|
139
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.already_off')
|
140
|
-
when :not_created
|
141
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def self.reload
|
148
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
149
|
-
builder.use ConfigValidate
|
150
|
-
builder.use Call, CheckState do |env, b|
|
151
|
-
case env[:machine_state]
|
152
|
-
when :Active
|
153
|
-
b.use Reload
|
154
|
-
b.use provision
|
155
|
-
when :off
|
156
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.off')
|
157
|
-
when :not_created
|
158
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def self.rebuild
|
165
|
-
return Vagrant::Action::Builder.new.tap do |builder|
|
166
|
-
builder.use ConfigValidate
|
167
|
-
builder.use Call, CheckState do |env, b|
|
168
|
-
case env[:machine_state]
|
169
|
-
when :Active, :off
|
170
|
-
b.use Rebuild
|
171
|
-
b.use PrivateNetwork
|
172
|
-
b.use SetupSudo
|
173
|
-
b.use SetupUser
|
174
|
-
b.use provision
|
175
|
-
when :not_created
|
176
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module OneCloud
|
3
|
-
module Actions
|
4
|
-
class CheckState
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
@machine = env[:machine]
|
8
|
-
@logger = Log4r::Logger.new('vagrant::onecloud::check_state')
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
env[:machine_state] = @machine.state.id
|
13
|
-
@logger.info "Machine state is '#{@machine.state.id}'"
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'vagrant-1cloud/helpers/client'
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module OneCloud
|
5
|
-
module Actions
|
6
|
-
class Create
|
7
|
-
include Helpers::Client
|
8
|
-
|
9
|
-
def initialize(app, env)
|
10
|
-
@app = app
|
11
|
-
@machine = env[:machine]
|
12
|
-
@client = client
|
13
|
-
@logger = Log4r::Logger.new('vagrant::onecloud::create')
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
ssh_key_id = [env[:ssh_key_id]]
|
18
|
-
|
19
|
-
# submit new droplet request
|
20
|
-
result = @client.post('/server', {
|
21
|
-
:HDD => @machine.provider_config.hdd,
|
22
|
-
:HDDType => @machine.provider_config.hdd_type,
|
23
|
-
:CPU => @machine.provider_config.cpu,
|
24
|
-
:RAM => @machine.provider_config.ram,
|
25
|
-
:DCLocation => @machine.provider_config.region,
|
26
|
-
:ImageID => @machine.provider_config.image,
|
27
|
-
:Name => @machine.name,
|
28
|
-
:SshKeys => ssh_key_id,
|
29
|
-
:isHighPerformance => @machine.provider_config.hi_perf
|
30
|
-
}.delete_if { |k, v| v.nil? })
|
31
|
-
|
32
|
-
# assign the machine id for reference in other commands
|
33
|
-
@machine.id = result['body']['ID'].to_s
|
34
|
-
|
35
|
-
# wait for request to complete
|
36
|
-
result = @client.request("/server/#{@machine.id}/action")
|
37
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.creating')
|
38
|
-
@client.wait_for_event(env, @machine.id, result['body'].first['ID'])
|
39
|
-
|
40
|
-
# refresh droplet state with provider
|
41
|
-
droplet = Provider.droplet(@machine, :refresh => true)
|
42
|
-
|
43
|
-
user = @machine.config.ssh.username
|
44
|
-
@machine.config.ssh.username = 'root'
|
45
|
-
|
46
|
-
# wait for ssh to be ready
|
47
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.ssh')
|
48
|
-
@client.wait_for_ssh(env, 3, 30)
|
49
|
-
|
50
|
-
# change authorized_keys file permissions, host name and set public network rules
|
51
|
-
@machine.communicate.execute(<<-BASH)
|
52
|
-
chmod 600 ~/.ssh/authorized_keys
|
53
|
-
|
54
|
-
sed -i -e "s/127.0.1.1.*/127.0.1.1\t#{@machine.config.vm.hostname}/" /etc/hosts
|
55
|
-
sed -i -e "s/#{droplet['IP']}.*/#{droplet['IP']}\t#{@machine.config.vm.hostname}/" /etc/hosts
|
56
|
-
echo #{@machine.config.vm.hostname} > /etc/hostname
|
57
|
-
hostname #{@machine.config.vm.hostname}
|
58
|
-
|
59
|
-
ifdown -a
|
60
|
-
export INTERFACE=eth0
|
61
|
-
export MATCHADDR=$(ifconfig eth0 | awk 'NR==1{print $NF}')
|
62
|
-
export MATCHID=$(udevadm info /sys/class/net/eth0 | grep P: | awk -F/ '{print $(NF-2)}')
|
63
|
-
/lib/udev/write_net_rules
|
64
|
-
udevadm control --reload-rules && udevadm trigger
|
65
|
-
ifup -a
|
66
|
-
BASH
|
67
|
-
|
68
|
-
@machine.config.ssh.username = user
|
69
|
-
|
70
|
-
@app.call(env)
|
71
|
-
end
|
72
|
-
|
73
|
-
# Both the recover and terminate are stolen almost verbatim from
|
74
|
-
# the Vagrant AWS provider up action
|
75
|
-
def recover(env)
|
76
|
-
return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
|
77
|
-
|
78
|
-
if @machine.state.id != :not_created
|
79
|
-
terminate(env)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def terminate(env)
|
84
|
-
destroy_env = env.dup
|
85
|
-
destroy_env.delete(:interrupted)
|
86
|
-
destroy_env[:config_validate] = false
|
87
|
-
destroy_env[:force_confirm_destroy] = true
|
88
|
-
env[:action_runner].run(Actions.destroy, destroy_env)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|