Module: VagrantPlugins::SimpleCloud::Actions

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

Defined Under Namespace

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

Class Method Summary collapse

Class Method Details

.destroy ⇒ Object



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

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_simple_cloud.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

.halt ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/vagrant-simplecloud/actions.rb', line 110

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
        if env[:force_halt] 
          b.use PowerOff
        else
          b.use ShutDown
        end
      when :off
        env[:ui].info I18n.t('vagrant_simple_cloud.info.already_off')
      when :not_created
        env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
      end
    end
  end
end

.provision ⇒ Object



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

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_simple_cloud.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
      end
    end
  end
end

.rebuild ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/vagrant-simplecloud/actions.rb', line 147

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_simple_cloud.info.not_created')
      end
    end
  end
end

.reload ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/vagrant-simplecloud/actions.rb', line 130

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_simple_cloud.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
      end
    end
  end
end

.ssh ⇒ Object



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

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_simple_cloud.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
      end
    end
  end
end

.ssh_run ⇒ Object



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

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_simple_cloud.info.off')
      when :not_created
        env[:ui].info I18n.t('vagrant_simple_cloud.info.not_created')
      end
    end
  end
end

.up ⇒ Object



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

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_simple_cloud.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