def test_install_deis(): path = path_utils.executable_path('deis') responses.add(responses.GET, settings.DEIS_INSTALL_URL, body='echo $1 > deis') assert not os.path.exists(path) _install_deis() assert os.path.exists(path)
def _install_deisctl(): script = requests.get(settings.DEISCTL_INSTALL_URL).text subprocess.check_call([ 'bash', '-c', script, 'install.sh', '1.12.3', private_dir.private_dir_path(settings.APP_NAME) ]) os.chmod(path_utils.executable_path('deisctl'), stat.S_IRWXU)
def new_func(ctx, *args, **kwargs): """ @type ctx: click.Context """ path = path_utils.executable_path(name) if not os.path.exists(path): echo_heading('Installing {}.'.format(name), marker='-', marker_color='magenta') get_executable() assert os.path.exists(path) return ctx.invoke(f, *args, **kwargs)
def create_admin(password, email): """Create an admin user on Deis """ echo_heading('Creating admin user.') username = '******' if password is None: password = random_string(length=30) deis = path_utils.executable_path('deis') subprocess.check_call([deis, 'register', 'http://deis.' + settings.DOMAIN_NAME, '--username={}'.format(username), '--email={}'.format(email), '--password={}'.format(password)]) store.set('deis__username', username) store.set('deis__password', password) store.set('deis__email', email) click.echo('Done.')
def create_admin(password, email): """Create an admin user on Deis """ echo_heading('Creating admin user.') username = '******' if password is None: password = random_string(length=30) deis = path_utils.executable_path('deis') subprocess.check_call([ deis, 'register', 'http://deis.' + settings.DOMAIN_NAME, '--username={}'.format(username), '--email={}'.format(email), '--password={}'.format(password) ]) store.set('deis__username', username) store.set('deis__password', password) store.set('deis__email', email) click.echo('Done.')
def test_ensure_executable_exists(runner): name = 'deis' path = path_utils.executable_path(name) def install_executable(): assert not os.path.exists(path) assert not os.system('touch {}'.format(path)) @click.command() @ensure_executable_exists(name, install_executable) def dummy(): pass assert not os.path.exists(path) runner.invoke(dummy) assert os.path.exists(path) # call again and make sure assertion is not triggered runner.invoke(dummy)
def create(stack): """Create a new Deis cluster. """ deisctl = path_utils.executable_path('deisctl') subprocess.check_call(['ssh-add', path_utils.ssh_path('deis')]) with contextmanagers.chdir(os.path.join(get_project_path(), 'deis')): subprocess.check_call(['make', 'discovery-url']) click.echo('Provisioning machines.') with contextmanagers.chdir('contrib/aws'): subprocess.check_call(['./provision-aws-cluster.sh', stack]) ec2 = boto3.resource('ec2') instances = ec2.instances.filter(Filters=[ { 'Name': 'instance-state-name', 'Values': ['running'], }, { 'Name': 'tag:aws:cloudformation:stack-name', 'Values': [stack], }, ]).limit(1) ip = None for i in instances: ip = i.public_ip_address assert ip is not None click.echo('Machines provisioned. An IP address is {}.'.format(ip)) env = {'DEISCTL_TUNNEL': ip} env.update(os.environ) click.echo('Installing Deis.') subprocess.check_call([ deisctl, 'config', 'platform', 'set', 'sshPrivateKey=' + path_utils.ssh_path('deis') ], env=env) subprocess.check_call([ deisctl, 'config', 'platform', 'set', 'domain=' + settings.DOMAIN_NAME ], env=env) subprocess.check_call([deisctl, 'refresh-units'], env=env) subprocess.check_call([deisctl, 'install', 'platform'], env=env) subprocess.check_call([deisctl, 'start', 'platform'], env=env)
def _install_deis(): script = requests.get(settings.DEIS_INSTALL_URL).text with contextmanagers.chdir(private_dir.private_dir_path( settings.APP_NAME)): subprocess.check_call(['bash', '-c', script, 'install.sh', '1.12.3']) os.chmod(path_utils.executable_path('deis'), stat.S_IRWXU)