Beispiel #1
0
def create_migration_checklist_logger():
    account_name = Sts().account_name
    filename = f"{account_name}-migration-checklist.log"
    file_logger = create_file_logger(name="migration", filename=filename)
    get_console().print(
        f"* Check activity is being logged to [blue]log/{account_name}-migration-checklist.log[/blue]"
    )

    return file_logger
Beispiel #2
0
    def __init__(self):
        self._console = get_console()
        self._ec2 = Ec2()
        self._sts = Sts()
        self._docker = DockerClient()
        self._clusters_data_dir = os.path.join(get_repo_path(),
                                               "data/elasticsearch-comrade")
        self._host_data_dir = os.path.join(os.environ["HOST_REPO_PATH"],
                                           "data/elasticsearch-comrade")

        self._use_docker_py = False
Beispiel #3
0
 def __init__(
     self,
     ssh_server: str,
     destination_host: str,
     destination_port: int,
     local_host="0.0.0.0",
     local_port=None,
 ):
     self.ssh_server = ssh_server
     self.destination_host = destination_host
     self.destination_port = destination_port
     self.local_host = local_host
     self.local_port = destination_port if local_port is None else local_port
     self._console = get_console()
Beispiel #4
0
class Check(object):
    _description = None
    _is_successful = None
    _requires_manual_intervention = False
    _console = get_console()
    _sts = None
    _logger = None

    def check(self):
        raise NotImplementedException

    def check_interactively(self):
        raise NotImplementedException

    @property
    def description(self) -> str:
        return self._description

    def is_successful(self) -> bool:
        return self._is_successful

    def requires_manual_intervention(self) -> bool:
        return self._requires_manual_intervention

    def launch_manual_intervention_prompt(self):
        result = Prompt.ask(
            "Please enter the result for this check",
            choices=["pass", "fail"],
            default="fail",
        )
        self._is_successful = True if result == "pass" else False

    @property
    def logger(self):
        if self._logger is None:
            self._logger = get_migration_checklist_logger()
        return self._logger

    @property
    def sts(self):
        if self._sts is None:
            self._sts = Sts()
        return self._sts
Beispiel #5
0
 def __init__(self):
     self._console = get_console()
     self._msk = Msk()
Beispiel #6
0
 def __init__(self):
     self._console = get_console()
     self._asg = Asg()
Beispiel #7
0
}


def is_running_in_docker() -> bool:
    docker_mode = os.getenv("TELESCOPE_DEVKIT_DOCKER_MODE",
                            'False').lower() in ('true', '1', 't', 'y', 'yes')
    if docker_mode:
        return True

    if not os.path.isfile("/proc/1/cgroup"):
        return False

    with open("/proc/1/cgroup", "rt") as ifh:
        return "docker" in ifh.read()


def setup_ssh_config():
    if not isdir("/root/.ssh"):
        shutil.copytree("/root/.ssh_host", "/root/.ssh")


if __name__ == "__main__":
    try:
        if is_running_in_docker():
            setup_ssh_config()
        exit_code = cli(commands, name="telescope")
        if isinstance(exit_code, int):
            sys.exit(exit_code)
    except Exception as e:
        get_console().print_exception()
Beispiel #8
0
 def __init__(self):
     self._console = get_console()
     self._codebuild = Codebuild()
Beispiel #9
0
from telemetry.telescope_devkit import APP_NAME
from telemetry.telescope_devkit.cli import get_console
from telemetry.telescope_devkit.git import TelescopeDevkitGitRepo
from telemetry.telescope_devkit.git import TelescopeDevkitGitRepoException

console = get_console()


class DevkitCli(object):
    @staticmethod
    def update(debug: bool = False) -> int:
        console.print(
            f"Going to update [bold blue]{APP_NAME}[/bold blue] to the latest version available..."
        )
        try:
            repo = TelescopeDevkitGitRepo(debug=debug)
            console.print(
                f"Current version: [yellow]{repo.current_version}[/yellow]")
            repo.update()
            console.print(
                f"New version: [yellow]{repo.current_version}[/yellow]")
            console.print(f"Update completed.")

            return 0
        except TelescopeDevkitGitRepoException as e:
            console.print(f"[red]ERROR: {e}")

            return 1
        pass
Beispiel #10
0
 def __init__(self):
     self._console = get_console()
     self._ec2 = Ec2()