Best Python code snippet using avocado_python
create.py
Source:create.py
1"""2Tools for creating a DC/OS cluster.3"""4import json5from pathlib import Path6from typing import Any, Dict, List, Optional, Tuple7import click8from dcos_e2e.backends import Vagrant9from dcos_e2e_cli.common.arguments import installer_path_argument10from dcos_e2e_cli.common.create import CREATE_HELP, create_cluster, get_config11from dcos_e2e_cli.common.doctor import get_doctor_message12from dcos_e2e_cli.common.install import (13 cluster_install_dcos_from_path,14 run_post_install_steps,15)16from dcos_e2e_cli.common.options import (17 cluster_id_option,18 copy_to_master_option,19 enable_selinux_enforcing_option,20 enable_spinner_option,21 extra_config_option,22 license_key_option,23 security_mode_option,24 variant_option,25 verbosity_option,26)27from dcos_e2e_cli.common.options.cluster_size import (28 agents_option,29 masters_option,30 public_agents_option,31)32from dcos_e2e_cli.common.options.genconf_dir import genconf_dir_option33from dcos_e2e_cli.common.utils import check_cluster_id_unique, command_path34from dcos_e2e_cli.common.variants import get_install_variant35from dcos_e2e_cli.common.workspaces import workspace_dir_option36from ._common import (37 CLUSTER_ID_DESCRIPTION_KEY,38 WORKSPACE_DIR_DESCRIPTION_KEY,39 ClusterVMs,40 existing_cluster_ids,41)42from ._options import (43 vagrant_box_url_option,44 vagrant_box_version_option,45 vm_memory_mb_option,46)47from ._wait_for_dcos import wait_for_dcos_option48from .doctor import doctor49from .wait import wait50@click.command('create', help=CREATE_HELP)51@installer_path_argument52@masters_option53@agents_option54@extra_config_option55@public_agents_option56@workspace_dir_option57@variant_option58@license_key_option59@genconf_dir_option60@security_mode_option61@copy_to_master_option62@cluster_id_option63@verbosity_option64@vm_memory_mb_option65@enable_selinux_enforcing_option66@enable_spinner_option67@vagrant_box_url_option68@vagrant_box_version_option69@wait_for_dcos_option70@click.pass_context71def create(72 ctx: click.core.Context,73 agents: int,74 installer: Path,75 extra_config: Dict[str, Any],76 masters: int,77 public_agents: int,78 variant: str,79 workspace_dir: Path,80 license_key: Optional[Path],81 security_mode: Optional[str],82 copy_to_master: List[Tuple[Path, Path]],83 cluster_id: str,84 enable_selinux_enforcing: bool,85 files_to_copy_to_genconf_dir: List[Tuple[Path, Path]],86 wait_for_dcos: bool,87 vm_memory_mb: int,88 enable_spinner: bool,89 vagrant_box_url: str,90 vagrant_box_version: str,91) -> None:92 """93 Create a DC/OS cluster.94 """95 check_cluster_id_unique(96 new_cluster_id=cluster_id,97 existing_cluster_ids=existing_cluster_ids(),98 )99 doctor_command_name = command_path(sibling_ctx=ctx, command=doctor)100 wait_command_name = command_path(sibling_ctx=ctx, command=wait)101 doctor_message = get_doctor_message(102 doctor_command_name=doctor_command_name,103 )104 dcos_variant = get_install_variant(105 given_variant=variant,106 installer_path=installer,107 workspace_dir=workspace_dir,108 doctor_message=doctor_message,109 enable_spinner=enable_spinner,110 )111 description = {112 CLUSTER_ID_DESCRIPTION_KEY: cluster_id,113 WORKSPACE_DIR_DESCRIPTION_KEY: str(workspace_dir),114 }115 cluster_backend = Vagrant(116 workspace_dir=workspace_dir,117 virtualbox_description=json.dumps(obj=description),118 vm_memory_mb=vm_memory_mb,119 vagrant_box_url=vagrant_box_url,120 vagrant_box_version=vagrant_box_version,121 )122 cluster = create_cluster(123 cluster_backend=cluster_backend,124 masters=masters,125 agents=agents,126 public_agents=public_agents,127 doctor_message=doctor_message,128 enable_spinner=enable_spinner,129 )130 nodes = {*cluster.masters, *cluster.agents, *cluster.public_agents}131 for node in nodes:132 if enable_selinux_enforcing:133 node.run(args=['setenforce', '1'], sudo=True)134 for node in cluster.masters:135 for path_pair in copy_to_master:136 local_path, remote_path = path_pair137 node.send_file(138 local_path=local_path,139 remote_path=remote_path,140 )141 cluster_vms = ClusterVMs(cluster_id=cluster_id)142 dcos_config = get_config(143 cluster_representation=cluster_vms,144 extra_config=extra_config,145 dcos_variant=dcos_variant,146 security_mode=security_mode,147 license_key=license_key,148 )149 cluster_install_dcos_from_path(150 cluster=cluster,151 cluster_representation=cluster_vms,152 dcos_config=dcos_config,153 ip_detect_path=cluster_backend.ip_detect_path,154 doctor_message=doctor_message,155 dcos_installer=installer,156 files_to_copy_to_genconf_dir=files_to_copy_to_genconf_dir,157 enable_spinner=enable_spinner,158 )159 run_post_install_steps(160 cluster=cluster,161 cluster_id=cluster_id,162 dcos_config=dcos_config,163 doctor_command_name=doctor_command_name,164 http_checks=True,165 wait_command_name=wait_command_name,166 wait_for_dcos=wait_for_dcos,167 enable_spinner=enable_spinner,...
provision.py
Source:provision.py
1"""2Tools for provisioning a Vagrant cluster to install DC/OS.3"""4import json5from pathlib import Path6import click7from dcos_e2e.backends import Vagrant8from dcos_e2e_cli.common.create import create_cluster9from dcos_e2e_cli.common.doctor import get_doctor_message10from dcos_e2e_cli.common.options import (11 cluster_id_option,12 enable_selinux_enforcing_option,13 enable_spinner_option,14 verbosity_option,15)16from dcos_e2e_cli.common.options.cluster_size import (17 agents_option,18 masters_option,19 public_agents_option,20)21from dcos_e2e_cli.common.utils import check_cluster_id_unique, command_path22from dcos_e2e_cli.common.workspaces import workspace_dir_option23from ._common import (24 CLUSTER_ID_DESCRIPTION_KEY,25 WORKSPACE_DIR_DESCRIPTION_KEY,26 existing_cluster_ids,27)28from ._options import (29 vagrant_box_url_option,30 vagrant_box_version_option,31 vm_memory_mb_option,32)33from .doctor import doctor34@click.command('provision')35@masters_option36@agents_option37@public_agents_option38@workspace_dir_option39@cluster_id_option40@verbosity_option41@enable_selinux_enforcing_option42@enable_spinner_option43@vagrant_box_url_option44@vagrant_box_version_option45@vm_memory_mb_option46@click.pass_context47def provision(48 ctx: click.core.Context,49 agents: int,50 masters: int,51 public_agents: int,52 workspace_dir: Path,53 cluster_id: str,54 enable_selinux_enforcing: bool,55 vm_memory_mb: int,56 enable_spinner: bool,57 vagrant_box_url: str,58 vagrant_box_version: str,59) -> None:60 """61 Provision a Vagrant cluster for installing DC/OS.62 """63 check_cluster_id_unique(64 new_cluster_id=cluster_id,65 existing_cluster_ids=existing_cluster_ids(),66 )67 doctor_command_name = command_path(sibling_ctx=ctx, command=doctor)68 doctor_message = get_doctor_message(69 doctor_command_name=doctor_command_name,70 )71 description = {72 CLUSTER_ID_DESCRIPTION_KEY: cluster_id,73 WORKSPACE_DIR_DESCRIPTION_KEY: str(workspace_dir),74 }75 cluster_backend = Vagrant(76 workspace_dir=workspace_dir,77 virtualbox_description=json.dumps(obj=description),78 vm_memory_mb=vm_memory_mb,79 vagrant_box_url=vagrant_box_url,80 vagrant_box_version=vagrant_box_version,81 )82 cluster = create_cluster(83 cluster_backend=cluster_backend,84 masters=masters,85 agents=agents,86 public_agents=public_agents,87 doctor_message=doctor_message,88 enable_spinner=enable_spinner,89 )90 nodes = {*cluster.masters, *cluster.agents, *cluster.public_agents}91 for node in nodes:92 if enable_selinux_enforcing:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!