Ejemplo n.º 1
0
def check_node_ready(conf, platform, role, node):
    platform = platforms.get_platform(conf, platform)
    node_name = platform.get_nodes_names(role)[node]
    cmd = ("get nodes {} -o jsonpath='{{range @.status.conditions[*]}}"
           "{{@.type}}={{@.status}};{{end}}'").format(node_name)
    kubectl = Kubectl(conf, platform)
    return kubectl.run_kubectl(cmd).find("Ready=True") != -1
Ejemplo n.º 2
0
 def request_update_download_url(self):
     payload = json.dumps({
         'platform': platforms.get_platform(),
         'client_version': version.version
     })
     headers = {
         "Content-Type": "application/json",
         "Content-Length": str(len(payload))
     }
     url = 'update.3dprinteros.com'
     port = 80
     path = '/request_update_url'
     try:
         connection = httplib.HTTPConnection(url, port, timeout=2)
         connection.connect()
         connection.request('POST', path, payload, headers)
         resp = connection.getresponse()
         update_download_url = resp.read()
         connection.close()
     except Exception as e:
         self.logger.warning('Unable to connect to updater server. ' +
                             str(e))
     else:
         self.logger.debug('Update address received: ' +
                           update_download_url)
         return update_download_url
Ejemplo n.º 3
0
 def __init__(self, conf, platform):
     self.conf = conf
     self.binpath = self.conf.skuba.binpath
     self.utils = Utils(self.conf)
     self.platform = platforms.get_platform(conf, platform)
     self.cwd = "{}/test-cluster".format(self.conf.workspace)
     self.utils.setup_ssh()
Ejemplo n.º 4
0
def check_etcd_health(conf, platform, role, node):
    platform = platforms.get_platform(conf, platform)
    cmd = ('sudo curl -Ls --cacert /etc/kubernetes/pki/etcd/ca.crt '
           '--key /etc/kubernetes/pki/etcd/server.key '
           '--cert /etc/kubernetes/pki/etcd/server.crt '
           'https://localhost:2379/health')
    output = platform.ssh_run(role, node, cmd)
    return output.find("true") > -1
Ejemplo n.º 5
0
 def __init__(self, conf, platform):
     self.conf = conf
     self.binpath = self.conf.skuba.binpath
     self.utils = Utils(self.conf)
     self.platform = platforms.get_platform(conf, platform)
     self.workdir = self.conf.skuba.workdir
     self.cluster = self.conf.skuba.cluster
     self.cluster_dir = os.path.join(self.workdir, self.cluster)
     self.utils.setup_ssh()
     self.checker = Checker(conf, platform)
Ejemplo n.º 6
0
 def request_update_download_url(self):
     payload = json.dumps( {'platform': platforms.get_platform(), 'client_version': version.version} )
     headers = {"Content-Type": "application/json", "Content-Length": str(len(payload))}
     url = 'update.3dprinteros.com'
     port = 80
     path = '/request_update_url'
     try:
         connection = httplib.HTTPConnection(url, port, timeout=2)
         connection.connect()
         connection.request('POST', path, payload, headers)
         resp = connection.getresponse()
         update_download_url = resp.read()
         connection.close()
     except Exception as e:
         self.logger.warning('Unable to connect to updater server. ' + str(e))
     else:
         self.logger.debug('Update address received: ' + update_download_url)
         return update_download_url
 def start_camera_process(self, camera_name=None, token=None):
     if not config.get_settings()["camera"]["enabled"]:
         self.logger.info("Can't launch camera - disabled in config")
         return False
     self.logger.info('Launching camera subprocess')
     if not token:
         token = self.token
     if not camera_name:
         camera_name = config.get_settings()['camera']['default']
     module_name = self.CAMERA_MODULES[camera_name]
     if module_name:
         cam_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 module_name)
         if cam_path and cam_path.endswith('.py'):
             start_command = [sys.executable, cam_path, token, self.mac]
         elif camera_name == self.HD_CAMERA_NAME:
             binary_name = os.path.basename(cam_path)
             if platforms.get_platform() != 'win':
                 binary_name = './' + binary_name
             start_command = [
                 binary_name, self.HD_CAMERA_URL, self.HD_CAMERA_PORT, token
             ]
         else:
             self.logger.warning(
                 'Unable to launch camera: unknown module - ' +
                 os.path.basename(cam_path))
             return False
         try:
             self.camera_process = subprocess.Popen(start_command,
                                                    close_fds=True)
         except Exception as e:
             self.logger.warning('Could not launch camera due to error:\n' +
                                 str(e))
         else:
             self.current_camera_name = camera_name
             self.token = token
             self.logger.info('Camera started: ' + camera_name)
             return True
Ejemplo n.º 8
0
def ssh(options):
    platforms.get_platform(options.conf,
                           options.platform).ssh_run(role=options.role,
                                                     nr=options.node,
                                                     cmd=" ".join(options.cmd))
Ejemplo n.º 9
0
def get_logs(options):
    platform_logging_errors = platforms.get_platform(
        options.conf, options.platform).gather_logs()

    if platform_logging_errors:
        raise Exception("Failure(s) while collecting logs")
Ejemplo n.º 10
0
def provision(options):
    platforms.get_platform(options.conf, options.platform).provision(
        num_master=options.master_count, num_worker=options.worker_count)
Ejemplo n.º 11
0
def cleanup(options):
    platforms.get_platform(options.conf, options.platform).cleanup()
    Skuba.cleanup(options.conf)
Ejemplo n.º 12
0
# Author: Oleg Panasevych <*****@*****.**>

