]>
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 }],
65 portal
=> { fixed
=> 1 },
66 target
=> { fixed
=> 1 },
67 nodes
=> { optional
=> 1},
68 disable
=> { optional
=> 1},
69 content
=> { optional
=> 1},
73 # Storage implementation
76 my ($class, $volname) = @_;
79 if ($volname =~ m/^lun(\d+)$/) {
80 return ('images', $1, undef, undef, undef, undef, 'raw');
83 die "unable to parse iscsi volume name '$volname'\n";
88 my ($class, $scfg, $volname, $storeid, $snapname) = @_;
90 die "volume snapshot is not possible on iscsi device"
91 if defined($snapname);
93 my ($vtype, $lun, $vmid) = $class->parse_volname($volname);
95 my $target = $scfg->{target
};
96 my $portal = $scfg->{portal
};
98 my $path = "iscsi://$portal/$target/$lun";
100 return ($path, $vmid, $vtype);
104 my ($class, $storeid, $scfg, $volname) = @_;
106 die "can't create base images in iscsi storage\n";
110 my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
112 die "can't clone images in iscsi storage\n";
116 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
118 die "can't allocate space in iscsi storage\n";
122 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
124 die "can't free space in iscsi storage\n";
129 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
133 $cache->{directiscsi
} = iscsi_ls
($scfg,$storeid) if !$cache->{directiscsi
};
135 # we have no owner for iscsi devices
137 my $target = $scfg->{target
};
139 if (my $dat = $cache->{directiscsi
}->{$storeid}) {
141 foreach my $volname (keys %$dat) {
143 my $volid = "$storeid:$volname";
146 my $found = grep { $_ eq $volid } @$vollist;
149 # we have no owner for iscsi devices
150 next if defined($vmid);
153 my $info = $dat->{$volname};
154 $info->{volid
} = $volid;
165 my ($class, $storeid, $scfg, $cache) = @_;
171 return ($total,$free,$used,$active);
176 sub activate_storage
{
177 my ($class, $storeid, $scfg, $cache) = @_;
181 sub deactivate_storage
{
182 my ($class, $storeid, $scfg, $cache) = @_;
186 sub activate_volume
{
187 my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
191 sub deactivate_volume
{
192 my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
196 sub volume_size_info
{
197 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
199 my $vollist = iscsi_ls
($scfg,$storeid);
200 my $info = $vollist->{$storeid}->{$volname};
202 return $info->{size
};
206 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
207 die "volume resize is not possible on iscsi device";
210 sub volume_snapshot
{
211 my ($class, $scfg, $storeid, $volname, $snap) = @_;
212 die "volume snapshot is not possible on iscsi device";
215 sub volume_snapshot_rollback
{
216 my ($class, $scfg, $storeid, $volname, $snap) = @_;
217 die "volume snapshot rollback is not possible on iscsi device";
220 sub volume_snapshot_delete
{
221 my ($class, $scfg, $storeid, $volname, $snap) = @_;
222 die "volume snapshot delete is not possible on iscsi device";
225 sub volume_has_feature
{
226 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
229 copy
=> { current
=> 1},
232 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
233 $class->parse_volname($volname);
239 $key = $isBase ?
'base' : 'current';
241 return 1 if $features->{$feature}->{$key};