]>
git.proxmox.com Git - pve-storage.git/blob - PVE/Storage/ISCSIDirectPlugin.pm
1 package PVE
::Storage
::ISCSIDirectPlugin
;
8 use PVE
::Tools
qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach);
9 use PVE
::Storage
::Plugin
;
10 use PVE
::JSONSchema
qw(get_standard_option);
12 use base
qw(PVE::Storage::Plugin);
15 my ($scfg, $storeid) = @_;
17 my $portal = $scfg->{portal
};
18 my $cmd = ['/usr/bin/iscsi-ls', '-s', 'iscsi://'.$portal ];
23 "G" => 1024*1024*1024,
24 "T" => 1024*1024*1024*1024
28 run_command
($cmd, errmsg
=> "iscsi error", errfunc
=> sub {}, outfunc
=> sub {
31 if( $line =~ /Lun:(\d+)\s+([A-Za-z0-9\-\_\.\:]*)\s+\(Size:([0-9\.]*)(k|M|G|T)\)/ ) {
36 $list->{$storeid}->{$image} = {
38 size
=> $size * $unittobytes{$unit},
45 die $err if $err && $err !~ m/TESTUNITREADY failed with SENSE KEY/ ;
59 content
=> [ {images
=> 1, none
=> 1}, { images
=> 1 }],
66 portal
=> { fixed
=> 1 },
67 target
=> { fixed
=> 1 },
68 nodes
=> { optional
=> 1},
69 disable
=> { optional
=> 1},
70 content
=> { optional
=> 1},
71 bwlimit
=> { optional
=> 1 },
75 # Storage implementation
78 my ($class, $volname) = @_;
81 if ($volname =~ m/^lun(\d+)$/) {
82 return ('images', $1, undef, undef, undef, undef, 'raw');
85 die "unable to parse iscsi volume name '$volname'\n";
90 my ($class, $scfg, $volname, $storeid, $snapname) = @_;
92 die "volume snapshot is not possible on iscsi device"
93 if defined($snapname);
95 my ($vtype, $lun, $vmid) = $class->parse_volname($volname);
97 my $target = $scfg->{target
};
98 my $portal = $scfg->{portal
};
100 my $path = "iscsi://$portal/$target/$lun";
102 return ($path, $vmid, $vtype);
106 my ($class, $storeid, $scfg, $volname) = @_;
108 die "can't create base images in iscsi storage\n";
112 my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
114 die "can't clone images in iscsi storage\n";
118 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
120 die "can't allocate space in iscsi storage\n";
124 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
126 die "can't free space in iscsi storage\n";
131 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
135 $cache->{directiscsi
} = iscsi_ls
($scfg,$storeid) if !$cache->{directiscsi
};
137 # we have no owner for iscsi devices
139 my $target = $scfg->{target
};
141 if (my $dat = $cache->{directiscsi
}->{$storeid}) {
143 foreach my $volname (keys %$dat) {
145 my $volid = "$storeid:$volname";
148 my $found = grep { $_ eq $volid } @$vollist;
151 # we have no owner for iscsi devices
152 next if defined($vmid);
155 my $info = $dat->{$volname};
156 $info->{volid
} = $volid;
167 my ($class, $storeid, $scfg, $cache) = @_;
173 return ($total,$free,$used,$active);
178 sub activate_storage
{
179 my ($class, $storeid, $scfg, $cache) = @_;
183 sub deactivate_storage
{
184 my ($class, $storeid, $scfg, $cache) = @_;
188 sub activate_volume
{
189 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
191 die "volume snapshot is not possible on iscsi device" if $snapname;
196 sub deactivate_volume
{
197 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
199 die "volume snapshot is not possible on iscsi device" if $snapname;
204 sub volume_size_info
{
205 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
207 my $vollist = iscsi_ls
($scfg,$storeid);
208 my $info = $vollist->{$storeid}->{$volname};
210 return $info->{size
};
214 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
215 die "volume resize is not possible on iscsi device";
218 sub volume_snapshot
{
219 my ($class, $scfg, $storeid, $volname, $snap) = @_;
220 die "volume snapshot is not possible on iscsi device";
223 sub volume_snapshot_rollback
{
224 my ($class, $scfg, $storeid, $volname, $snap) = @_;
225 die "volume snapshot rollback is not possible on iscsi device";
228 sub volume_snapshot_delete
{
229 my ($class, $scfg, $storeid, $volname, $snap) = @_;
230 die "volume snapshot delete is not possible on iscsi device";
233 sub volume_has_feature
{
234 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
237 copy
=> { current
=> 1},
240 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
241 $class->parse_volname($volname);
247 $key = $isBase ?
'base' : 'current';
249 return 1 if $features->{$feature}->{$key};