vagrant-1cloud 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a827c5cc11ddcb5c3d2426168670fac8d653e3bd
4
- data.tar.gz: 4045cfdcf19f514bf9500a3f3c448ef9945959d5
3
+ metadata.gz: f33e37cd708c23ddb0f9f4e42e637cbbdb71caa1
4
+ data.tar.gz: f67a1b29295ac6518349df39581065c0c1a6078d
5
5
  SHA512:
6
- metadata.gz: 1e50edceee955d1bf09944d61924848b28a0ded2503ca480015f650a846ff6aeecd169a7a5928b69355a1725ffe33f6c783f0b2324280666b3d545ef6fbc6020
7
- data.tar.gz: 6ab8e44383179d01d3dc573586357764c44d9c4a579f5fae0da9d488542811975eef045e8f48e0b208a1afbe6e1cfd8db94098caabdfa621404ae225bc4ceca8
6
+ metadata.gz: 39d39d01ea97e4e98eeae9318e914531ec27b7f1274d7af08ca0d2a3c0320a14583d4493c07763f1b4adeb8236fa891ed25b3e537ae71f9ac2fc57cf982e5f1b
7
+ data.tar.gz: f0fd940ed6e172994d60b8d23fce925d03e1581ffa3b023befe2a730dd5177222f1451a5359394cad3e93aad0ead34f514097cf4419f3ab4b6dbf9437996aa94
@@ -1,4 +1,5 @@
1
1
  require 'vagrant-1cloud/helpers/client'
2
+ require 'net/ssh'
2
3
 
3
4
  module VagrantPlugins
4
5
  module OneCloud
@@ -16,7 +17,7 @@ module VagrantPlugins
16
17
 
17
18
  def call(env)
18
19
  # submit new droplet request
19
- result = @clientservice.post('/server', {
20
+ result = @client.post('/server', {
20
21
  :HDD => @machine.provider_config.hdd,
21
22
  :HDDType => @machine.provider_config.hdd_type,
22
23
  :CPU => @machine.provider_config.cpu,
@@ -25,45 +26,60 @@ module VagrantPlugins
25
26
  :ImageID => @machine.provider_config.image,
26
27
  :Name => @machine.config.vm.hostname || @machine.name,
27
28
  :isHighPerformance => @machine.provider_config.hi_perf
28
- })
29
+ }.delete_if { |k, v| v.nil? })
29
30
 
30
31
  # assign the machine id for reference in other commands
31
- @machine.id = result['id'].to_s
32
+ @machine.id = result['body']['ID'].to_s
32
33
 
33
34
  # wait for request to complete
34
35
  result = @client.request("/server/#{@machine.id}/action")
35
36
  env[:ui].info I18n.t('vagrant_1cloud.info.creating')
36
- @client.wait_for_event(env, @machine.id, result.first['ID'])
37
+ @client.wait_for_event(env, @machine.id, result['body'].first['ID'])
37
38
 
38
39
  # refresh droplet state with provider
39
40
  droplet = Provider.droplet(@machine, :refresh => true)
40
41
 
42
+ path = @machine.config.ssh.private_key_path
43
+ path = path[0] if path.is_a?(Array)
44
+ path = File.expand_path(path, @machine.env.root_path)
45
+ pub_key = OneCloud.public_key(path)
46
+ Net::SSH.start(droplet['IP'], droplet['AdminUserName'], :password => droplet['AdminPassword']) do |ssh|
47
+ ssh.exec!("mkdir ~/.ssh")
48
+ ssh.exec!("touch ~/.ssh/authorized_keys")
49
+ ssh.exec!("echo \"#{pub_key}\" >> ~/.ssh/authorized_keys")
50
+ end
51
+
52
+ user = @machine.config.ssh.username
53
+ @machine.config.ssh.username = 'root'
54
+
41
55
  # wait for ssh to be ready
42
56
  retryable(:tries => 120, :sleep => 10) do
43
57
  next if env[:interrupted]
44
58
  raise 'not ready' if !@machine.communicate.ready?
45
59
  end
46
60
 
61
+ @machine.config.ssh.username = user
62
+
47
63
  @app.call(env)
48
64
  end
49
65
 
50
66
  # Both the recover and terminate are stolen almost verbatim from
51
67
  # the Vagrant AWS provider up action
52
- # def recover(env)
53
- # return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
68
+ def recover(env)
69
+ return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
54
70
 
55
- # if @machine.state.id != :not_created
56
- # terminate(env)
57
- # end
58
- # end
71
+ if @machine.state.id != :not_created
72
+ terminate(env)
73
+ end
74
+ end
59
75
 
60
- # def terminate(env)
61
- # destroy_env = env.dup
62
- # destroy_env.delete(:interrupted)
63
- # destroy_env[:config_validate] = false
64
- # destroy_env[:force_confirm_destroy] = true
65
- # env[:action_runner].run(Actions.destroy, destroy_env)
66
- # end
76
+ def terminate(env)
77
+ destroy_env = env.dup
78
+ destroy_env.delete(:interrupted)
79
+ destroy_env[:config_validate] = false
80
+ destroy_env[:force_confirm_destroy] = true
81
+ env[:action_runner].run(Actions.destroy, destroy_env)
82
+ end
67
83
  end
68
84
  end
69
85
  end
@@ -0,0 +1,38 @@
1
+ module VagrantPlugins
2
+ module OneCloud
3
+ module Actions
4
+ class ModifyProvisionPath
5
+ def initialize(app, env)
6
+ @app = app
7
+ @machine = env[:machine]
8
+ @logger =
9
+ Log4r::Logger.new('vagrant::onecloud::modify_provision_path')
10
+ end
11
+
12
+ def call(env)
13
+ # check if provisioning is enabled
14
+ enabled = true
15
+ enabled = env[:provision_enabled] if env.has_key?(:provision_enabled)
16
+ return @app.call(env) if !enabled
17
+
18
+ username = @machine.ssh_info()[:username]
19
+
20
+ # change ownership of the provisioning path recursively to the
21
+ # ssh user
22
+ #
23
+ # TODO submit patch to vagrant to set appropriate permissions
24
+ # based on ssh username
25
+ @machine.config.vm.provisioners.each do |provisioner|
26
+ cfg = provisioner.config
27
+ path = cfg.upload_path if cfg.respond_to? :upload_path
28
+ path = cfg.provisioning_path if cfg.respond_to? :provisioning_path
29
+ @machine.communicate.sudo("chown -R #{username} #{path}",
30
+ :error_check => false)
31
+ end
32
+
33
+ @app.call(env)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  require 'vagrant-1cloud/helpers/client'
2
- #TODO: --force
2
+
3
3
  module VagrantPlugins
4
4
  module OneCloud
5
5
  module Actions