import sys

import paths
paths.init_path_to_libs()
import tray_common
import platforms
try:
    import wx
except:
    print 'No WX module found'
    sys.exit()

PLATFORM = platforms.get_platform()


class TaskBarIcon(wx.TaskBarIcon):
    @staticmethod
    def create_menu_item(menu, label, function):
        item = wx.MenuItem(menu, -1, label)
        menu.Bind(wx.EVT_MENU, function, id=item.GetId())
        menu.AppendItem(item)
        return item

    def __init__(self):
        super(TaskBarIcon, self).__init__()
        self.set_icon(tray_common.ICON_PATH)
        self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_show_status)
        self.status_checker = tray_common.StatusChecker(self.ShowBalloon)
Ejemplo n.º 13
0
# Author: Oleg Panasevych <*****@*****.**>

import sys

import paths
paths.init_path_to_libs()
import tray_common
import platforms
try:
    import wx
except:
    print 'No WX module found'
    sys.exit()

PLATFORM = platforms.get_platform()


class TaskBarIcon(wx.TaskBarIcon):

    @staticmethod
    def create_menu_item(menu, label, function):
        item = wx.MenuItem(menu, -1, label)
        menu.Bind(wx.EVT_MENU, function, id=item.GetId())
        menu.AppendItem(item)
        return item

    def __init__(self):
        super(TaskBarIcon, self).__init__()
        self.set_icon(tray_common.ICON_PATH)
        self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_show_status)
Ejemplo n.º 14
0
def check_apiserver_healthz(conf, platform, role, node):
    platform = platforms.get_platform(conf, platform)
    cmd = 'curl -Ls --insecure https://localhost:6443/healthz'
    output = platform.ssh_run(role, node, cmd)
    return output.find("ok") > -1
Ejemplo n.º 15
0
 def __init__(self, conf, platform):
     self.conf = conf
     self.utils = Utils(self.conf)
     self.platform = platforms.get_platform(conf, platform)
     self.skuba = Skuba(conf, platform)
Ejemplo n.º 16
0
def platform(conf, target):
    platform = platforms.get_platform(conf, target)
    return platform
class CameraController:

    HD_CAMERA_NAME = 'HD camera'
    CAMERA_MODULES = {
        "Dual camera": "dual_cam.py",
        "Multi camera": "multi_cam.py",
        "Disable camera": None
    }
    if platforms.get_platform() == 'win':
        CAMERA_MODULES[HD_CAMERA_NAME] = "hdcamera.exe"
    else:
        CAMERA_MODULES[HD_CAMERA_NAME] = "hdcamera"
    CAMERA_MODULES = remove_non_existed_modules(CAMERA_MODULES)
    HD_CAMERA_URL = 'hdcam-' + config.get_settings()['URL']
    HD_CAMERA_PORT = '443'

    def __init__(self, token, mac):
        self.logger = logging.getLogger(__name__)
        self.token = token
        self.mac = mac
        self.camera_process = None
        self.current_camera_name = "Disable camera"
        self.start_camera_process()

    def start_camera_process(self, camera_name=None, token=None):
        if not config.get_settings()["camera"]["enabled"]:
            self.logger.info("Can't launch camera - disabled in config")
            return False
        self.logger.info('Launching camera subprocess')
        if not token:
            token = self.token
        if not camera_name:
            camera_name = config.get_settings()['camera']['default']
        module_name = self.CAMERA_MODULES[camera_name]
        if module_name:
            cam_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    module_name)
            if cam_path and cam_path.endswith('.py'):
                start_command = [sys.executable, cam_path, token, self.mac]
            elif camera_name == self.HD_CAMERA_NAME:
                binary_name = os.path.basename(cam_path)
                if platforms.get_platform() != 'win':
                    binary_name = './' + binary_name
                start_command = [
                    binary_name, self.HD_CAMERA_URL, self.HD_CAMERA_PORT, token
                ]
            else:
                self.logger.warning(
                    'Unable to launch camera: unknown module - ' +
                    os.path.basename(cam_path))
                return False
            try:
                self.camera_process = subprocess.Popen(start_command,
                                                       close_fds=True)
            except Exception as e:
                self.logger.warning('Could not launch camera due to error:\n' +
                                    str(e))
            else:
                self.current_camera_name = camera_name
                self.token = token
                self.logger.info('Camera started: ' + camera_name)
                return True

    def restart_camera(self):
        self.logger.info('Restarting camera module: ' +
                         self.current_camera_name)
        current_camera_name = self.current_camera_name
        self.stop_camera_process()
        return self.start_camera_process(current_camera_name)

    def get_current_camera_name(self):
        return self.current_camera_name

    def switch_camera(self, new_camera_name, token):
        if new_camera_name != self.HD_CAMERA_NAME:  #for starting camera by command from base sender
            token = config.get_app().user_login.user_token
        self.logger.info('Switching camera module from %s to %s' %
                         (self.current_camera_name, new_camera_name))
        self.stop_camera_process()
        return self.start_camera_process(camera_name=new_camera_name,
                                         token=token)

    def stop_camera_process(self):
        if self.camera_process:
            self.logger.info('Terminating camera process...')
            #if platforms.PLATFORM == 'win':
            #self.camera_process.send_signal(signal.CTRL_C_EVENT)
            #else:
            self.camera_process.terminate()
            while True:
                try:
                    if self.camera_process.poll() != None:
                        break
                except OSError:
                    break
            self.logger.info('...camera process terminated.')
            self.current_camera_name = "Disable camera"
            self.camera_process = None