Module: VagrantPlugins::StartCloud::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-startcloud/action.rb,
lib/vagrant-startcloud/action/is_created.rb,
lib/vagrant-startcloud/action/load_config.rb,
lib/vagrant-startcloud/action/is_virtualbox.rb,
lib/vagrant-startcloud/action/configure_disks.rb,
lib/vagrant-startcloud/action/configure_networks.rb,
lib/vagrant-startcloud/action/configure_providers.rb,
lib/vagrant-startcloud/action/configure_provisioners.rb,
lib/vagrant-startcloud/action/configure_shared_folders.rb

Defined Under Namespace

Classes: ConfigureDisks, ConfigureNetworks, ConfigureProviders, ConfigureProvisioners, ConfigureSharedFolders, IsCreated, IsVirtualBox, LoadConfig

Class Method Summary collapse

Class Method Details

.action_destroyObject



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

def action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use action_halt
        b2.use Call, IsVirtualBox do |env2, b3|
          if env2[:result]
            b3.use VagrantPlugins::ProviderVirtualBox::Action::Destroy
          else
            b3.use VagrantPlugins::ProviderZone::Action::Destroy
          end
        end
        b2.use CleanupNetworks
        b2.use ProvisionerCleanup
      end
    end
  end
end

.action_haltObject



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

def action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use Call, IsVirtualBox do |env2, b3|
          if env2[:result]
            b3.use VagrantPlugins::ProviderVirtualBox::Action::GracefulHalt
          else
            b3.use VagrantPlugins::ProviderZone::Action::GracefulHalt
          end
        end
        b2.use PowerOff
      end
    end
  end
end

.action_reloadObject



69
70
71
# File 'lib/vagrant-startcloud/action.rb', line 69

def action_reload
  action_up
end

.action_upObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vagrant-startcloud/action.rb', line 53

def action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use configure_machine
    b.use configure_providers
    b.use Call, IsVirtualBox do |env, b2|
      if env[:result]
        b2.use ConfigureDisks, provider: :virtualbox
      else
        b2.use ConfigureDisks, provider: :zones
      end
    end
    b.use configure_networks
    b.use configure_shared_folders
  end
end

.configure_machineObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-startcloud/action.rb', line 11

def configure_machine
  @configure_machine ||= Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use HandleBox
        b2.use Import
      end
    end
  end
end

.configure_networksObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-startcloud/action.rb', line 23

def configure_networks
  @configure_networks ||= Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsVirtualBox do |env, b2|
      if env[:result]
        b2.use ConfigureNetworks, provider: :virtualbox
      else
        b2.use ConfigureNetworks, provider: :zones
      end
    end
  end
end

.configure_providersObject



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

def configure_providers
  @configure_providers ||= Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsVirtualBox do |env, b2|
      if env[:result]
        b2.use ConfigureProviders, provider: :virtualbox
      else
        b2.use ConfigureProviders, provider: :zones
      end
    end
  end
end

.configure_shared_foldersObject



47
48
49
50
51
# File 'lib/vagrant-startcloud/action.rb', line 47

def configure_shared_folders
  @configure_shared_folders ||= Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigureSharedFolders
  end
end

.with_target_vms(machine_name = nil, **opts, &block) ⇒ Object



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

def with_target_vms(machine_name = nil, **opts, &block)
  env = opts.fetch(:env, Vagrant::Environment.new)
  env.machine_names = [machine_name] if machine_name

  env.batch(parallel: true) do |batch|
    env.active_machines.each do |name, provider|
      batch.action(env.machine(name, provider), :up, &block)
    end
  end
end