Module: VagrantPlugins::Scaleway::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-scaleway/action.rb,
lib/vagrant-scaleway/action/is_created.rb,
lib/vagrant-scaleway/action/is_stopped.rb,
lib/vagrant-scaleway/action/read_state.rb,
lib/vagrant-scaleway/action/list_images.rb,
lib/vagrant-scaleway/action/stop_server.rb,
lib/vagrant-scaleway/action/start_server.rb,
lib/vagrant-scaleway/action/create_server.rb,
lib/vagrant-scaleway/action/read_ssh_info.rb,
lib/vagrant-scaleway/action/warn_networks.rb,
lib/vagrant-scaleway/action/destroy_server.rb,
lib/vagrant-scaleway/action/connect_scaleway.rb,
lib/vagrant-scaleway/action/list_bootscripts.rb,
lib/vagrant-scaleway/action/message_not_created.rb,
lib/vagrant-scaleway/action/list_security_groups.rb,
lib/vagrant-scaleway/action/message_already_created.rb,
lib/vagrant-scaleway/action/message_will_not_destroy.rb

Defined Under Namespace

Classes: ConnectScaleway, CreateServer, DestroyServer, IsCreated, IsStopped, ListBootscripts, ListImages, ListSecurityGroups, MessageAlreadyCreated, MessageNotCreated, MessageWillNotDestroy, ReadSSHInfo, ReadState, StartServer, StopServer, WarnNetworks

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant-scaleway/action.rb', line 10

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

          b3.use ConnectScaleway
          b3.use ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
          b3.use DestroyServer
        end
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject

This action is called to halt the remote machine.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vagrant-scaleway/action.rb', line 33

def self.action_halt
  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 ConnectScaleway
      b2.use StopServer
    end
  end
end

.action_list_bootscriptsObject

This action is called to list available bootscripts.



163
164
165
166
167
168
# File 'lib/vagrant-scaleway/action.rb', line 163

def self.action_list_bootscripts
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectScaleway
    b.use ListBootscripts
  end
end

.action_list_imagesObject

This action is called to list available images.



171
172
173
174
175
176
# File 'lib/vagrant-scaleway/action.rb', line 171

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

.action_list_security_groupsObject

This action is called to list available security groups.



179
180
181
182
183
184
# File 'lib/vagrant-scaleway/action.rb', line 179

def self.action_list_security_groups
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectScaleway
    b.use ListSecurityGroups
  end
end

.action_provisionObject

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



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vagrant-scaleway/action.rb', line 49

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.



66
67
68
69
70
71
72
# File 'lib/vagrant-scaleway/action.rb', line 66

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectScaleway
    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.



77
78
79
80
81
82
83
# File 'lib/vagrant-scaleway/action.rb', line 77

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

.action_reloadObject

This action is called to restart the remote machine.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vagrant-scaleway/action.rb', line 86

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

      b1.use action_halt
      b1.use action_up
    end
  end
end

.action_sshObject

This action is called to SSH into the machine.



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/vagrant-scaleway/action.rb', line 103

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

This action is called to execute a command on the machine via SSH.



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/vagrant-scaleway/action.rb', line 118

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

This action is called to bring the box up from nothing.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/vagrant-scaleway/action.rb', line 133

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use BoxCheckOutdated
    b.use ConnectScaleway
    b.use Call, IsCreated do |env1, b1|
      if env1[:result]
        b1.use Call, IsStopped do |env2, b2|
          if env2[:result]
            b2.use Provision
            b2.use SyncedFolders
            b2.use WarnNetworks
            b2.use StartServer
          else
            b2.use MessageAlreadyCreated
          end
        end
      else
        b1.use Provision
        b1.use SyncedFolders
        b1.use WarnNetworks
        b1.use CreateServer
        b1.use StartServer
      end
    end
  end
end