A prog2-höz tartozó friss repo anyagok itt elérhetőek: https://git.iit.bme.hu/prog2

You need to sign in or sign up before continuing.
Commit 0af3e59f by Karsa Zoltán István

resourcepool configuration manual mode

parent 1b1e1bf3
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)
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):
......
......@@ -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":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment