Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
balancer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0af3e59f
authored
Jul 13, 2023
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resourcepool configuration manual mode
parent
1b1e1bf3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
balancer/algo.py
+0
-0
balancer/util.py
+20
-2
core/models.py
+8
-0
sredis/sredis.py
+4
-0
No files found.
balancer/algo.py
0 → 100644
View file @
0af3e59f
balancer/util.py
View file @
0af3e59f
from
fastapi.responses
import
ORJSONResponse
from
sredis.sredis
import
get_datacenter_token
,
rr_get
from
sredis.sredis
import
get_
all_datacenter
,
get_
datacenter_token
,
rr_get
from
fastapi
import
HTTPException
import
requests
import
json
...
...
@@ -74,5 +74,23 @@ def create_vm_from_template(
raise
HTTPException
(
status_code
=
500
,
detail
=
"Remote server error"
)
def
create_rp
(
username
:
str
,
rp
:
ResourcePoolSchema
):
def
get_stat_from_dc
(
datacenter
):
pass
def
create_rp
(
username
:
str
,
rp
:
ResourcePoolSchema
):
if
rp
.
manual
:
id
=
0
for
dc
,
cnt
in
rp
.
manual
.
items
():
for
_
in
range
(
cnt
):
create_vm_from_template
(
dc
,
username
,
name
=
f
"{rp.rpname} #{id}"
,
template_name
=
rp
.
from_template
,
)
id
+=
1
else
:
datacenters
=
get_all_datacenter
()
for
dc
in
datacenters
:
get_stat_from_dc
(
dc
)
core/models.py
View file @
0af3e59f
from
typing
import
Dict
from
pydantic
import
BaseModel
,
EmailStr
,
Field
...
...
@@ -31,6 +32,13 @@ class ResourcePoolSchema(BaseModel):
rpname
:
str
=
Field
(
min_length
=
3
,
max_length
=
50
)
from_template
:
str
=
Field
(
default
=
""
)
num_vms
:
int
=
Field
(
default
=
1
)
manual
:
Dict
=
Field
(
default
=
{
"https://kappa1.fured.cloud.bme.hu"
:
0
,
"https://kappa2.fured.cloud.bme.hu"
:
0
,
"https://kappa3.fured.cloud.bme.hu"
:
0
,
}
)
class
VMFromRP
(
BaseModel
):
...
...
sredis/sredis.py
View file @
0af3e59f
...
...
@@ -38,6 +38,10 @@ def reset():
pipe
.
execute
()
def
get_all_datacenter
():
return
r
.
lrange
(
"rrlist"
,
0
,
-
1
)
def
update_status
(
datacenter
):
status
=
"OK"
if
get_status
(
datacenter_url
=
datacenter
)
is
True
else
"Wrong"
if
status
==
"Wrong"
:
...
...
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