Top Level Namespace

Includes:
Commander::Delegates, Commander::UI, Commander::UI::AskForClass

Defined Under Namespace

Modules: RestClient, VirtualMaster

Instance Method Summary collapse

Instance Method Details

#callback(name, &block) ⇒ Object



3
4
5
6
7
# File 'lib/vmaster/callbacks.rb', line 3

def callback(name, &block)
  cb = VirtualMaster::Callbacks::Callback.new(name, &block)

  VirtualMaster::CLI.callbacks << cb
end

#copy_file(session, file, destination) ⇒ Object

Shell Provisioner



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/vmaster/callbacks/shell_provisioner.rb', line 5

def copy_file(session, file, destination)
  session.open_channel do |channel|
    channel.exec("cat > #{destination}") do |channel, success|
      channel.on_data do |ch,data|
        puts data
      end

      open(file) { |f| channel.send_data(f.read) }
      channel.eof!
    end
  end
  session.loop
end

#instance_action(action, options, args) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/vmaster/server_commands.rb', line 141

def instance_action(action, options, args)
  name = args.shift || abort('server name required')

  instance = VirtualMaster::Helpers.get_instance(name)

  abort "Invalid instance name!" if instance.nil?

  VirtualMaster::Callbacks.trigger_event(action.to_sym, :before, options.__hash__, instance)

  instance.send("#{action}!")

  VirtualMaster::Callbacks.trigger_event(action.to_sym, :after, options.__hash__, instance)

end

#run_command(session, command) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/vmaster/callbacks/shell_provisioner.rb', line 19

def run_command(session, command)
  session.open_channel do |channel|
    channel.on_data do |ch,data|
      puts data
    end

    channel.exec command
  end
  session.loop
end