]>
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);
83 die "unable to parse iscsi volume name '$volname'\n";
88 my ($class, $scfg, $volname) = @_;
90 my ($vtype, $lun, $vmid) = $class->parse_volname($volname);
92 my $target = $scfg->{target
};
93 my $portal = $scfg->{portal
};
95 my $path = "iscsi://$portal/$target/$lun";
97 return ($path, $vmid, $vtype);
101 my ($class, $storeid, $scfg, $volname) = @_;
103 die "can't create base images in iscsi storage\n";
107 my ($class, $scfg, $storeid, $volname, $vmid) = @_;
109 die "can't clone images in iscsi storage\n";
113 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
115 die "can't allocate space in iscsi storage\n";
119 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
121 die "can't free space in iscsi storage\n";
126 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
130 $cache->{directiscsi
} = iscsi_ls
($scfg,$storeid) if !$cache->{directiscsi
};
132 # we have no owner for iscsi devices
134 my $target = $scfg->{target
};
136 if (my $dat = $cache->{directiscsi
}->{$storeid}) {
138 foreach my $volname (keys %$dat) {
140 my $volid = "$storeid:$volname";
143 my $found = grep { $_ eq $volid } @$vollist;
146 # we have no owner for iscsi devices
147 next if defined($vmid);
150 my $info = $dat->{$volname};
151 $info->{volid
} = $volid;
162 my ($class, $storeid, $scfg, $cache) = @_;
168 return ($total,$free,$used,$active);
173 sub activate_storage
{
174 my ($class, $storeid, $scfg, $cache) = @_;
178 sub deactivate_storage
{
179 my ($class, $storeid, $scfg, $cache) = @_;
183 sub activate_volume
{
184 my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
188 sub deactivate_volume
{
189 my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
193 sub volume_size_info
{
194 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
196 my $vollist = iscsi_ls
($scfg,$storeid);
197 my $info = $vollist->{$storeid}->{$volname};
199 return $info->{size
};
203 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
204 die "volume resize is not possible on iscsi device";
207 sub volume_snapshot
{
208 my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
209 die "volume snapshot is not possible on iscsi device";
212 sub volume_snapshot_rollback
{
213 my ($class, $scfg, $storeid, $volname, $snap) = @_;
214 die "volume snapshot rollback is not possible on iscsi device";
217 sub volume_snapshot_delete
{
218 my ($class, $scfg, $storeid, $volname, $snap) = @_;
219 die "volume snapshot delete is not possible on iscsi device";
222 sub volume_has_feature
{
223 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;