Module: VagrantPlugins::ProfitBricks::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-profitbricks/action.rb,
lib/vagrant-profitbricks/action/is_created.rb,
lib/vagrant-profitbricks/action/read_state.rb,
lib/vagrant-profitbricks/action/list_images.rb,
lib/vagrant-profitbricks/action/stop_server.rb,
lib/vagrant-profitbricks/action/list_flavors.rb,
lib/vagrant-profitbricks/action/start_server.rb,
lib/vagrant-profitbricks/action/create_server.rb,
lib/vagrant-profitbricks/action/delete_server.rb,
lib/vagrant-profitbricks/action/read_ssh_info.rb,
lib/vagrant-profitbricks/action/reboot_server.rb,
lib/vagrant-profitbricks/action/run_init_script.rb,
lib/vagrant-profitbricks/action/message_not_created.rb,
lib/vagrant-profitbricks/action/connect_profitbricks.rb,
lib/vagrant-profitbricks/action/message_already_created.rb

Defined Under Namespace

Classes: ConnectProfitBricks, CreateServer, DeleteServer, IsCreated, ListFlavors, ListImages, MessageAlreadyCreated, MessageNotCreated, ReadSSHInfo, ReadState, Reboot, RunInitScript, Start, Stop

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to destroy the remote machine.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vagrant-profitbricks/action.rb', line 33

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      unless env[:result]
        b1.use MessageNotCreated
        next
      end

      b1.use Call, DestroyConfirm do |env1, b2|
        if env1[:result]
          b2.use ConnectProfitBricks
          b2.use DeleteServer
          b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
        else
          b2.use Message, I18n.t('vagrant_profitbricks.will_not_destroy')
          next
        end
      end
    end
  end
end

.action_haltObject



160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/vagrant-profitbricks/action.rb', line 160

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |env, b1|
      unless env[:result]
        b1.use MessageNotCreated
        next
      end

      b1.use ConfigValidate
      b1.use ConnectProfitBricks
      b1.use Stop
    end
  end
end

.action_list_flavorsObject



189
190
191
192
193
194
195
# File 'lib/vagrant-profitbricks/action.rb', line 189

def self.action_list_flavors
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectProfitBricks
    b.use ListFlavors
  end
end

.action_list_imagesObject



197
198
199
200
201
202
# File 'lib/vagrant-profitbricks/action.rb', line 197

def self.action_list_images
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectProfitBricks
    b.use ListImages
  end
end

.action_provisionObject

This action is called when ‘vagrant provision` is called.



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vagrant-profitbricks/action.rb', line 75

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Provision
    end
  end
end

.action_read_ssh_infoObject

This action is called to read the SSH info of the machine. The resulting state is expected to be put into the ‘:machine_ssh_info` key.



92
93
94
95
96
97
98
# File 'lib/vagrant-profitbricks/action.rb', line 92

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectProfitBricks
    b.use ReadSSHInfo
  end
end

.action_read_stateObject

This action is called to read the state of the machine. The resulting state is expected to be put into the ‘:machine_state_id` key.



103
104
105
106
107
108
109
# File 'lib/vagrant-profitbricks/action.rb', line 103

def self.action_read_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectProfitBricks
    b.use ReadState
  end
end

.action_reloadObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/vagrant-profitbricks/action.rb', line 56

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectProfitBricks
    b.use Call, GetState do |env, b1|
      case env[:machine_state]
      when :active
        b1.use Reload
        b1.use Provision
      when :off
        env[:ui].info I18n.t('vagrant_profitbricks.states.long_off')
      when :not_created
        env[:ui].info I18n.t('vagrant_profitbricks.not_created')
      end
    end
  end
end

.action_sshObject



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

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SSHExec
    end
  end
end

.action_ssh_runObject



125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/vagrant-profitbricks/action.rb', line 125

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SSHRun
    end
  end
end

.action_upObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/vagrant-profitbricks/action.rb', line 139

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectProfitBricks
    b.use Call, ReadState do |env, b2|
      if env[:result]
        b2.use MessageAlreadyCreated
        next
      end
      case env[:machine_state_id]
      when :not_created
        b2.use CreateServer
        b2.use Provision
      when :off
        b2.use Start
        b2.use Provision
      end
    end
  end
end