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
b96ff434
There was an error fetching the commit references. Please try again later.
Commit
b96ff434
authored
1 year ago
by
Recolic
Browse files
Options
Downloads
Patches
Plain Diff
.WIP
parent
fd34e5a1
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
src/cron-callback.sh
+49
-24
49 additions, 24 deletions
src/cron-callback.sh
src/init.settings
+1
-1
1 addition, 1 deletion
src/init.settings
src/runtime.settings
+4
-4
4 additions, 4 deletions
src/runtime.settings
with
54 additions
and
29 deletions
src/cron-callback.sh
+
49
−
24
View file @
b96ff434
...
...
@@ -3,9 +3,12 @@
workdir
=
./data
mkdir
-p
"
$workdir
"
cd
"
$workdir
"
cd
"
$workdir
"
||
exit
$?
mkdir
-p
base vm tmp
function
echo2
()
{
echo
"
$@
"
1>&2
}
function
generate_metadata
()
{
local
name
=
$1
echo
"local-hostname:
$name
"
...
...
@@ -78,28 +81,50 @@ function start_vm_if_not_running () {
# create_vm_from "$1" 2 4G 50G __hardcoded__ r 1 "$2" __hardcoded__ || exit $?
# echo "DEBUG: sshpass -p 1 ssh -p 30472 r@localhost"
while
IFS
=
read
-r
line
;
do
# Ignore lines starting with #
if
[[
"
$line
"
=
~ ^
\#
]]
;
then
continue
fi
# Trim leading and trailing whitespaces
line
=
$(
echo
"
$line
"
|
sed
-e
's/^[[:space:]]*//'
-e
's/[[:space:]]*$//'
)
# Check if the line is non-empty
if
[
-n
"
$line
"
]
;
then
# Parse the line as "name;cloudimg;disk;username;password"
IFS
=
';'
read
-r
name cloudimg disk username password
<<<
"
$line
"
# Print the parsed values
echo
"Name:
$name
"
echo
"Cloud Image:
$cloudimg
"
echo
"Disk:
$disk
"
echo
"Username:
$username
"
echo
"Password:
$password
"
echo
"---------------------"
fi
done
< ./init.settings
function
do_init
()
{
while
IFS
=
read
-r
line
;
do
# Check if the line is non-empty
if
[
-n
"
$line
"
]
;
then
# 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
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.
$?
"
else
echo2
"Error: Bad configuration line:
$line
"
fi
fi
done
< ../init.settings
}
function
do_start
()
{
while
IFS
=
read
-r
line
;
do
# Ignore lines starting with #
if
[[
"
$line
"
=
~ ^
\#
]]
;
then
continue
fi
# Trim leading and trailing whitespaces
line
=
$(
echo
"
$line
"
|
sed
-e
's/^[[:space:]]*//'
-e
's/[[:space:]]*$//'
)
# Check if the line is non-empty
if
[
-n
"
$line
"
]
;
then
# Parse the line as "name;options", only trim space in name, options can contain ;
name
=
$(
echo
"
$line
"
|
sed
-e
's/[[:space:]]*;.*$//'
-e
's/^[[:space:]]*//'
)
options
=
$(
echo
"
$line
"
|
sed
's/^[^:]*://'
)
# Check if the name is empty
if
[
-n
"
$name
"
]
;
then
# Print the parsed values
echo
"Name:
$name
|"
echo
"Options:
$options
|"
echo
"---------------------"
else
# Print an error message for empty name
echo
"Error: Name is empty. Skipping the line."
fi
fi
done
< ../runtime.settings
}
This diff is collapsed.
Click to expand it.
src/init.settings
+
1
−
1
View file @
b96ff434
# name;cloudimg;disk;username;password
# name;cloudimg;disk;username;password
(space will be trimmed)
instance1;focal-server-cloudimg-amd64.img;60G;r;1
gitlab-ci;focal-server-cloudimg-amd64.img;60G;r;1
httptest ;focal-server-cloudimg-amd64.img;60G;r;1
This diff is collapsed.
Click to expand it.
src/runtime.settings
+
4
−
4
View file @
b96ff434
# name;options
instance1;
focal-server-cloudimg-amd64.img;60G;
-m 2G -smp 2 -vnc :11 -net user,hostfwd=tcp::30472-:22
gitlab-ci;
focal-server-cloudimg-amd64.img;40G;
-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22
httptest
;focal-server-cloudimg-amd64.img;20G
;-m 1G -smp 1 -vnc :13 -net user,hostfwd=tcp::30474-:22
# name;options
(space in name will be trimmed)
instance1;-m 2G -smp 2 -vnc :11 -net user,hostfwd=tcp::30472-:22
gitlab-ci;-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22
httptest ;-m 1G -smp 1 -vnc :13 -net user,hostfwd=tcp::30474-:22
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