]>
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 ];
31 run_command
($cmd, errmsg
=> "iscsi error", errfunc
=> $errfunc, outfunc
=> sub {
34 if( $line =~ /Lun:(\d+)\s+([A-Za-z0-9\-\_\.\:]*)\s+\(Size:(\d+)G\)/ ) {
40 $list->{$storeid}->{$image} = {
49 die $err if $err && $err !~ m/TESTUNITREADY failed with SENSE KEY/ ;
61 content
=> [ {images
=> 1, none
=> 1}, { images
=> 1 }],
67 portal
=> { fixed
=> 1 },
68 target
=> { fixed
=> 1 },
69 nodes
=> { optional
=> 1},
70 disable
=> { optional
=> 1},
71 content
=> { optional
=> 1},
75 # Storage implementation
78 my ($class, $volname) = @_;
81 if ($volname =~ m/^(\d+)$/) {
82 return ('images', $1, undef);
85 die "unable to parse iscsi volume name '$volname'\n";
90 my ($class, $scfg, $volname) = @_;
92 my ($vtype, $lun, $vmid) = $class->parse_volname($volname);
94 my $target = $scfg->{target
};
95 my $portal = $scfg->{portal
};
97 my $path = "iscsi://$portal/$target/$lun";
99 return ($path, $vmid, $vtype);
104 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
106 die "can't allocate space in iscsi storage\n";
110 my ($class, $storeid, $scfg, $volname) = @_;
112 die "can't free space in iscsi storage\n";
117 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
121 $cache->{directiscsi
} = iscsi_ls
($scfg,$storeid) if !$cache->{directiscsi
};
123 # we have no owner for iscsi devices
125 my $target = $scfg->{target
};
127 if (my $dat = $cache->{directiscsi
}->{$storeid}) {
129 foreach my $volname (keys %$dat) {
131 my $volid = "$storeid:$volname";
134 my $found = grep { $_ eq $volid } @$vollist;
137 # we have no owner for iscsi devices
138 next if defined($vmid);
141 my $info = $dat->{$volname};
142 $info->{volid
} = $volid;
153 my ($class, $storeid, $scfg, $cache) = @_;
159 return ($total,$free,$used,$active);
164 sub activate_storage
{
165 my ($class, $storeid, $scfg, $cache) = @_;
169 sub deactivate_storage
{
170 my ($class, $storeid, $scfg, $cache) = @_;
174 sub activate_volume
{
175 my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
179 sub deactivate_volume
{
180 my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;