Module: VagrantPlugins::OCI::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-oci/action.rb,
lib/vagrant-oci/action/is_created.rb,
lib/vagrant-oci/action/is_stopped.rb,
lib/vagrant-oci/action/read_state.rb,
lib/vagrant-oci/action/connect_oci.rb,
lib/vagrant-oci/action/run_instance.rb,
lib/vagrant-oci/action/is_terminated.rb,
lib/vagrant-oci/action/read_ssh_info.rb,
lib/vagrant-oci/action/stop_instance.rb,
lib/vagrant-oci/action/warn_networks.rb,
lib/vagrant-oci/action/warn_ssh_keys.rb,
lib/vagrant-oci/action/start_instance.rb,
lib/vagrant-oci/action/terminate_instance.rb,
lib/vagrant-oci/action/message_not_created.rb,
lib/vagrant-oci/action/message_already_created.rb

Overview

rubocop:disable Metrics/ModuleLength

Defined Under Namespace

Classes: ConnectOCI, IsCreated, IsStopped, IsTerminated, MessageAlreadyCreated, MessageNotCreated, ReadSSHInfo, ReadState, RunInstance, StartInstance, StopInstance, TerminateInstance, WarnNetworks, WarnSshKeys

Class Method Summary collapse

Class Method Details

.action_destroyObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vagrant-oci/action.rb', line 120

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 ConnectOCI
          b3.use TerminateInstance
        end
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/vagrant-oci/action.rb', line 105

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

      b2.use ConnectOCI
      b2.use StopInstance
    end
  end
end

.action_provisionObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/vagrant-oci/action.rb', line 90

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
      b2.use SyncedFolders
    end
  end
end

.action_read_ssh_infoObject



17
18
19
20
21
22
23
# File 'lib/vagrant-oci/action.rb', line 17

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

.action_read_stateObject



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

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

.action_sshObject

This action is called to SSH into the machine.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vagrant-oci/action.rb', line 26

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



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

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



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vagrant-oci/action.rb', line 54

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use BoxCheckOutdated
    b.use ConnectOCI
    b.use Call, IsCreated do |env1, b1|
      if env1[:result]
        b1.use Call, IsTerminated do |env2, b2|
          if env2[:result]
            b2.use Provision
            b2.use SyncedFolders
            b2.use WarnNetworks
            b2.use WarnSshKeys
            b2.use RunInstance
          else
            b2.use Call, IsStopped do |env3, b3|
              if env3[:result]
                b3.use StartInstance
              else
                b2.use MessageAlreadyCreated # TODO write a better message
              end
            end
          end
        end
      else
        b1.use Provision
        b1.use SyncedFolders
        b1.use WarnNetworks
        b1.use WarnSshKeys
        b1.use RunInstance
      end
    end
  end
end