Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
fa9c2091
Commit
fa9c2091
authored
Apr 18, 2012
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement startall/stopall
parent
15e44239
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
1 deletion
+121
-1
pvectl
bin/pvectl
+114
-0
changelog.Debian
debian/changelog.Debian
+6
-0
defines.mk
defines.mk
+1
-1
No files found.
bin/pvectl
View file @
fa9c2091
...
...
@@ -35,6 +35,118 @@ my $upid_exit = sub {
exit
(
$status
eq
'
OK
'
?
0
:
-
1
);
};
__PACKAGE__
->
register_method
({
name
=>
'
startall
',
path
=>
'
startall
',
method
=>
'
POST
',
description
=>
"
Start all containers (when onboot=1).
",
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{},
},
returns
=>
{
type
=>
'
null
'},
code
=>
sub
{
my
(
$param
)
=
@_
;
# wait up to 10 seconds for quorum
for
(
my
$i
=
10
;
$i
>=
0
;
$i
--
)
{
last
if
PVE::Cluster::
check_cfs_quorum
(
$i
!=
0
?
1
:
0
);
sleep
(
1
);
}
my
$vzlist
=
PVE::OpenVZ::
vmstatus
();
my
$cc
=
PVE::Cluster::
cfs_read_file
('
cluster.conf
');
my
$startList
=
{};
foreach
my
$vmid
(
keys
%
$vzlist
)
{
next
if
$vzlist
->
{
$vmid
}
->
{
status
}
eq
'
running
';
# already running
my
$conf
;
eval
{
$conf
=
PVE::OpenVZ::
load_config
(
$vmid
);
};
if
(
my
$err
=
$@
)
{
warn
$err
;
next
;
}
next
if
!
$conf
;
next
if
!
(
$conf
->
{
onboot
}
&&
$conf
->
{
onboot
}
->
{
value
});
# skip ha managed VMs (started by rgmanager)
next
if
PVE::Cluster::
cluster_conf_lookup_pvevm
(
$cc
,
0
,
$vmid
,
1
);
if
(
$conf
->
{
bootorder
}
&&
defined
(
$conf
->
{
bootorder
}
->
{
value
}))
{
$vzlist
->
{
$vmid
}
->
{
bootorder
}
=
$conf
->
{
bootorder
}
->
{
value
};
}
else
{
$vzlist
->
{
$vmid
}
->
{
bootorder
}
=
-
1000000000
;
}
$startList
->
{
$vmid
}
=
$vzlist
->
{
$vmid
};
}
foreach
my
$vmid
(
sort
{
return
$a
<=>
$b
if
$startList
->
{
$b
}
->
{
bootorder
}
==
$startList
->
{
$a
}
->
{
bootorder
};
return
$startList
->
{
$b
}
->
{
bootorder
}
<=>
$startList
->
{
$a
}
->
{
bootorder
};
}
keys
%
$startList
)
{
PVE::Cluster::
check_cfs_quorum
();
# abort when we loose quorum
eval
{
print
STDERR
"
Starting CT
$vmid
\n
";
PVE::API2::
OpenVZ
->
vm_start
({
node
=>
$nodename
,
vmid
=>
$vmid
});
};
warn
$@
if
$@
;
}
return
undef
;
}});
__PACKAGE__
->
register_method
({
name
=>
'
stopall
',
path
=>
'
stopall
',
method
=>
'
POST
',
description
=>
"
Stop all containers.
",
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
timeout
=>
{
description
=>
"
Wait maximal timeout seconds.
",
type
=>
'
integer
',
minimum
=>
0
,
optional
=>
1
,
default
=>
60
,
},
},
},
returns
=>
{
type
=>
'
null
'},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$vzlist
=
PVE::OpenVZ::
vmstatus
();
my
$timeout
=
defined
(
$param
->
{
timeout
})
?
$param
->
{
timeout
}
:
60
;
syslog
('
info
',
"
Stopping all Container
");
foreach
my
$vmid
(
keys
%
$vzlist
)
{
next
if
$vzlist
->
{
$vmid
}
->
{
status
}
ne
'
running
';
# not running
eval
{
print
STDERR
"
Stoping CT
$vmid
\n
";
# Set fairsched parameters to maximum so CT will stop fast
# ignore any errors
system
("
vzctl set
$vmid
--cpuunits 2000 --cpulimit 0 >/dev/null 2>&1
");
PVE::API2::
OpenVZ
->
vm_shutdown
({
node
=>
$nodename
,
vmid
=>
$vmid
,
timeout
=>
$timeout
,
forceStop
=>
1
});
};
warn
$@
if
$@
;
}
return
undef
;
}});
my
$cmddef
=
{
list
=>
[
"
PVE::API2::OpenVZ
",
'
vmlist
',
[]
,
...
...
@@ -79,6 +191,8 @@ my $cmddef = {
umount
=>
[
'
PVE::API2::OpenVZ
',
'
vm_umount
',
['
vmid
'],
{
node
=>
$nodename
},
$upid_exit
],
migrate
=>
[
"
PVE::API2::OpenVZ
",
'
migrate_vm
',
['
vmid
',
'
target
'],
{
node
=>
$nodename
},
$upid_exit
],
startall
=>
[
__PACKAGE__
,
'
startall
',
[]
],
stopall
=>
[
__PACKAGE__
,
'
stopall
',
[]
],
};
my
$cmd
=
shift
;
...
...
debian/changelog.Debian
View file @
fa9c2091
pve-manager (2.0-63) unstable; urgency=low
* fix bug 128: implement pvectl startall/stopall
-- Proxmox Support Team <support@proxmox.com> Wed, 18 Apr 2012 10:02:54 +0200
pve-manager (2.0-62) unstable; urgency=low
* fix bug #115: simplify GUI for users without permissions.
...
...
defines.mk
View file @
fa9c2091
...
...
@@ -2,7 +2,7 @@ RELEASE=2.0
VERSION=2.0
PACKAGE=pve-manager
PACKAGERELEASE=6
2
PACKAGERELEASE=6
3
BINDIR=${DESTDIR}/usr/bin
PERLLIBDIR=${DESTDIR}/usr/share/perl5
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment