Skip to content

Commit

Permalink
feat: rewrite core system
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroday0619 committed Nov 9, 2020
1 parent d5be37b commit 9ca5288
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 630 deletions.
3 changes: 0 additions & 3 deletions API/v1/VM/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from API.v1.Interface import NameArgs
from API.v1.VM.serialize import serialize
from app.settings import Settings
from MySQL.VM import XenVm

router = APIRouter()

Expand Down Expand Up @@ -74,8 +73,6 @@ async def instance_clone_inurl(cluster_id: str, vm_uuid: str, clone_name: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=new_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down
3 changes: 0 additions & 3 deletions API/v1/VM/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from XenGarden.VM import VM

from app.settings import Settings
from MySQL.VM import XenVm

router = APIRouter()

Expand All @@ -31,8 +30,6 @@ async def vm_delete(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().remove_orphaned(cluster_id=cluster_id)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down
7 changes: 0 additions & 7 deletions API/v1/VM/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from API.v1.Interface import DescriptionArgs, NameArgs
from app.settings import Settings
from MySQL.VM import XenVm

router = APIRouter()

Expand Down Expand Up @@ -94,8 +93,6 @@ async def instance_set_name(cluster_id: str, vm_uuid: str, args: NameArgs):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -129,8 +126,6 @@ async def instance_set_name_inurl(
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -197,8 +192,6 @@ async def instance_set_description_inurl(
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down
19 changes: 1 addition & 18 deletions API/v1/VM/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from XenGarden.VM import VM

from app.settings import Settings
from MySQL.VM import XenVm

router = APIRouter()

Expand Down Expand Up @@ -57,13 +56,11 @@ async def vm_start(cluster_id: str, vm_uuid: str):
)

_vm: VM = VM.get_by_uuid(session=session, uuid=vm_uuid)
if XenVm is not None:
if _vm is not None:
ret = dict(success=_vm.start())
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -95,8 +92,6 @@ async def vm_shutdown(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -127,8 +122,6 @@ async def vm_power_force_shutdown(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -160,8 +153,6 @@ async def vm_power_restart(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -192,8 +183,6 @@ async def vm_power_suspend(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -224,8 +213,6 @@ async def vm_power_resume(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -256,8 +243,6 @@ async def vm_power_pause(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -288,8 +273,6 @@ async def vm_power_unpause(cluster_id: str, vm_uuid: str):
else:
ret = dict(success=False)

await XenVm().update(cluster_id=cluster_id, _vm=_vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down
9 changes: 0 additions & 9 deletions API/v1/VM/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from API.v1.Interface import MemoryArgs, VCpuArgs
from app.settings import Settings
from MySQL.VM import XenVm

router = APIRouter()

Expand Down Expand Up @@ -91,8 +90,6 @@ async def vm_set_vCPU(cluster_id: str, vm_uuid: str, args: VCpuArgs):
else:
ret = dict(success=False)

await XenVm().update(cluster_id, _vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -123,8 +120,6 @@ async def vm_set_vCPU_inurl(cluster_id: str, vm_uuid: str, vCPU_count: int):
else:
ret = dict(success=False)

await XenVm().update(cluster_id, _vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -186,8 +181,6 @@ async def vm_set_memory(cluster_id: str, vm_uuid: str, args: MemoryArgs):
else:
ret = dict(success=False)

await XenVm().update(cluster_id, _vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down Expand Up @@ -218,8 +211,6 @@ async def vm_set_memory_inurl(cluster_id: str, vm_uuid: str, memory_size: int):
else:
ret = dict(success=False)

await XenVm().update(cluster_id, _vm)

session.xenapi.session.logout()
return ret
except Fault as xml_rpc_error:
Expand Down
109 changes: 0 additions & 109 deletions MySQL/Host/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions MySQL/Status/__init__.py

This file was deleted.

0 comments on commit 9ca5288

Please sign in to comment.