Class: Conjure::Service::Volume

Inherits:
Object
  • Object
show all
Defined in:
lib/conjure/service/volume.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Volume

Returns a new instance of Volume.



6
7
8
9
10
# File 'lib/conjure/service/volume.rb', line 6

def initialize(options)
  @target = options[:target]
  @host_path = options[:host_path]
  @container_path = options[:container_path]
end

Instance Attribute Details

#container_pathObject (readonly)

Returns the value of attribute container_path.



4
5
6
# File 'lib/conjure/service/volume.rb', line 4

def container_path
  @container_path
end

#targetObject (readonly)

Returns the value of attribute target.



4
5
6
# File 'lib/conjure/service/volume.rb', line 4

def target
  @target
end

Instance Method Details

#read(filename) ⇒ Object



12
13
14
# File 'lib/conjure/service/volume.rb', line 12

def read(filename)
  shell.command "cat #{@container_path}/#{filename}"
end

#shellObject



20
21
22
23
24
25
# File 'lib/conjure/service/volume.rb', line 20

def shell
  @shell ||= @target.shell.prepare(
    :label => "volume",
    :host_volumes => {@host_path => @container_path},
  )
end

#write(filename, data) ⇒ Object



16
17
18
# File 'lib/conjure/service/volume.rb', line 16

def write(filename, data)
  shell.command "echo '#{data}' >#{@container_path}/#{filename}"
end