Class: Backstore_block_lv

Inherits:
Backstore_block show all
Defined in:
lib/Targetcli/Backstore_block_lv.rb

Instance Attribute Summary collapse

Attributes inherited from Backstore

#name, #path, #size, #status, #type, #write

Instance Method Summary collapse

Constructor Details

#initializeBackstore_block_lv



6
7
8
# File 'lib/Targetcli/Backstore_block_lv.rb', line 6

def initialize
  super
end

Instance Attribute Details

#lvObject

Returns the value of attribute lv.



4
5
6
# File 'lib/Targetcli/Backstore_block_lv.rb', line 4

def lv
  @lv
end

#vgObject

Returns the value of attribute vg.



3
4
5
# File 'lib/Targetcli/Backstore_block_lv.rb', line 3

def vg
  @vg
end

Instance Method Details

#create_cmdObject



34
35
36
# File 'lib/Targetcli/Backstore_block_lv.rb', line 34

def create_cmd
  @command + ' /backstores/block create name=' + @name + ' dev=/dev/' + @vg + '/' + @lv
end

#delete_cmdObject



38
39
40
# File 'lib/Targetcli/Backstore_block_lv.rb', line 38

def delete_cmd
  @command + ' /backstores/block delete ' + @name
end

#ls_all_cmdObject



42
43
44
# File 'lib/Targetcli/Backstore_block_lv.rb', line 42

def ls_all_cmd
  @command + ' /backstores/block ls'
end

#lsDecode(string) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/Targetcli/Backstore_block_lv.rb', line 10

def lsDecode string

  regexp_ls_backstore =  /^\s*\|\s+\|\s+\o\-\s+([\w\_]+)\s+[\.]+\s+\[\/dev\/([\w\_]+)\/([\w\_]+)\s+\((\d+\.\d+[MG]iB)\)\s+(write-thru)\s(activated)\]$/

  if %r{^No\ssuch\spath\s}.match(string)
    'no device'
  elsif match_ls_backstore = regexp_ls_backstore.match(string)

    @name = match_ls_backstore[1]
    @vg = match_ls_backstore[2]
    @lv = match_ls_backstore[3]
    @size = match_ls_backstore[4]
    @write = match_ls_backstore[5]
    @status = match_ls_backstore[6]

    @path = '/dev/' + @vg + '/' +@lv

    return 'device found'
  else
    puts "RegExp couldn't decode string >#{string}<"
    raise "Couldn't decode string"
  end
end