]>
git.proxmox.com Git - pve-storage.git/blob - PVE/API2/Disks/LVM.pm
1 package PVE
::API2
::Disks
::LVM
;
6 use PVE
::Storage
::LVMPlugin
;
8 use PVE
::JSONSchema
qw(get_standard_option);
9 use PVE
::API2
::Storage
::Config
;
10 use PVE
::Tools
qw(lock_file);
12 use PVE
::RPCEnvironment
;
15 use base
qw(PVE::RESTHandler);
17 __PACKAGE__-
>register_method ({
24 check
=> ['perm', '/', ['Sys.Audit', 'Datastore.Audit'], any
=> 1],
26 description
=> "List LVM Volume Groups",
28 additionalProperties
=> 0,
30 node
=> get_standard_option
('pve-node'),
49 description
=> 'The name of the volume group',
53 description
=> 'The size of the volume group in bytes',
57 description
=> 'The free bytes in the volume group',
62 description
=> 'The underlying physical volumes',
71 description
=> 'The name of the physical volume',
75 description
=> 'The size of the physical volume in bytes',
79 description
=> 'The free bytes in the physical volume',
94 my $vgs = PVE
::Storage
::LVMPlugin
::lvm_vgs
(1);
96 foreach my $vg_name (sort keys %$vgs) {
97 my $vg = $vgs->{$vg_name};
98 $vg->{name
} = $vg_name;
100 foreach my $pv (@{$vg->{pvs
}}) {
103 $vg->{children
} = delete $vg->{pvs
};
113 __PACKAGE__-
>register_method ({
120 check
=> ['perm', '/', ['Sys.Modify', 'Datastore.Allocate']],
122 description
=> "Create an LVM Volume Group",
124 additionalProperties
=> 0,
126 node
=> get_standard_option
('pve-node'),
127 name
=> get_standard_option
('pve-storage-id'),
130 description
=> 'The block device you want to create the volume group on',
133 description
=> "Configure storage using the Volume Group",
140 returns
=> { type
=> 'string' },
144 my $rpcenv = PVE
::RPCEnvironment
::get
();
145 my $user = $rpcenv->get_user();
147 my $name = $param->{name
};
148 my $dev = $param->{device
};
149 my $node = $param->{node
};
151 $dev = PVE
::Diskmanage
::verify_blockdev_path
($dev);
152 PVE
::Diskmanage
::check_unused
($dev);
153 PVE
::Storage
::assert_sid_unused
($name) if $param->{add_storage
};
156 PVE
::Diskmanage
::locked_disk_action
(sub {
157 PVE
::Storage
::LVMPlugin
::lvm_create_volume_group
($dev, $name);
159 if ($param->{add_storage
}) {
160 my $storage_params = {
164 content
=> 'rootdir,images',
169 PVE
::API2
::Storage
::Config-
>create($storage_params);
174 return $rpcenv->fork_worker('lvmcreate', $name, $user, $worker);