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
4cda3858
Commit
4cda3858
authored
Feb 09, 2015
by
Alexandre Derumier
Committed by
Dietmar Maurer
Feb 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api2 : node : add migrate_all
Signed-off-by:
Alexandre Derumier
<
aderumier@odiso.com
>
parent
77773600
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
Nodes.pm
PVE/API2/Nodes.pm
+102
-0
No files found.
PVE/API2/Nodes.pm
View file @
4cda3858
...
@@ -190,6 +190,7 @@ __PACKAGE__->register_method({
...
@@ -190,6 +190,7 @@ __PACKAGE__->register_method({
},
},
method
=>
'
GET
',
method
=>
'
GET
',
proxyto
=>
'
node
',
proxyto
=>
'
node
',
proxyto
=>
'
node
',
protected
=>
1
,
# openvz /proc entries are only readable by root
protected
=>
1
,
# openvz /proc entries are only readable by root
description
=>
"
Get user_beancounters failcnt for all active containers.
",
description
=>
"
Get user_beancounters failcnt for all active containers.
",
parameters
=>
{
parameters
=>
{
...
@@ -1277,6 +1278,7 @@ __PACKAGE__->register_method ({
...
@@ -1277,6 +1278,7 @@ __PACKAGE__->register_method ({
path
=>
'
startall
',
path
=>
'
startall
',
method
=>
'
POST
',
method
=>
'
POST
',
protected
=>
1
,
protected
=>
1
,
proxyto
=>
'
node
',
description
=>
"
Start all VMs and containers (when onboot=1).
",
description
=>
"
Start all VMs and containers (when onboot=1).
",
parameters
=>
{
parameters
=>
{
additionalProperties
=>
0
,
additionalProperties
=>
0
,
...
@@ -1403,6 +1405,7 @@ __PACKAGE__->register_method ({
...
@@ -1403,6 +1405,7 @@ __PACKAGE__->register_method ({
path
=>
'
stopall
',
path
=>
'
stopall
',
method
=>
'
POST
',
method
=>
'
POST
',
protected
=>
1
,
protected
=>
1
,
proxyto
=>
'
node
',
description
=>
"
Stop all VMs and Containers.
",
description
=>
"
Stop all VMs and Containers.
",
parameters
=>
{
parameters
=>
{
additionalProperties
=>
0
,
additionalProperties
=>
0
,
...
@@ -1467,6 +1470,105 @@ __PACKAGE__->register_method ({
...
@@ -1467,6 +1470,105 @@ __PACKAGE__->register_method ({
}});
}});
my
$create_migrate_worker
=
sub
{
my
(
$nodename
,
$type
,
$vmid
,
$target
)
=
@_
;
my
$upid
;
if
(
$type
eq
'
openvz
')
{
my
$online
=
PVE::OpenVZ::
check_running
(
$vmid
)
?
1
:
0
;
print
STDERR
"
Migrating CT
$vmid
\n
";
$upid
=
PVE::API2::
OpenVZ
->
migrate_vm
({
node
=>
$nodename
,
vmid
=>
$vmid
,
target
=>
$target
,
online
=>
$online
});
}
elsif
(
$type
eq
'
qemu
')
{
my
$online
=
PVE::QemuServer::
check_running
(
$vmid
,
1
)
?
1
:
0
;
print
STDERR
"
Migrating VM
$vmid
\n
";
$upid
=
PVE::API2::
Qemu
->
migrate_vm
({
node
=>
$nodename
,
vmid
=>
$vmid
,
target
=>
$target
,
online
=>
$online
});
}
else
{
die
"
unknown VM type '
$type
'
\n
";
}
my
$res
=
PVE::Tools::
upid_decode
(
$upid
);
return
$res
->
{
pid
};
};
__PACKAGE__
->
register_method
({
name
=>
'
migrateall
',
path
=>
'
migrateall
',
method
=>
'
POST
',
proxyto
=>
'
node
',
protected
=>
1
,
description
=>
"
Migrate all VMs and Containers.
",
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
node
=>
get_standard_option
('
pve-node
'),
target
=>
get_standard_option
('
pve-node
',
{
description
=>
"
Target node.
"
}),
maxworkers
=>
{
description
=>
"
Max parralel migration job.
",
type
=>
'
integer
',
minimum
=>
1
},
},
},
returns
=>
{
type
=>
'
string
',
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$rpcenv
=
PVE::RPCEnvironment::
get
();
my
$authuser
=
$rpcenv
->
get_user
();
my
$nodename
=
$param
->
{
node
};
$nodename
=
PVE::INotify::
nodename
()
if
$nodename
eq
'
localhost
';
my
$target
=
$param
->
{
target
};
my
$maxWorkers
=
$param
->
{
maxworkers
};
my
$code
=
sub
{
$rpcenv
->
{
type
}
=
'
priv
';
# to start tasks in background
my
$migrateList
=
&
$get_start_stop_list
(
$nodename
);
foreach
my
$order
(
sort
{
$b
<=>
$a
}
keys
%
$migrateList
)
{
my
$vmlist
=
$migrateList
->
{
$order
};
my
$workers
=
{};
foreach
my
$vmid
(
sort
{
$b
<=>
$a
}
keys
%
$vmlist
)
{
my
$d
=
$vmlist
->
{
$vmid
};
my
$pid
;
eval
{
$pid
=
&
$create_migrate_worker
(
$nodename
,
$d
->
{
type
},
$vmid
,
$target
);
};
warn
$@
if
$@
;
next
if
!
$pid
;
$workers
->
{
$pid
}
=
1
;
while
(
scalar
(
keys
%
$workers
)
>=
$maxWorkers
)
{
foreach
my
$p
(
keys
%
$workers
)
{
if
(
!
PVE::ProcFSTools::
check_process_running
(
$p
))
{
delete
$workers
->
{
$p
};
}
}
sleep
(
1
);
}
}
while
(
scalar
(
keys
%
$workers
))
{
foreach
my
$p
(
keys
%
$workers
)
{
if
(
!
PVE::ProcFSTools::
check_process_running
(
$p
))
{
delete
$workers
->
{
$p
};
}
}
sleep
(
1
);
}
}
return
;
};
return
$rpcenv
->
fork_worker
('
migrateall
',
undef
,
$authuser
,
$code
);
}});
package
PVE::API2::
Nodes
;
package
PVE::API2::
Nodes
;
use
strict
;
use
strict
;
...
...
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