@@ -0,0 +1,72 @@
1
+ require 'vagrant-1cloud/helpers/client'
2
+
3
+ module VagrantPlugins
4
+ module OneCloud
5
+ module Actions
6
+ class PrivateNetwork
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::private_network')
14
+ end
15
+
16
+ def call(env)
17
+ # check if network name is set
18
+ return @app.call(env) unless @machine.provider_config.net_name
19
+
20
+ result = @client.request('/network')
21
+ private_network = result['body'].find { |network| network['Name'] == @machine.provider_config.net_name.to_s }
22
+
23
+ if !private_network
24
+ result = @client.post("/network", {
25
+ :Name => @machine.provider_config.net_name,
26
+ :IsDHCP => false,
27
+ :DCLocation => @machine.provider_config.region
28
+ })
29
+ env[:ui].info I18n.t('vagrant_1cloud.info.creating_private_network')
30
+ @client.wait_for_network(env, result['body']['ID'])
31
+
32
+ result = @client.request("/network/#{result['body']['ID']}")
33
+ private_network = result['body']
34
+ end
35
+
36
+ result = @client.post("/Server/#{@machine.id}/Action", {
37
+ :Type => "AddNetwork",
38
+ :NetworkID => private_network['ID']
39
+ })
40
+
41
+ env[:ui].info I18n.t('vagrant_1cloud.info.setting_private_network')
42
+ @client.wait_for_event(env, @machine.id, result['body']['ID'])
43
+
44
+ result = @client.request("/server/#{@machine.id}")
45
+ linked_network = result['body']['LinkedNetworks'].find { |network| network['NetworkID'] == private_network['ID'] }
46
+
47
+ if !@machine.provider_config.private_ip
48
+ @machine.provider_config.private_ip = linked_network['IP']
49
+ end
50
+
51
+ # override ssh username to root temporarily
52
+ user = @machine.config.ssh.username
53
+ @machine.config.ssh.username = 'root'
54
+
55
+ # set private network
56
+ @machine.communicate.execute(<<-BASH)
57
+ ifconfig -a | grep #{linked_network['MAC']} | awk '{print "auto " $1}' >> /etc/network/interfaces
58
+ ifconfig -a | grep #{linked_network['MAC']} | awk '{print "iface " $1 " inet static"}' >> /etc/network/interfaces
59
+ echo "address #{@machine.provider_config.private_ip}" >> /etc/network/interfaces
60
+ echo "netmask #{private_network['Mask']}" >> /etc/network/interfaces
61
+ ifconfig -a | grep #{linked_network['MAC']} | awk '{system("ifdown "$1" && ifup "$1)}'
62
+ BASH
63
+
64
+ # reset username
65
+ @machine.config.ssh.username = user
66
+
67
+ @app.call(env)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,63 @@
1
+ module VagrantPlugins
2
+ module OneCloud
3
+ module Actions
4
+ class SetupUser
5
+ def initialize(app, env)
6
+ @app = app
7
+ @machine = env[:machine]
8
+ @logger = Log4r::Logger.new('vagrant::onecloud::setup_user')
9
+ end
10
+
11
+ def call(env)
12
+ # check if a username has been specified
13
+ return @app.call(env) unless @machine.config.ssh.username
14
+
15
+ # override ssh username to root temporarily
16
+ user = @machine.config.ssh.username
17
+ @machine.config.ssh.username = 'root'
18
+
19
+ env[:ui].info I18n.t('vagrant_1cloud.info.creating_user', {
20
+ :user => user
21
+ })
22
+
23
+ # create user account
24
+ @machine.communicate.execute(<<-BASH)
25
+ if ! (grep ^#{user}: /etc/passwd); then
26
+ adduser #{user};
27
+ fi
28
+ BASH
29
+
30
+ # grant user sudo access with no password requirement
31
+ @machine.communicate.execute(<<-BASH)
32
+ if ! (grep #{user} /etc/sudoers); then
33
+ echo "#{user} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers;
34
+ else
35
+ sed -i -e "/#{user}/ s/=.*/=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers;
36
+ fi
37
+ BASH
38
+
39
+ # create the .ssh directory in the users home
40
+ @machine.communicate.execute("su #{user} -c 'mkdir -p ~/.ssh'")
41
+
42
+ # add the specified key to the authorized keys file
43
+ path = @machine.config.ssh.private_key_path
44
+ path = path[0] if path.is_a?(Array)
45
+ path = File.expand_path(path, @machine.env.root_path)
46
+ pub_key = OneCloud.public_key(path)
47
+ @machine.communicate.execute(<<-BASH)
48
+ if ! grep '#{pub_key}' /home/#{user}/.ssh/authorized_keys; then
49
+ echo '#{pub_key}' >> /home/#{user}/.ssh/authorized_keys;
50
+ fi
51
+
52
+ chown -R #{user} /home/#{user}/.ssh;
53
+ BASH
54
+
55
+ # reset username
56
+ @machine.config.ssh.username = user
57
+
58
+ @app.call(env)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -5,6 +5,9 @@ require 'vagrant-1cloud/actions/shut_down'
5
5
  require 'vagrant-1cloud/actions/power_off'
6
6
  require 'vagrant-1cloud/actions/power_on'
7
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'
8
11
 
9
12
  module VagrantPlugins
10
13
  module OneCloud
@@ -35,7 +38,7 @@ module VagrantPlugins
35
38
  builder.use ConfigValidate
36
39
  builder.use Call, CheckState do |env, b|
37
40
  case env[:machine_state]
38
- when :active
41
+ when :Active
39
42
  b.use SSHExec
40
43
  when :off
41
44
  env[:ui].info I18n.t('vagrant_1cloud.info.off')
@@ -46,29 +49,14 @@ module VagrantPlugins
46
49
  end
47
50
  end
48
51
 
49
- def self.ssh_run
50
- return Vagrant::Action::Builder.new.tap do |builder|
51
- builder.use ConfigValidate
52
- builder.use Call, CheckState do |env, b|
53
- case env[:machine_state]
54
- when :active
55
- b.use SSHRun
56
- when :off
57
- env[:ui].info I18n.t('vagrant_1cloud.info.off')
58
- when :not_created
59
- env[:ui].info I18n.t('vagrant_1cloud.info.not_created')
60
- end
61
- end
62
- end
63
- end
64
-
65
52
  def self.provision
66
53
  return Vagrant::Action::Builder.new.tap do |builder|
67
54
  builder.use ConfigValidate
68
55
  builder.use Call, CheckState do |env, b|
69
56
  case env[:machine_state]
70
- when :active
57
+ when :Active
71
58
  b.use Provision
59
+ b.use ModifyProvisionPath
72
60
  b.use SyncedFolders
73
61
  when :off
74
62
  env[:ui].info I18n.t('vagrant_1cloud.info.off')
@@ -84,13 +72,15 @@ module VagrantPlugins
84
72
  builder.use ConfigValidate
85
73
  builder.use Call, CheckState do |env, b|
86
74
  case env[:machine_state]
87
- when :active
75
+ when :Active
88
76
  env[:ui].info I18n.t('vagrant_1cloud.info.already_active')
89
77
  when :off
90
78
  b.use PowerOn
91
79
  b.use provision
92
80
  when :not_created
93
81
  b.use Create
82
+ b.use PrivateNetwork
83
+ b.use SetupUser
94
84
  b.use provision
95
85
  end
96
86
  end
@@ -102,7 +92,7 @@ module VagrantPlugins
102
92
  builder.use ConfigValidate
103
93
  builder.use Call, CheckState do |env, b|
104
94
  case env[:machine_state]
105
- when :active
95
+ when :Active
106
96
  if env[:force_halt]
107
97
  b.use PowerOff
108
98
  else
@@ -122,7 +112,7 @@ module VagrantPlugins
122
112
  builder.use ConfigValidate
123
113
  builder.use Call, CheckState do |env, b|
124
114
  case env[:machine_state]
125
- when :active
115
+ when :Active
126
116
  b.use Reload
127
117
  b.use provision
128
118
  when :off
@@ -10,6 +10,8 @@ module VagrantPlugins
10
10
  attr_accessor :ram
11
11
  attr_accessor :hi_perf
12
12
  attr_accessor :ca_path
13
+ attr_accessor :net_name
14
+ attr_accessor :private_ip
13
15
 
14
16
  def initialize
15
17
  @token = UNSET_VALUE
@@ -21,24 +23,38 @@ module VagrantPlugins
21
23
  @ram = UNSET_VALUE
22
24
  @hi_perf = UNSET_VALUE
23
25
  @ca_path = UNSET_VALUE
26
+ @net_name = UNSET_VALUE
27
+ @private_ip = UNSET_VALUE
24
28
  end
25
29
 
26
30
  def finalize!
27
31
  @token = ENV['DO_TOKEN'] if @token == UNSET_VALUE
28
32
  @image = '7' if @image == UNSET_VALUE
29
- @region = 'SDN_SPb' if @region == UNSET_VALUE
30
- @hdd = '1' if @hdd == UNSET_VALUE
33
+ @region = 'SdnSpb' if @region == UNSET_VALUE
34
+ @hdd = '10' if @hdd == UNSET_VALUE
31
35
  @hdd_type = 'SAS' if @hdd_type == UNSET_VALUE
32
36
  @cpu = '1' if @cpu == UNSET_VALUE
33
37
  @ram = '512' if @ram == UNSET_VALUE
34
38
  @hi_perf = false if @hi_perf == UNSET_VALUE
35
39
  @ca_path = nil if @ca_path == UNSET_VALUE
40
+ @net_name = nil if @net_name == UNSET_VALUE
41
+ @private_ip = nil if @private_ip == UNSET_VALUE
36
42
  end
37
43
 
38
44
  def validate(machine)
39
45
  errors = []
40
46
  errors << I18n.t('vagrant_1cloud.config.token') if !@token
41
47
 
48
+ key = machine.config.ssh.private_key_path
49
+ key = key[0] if key.is_a?(Array)
50
+ if !key
51
+ errors << I18n.t('vagrant_1cloud.config.private_key')
52
+ elsif !File.file?(File.expand_path("#{key}.pub", machine.env.root_path))
53
+ errors << I18n.t('vagrant_1cloud.config.public_key', {
54
+ :key => "#{key}.pub"
55
+ })
56
+ end
57
+
42
58
  { '1cloud Provider' => errors }
43
59
  end
44
60
  end
@@ -21,8 +21,8 @@ module VagrantPlugins
21
21
  error_key(:certificate)
22
22
  end
23
23
 
24
- class LocalIPError < OneCloudError
25
- error_key(:local_ip)
24
+ class PublicKeyError < OneCloudError
25
+ error_key(:public_key)
26
26
  end
27
27
 
28
28
  class RsyncError < OneCloudError
@@ -53,6 +53,20 @@ module VagrantPlugins
53
53
  raise e
54
54
  end
55
55
 
56
+ unless method == :delete
57
+ begin
58
+ body = JSON.parse(%Q[{"body":#{result.body}}])
59
+ @logger.info "Response: #{body}"
60
+ rescue JSON::ParserError => e
61
+ raise(Errors::JSONError, {
62
+ :message => e.message,
63
+ :path => path,
64
+ :params => params,
65
+ :response => result.body
66
+ })
67
+ end
68
+ end
69
+
56
70
  unless /^2\d\d$/ =~ result.status.to_s
57
71
  raise(Errors::APIStatusError, {
58
72
  :path => path,
@@ -62,7 +76,7 @@ module VagrantPlugins
62
76
  })
63
77
  end
64
78
 
65
- Result.new(result)
79
+ Result.new(body)
66
80
  end
67
81
 
68
82
  def wait_for_event(env, m_id, id)
@@ -74,7 +88,20 @@ module VagrantPlugins
74
88
  result = self.request("/server/#{m_id}/action/#{id}")
75
89
 
76
90
  yield result if block_given?
77
- raise 'not ready' if result['State'] != 'Completed'
91
+ raise 'not ready' if result['body']['State'] != 'Completed'
92
+ end
93
+ end
94
+
95
+ def wait_for_network(env, net_id)
96
+ retryable(:tries => 120, :sleep => 10) do
97
+ # stop waiting if interrupted
98
+ next if env[:interrupted]
99
+
100
+ # check network status
101
+ result = self.request("/network/#{net_id}")
102
+
103
+ yield result if block_given?
104
+ raise 'not ready' if result['body']['State'] != 'Active'
78
105
  end
79
106
  end
80
107
  end
@@ -11,7 +11,7 @@ module VagrantPlugins
11
11
  end
12
12
 
13
13
  def find_id(sub_obj, search)
14
- find(sub_obj, search)["id"]
14
+ find(sub_obj, search)["ID"]
15
15
  end
16
16
 
17
17
  def find(sub_obj, search)
@@ -37,4 +37,4 @@ module VagrantPlugins
37
37
  end
38
38
  end
39
39
  end
40
- end
40
+ end
@@ -12,16 +12,18 @@ module VagrantPlugins
12
12
 
13
13
  # load status of droplets if it has not been done before
14
14
  if !@droplets
15
- @droplets = client.request('/server')
15
+ result = client.request('/Server')
16
+ @droplets = result['body']
16
17
  end
17
18
 
18
19
  if opts[:refresh] && machine.id
19
20
  # refresh the droplet status for the given machine
20
- @droplets.delete_if { |d| d['id'].to_s == machine.id }
21
- @droplets << droplet = client.request("/server/#{machine.id}")
21
+ @droplets.delete_if { |d| d['ID'].to_s == machine.id }
22
+ result = client.request("/Server/#{machine.id}")
23
+ @droplets << droplet = result['body']
22
24
  else
23
25
  # lookup droplet status for the given machine
24
- droplet = @droplets.find { |d| d['id'].to_s == machine.id }
26
+ droplet = @droplets.find { |d| d['ID'].to_s == machine.id }
25
27
  end
26
28
 
27
29
  # if lookup by id failed, check for a droplet with a matching name
@@ -29,11 +31,11 @@ module VagrantPlugins
29
31
  # TODO allow the user to configure this behavior
30
32
  if !droplet
31
33
  name = machine.config.vm.hostname || machine.name
32
- droplet = @droplets.find { |d| d['name'] == name.to_s }
33
- machine.id = droplet['id'].to_s if droplet
34
+ droplet = @droplets.find { |d| d['Name'] == name.to_s }
35
+ machine.id = droplet['ID'].to_s if droplet
34
36
  end
35
37
 
36
- droplet ||= {'state' => 'not_created'}
38
+ droplet ||= {'State' => 'not_created'}
37
39
  end
38
40
 
39
41
  def initialize(machine)
@@ -54,14 +56,51 @@ module VagrantPlugins
54
56
  def machine_id_changed
55
57
  end
56
58
 
59
+ # This should return a hash of information that explains how to
60
+ # SSH into the machine. If the machine is not at a point where
61
+ # SSH is even possible, then `nil` should be returned.
62
+ #
63
+ # The general structure of this returned hash should be the
64
+ # following:
65
+ #
66
+ # {
67
+ # :host => "1.2.3.4",
68
+ # :port => "22",
69
+ # :username => "mitchellh",
70
+ # :private_key_path => "/path/to/my/key"
71
+ # }
72
+ #
73
+ # **Note:** Vagrant only supports private key based authenticatonion,
74
+ # mainly for the reason that there is no easy way to exec into an
75
+ # `ssh` prompt with a password, whereas we can pass a private key
76
+ # via commandline.
77
+ def ssh_info
78
+ droplet = Provider.droplet(@machine)
79
+ return nil if droplet['State'].to_sym != :Active
80
+ public_network = droplet['IP']
81
+
82
+ return {
83
+ :host => public_network,
84
+ :port => '22',
85
+ :username => 'root',
86
+ :private_key_path => nil
87
+ }
88
+ end
89
+
57
90
  # This should return the state of the machine within this provider.
58
91
  # The state must be an instance of {MachineState}. Please read the
59
92
  # documentation of that class for more information.
60
93
  def state
61
- state = Provider.droplet(@machine)['state'].to_sym
94
+ state = Provider.droplet(@machine)['State'].to_sym
95
+ if state == :Active
96
+ power = Provider.droplet(@machine)['IsPowerOn']
97
+ if power == false
98
+ state = 'off'
99
+ end
100
+ end
62
101
  long = short = state.to_s
63
102
  Vagrant::MachineState.new(state, short, long)
64
103
  end
65
104
  end
66
105
  end
67
- end
106
+ end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module OneCloud
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
@@ -8,6 +8,12 @@ module VagrantPlugins
8
8
  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
9
9
  end
10
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
+
11
17
  I18n.load_path << File.expand_path('locales/en.yml', source_root)
12
18
  I18n.reload!
13
19
  end
data/locales/en.yml CHANGED
@@ -11,9 +11,20 @@ en:
11
11
  powering_off: "Powering off the droplet..."
12
12
  powering_on: "Powering on the droplet..."
13
13
  reloading: "Rebooting the droplet..."
14
+ creating_user: "Creating user account: %{user}..."
15
+ setting_private_network: "Setting private network..."
16
+ creating_private_network: "Creating private network..."
14
17
  config:
15
18
  token: "Token is required"
19
+ private_key: "SSH private key path is required"
20
+ public_key: "SSH public key not found: %{key}"
16
21
  errors:
22
+ public_key: |-
23
+ There was an issue reading the public key at:
24
+
25
+ Path: %{path}
26
+
27
+ Please check the file's permissions.
17
28
  api_status: |-
18
29
  There was an issue with the request made to the 1cloud
19
30
  API at:
@@ -62,6 +73,4 @@ en:
62
73
 
63
74
  This is generally caused by the OpenSSL configuration associated
64
75
  with the Ruby install being unaware of the system specific ca
65
- certs.
66
- local_ip: |-
67
- The 1cloud provider was unable to determine the host's IP.
76
+ certs.
data/test/Vagrantfile CHANGED
@@ -1,16 +1,14 @@
1
1
  Vagrant.require_plugin('vagrant-1cloud')
2
2
 
3
3
  Vagrant.configure('2') do |config|
4
-
5
- config.vm.provider :onecloud do |provider|
6
- provider.token = ENV['DO_TOKEN']
7
- end
8
-
9
4
  config.vm.define "test" do |t|
10
- t.ssh.insert_key = false
11
- t.ssh.private_key_path = '~/.ssh/id_rsa'
12
- t.vm.box = 'onecloud'
13
- t.vm.hostname = 'test'
14
- t.vm.provision :shell, :path => 'scripts/provision.sh'
5
+ t.vm.provider :onecloud do |provider, override|
6
+ override.ssh.private_key_path = 'test_id_rsa'
7
+ override.vm.box = 'onecloud'
8
+ override.vm.hostname = 'test'
9
+ override.vm.provision :shell, :path => 'scripts/provision.sh'
10
+
11
+ provider.token = ENV['DO_TOKEN']
12
+ end
15
13
  end
16
14
  end
@@ -1,3 +1,3 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  echo 'Testing 1 2 3!'
data/test/test.sh CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env bash
1
2
  cd test
2
3
 
3
4
  bundle exec vagrant up --provider=onecloud
@@ -6,4 +7,4 @@ bundle exec vagrant provision
6
7
  bundle exec vagrant halt
7
8
  bundle exec vagrant destroy
8
9
 
9
- cd ..
10
+ cd ..
data/test/test_id_rsa ADDED
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEowIBAAKCAQEAmxZRyfvgXFxlPW9ivoxffdK9erqpCp1oitghUtDxbzPSCbNw
3
+ qBoiJcnPVA/TuCxMnruUcNEXYgKfTL8lD3A1Hom8N1pTAhSed5m4qAGqTMubT15s
4
+ cSR+SnDdriShErB/9YSb9LVn1aR0MsFS3H/+x1j4w5d6hBas8BhDfuVd16shvoaA
5
+ OKy0ywy+NBuvGy/6Au3q3t7M9wdelODRnYLSWWqaLeYExRKxWWc7ape+oduQoe4r
6
+ BNVwGmIOjWOM9aFPEPVHdLGO+LQyPExdeuS0rW96a39U4p8GjGzsrkNcKzVOGjM3
7
+ pIsGs3qOi7RzJ3z48HiBj9NT8I2fFpGHERerbQIDAQABAoIBABXsIcObhyuHJAh7
8
+ JkopLZZro70lhZ+qgIyf4JYEUxyVBqu4YcRhbVJKJLSNSDBQksQdX+5SoCuKk1oV
9
+ 6vcztU6Lyb9JVVKF96CQajnVgm04msutXUbhEbkUG0Hyi5JIwM3D4QfGXNcmWAaU
10
+ rVHeBfXH7eI4F2l0ix2lUGUvpwRFRDq9HgpOjXzyc57B4jeF7na/UTnt+Uoi4hzZ
11
+ FjjQ7nSLqEJLXtQBqt4EnAZu6/9JlAApunyMOX2oTqRNn8XGmD0Rc+AouipHM+Mc
12
+ 9/fN9oqVxxXw2MdJA6S/sEFLEDrbifmyyHOereuZtOjdWLqsCdZwewYl8nuBnYEU
13
+ GjVzYgECgYEAx+efis7xma28HWqtW9GLvjBcFAD/f+MDDeqX9TKFwf+91tUq0QZi
14
+ SqXvmIvCnpsO8I70WEskT+pPwJWReAbZBrCbCVDbH34KEkAHywH9sK6chWnB8OpU
15
+ 0mp0gH89A4bq/tedKVHCQ2sAbKgbIc1zf3zpmMQiV+smMDQXU1fTg/kCgYEAxpst
16
+ BD2cYftFjxFZE1v8fx6t6oHtzYRtNNFTYzfxzzRBaTTRRzdhSfh0tLFueyg/fcKR
17
+ oCXUxbfCYRLk+zHP2p/AyyN9R5p2AMAc6lOZPpBj7u9kjjDVnk76DYnLDqP3Da2s
18
+ i7b0DNYxm2gt1VSZfOuJHv7z85SLcJQsg+3ymBUCgYBrOpFX0d3Cw3COjvRitiox
19
+ YJtjl411uf2fb2EHg4xAHcBlBn8rFDOROyUkPIOutBn1a5kh61yVCWiyMwiOy42K
20
+ ixz+iEKhx+f7FiGYAX9lUKRg4/PGGMxa+gN4EchWpf5TqLCCw3pi03is0BeNsDjt
21
+ /8EF0t9hLZ+UZ7zDVe79cQKBgGTPi5AlfeW2V96BHcfX31jfR8RLY1v4pj4zKrKo
22
+ SRO2IKW4a6pMkBOuC/9UORJGocPCKY0y5sfduMrxfk2LQUhl4sS6JPNdkhxbZ9IB
23
+ 0T2SqUc1OMN8QlJzIDYTBYFO9S56Q6U/nq2NY+zQesNYh/iCzj1viIDRm93vOJFX
24
+ DNbpAoGBALlQvzzMsT3/fPYn8moQiUCJ9XRZ4X2qwYy5Q8J8QvutI+j9o9+pJBhc
25
+ 3zSlB8HHa7asf27GUbYtv7oFDpqqcC6EFtvfp1OCiX/OjBIJA1YXTFG3YWC5ngC4
26
+ JPxyTn4MdoX0enm8PRDg7CSZwa4AK1MIYetbiuJgWJ2wKXDFxuGH
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1 @@
1
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbFlHJ++BcXGU9b2K+jF990r16uqkKnWiK2CFS0PFvM9IJs3CoGiIlyc9UD9O4LEyeu5Rw0RdiAp9MvyUPcDUeibw3WlMCFJ53mbioAapMy5tPXmxxJH5KcN2uJKESsH/1hJv0tWfVpHQywVLcf/7HWPjDl3qEFqzwGEN+5V3XqyG+hoA4rLTLDL40G68bL/oC7ere3sz3B16U4NGdgtJZapot5gTFErFZZztql76h25Ch7isE1XAaYg6NY4z1oU8Q9Ud0sY74tDI8TF165LStb3prf1TinwaMbOyuQ1wrNU4aMzekiwazeo6LtHMnfPjweIGP01PwjZ8WkYcRF6tt onecloud provider test key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-1cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bulat Yusupov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -68,9 +68,12 @@ files:
68
68
  - lib/vagrant-1cloud/actions/check_state.rb
69
69
  - lib/vagrant-1cloud/actions/create.rb
70
70
  - lib/vagrant-1cloud/actions/destroy.rb
71
+ - lib/vagrant-1cloud/actions/modify_provision_path.rb
71
72
  - lib/vagrant-1cloud/actions/power_off.rb
72
73
  - lib/vagrant-1cloud/actions/power_on.rb
74
+ - lib/vagrant-1cloud/actions/private_network.rb
73
75
  - lib/vagrant-1cloud/actions/reload.rb
76
+ - lib/vagrant-1cloud/actions/setup_user.rb
74
77
  - lib/vagrant-1cloud/actions/shut_down.rb
75
78
  - lib/vagrant-1cloud/config.rb
76
79
  - lib/vagrant-1cloud/errors.rb
@@ -83,6 +86,8 @@ files:
83
86
  - test/Vagrantfile
84
87
  - test/scripts/provision.sh
85
88
  - test/test.sh
89
+ - test/test_id_rsa
90
+ - test/test_id_rsa.pub
86
91
  - vagrant-1cloud.gemspec
87
92
  homepage:
88
93
  licenses: []
@@ -103,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
108
  version: '0'
104
109
  requirements: []
105
110
  rubyforge_project:
106
- rubygems_version: 2.6.8
111
+ rubygems_version: 2.5.1
107
112
  signing_key:
108
113
  specification_version: 4
109
114
  summary: Enables Vagrant to manage 1cloud droplets. Based on https://github.com/devopsgroup-io/vagrant-digitalocean.
@@ -111,3 +116,5 @@ test_files:
111
116
  - test/Vagrantfile
112
117
  - test/scripts/provision.sh
113
118
  - test/test.sh
119
+ - test/test_id_rsa
120
+ - test/test_id_rsa.pub