-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b3ae6b
commit 1d811c1
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from lxc_management import LXCManager | ||
from utils import create_response, handle_error | ||
|
||
def scale_cpu(vm_id, cores): | ||
try: | ||
lxc_manager = LXCManager() | ||
result = lxc_manager.scale_cpu(vm_id, cores) | ||
return create_response(data=result, message=f"CPU cores set to {cores} for container {vm_id}") | ||
except Exception as e: | ||
return handle_error(e) | ||
|
||
def scale_ram(vm_id, memory): | ||
try: | ||
lxc_manager = LXCManager() | ||
result = lxc_manager.scale_ram(vm_id, memory) | ||
return create_response(data=result, message=f"RAM set to {memory} MB for container {vm_id}") | ||
except Exception as e: | ||
return handle_error(e) | ||
|
||
def resize_storage(vm_id, disk_size): | ||
try: | ||
lxc_manager = LXCManager() | ||
result = lxc_manager.resize_storage(vm_id, disk_size) | ||
return create_response(data=result, message=f"Storage increased by {disk_size} GB for container {vm_id}") | ||
except Exception as e: | ||
return handle_error(e) |