Module: VagrantPlugins::Rackspace::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-rackspace/action.rb,
lib/vagrant-rackspace/action/is_created.rb,
lib/vagrant-rackspace/action/read_state.rb,
lib/vagrant-rackspace/action/list_images.rb,
lib/vagrant-rackspace/action/create_image.rb,
lib/vagrant-rackspace/action/list_flavors.rb,
lib/vagrant-rackspace/action/list_servers.rb,
lib/vagrant-rackspace/action/sync_folders.rb,
lib/vagrant-rackspace/action/create_server.rb,
lib/vagrant-rackspace/action/delete_server.rb,
lib/vagrant-rackspace/action/list_keypairs.rb,
lib/vagrant-rackspace/action/list_networks.rb,
lib/vagrant-rackspace/action/read_ssh_info.rb,
lib/vagrant-rackspace/action/connect_rackspace.rb,
lib/vagrant-rackspace/action/message_not_created.rb,
lib/vagrant-rackspace/action/message_already_created.rb

Defined Under Namespace

Classes: ConnectRackspace, CreateImage, CreateServer, DeleteServer, IsCreated, ListFlavors, ListImages, ListKeyPairs, ListNetworks, ListServers, MessageAlreadyCreated, MessageNotCreated, ReadSSHInfo, ReadState, SyncFolders

Class Method Summary collapse

Class Method Details

.action_create_imageObject



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vagrant-rackspace/action.rb', line 126

def self.action_create_image
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      created = env[:result]

      if !created
        b2.use MessageNotCreated
        next
      end

      b2.use ConnectRackspace
      b2.use CreateImage
    end
  end
end

.action_destroyObject

This action is called to destroy the remote machine.



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

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

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

.action_list_flavorsObject



152
153
154
155
156
157
158
# File 'lib/vagrant-rackspace/action.rb', line 152

def self.action_list_flavors
  Vagrant::Action::Builder.new.tap do |b|
    # b.use ConfigValidate # is this per machine?
    b.use ConnectRackspace
    b.use ListFlavors
  end
end

.action_list_imagesObject

Extended actions



144
145
146
147
148
149
150
# File 'lib/vagrant-rackspace/action.rb', line 144

def self.action_list_images
  Vagrant::Action::Builder.new.tap do |b|
    # b.use ConfigValidate # is this per machine?
    b.use ConnectRackspace
    b.use ListImages
  end
end

.action_list_keypairsObject



160
161
162
163
164
165
# File 'lib/vagrant-rackspace/action.rb', line 160

def self.action_list_keypairs
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectRackspace
    b.use ListKeyPairs
  end
end

.action_provisionObject

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



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

def self.action_provision
  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 Provision
      if defined?(SyncedFolders)
        b2.use SyncedFolders
      else
        b2.use SyncFolders
      end
    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.



58
59
60
61
62
63
64
# File 'lib/vagrant-rackspace/action.rb', line 58

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



69
70
71
72
73
74
75
# File 'lib/vagrant-rackspace/action.rb', line 69

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

.action_sshObject



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

def self.action_ssh
  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 SSHExec
    end
  end
end

.action_ssh_runObject



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

def self.action_ssh_run
  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 SSHRun
    end
  end
end

.action_upObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/vagrant-rackspace/action.rb', line 105

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

      b2.use ConnectRackspace
      b2.use Provision
      if defined?(SyncedFolders)
        b2.use SyncedFolders
      else
        b2.use SyncFolders
      end
      b2.use CreateServer
    end
  end
end