Module: VagrantPlugins::DigitalOcean::Actions

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-digitalocean/actions.rb,
lib/vagrant-digitalocean/actions/create.rb,
lib/vagrant-digitalocean/actions/reload.rb,
lib/vagrant-digitalocean/actions/destroy.rb,
lib/vagrant-digitalocean/actions/rebuild.rb,
lib/vagrant-digitalocean/actions/power_on.rb,
lib/vagrant-digitalocean/actions/power_off.rb,
lib/vagrant-digitalocean/actions/setup_key.rb,
lib/vagrant-digitalocean/actions/setup_sudo.rb,
lib/vagrant-digitalocean/actions/setup_user.rb,
lib/vagrant-digitalocean/actions/check_state.rb,
lib/vagrant-digitalocean/actions/sync_folders.rb,
lib/vagrant-digitalocean/actions/modify_provision_path.rb

Defined Under Namespace

Classes: CheckState, Create, Destroy, ModifyProvisionPath, PowerOff, PowerOn, Rebuild, Reload, SetupKey, SetupSudo, SetupUser, SyncFolders

Class Method Summary collapse

Class Method Details

.destroyObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-digitalocean/actions.rb', line 19

def self.destroy
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      else
        b.use Call, DestroyConfirm do |env2, b2|
          if env2[:result]
            b2.use Destroy
            b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
          end
        end
      end
    end
  end
end

.haltObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/vagrant-digitalocean/actions.rb', line 109

def self.halt
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active
        b.use PowerOff
      when :off
        env[:ui].info I18n.t('vagrant_digital_ocean.info.already_off')
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      end
    end
  end
end

.provisionObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vagrant-digitalocean/actions.rb', line 70

def self.provision
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active
        b.use Provision
        b.use ModifyProvisionPath
        b.use SyncFolders
      when :off
        env[:ui].info I18n.t('vagrant_digital_ocean.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      end
    end
  end
end

.rebuildObject



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/vagrant-digitalocean/actions.rb', line 142

def self.rebuild
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active, :off
        b.use Rebuild
        b.use SetupSudo
        b.use SetupUser
        b.use provision
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      end
    end
  end
end

.reloadObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/vagrant-digitalocean/actions.rb', line 125

def self.reload
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active
        b.use Reload
        b.use provision
      when :off
        env[:ui].info I18n.t('vagrant_digital_ocean.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      end
    end
  end
end

.sshObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vagrant-digitalocean/actions.rb', line 38

def self.ssh
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active
        b.use SSHExec
      when :off
        env[:ui].info I18n.t('vagrant_digital_ocean.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      end
    end
  end
end

.ssh_runObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/vagrant-digitalocean/actions.rb', line 54

def self.ssh_run
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active
        b.use SSHRun
      when :off
        env[:ui].info I18n.t('vagrant_digital_ocean.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_digital_ocean.info.not_created')
      end
    end
  end
end

.upObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vagrant-digitalocean/actions.rb', line 88

def self.up
  return Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, CheckState do |env, b|
      case env[:machine_state]
      when :active
        env[:ui].info I18n.t('vagrant_digital_ocean.info.already_active')
      when :off
        b.use PowerOn
        b.use provision
      when :not_created
        b.use SetupKey
        b.use Create
        b.use SetupSudo
        b.use SetupUser
        b.use provision
      end
    end
  end
end