Add docker provider framework
This commit is contained in:
64
desktop_env/providers/docker/provider.py
Normal file
64
desktop_env/providers/docker/provider.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import time
|
||||
import docker
|
||||
|
||||
from desktop_env.providers.base import Provider
|
||||
|
||||
logger = logging.getLogger("desktopenv.providers.vmware.VMwareProvider")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
WAIT_TIME = 3
|
||||
|
||||
|
||||
def get_vmrun_type(return_list=False):
|
||||
if platform.system() == 'Windows' or platform.system() == 'Linux':
|
||||
if return_list:
|
||||
return ['-T', 'ws']
|
||||
else:
|
||||
return '-T ws'
|
||||
elif platform.system() == 'Darwin': # Darwin is the system name for macOS
|
||||
if return_list:
|
||||
return ['-T', 'fusion']
|
||||
else:
|
||||
return '-T fusion'
|
||||
else:
|
||||
raise Exception("Unsupported operating system")
|
||||
|
||||
|
||||
class DockerProvider(Provider):
|
||||
def __init__(self, region: str):
|
||||
self.client = docker.from_env()
|
||||
|
||||
@staticmethod
|
||||
def _execute_command(command: list, return_output=False):
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
if return_output:
|
||||
output = process.communicate()[0].strip()
|
||||
return output
|
||||
else:
|
||||
return None
|
||||
|
||||
def start_emulator(self, path_to_vm: str, headless: bool, os_type: str):
|
||||
pass
|
||||
|
||||
def get_ip_address(self, path_to_vm: str) -> str:
|
||||
pass
|
||||
|
||||
def save_state(self, path_to_vm: str, snapshot_name: str):
|
||||
pass
|
||||
|
||||
def revert_to_snapshot(self, path_to_vm: str, snapshot_name: str):
|
||||
pass
|
||||
|
||||
def stop_emulator(self, path_to_vm: str):
|
||||
pass
|
||||
Reference in New Issue
Block a user