Module: Pipette::Commands

Included in:
Pipette
Defined in:
lib/pipette/commands.rb

Instance Method Summary collapse

Instance Method Details

#add(cmd_opts) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/pipette/commands.rb', line 34

def add(cmd_opts)
  raise "No logical volume name specified" unless cmd_opts[:name]
  raise "No logical volume size specified" unless cmd_opts[:size]
  raise "No volume group name specified" unless cmd_opts[:volume]

  dev = lv_create(cmd_opts[:name], cmd_opts[:volume], cmd_opts[:size])
  format(dev)
  mount(dev, "/data/#{cmd_opts[:name]}")
end

#append(cmd_opts) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/pipette/commands.rb', line 23

def append(cmd_opts)
  raise "No volume group name specified" unless cmd_opts[:name]
  raise "No EBS volume size specified" unless cmd_opts[:size]

  md_devs = create_mirrors(cmd_opts[:size],
                           cmd_opts[:num_mirrors],
                           cmd_opts[:ebs_per_mirror])

  vg_extend cmd_opts[:name], md_devs
end

#grow(cmd_opts) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/pipette/commands.rb', line 44

def grow(cmd_opts)
  raise "No logical volume name specified" unless cmd_opts[:name]
  raise "No logical volume size specified" unless cmd_opts[:size]
  raise "No volume group name specified" unless cmd_opts[:volume]

  dev = lv_dev(cmd_opts[:volume], cmd_opts[:name])
  lv_extend(dev, cmd_opts[:size])
  growfs(dev)
end

#init(cmd_opts) ⇒ Object

cmd_opts:

size: Size of each volume, in GB
name: Name of the volume group to create
ebs_per_mirror: Number of EBS volumes to put in each mirrored disk. Default 2.
num_mirrors: Number of mirrors to create, to be spanned by the volume group. Default 2.


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pipette/commands.rb', line 11

def init(cmd_opts)
  raise "No volume group name specified" unless cmd_opts[:name]
  raise "No EBS volume size specified" unless cmd_opts[:size]

  md_devs = create_mirrors(cmd_opts[:size],
                           cmd_opts[:num_mirrors],
                           cmd_opts[:ebs_per_mirror])


  vg_create cmd_opts[:name], md_devs
end

#remove(cmd_opts) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/pipette/commands.rb', line 54

def remove(cmd_opts)
    raise "No logical volume name specified" unless cmd_opts[:name]
    raise "No volume group name specified" unless cmd_opts[:volume]

	dev = lv_dev(cmd_opts[:volume], cmd_opts[:name])
	umount(dev)
	lv_remove(dev)
end