Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simple-vm-manager
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
simple-vm-manager
Commits
0e8f22d6
There was an error fetching the commit references. Please try again later.
Commit
0e8f22d6
authored
1 year ago
by
Recolic
Browse files
Options
Downloads
Patches
Plain Diff
.backing_file
parent
351f2475
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cron-callback.sh
+15
-7
15 additions, 7 deletions
cron-callback.sh
init.settings
+5
-1
5 additions, 1 deletion
init.settings
runtime.settings
+2
-2
2 additions, 2 deletions
runtime.settings
with
22 additions
and
10 deletions
cron-callback.sh
+
15
−
7
View file @
0e8f22d6
...
...
@@ -64,13 +64,19 @@ function create_vm_if_not_exist () {
download_cloud_img_if_not_exist
"
$cloudimg
"
||
return
$?
rm
-rf
"vm/
$name
"
;
mkdir
-p
"vm/
$name
"
# create it
echo2
"+ Creating VM image
$name
with options
$@
..."
generate_metadata
"
$name
"
>
"vm/
$name
/meta-data"
||
return
$?
generate_userdata
"
$username
"
"
$password
"
"
$name
"
>
"vm/
$name
/user-data"
||
return
$?
(
cd
"vm/
$name
"
;
genisoimage
-output
initimg.iso
-volid
cidata
-joliet
-rock
user-data meta-data
)
||
return
$?
qemu-img create
-f
qcow2
-F
qcow2
-o
backing_file
=
"../../base/
$cloudimg
"
"vm/
$name
/disk.img"
||
return
$?
qemu-img resize
"vm/
$name
/disk.img"
"
$disk
"
||
return
$?
if
[
-z
"
$disk
"
]
;
then
# create from cloudimg
generate_metadata
"
$name
"
>
"vm/
$name
/meta-data"
||
return
$?
generate_userdata
"
$username
"
"
$password
"
"
$name
"
>
"vm/
$name
/user-data"
||
return
$?
(
cd
"vm/
$name
"
;
genisoimage
-output
initimg.iso
-volid
cidata
-joliet
-rock
user-data meta-data
)
||
return
$?
qemu-img create
-f
qcow2
-F
qcow2
-b
"../../base/
$cloudimg
"
"vm/
$name
/disk.img"
||
return
$?
qemu-img resize
"vm/
$name
/disk.img"
"
$disk
"
||
return
$?
else
# create from baseimg
qemu-img create
-f
qcow2
-F
qcow2
-b
"../../base/
$cloudimg
"
"vm/
$name
/disk.img"
||
return
$?
fi
}
function
start_vm_if_not_running
()
{
...
...
@@ -104,9 +110,11 @@ function do_init () {
# Parse the line as "name;cloudimg;disk;username;password", trim space
IFS
=
';'
read
-r
name cloudimg disk username password
<<<
"
$(
echo
"
$line
"
|
tr
-s
'[:space:]'
';'
)
"
#
Check if all fields are non-empty
#
2 options or 5 options allowed, otherwise bad config line.
if
[
-n
"
$name
"
]
&&
[
-n
"
$cloudimg
"
]
&&
[
-n
"
$disk
"
]
&&
[
-n
"
$username
"
]
&&
[
-n
"
$password
"
]
;
then
create_vm_if_not_exist
"
$name
"
"
$cloudimg
"
"
$disk
"
"
$username
"
"
$password
"
||
echo2
"Failed to create_vm_if_not_exist.
$?
"
elif
[
-n
"
$name
"
]
&&
[
-n
"
$cloudimg
"
]
&&
[
!
-n
"
$disk
"
]
&&
[
!
-n
"
$username
"
]
&&
[
!
-n
"
$password
"
]
;
then
create_vm_if_not_exist
"
$name
"
"
$cloudimg
"
||
echo2
"Failed to create_vm_if_not_exist.
$?
"
else
echo2
"Error: Bad configuration line:
$line
"
fi
...
...
This diff is collapsed.
Click to expand it.
init.settings
+
5
−
1
View file @
0e8f22d6
## init VM from cloudimg
# name;cloudimg;disk;username;password (space will be trimmed)
instance1;focal-server-cloudimg-amd64.img;60G;r;1
gitlab-ci;Arch-Linux-x86_64-cloudimg.qcow2;40G;r;1
#httptest ;focal-server-cloudimg-amd64.img;20G;r;1
## or init VM from pre-deployed backing image (please put it into data/base/)
# name;existing_img_fname
devbox;win10pro-22h2-virtio-uefi.qcow2
This diff is collapsed.
Click to expand it.
runtime.settings
+
2
−
2
View file @
0e8f22d6
# name;options (name will be trimmed, options will be passed as-is)
instance1;-m 2G -smp 2 -vnc :11 -net user,hostfwd=tcp::30471-:22
gitlab-ci;-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22
#httptest
;-m
1
G -smp
1
-vnc :13 -net user,hostfwd=tcp::3047
4
-:
22,hostfwd=tcp::30480-:80
gitlab-ci;-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22
,hostfwd=tcp::30474-:8080
devbox
;-m
6
G -smp
6
-vnc :13 -net user,hostfwd=tcp::3047
5
-:
3389 -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time
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