Module: VagrantPlugins::ProviderIijGp::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-iijgp/action.rb,
lib/vagrant-iijgp/action/boot.rb,
lib/vagrant-iijgp/action/destroy.rb,
lib/vagrant-iijgp/action/gc_list.rb,
lib/vagrant-iijgp/action/create_vm.rb,
lib/vagrant-iijgp/action/set_label.rb,
lib/vagrant-iijgp/action/is_created.rb,
lib/vagrant-iijgp/action/is_stopped.rb,
lib/vagrant-iijgp/action/read_state.rb,
lib/vagrant-iijgp/action/sync_folders.rb,
lib/vagrant-iijgp/action/check_running.rb,
lib/vagrant-iijgp/action/read_ssh_info.rb,
lib/vagrant-iijgp/action/prepare_iijapi.rb,
lib/vagrant-iijgp/action/vagrant_tweaks.rb,
lib/vagrant-iijgp/action/message_not_created.rb,
lib/vagrant-iijgp/action/stop_virtual_machine.rb,
lib/vagrant-iijgp/action/message_invalid_status.rb,
lib/vagrant-iijgp/action/message_already_running.rb,
lib/vagrant-iijgp/action/describe_virtual_machine.rb,
lib/vagrant-iijgp/action/message_will_not_destroy.rb

Defined Under Namespace

Classes: Boot, CheckRunning, CreateVM, DescribeVirtualMachine, Destroy, GcList, IsCreated, IsStopped, MessageAlreadyRunning, MessageInvalidStatus, MessageNotCreated, MessageWillNotDestroy, PrepareIIJAPI, ReadSSHInfo, ReadState, SetLabel, StopVirtualMachine, SyncFolders, VagrantTweaks

Class Method Summary collapse

Class Method Details

.action_bootObject



8
9
10
11
12
13
14
15
16
# File 'lib/vagrant-iijgp/action.rb', line 8

def self.action_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use Provision
    b.use SyncFolders
    b.use SetLabel
    b.use Boot
    b.use WaitForCommunicator, [:starting, :running]
  end
end

.action_destroyObject



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

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

      b1.use Call, DestroyConfirm do |env2, b2|
        if env2[:result]
          b2.use EnvSet, :force_halt => true
          b2.use action_halt
          b2.use Destroy
          b2.use ProvisionerCleanup
        else
          b2.use MessageWillNotDestroy
        end
      end
    end
  end
end

.action_gc_listObject



93
94
95
96
97
98
99
100
# File 'lib/vagrant-iijgp/action.rb', line 93

def self.action_gc_list
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PrepareIIJAPI
    b.use DescribeVirtualMachine
    b.use GcList
  end
end

.action_haltObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vagrant-iijgp/action.rb', line 40

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PrepareIIJAPI
    b.use Call, IsCreated do |env1, b1|
      if env1[:result]
        b1.use Call, IsStopped do |env2, b2|
          if !env2[:result]
            b2.use StopVirtualMachine
          end
        end
      else
        b1.use MessageNotCreated
      end
    end
  end
end

.action_provisionObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vagrant-iijgp/action.rb', line 58

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PrepareIIJAPI
    b.use Call, ReadState do |env1, b1|
      case env1[:machine_state]
      when :running
        b1.use Provision
        b1.use SyncFolders
        b1.use VagrantTweaks
      when :not_created, :initialized
        b1.use MessageNotCreated
      else
        b1.use MessageInvalidStatus
      end
    end
  end
end

.action_read_ssh_infoObject



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

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

.action_read_stateObject



110
111
112
113
114
115
116
# File 'lib/vagrant-iijgp/action.rb', line 110

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

.action_reloadObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vagrant-iijgp/action.rb', line 77

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

      b1.use action_halt
      b1.use action_up
    end
  end
end

.action_sshObject



118
119
120
121
122
123
124
125
# File 'lib/vagrant-iijgp/action.rb', line 118

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PrepareIIJAPI
    b.use CheckRunning
    b.use SSHExec
  end
end

.action_ssh_runObject



127
128
129
130
131
132
133
134
# File 'lib/vagrant-iijgp/action.rb', line 127

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PrepareIIJAPI
    b.use CheckRunning
    b.use SSHRun
  end
end

.action_startObject



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/vagrant-iijgp/action.rb', line 136

def self.action_start
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsStopped do |env1, b1|
      if env1[:result]
        b1.use action_boot
      else
        b1.use MessageAlreadyRunning
        next
      end
    end
  end
end

.action_upObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/vagrant-iijgp/action.rb', line 149

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PrepareIIJAPI
    b.use Call, ReadState do |env1, b1|
      case env1[:machine_state]
      when :not_created, :initialized
        b1.use CreateVM
        b1.use action_start
        b1.use VagrantTweaks
      when :stopped
        b1.use action_start
      when :running
        b1.use MessageAlreadyRunning
      else
        b1.use MessageInvalidStatus
      end
    end
  end
end