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
d667a3f3
Commit
d667a3f3
authored
Apr 22, 2015
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc: implement startup and onboot option
parent
445ed928
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
7 deletions
+181
-7
Nodes.pm
PVE/API2/Nodes.pm
+36
-7
Makefile
www/manager/Makefile
+1
-0
Config.js
www/manager/lxc/Config.js
+5
-0
Options.js
www/manager/lxc/Options.js
+139
-0
No files found.
PVE/API2/Nodes.pm
View file @
d667a3f3
...
@@ -1199,12 +1199,22 @@ my $get_start_stop_list = sub {
...
@@ -1199,12 +1199,22 @@ my $get_start_stop_list = sub {
my
$bootorder
=
LONG_MAX
;
my
$bootorder
=
LONG_MAX
;
if
(
$d
->
{
type
}
eq
'
qemu
')
{
if
(
$d
->
{
type
}
eq
'
lxc
')
{
my
$conf
=
PVE::LXC::
load_config
(
$vmid
);
return
if
$autostart
&&
!
$conf
->
{'
pve.onboot
'};
if
(
$conf
->
{'
pve.startup
'})
{
$startup
=
PVE::JSONSchema::
parse_startup
(
$conf
->
{'
pve.startup
'});
$startup
->
{
order
}
=
$bootorder
if
!
defined
(
$startup
->
{
order
});
}
else
{
$startup
=
{
order
=>
$bootorder
};
}
}
elsif
(
$d
->
{
type
}
eq
'
qemu
')
{
my
$conf
=
PVE::QemuServer::
load_config
(
$vmid
);
my
$conf
=
PVE::QemuServer::
load_config
(
$vmid
);
return
if
$autostart
&&
!
$conf
->
{
onboot
};
return
if
$autostart
&&
!
$conf
->
{
onboot
};
if
(
$conf
->
{
startup
})
{
if
(
$conf
->
{
startup
})
{
$startup
=
PVE::QemuServer
::
parse_startup
(
$conf
->
{
startup
});
$startup
=
PVE::JSONSchema
::
parse_startup
(
$conf
->
{
startup
});
$startup
->
{
order
}
=
$bootorder
if
!
defined
(
$startup
->
{
order
});
$startup
->
{
order
}
=
$bootorder
if
!
defined
(
$startup
->
{
order
});
}
else
{
}
else
{
$startup
=
{
order
=>
$bootorder
};
$startup
=
{
order
=>
$bootorder
};
...
@@ -1282,7 +1292,11 @@ __PACKAGE__->register_method ({
...
@@ -1282,7 +1292,11 @@ __PACKAGE__->register_method ({
my
$default_delay
=
0
;
my
$default_delay
=
0
;
my
$upid
;
my
$upid
;
if
(
$d
->
{
type
}
eq
'
qemu
')
{
if
(
$d
->
{
type
}
eq
'
lxc
')
{
return
if
PVE::LXC::
check_running
(
$vmid
);
print
STDERR
"
Starting CT
$vmid
\n
";
$upid
=
PVE::API2::
LXC
->
vm_start
({
node
=>
$nodename
,
vmid
=>
$vmid
});
}
elsif
(
$d
->
{
type
}
eq
'
qemu
')
{
$default_delay
=
3
;
# to redruce load
$default_delay
=
3
;
# to redruce load
return
if
PVE::QemuServer::
check_running
(
$vmid
,
1
);
return
if
PVE::QemuServer::
check_running
(
$vmid
,
1
);
print
STDERR
"
Starting VM
$vmid
\n
";
print
STDERR
"
Starting VM
$vmid
\n
";
...
@@ -1307,7 +1321,11 @@ __PACKAGE__->register_method ({
...
@@ -1307,7 +1321,11 @@ __PACKAGE__->register_method ({
}
}
}
}
}
else
{
}
else
{
print
STDERR
"
Starting VM
$vmid
failed: status
\n
";
if
(
$d
->
{
type
}
eq
'
lxc
')
{
print
STDERR
"
Starting CT
$vmid
failed:
$status
\n
";
}
elsif
(
$d
->
{
type
}
eq
'
qemu
')
{
print
STDERR
"
Starting VM
$vmid
failed: status
\n
";
}
}
}
};
};
warn
$@
if
$@
;
warn
$@
if
$@
;
...
@@ -1323,7 +1341,13 @@ my $create_stop_worker = sub {
...
@@ -1323,7 +1341,13 @@ my $create_stop_worker = sub {
my
(
$nodename
,
$type
,
$vmid
,
$down_timeout
)
=
@_
;
my
(
$nodename
,
$type
,
$vmid
,
$down_timeout
)
=
@_
;
my
$upid
;
my
$upid
;
if
(
$type
eq
'
qemu
')
{
if
(
$type
eq
'
lxc
')
{
return
if
!
PVE::LXC::
check_running
(
$vmid
);
my
$timeout
=
defined
(
$down_timeout
)
?
int
(
$down_timeout
)
:
60
;
print
STDERR
"
Stopping CT
$vmid
(timeout =
$timeout
seconds)
\n
";
$upid
=
PVE::API2::
LXC
->
vm_shutdown
({
node
=>
$nodename
,
vmid
=>
$vmid
,
timeout
=>
$timeout
,
forceStop
=>
1
});
}
elsif
(
$type
eq
'
qemu
')
{
return
if
!
PVE::QemuServer::
check_running
(
$vmid
,
1
);
return
if
!
PVE::QemuServer::
check_running
(
$vmid
,
1
);
my
$timeout
=
defined
(
$down_timeout
)
?
int
(
$down_timeout
)
:
60
*
3
;
my
$timeout
=
defined
(
$down_timeout
)
?
int
(
$down_timeout
)
:
60
*
3
;
print
STDERR
"
Stopping VM
$vmid
(timeout =
$timeout
seconds)
\n
";
print
STDERR
"
Stopping VM
$vmid
(timeout =
$timeout
seconds)
\n
";
...
@@ -1412,11 +1436,16 @@ my $create_migrate_worker = sub {
...
@@ -1412,11 +1436,16 @@ my $create_migrate_worker = sub {
my
(
$nodename
,
$type
,
$vmid
,
$target
)
=
@_
;
my
(
$nodename
,
$type
,
$vmid
,
$target
)
=
@_
;
my
$upid
;
my
$upid
;
if
(
$type
eq
'
qemu
')
{
if
(
$type
eq
'
lxc
')
{
my
$online
=
PVE::LXC::
check_running
(
$vmid
)
?
1
:
0
;
print
STDERR
"
Migrating CT
$vmid
\n
";
$upid
=
PVE::API2::
LXC
->
migrate_vm
({
node
=>
$nodename
,
vmid
=>
$vmid
,
target
=>
$target
,
online
=>
$online
});
}
elsif
(
$type
eq
'
qemu
')
{
my
$online
=
PVE::QemuServer::
check_running
(
$vmid
,
1
)
?
1
:
0
;
my
$online
=
PVE::QemuServer::
check_running
(
$vmid
,
1
)
?
1
:
0
;
print
STDERR
"
Migrating VM
$vmid
\n
";
print
STDERR
"
Migrating VM
$vmid
\n
";
$upid
=
PVE::API2::
Qemu
->
migrate_vm
({
node
=>
$nodename
,
vmid
=>
$vmid
,
target
=>
$target
,
$upid
=
PVE::API2::
Qemu
->
migrate_vm
({
node
=>
$nodename
,
vmid
=>
$vmid
,
target
=>
$target
,
online
=>
$online
});
online
=>
$online
});
}
else
{
}
else
{
die
"
unknown VM type '
$type
'
\n
";
die
"
unknown VM type '
$type
'
\n
";
}
}
...
...
www/manager/Makefile
View file @
d667a3f3
...
@@ -143,6 +143,7 @@ JSSRC= \
...
@@ -143,6 +143,7 @@ JSSRC= \
lxc/Summary.js
\
lxc/Summary.js
\
lxc/Network.js
\
lxc/Network.js
\
lxc/Resources.js
\
lxc/Resources.js
\
lxc/Options.js
\
lxc/Config.js
\
lxc/Config.js
\
lxc/CreateWizard.js
\
lxc/CreateWizard.js
\
pool/StatusView.js
\
pool/StatusView.js
\
...
...
www/manager/lxc/Config.js
View file @
d667a3f3
...
@@ -135,6 +135,11 @@ Ext.define('PVE.lxc.Config', {
...
@@ -135,6 +135,11 @@ Ext.define('PVE.lxc.Config', {
itemId
:
'
network
'
,
itemId
:
'
network
'
,
xtype
:
'
pveLxcNetworkView
'
xtype
:
'
pveLxcNetworkView
'
},
},
{
title
:
gettext
(
'
Options
'
),
itemId
:
'
options
'
,
xtype
:
'
pveLxcOptions
'
},
{
{
title
:
gettext
(
'
Task History
'
),
title
:
gettext
(
'
Task History
'
),
itemId
:
'
tasks
'
,
itemId
:
'
tasks
'
,
...
...
www/manager/lxc/Options.js
0 → 100644
View file @
d667a3f3
/*jslint confusion: true */
Ext
.
define
(
'
PVE.lxc.Options
'
,
{
extend
:
'
PVE.grid.ObjectGrid
'
,
alias
:
[
'
widget.pveLxcOptions
'
],
initComponent
:
function
()
{
var
me
=
this
;
var
i
;
var
nodename
=
me
.
pveSelNode
.
data
.
node
;
if
(
!
nodename
)
{
throw
"
no node name specified
"
;
}
var
vmid
=
me
.
pveSelNode
.
data
.
vmid
;
if
(
!
vmid
)
{
throw
"
no VM ID specified
"
;
}
var
caps
=
Ext
.
state
.
Manager
.
get
(
'
GuiCap
'
);
var
rows
=
{
onboot
:
{
header
:
gettext
(
'
Start at boot
'
),
defaultValue
:
''
,
renderer
:
PVE
.
Utils
.
format_boolean
,
editor
:
caps
.
vms
[
'
VM.Config.Options
'
]
?
{
xtype
:
'
pveWindowEdit
'
,
subject
:
gettext
(
'
Start at boot
'
),
items
:
{
xtype
:
'
pvecheckbox
'
,
name
:
'
onboot
'
,
uncheckedValue
:
0
,
defaultValue
:
0
,
fieldLabel
:
gettext
(
'
Start at boot
'
)
}
}
:
undefined
},
startup
:
{
header
:
gettext
(
'
Start/Shutdown order
'
),
defaultValue
:
''
,
renderer
:
PVE
.
Utils
.
render_kvm_startup
,
editor
:
caps
.
vms
[
'
VM.Config.Options
'
]
&&
caps
.
nodes
[
'
Sys.Modify
'
]
?
'
PVE.qemu.StartupEdit
'
:
undefined
},
ostemplate
:
{
header
:
gettext
(
'
Template
'
),
defaultValue
:
'
no set
'
},
storage
:
{
header
:
gettext
(
'
Storage
'
),
defaultValue
:
'
no set
'
},
cpuunits
:
{
header
:
gettext
(
'
CPU units
'
),
defaultValue
:
'
1024
'
,
editor
:
caps
.
vms
[
'
VM.Config.CPU
'
]
?
{
xtype
:
'
pveWindowEdit
'
,
subject
:
gettext
(
'
CPU units
'
),
items
:
{
xtype
:
'
numberfield
'
,
name
:
'
cpuunits
'
,
fieldLabel
:
gettext
(
'
CPU units
'
),
minValue
:
8
,
maxValue
:
500000
,
allowBlank
:
false
}
}
:
undefined
}
};
var
baseurl
=
'
nodes/
'
+
nodename
+
'
/lxc/
'
+
vmid
+
'
/config
'
;
var
reload
=
function
()
{
me
.
rstore
.
load
();
};
var
sm
=
Ext
.
create
(
'
Ext.selection.RowModel
'
,
{});
var
run_editor
=
function
()
{
var
rec
=
sm
.
getSelection
()[
0
];
if
(
!
rec
)
{
return
;
}
var
rowdef
=
rows
[
rec
.
data
.
key
];
if
(
!
rowdef
.
editor
)
{
return
;
}
var
win
;
if
(
Ext
.
isString
(
rowdef
.
editor
))
{
win
=
Ext
.
create
(
rowdef
.
editor
,
{
pveSelNode
:
me
.
pveSelNode
,
confid
:
rec
.
data
.
key
,
url
:
'
/api2/extjs/
'
+
baseurl
});
}
else
{
var
config
=
Ext
.
apply
({
pveSelNode
:
me
.
pveSelNode
,
confid
:
rec
.
data
.
key
,
url
:
'
/api2/extjs/
'
+
baseurl
},
rowdef
.
editor
);
win
=
Ext
.
createWidget
(
rowdef
.
editor
.
xtype
,
config
);
win
.
load
();
}
win
.
show
();
win
.
on
(
'
destroy
'
,
reload
);
};
var
edit_btn
=
new
PVE
.
button
.
Button
({
text
:
gettext
(
'
Edit
'
),
disabled
:
true
,
selModel
:
sm
,
enableFn
:
function
(
rec
)
{
var
rowdef
=
rows
[
rec
.
data
.
key
];
return
!!
rowdef
.
editor
;
},
handler
:
run_editor
});
Ext
.
applyIf
(
me
,
{
url
:
"
/api2/json/nodes/
"
+
nodename
+
"
/lxc/
"
+
vmid
+
"
/config
"
,
selModel
:
sm
,
cwidth1
:
150
,
tbar
:
[
edit_btn
],
rows
:
rows
,
listeners
:
{
itemdblclick
:
run_editor
}
});
me
.
callParent
();
me
.
on
(
'
show
'
,
reload
);
}
});
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