Class: Dcmgr::Drivers::Raw
Instance Method Summary
collapse
#sh, #tryagain
Methods included from Logger
create, default_logdev, included
#delete_snapshot, select_backing_store
Instance Method Details
#create_snapshot(ctx, snap_file) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/dcmgr/drivers/raw.rb', line 43
def create_snapshot(ctx, snap_file)
@volume = ctx.volume
logger.info("creating new snapshot: #{snap_file}")
cp_sparse(vol_path, snap_file)
if $?.exitstatus != 0
raise "failed snapshot file : #{snap_file}"
end
du_hs(snap_file)
logger.info("created new snapshot: #{snap_file}")
end
|
#create_volume(ctx, snap_file = nil) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/dcmgr/drivers/raw.rb', line 9
def create_volume(ctx, snap_file = nil)
@volume_id = ctx.volume_id
@volume = ctx.volume
@snapshot = ctx.snapshot
logger.info("creating new volume: #{@volume_id}")
if @snapshot
cp_sparse(snap_file, vol_path)
if $?.exitstatus != 0
raise "failed copy snapshot: #{snap_file}"
end
else
unless File.exist?(vol_path)
logger.info("creating parent filesystem(size:#{@volume[:size]}): #{vol_path}")
sh("/bin/mkdir -p #{File.dirname(vol_path)}") unless File.directory?(File.dirname(vol_path))
sh("/bin/dd if=/dev/zero of=#{vol_path} bs=1 count=0 seek=#{@volume[:size] * 1024 * 1024}")
du_hs(vol_path)
logger.info("create parent filesystem(size:#{@volume[:size]}): #{vol_path}")
else
raise "volume already exists: #{@volume_id}"
end
end
logger.info("created new volume: #{@volume_id}")
end
|
#delete_volume(ctx) ⇒ Object
38
39
40
41
|
# File 'lib/dcmgr/drivers/raw.rb', line 38
def delete_volume(ctx)
@volume = ctx.volume
sh("/bin/rm %s", [vol_path]) if File.exists?(vol_path)
end
|