Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nexus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_projects
nexus_vdi
nexus
Commits
7fa64239
Commit
7fa64239
authored
2 years ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
Added a bash script, template_creator, to help with the creation of disk images for templates
parent
f832d2fd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+18
-12
18 additions, 12 deletions
README.md
tools/template_creator/template_creator
+40
-0
40 additions, 0 deletions
tools/template_creator/template_creator
with
58 additions
and
12 deletions
README.md
+
18
−
12
View file @
7fa64239
...
...
@@ -157,13 +157,13 @@ TODO:
### Template management
| Done | Route | Description | Method | Parameters
| Required capabilities |
|--- |--- |--- |--- |---
|--- |
| |
`/templates`
| create a template | POST | vmID/qcow,name,descr
iption
,access |
`CAP_TPL_CREATE`
|
| p |
`/templates/{name}`
| delete a template | DELETE |
|
`CAP_TPL_DESTROY|CAP_TPL_DESTROY_ANY`
|
| p |
`/templates`
| list templates | GET |
|
`CAP_TPL_LIST|CAP_TPL_LIST_ANY`
|
| p |
`/templates/{name}`
| list a template | GET |
|
`CAP_TPL_LIST|CAP_TPL_LIST_ANY`
|
| | | | |
| |
| Done | Route | Description | Method | Parameters | Required capabilities |
|--- |--- |--- |--- |--- |--- |
| |
`/templates`
| create a template | POST | vmID/qcow,name,descr,access |
`CAP_TPL_CREATE`
|
| p |
`/templates/{name}`
| delete a template | DELETE | |
`CAP_TPL_DESTROY|CAP_TPL_DESTROY_ANY`
|
| p |
`/templates`
| list templates | GET | |
`CAP_TPL_LIST|CAP_TPL_LIST_ANY`
|
| p |
`/templates/{name}`
| list a template | GET | |
`CAP_TPL_LIST|CAP_TPL_LIST_ANY`
|
| | | | | | |
Remarks:
...
...
@@ -187,7 +187,7 @@ Remarks:
VM launched with QEMU running a spice server:
```
qemu-system-x86_64 -enable-kvm -smp cpus=$CPU -m $RAM -drive file=$DISK,index=0,media=disk,format=qcow2,if=virtio -vga virtio -device virtio-serial-pci -spice port=$SPICE_PORT,password=$SPICE_PWD -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent -nic user,mac=$MAC,model=virtio-net-pci -soundhw hda
qemu-system-x86_64 -enable-kvm
-cpu host
-smp cpus=$CPU -m $RAM -drive file=$DISK,index=0,media=disk,format=qcow2,if=virtio -vga virtio -device virtio-serial-pci -spice port=$SPICE_PORT,password=$SPICE_PWD -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent -nic user,mac=$MAC,model=virtio-net-pci -soundhw hda
```
The following parameters are defined at instantiation:
...
...
@@ -212,10 +212,16 @@ The following parameters are defined at instantiation:
```
-
At creation time, expose an option to choose whether to feature a network interface or not (typically, for exams)
Remark: to list the baking file of a disk:
```
qemu-img info --backing-chain disk.qcow
```
Remarks:
-
To list the baking file of a disk:
```
qemu-img info --backing-chain disk.qcow
```
-
To create an empty disk of 200GB:
```
qemu-img create -f qcow2 disk.qcow 200G
```
## File structure
...
...
This diff is collapsed.
Click to expand it.
tools/template_creator/template_creator
0 → 100755
+
40
−
0
View file @
7fa64239
#!/bin/bash
CPU
=
2
RAM
=
4096
DISK
=
disk.qcow
DISK_SIZE
=
200G
overwrite
=
1
function
echoerr
{
echo
"
$@
"
>
&2
}
if
[
$#
-ne
1
]
;
then
appname
=
`
basename
$0
`
echoerr
"
$appname
, a tool to create a VM template from an ISO image."
echoerr
"Upon installation completion,
\"
$DISK
\"
can be used in a VM template."
echoerr
"Usage:
$appname
ISO"
echoerr
"where ISO is an ISO image file of the OS to install."
exit
1
fi
ISO_IMAGE
=
$1
if
!
[
-f
$ISO_IMAGE
]
;
then
echoerr
"ISO image
\"
$ISO_IMAGE
\"
not found!"
exit
1
fi
if
[
-f
$DISK
]
;
then
echo
"Disk image
\"
$DISK
\"
already exists."
read
-e
-p
"Overwrite it? [y/N] "
choice
[[
"
$choice
"
==
[
Yy]
*
]]
&&
overwrite
=
1
||
overwrite
=
0
fi
if
[
$overwrite
-eq
1
]
;
then
qemu-img create
-f
qcow2
$DISK
$DISK_SIZE
fi
qemu-system-x86_64
-enable-kvm
-cpu
host
-smp
cpus
=
$CPU
-m
$RAM
-drive
file
=
$DISK
,index
=
0,media
=
disk,format
=
qcow2,if
=
virtio
-vga
virtio
-device
virtio-serial-pci
-device
virtserialport,chardev
=
spicechannel0,name
=
com.redhat.spice.0
-chardev
spicevmc,id
=
spicechannel0,name
=
vdagent
-nic
user,model
=
virtio-net-pci
-soundhw
hda
-drive
file
=
$ISO_IMAGE
,index
=
1,media
=
cdrom,format
=
raw,read-only
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment