mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 11:32:41 +00:00
run openvz create_vm as background task
This commit is contained in:
parent
1ead9563a0
commit
7ca813e6fd
@ -108,10 +108,16 @@ __PACKAGE__->register_method({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
returns => { type => 'null'},
|
returns => {
|
||||||
|
type => 'string',
|
||||||
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
|
my $rpcenv = PVE::RPCEnvironment::get();
|
||||||
|
|
||||||
|
my $user = $rpcenv->get_user();
|
||||||
|
|
||||||
my $node = extract_param($param, 'node');
|
my $node = extract_param($param, 'node');
|
||||||
|
|
||||||
# fixme: fork worker?
|
# fixme: fork worker?
|
||||||
@ -164,6 +170,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $rawconf = PVE::OpenVZ::generate_raw_config($pve_base_ovz_config, $conf);
|
my $rawconf = PVE::OpenVZ::generate_raw_config($pve_base_ovz_config, $conf);
|
||||||
|
|
||||||
|
my $realcmd = sub {
|
||||||
PVE::Tools::file_set_contents($basecfg_fn, $rawconf);
|
PVE::Tools::file_set_contents($basecfg_fn, $rawconf);
|
||||||
|
|
||||||
my $cmd = ['vzctl', '--skiplock', 'create', $vmid, '--ostemplate', $tpath ];
|
my $cmd = ['vzctl', '--skiplock', 'create', $vmid, '--ostemplate', $tpath ];
|
||||||
@ -175,9 +182,10 @@ __PACKAGE__->register_method({
|
|||||||
PVE::OpenVZ::set_rootpasswd($vmid, $password) if defined($password);
|
PVE::OpenVZ::set_rootpasswd($vmid, $password) if defined($password);
|
||||||
};
|
};
|
||||||
|
|
||||||
PVE::OpenVZ::lock_container($vmid, $code);
|
return $rpcenv->fork_worker('vzcreate', $vmid, $user, $realcmd);
|
||||||
|
};
|
||||||
|
|
||||||
return undef;
|
return PVE::OpenVZ::lock_container($vmid, $code);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method({
|
__PACKAGE__->register_method({
|
||||||
|
Loading…
Reference in New Issue
Block a user