Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click cli #44

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
c27b746
Refactor for plugins
Apr 9, 2015
7017e59
Add debug plugins
Apr 11, 2015
6f5a308
Add debug plugins
Apr 11, 2015
11b5a2c
Moar debug plugins
Apr 11, 2015
aeb3651
Merge remote-tracking branch 'origin/plugins' into plugins
Apr 11, 2015
0967c0a
Fix test
Apr 11, 2015
782870d
Moar debuggers
Apr 13, 2015
51686b8
Version bump to 1.0.0
Apr 13, 2015
51f537a
Merge branch 'master' into plugins
May 7, 2015
4e43d02
Finish porting custom repo
May 8, 2015
d5afe6e
Fix provision
viglesiasce May 11, 2015
6f10d9c
First pass at docs
viglesiasce May 12, 2015
f35146d
Added eucalyptus_sosreport.py; updated debuggerplugin.py and setup.py
hspencer77 May 12, 2015
388bb40
Adding repo validation
May 12, 2015
7e1ff92
Use set instantiation that is compatible with Python 2.6
viglesiasce May 12, 2015
5bf77e6
repos validation
May 12, 2015
4f45142
repos validation
May 12, 2015
0ec9fda
updating debuggerplugin.py to have get_command tasks
hspencer77 May 12, 2015
27db135
Repos validation update
May 12, 2015
1bdde76
repos and storage validation
May 13, 2015
e734101
storage validation modifications
May 13, 2015
82f1e82
Updated eucalyptus-sosreport.py to run jobs in parallel. Downloads to…
hspencer77 May 13, 2015
a4b34e9
Storage validation update
May 13, 2015
88f122d
Storage validation update
May 13, 2015
6107d58
storage validation modifications
May 14, 2015
b7e3317
Changed function names get_command_* to get_file_*; moved tasks assoc…
hspencer77 May 14, 2015
371bdf9
Storage validation update
May 14, 2015
04370ef
Updated eucalyptus_sosreport.py to download sosreports from nodes to …
hspencer77 May 14, 2015
f144017
Updated README.md
hspencer77 May 14, 2015
3d7d2f0
Update README.md
hspencer77 May 14, 2015
5f2d3f2
Updated README.md; corrected list display
hspencer77 May 14, 2015
8d49807
Updated README.md; corrected list display, version 2
hspencer77 May 14, 2015
bcf172b
Updated README.md; corrected list display, version 3
hspencer77 May 14, 2015
1eed6e2
Updated README.md; corrected list display, version 4
hspencer77 May 14, 2015
9f482f1
Updated README.md; corrected list display, version 5; corrected links
hspencer77 May 14, 2015
145f6cb
Storage validation update
May 15, 2015
bb2aa71
Storage validation update
May 15, 2015
d1fbf5f
Storage validation update
May 15, 2015
015bf4b
envrionment update
May 15, 2015
87452fb
Minimized error message output when get_file_on_host fails
hspencer77 May 18, 2015
ae63d4f
Fix single line comments in debuggerplugin.py
hspencer77 May 18, 2015
12a0084
Merge pull request #37 from hspencer77/deploy-sosreports-addition
viglesiasce May 18, 2015
3a7b123
Doc: add Quick Start and ToC
viglesiasce May 18, 2015
56aad52
Merge remote-tracking branch 'origin/plugins' into plugins
viglesiasce May 18, 2015
8846d78
prepare spec file for use in jenkins/rpmfab/mock builds
mbacchi May 19, 2015
e04e15c
move version figuring to setup.py
mbacchi May 19, 2015
ad14fb9
update source to use rpmfab macro
mbacchi May 19, 2015
fbb2650
Doc: Start plugin documentation
viglesiasce May 20, 2015
b48acbd
update setup macro in RPM spec file
mbacchi May 20, 2015
e8227a2
add BuildRequires entries
mbacchi May 20, 2015
4d16b5d
correct capitalization of PyYAML
mbacchi May 20, 2015
1da9fe9
additional RPM dependencies, add config.yml, use RPM files syntax
mbacchi May 21, 2015
eed5b2c
forgot to tar config.yml before trying to package it in the RPM
mbacchi May 21, 2015
270dba4
Adding yml structure validation and repos updates
May 21, 2015
87576f2
Setup update
May 21, 2015
99939d9
Adding structure validation and repos updates
May 21, 2015
fd64610
Updated error handling
May 21, 2015
7d7e8eb
Adding structure validation and repos updates
May 21, 2015
48e185e
Adding structure validation and repos updates
May 22, 2015
b416182
Removing .idea files
May 22, 2015
869c8bb
Changing environment file to default
May 22, 2015
2701327
ship and install examples directory
mbacchi May 22, 2015
05318bf
Changing structre options
May 22, 2015
4756326
Merge pull request #39 from ccassler/plugins
viglesiasce May 22, 2015
1fff9ec
correct placement of config.yml in /etc/euca-deploy
mbacchi May 22, 2015
6a88eb0
Merge remote branch mbacchi:'origin/master' into plugins
mbacchi May 22, 2015
f3def4d
Merge pull request #40 from mbacchi/plugins
viglesiasce May 22, 2015
53b2afa
First pass at rename to calyptos
viglesiasce May 26, 2015
37e3b7b
Merge pull request #1 from eucalyptus/rename
viglesiasce May 26, 2015
7b7b70d
Update README.md
viglesiasce May 26, 2015
46c382f
Update README.md
viglesiasce May 26, 2015
82c5bd3
Update README.md
viglesiasce May 26, 2015
7e4e4f0
Refactor componentdeployer->rolebuilder
viglesiasce May 26, 2015
56af824
Merge pull request #2 from eucalyptus/refactor-componentdeployer
viglesiasce May 26, 2015
480e2aa
Update README.md
viglesiasce May 26, 2015
01d8a1c
Update README.md
viglesiasce May 26, 2015
1b54354
Remove references to Chef
viglesiasce May 26, 2015
587fc77
Check for DNS on UFS for 4.2
viglesiasce May 26, 2015
10b9dfd
Merge remote-tracking branch 'origin/master'
viglesiasce May 26, 2015
ad4aed6
Set euca-4.2 as default cookbook branch
viglesiasce May 26, 2015
eef9c03
Add debugger docs
viglesiasce May 26, 2015
c107d4b
Update README.md
viglesiasce May 26, 2015
828fd64
Prepare FS before writing env file
viglesiasce May 27, 2015
ac6f854
Merge remote-tracking branch 'origin/master'
viglesiasce May 27, 2015
c28661c
Install chefdk in chef deployer
viglesiasce May 27, 2015
541af48
Move ChefDK install to ChefManager
viglesiasce May 27, 2015
5541aac
Move install chefDK to before preparing FS
viglesiasce May 27, 2015
fec4db6
Configure ChefManager before installing ChefDK
viglesiasce May 27, 2015
b7f70f0
Make ChefDK install a staticmethod called as first step of _prepare_fs
viglesiasce May 27, 2015
77841bd
Second part of last fix
viglesiasce May 27, 2015
7225ccf
Ensure our version of ChefDK is installed
viglesiasce May 27, 2015
b251390
ship config.yml to /usr/share and copy to user home ~/.calyptos
mbacchi Jun 1, 2015
c878e0e
iterate through possible config file locations
mbacchi Jun 3, 2015
b4ced19
added ceph deploy in calyptos. Fixes QA-361
shaon Jun 6, 2015
8145708
added riakcs cluster deploy. Fixes QA-362
shaon Jun 8, 2015
d0de2a1
Merge pull request #6 from shaon/cephdeploy
viglesiasce Jun 9, 2015
3e32d88
Merge pull request #7 from shaon/riakcsdeploy
viglesiasce Jun 9, 2015
6cdc3d5
Merge pull request #4 from mbacchi/pkg_config
viglesiasce Jun 9, 2015
9954169
Make environment a required flag, remove default
viglesiasce Jun 9, 2015
dedfe01
update ceph+euca deployment yaml
shaon Jun 10, 2015
e6a3b27
Merge pull request #8 from shaon/cepheucayml
viglesiasce Jun 10, 2015
ffab720
Use click for main CLI
viglesiasce Jun 15, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.vagrant
Berksfile.lock
*~
Expand Down
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include MANIFEST.in
include README.md
include calyptos.spec
include etc/config.yml
include examples/*
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
# Euca Deploy
# Calyptos

This is a harness for running the Eucalyptus cookbook against a distributed system of nodes without a dependency on a Chef Server. We are using fabric and chef-zero to emulate the functionality of a chef-server.
This is a tool for managing your Eucalyptus deployments

# [Documentation](http://calyptos.readthedocs.org/en/latest/)

## Install

### On a CentOS 6 system:

yum install -y python-devel gcc git python-setuptools
easy_install fabric PyYAML
curl -L https://www.opscode.com/chef/install.sh | sudo bash -s -- -P chefdk
git clone https://github.com/viglesiasce/euca-deploy
cd euca-deploy
yum install -y python-devel gcc git python-setuptools fabric PyYAML python-stevedore
git clone https://github.com/eucalyptus/calyptos
cd calyptos
python setup.py install

## Lifecycle Actions
The cloud lifecycle is broken down into many phases:

### Configure
The configuration is written in YAML and uses the Chef environment structure. Examples can be found in the examples directory. For a full list of attributes that can be set look at the [Eucalyptus Cookbook attributes](https://github.com/eucalyptus/eucalyptus-cookbook/blob/testing/attributes/default.rb). Edit the etc/environment.yml file to match your deployment topology and configuration.
The configuration is written in YAML. Examples can be found in the examples directory. For a full list of attributes that can be set look at the [Eucalyptus Cookbook attributes](https://github.com/eucalyptus/eucalyptus-cookbook/blob/testing/attributes/default.rb). Edit the etc/environment.yml file to match your deployment topology and configuration.

### Validate
#### Not yet implemented!!!
In this stage we run validations against the configuration file to ensure that the deployment will succeed as we expect.

calyptos validate -e <your-environment-file>

### Prepare
This step ensures that Chef is installed on all servers and that we can SSH to all of them. It is nice to know that we are on good footing before we get going with the deployment.
This step ensures that our dependencies are installed on all servers and that we can SSH to all of them. It is nice to know that we are on good footing before we get going with the deployment.

euca-deploy prepare -p <root-ssh-password-for-deployment-systems>
calyptos prepare -p <root-ssh-password-for-deployment-systems>

### Bootstrap
This step deploys the CLC and initializes the database. Here we are getting a bit deeper and if complete, we can assume that we've are on good footing to continue deploying the rest of the cloud.

euca-deploy bootstrap -p <root-ssh-password-for-deployment-systems>
calyptos bootstrap -p <root-ssh-password-for-deployment-systems>

### Provision
Provisions the rest of the system or update the configuration of an existing system. If you change anything in your environment.yml, you can use this to push that change out to your cloud.

euca-deploy provision -p <root-ssh-password-for-deployment-systems>
calyptos provision -p <root-ssh-password-for-deployment-systems>

### Debug
#### Not yet implemented!!!
This step will grab all necessary information from a system in order to provide artifacts for use in debugging a problem.


This step will grab all necessary information from a system in order to provide artifacts for use in debugging a problem. In addition, this step will do the following:
* Confirm/install [sosreports](https://github.com/sosreport/sos) and [eucalyptus sosreports plugin](https://github.com/eucalyptus/eucalyptus-sosreport-plugins) on each node
* Run sosreports on each node
* Copy the sosreport back to the local client
```
calyptos debug -p <root-ssh-password-for-deployment-systems>
```

172 changes: 172 additions & 0 deletions bin/calyptos
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/usr/bin/env python -u
import click
from fabric.colors import yellow
from fabric.network import disconnect_all
from fabric.operations import run as fabric_run
from fabric.state import env
from fabric.tasks import execute as fabric_execute
from stevedore import driver as plugin_driver
from stevedore import extension
from calyptos.rolebuilder import RoleBuilder
import os
import shutil

dot_dir = os.path.expanduser('~/.calyptos')
# by default we look in users home dir first
default_cfgfile = os.path.join(dot_dir, "config.yml")
cfglist = []
cfglist.append(default_cfgfile)
cfglist.append('/usr/share/calyptos/config.yml')

def locate_cfgfile():
# if we find that the config file is in /usr/share
# but the rpm is not installed, we copy it to ~/.calyptos
# because that means calyptos was installed by setup.py
for item in cfglist:
if os.path.isfile(item):
if item != default_cfgfile:
import rpm # I think this is required by other parts of python so I'm safe using it
ts = rpm.TransactionSet()
mi = ts.dbMatch("name","calyptos")
if (len(mi) == 0):
if not os.path.isfile(default_cfgfile):
if not os.path.exists(dot_dir):
try:
os.makedirs(dot_dir)
except OSError as e:
print('Error: cannot create directory ~/.calyptos: %s' % e)
try:
# if this copy works, return default_cfgfile
# because it will be used going forward
shutil.copy('/usr/share/calyptos/config.yml', default_cfgfile)
return default_cfgfile
except shutil.Error as e:
print('Error: %s' % e)
except IOError as e:
print('Error: %s' % e.strerror)
# this is not in an else: block because its a
# last resort for the case where import rpm
# doesn't succeed above, because we still need
# to return a valid config file name
return item

def run_driver(namespace, driver, operation, ctx):
mgr = plugin_driver.DriverManager(
namespace=namespace,
name=driver,
invoke_on_load=True,
invoke_args=(ctx.obj['password'],
ctx.obj['environment'],
ctx.obj['config'],
ctx.obj['debug'],
ctx.obj['branch']),
)
function = getattr(mgr.driver, operation)
function()

@click.option('-c', '--config', default=locate_cfgfile(), show_default=True, help='Path to the configuration file for Calyptos')
@click.option('-e', '--environment', required=True, help='Path to the environment file that defines the system Calyptos will interact with')
@click.option('-p', '--password', prompt='Enter the SSH password for hosts in the deployment', help='SSH password for machines that Calyptos will interact with')
@click.option('--debug', default=False)
@click.group()
@click.pass_context
def cli(ctx, config, environment, password, debug):
ctx.obj['config'] = config
ctx.obj['environment'] = environment
ctx.obj['password'] = password
ctx.obj['debug'] = debug


@cli.command()
@click.pass_context
def validate(ctx):
component_deployer = RoleBuilder(ctx.obj['environment'])
mgr = extension.ExtensionManager(
namespace='calyptos.validator',
invoke_args=(component_deployer,),
invoke_on_load=True,
propagate_map_exceptions=True
)
results = mgr.map_method('validate')

@click.option('-b', '--branch', default='euca-4.2')
@click.option('--cookbook-repo', default='https://github.com/eucalyptus/eucalyptus-cookbook')
@click.option('-d', '--driver', default="chef")
@cli.command()
@click.pass_context
def prepare(ctx, branch, cookbook_repo, driver):
ctx.obj['cookbook-repo'] = cookbook_repo
ctx.obj['branch'] = branch
run_driver('calyptos.deployer', driver, 'prepare', ctx)


@click.option('-b', '--branch', default='euca-4.2')
@click.option('--cookbook-repo', default='https://github.com/eucalyptus/eucalyptus-cookbook')
@click.option('-d', '--driver', default="chef")
@cli.command()
@click.pass_context
def bootstrap(ctx, branch, cookbook_repo, driver):
ctx.obj['cookbook-repo'] = cookbook_repo
ctx.obj['branch'] = branch
run_driver('calyptos.deployer', driver, 'bootstrap', ctx)

@click.option('-b', '--branch', default='euca-4.2')
@click.option('--cookbook-repo', default='https://github.com/eucalyptus/eucalyptus-cookbook')
@click.option('-d', '--driver', default="chef")
@cli.command()
@click.pass_context
def provision(ctx, branch, cookbook_repo, driver):
ctx.obj['cookbook-repo'] = cookbook_repo
ctx.obj['branch'] = branch
run_driver('calyptos.deployer', driver, 'provision', ctx)

@click.option('-b', '--branch', default='euca-4.2')
@click.option('--cookbook-repo', default='https://github.com/eucalyptus/eucalyptus-cookbook')
@click.option('-d', '--driver', default="chef")
@cli.command()
@click.pass_context
def uninstall(ctx, branch, cookbook_repo, driver):
ctx.obj['cookbook-repo'] = cookbook_repo
ctx.obj['branch'] = branch
run_driver('calyptos.deployer', driver, 'uninstall', ctx)


@click.argument('command')
@click.option('-r', '--role', default='all')
@cli.command()
@click.pass_context
def execute(ctx, command, role):
component_deployer = RoleBuilder(ctx.obj['environment'])
env.hosts = component_deployer.roles[role]
env.password = ctx.obj['password']
env.user = 'root'
fabric_execute(fabric_run, command, hosts=component_deployer.roles[role])
disconnect_all()

@cli.command()
def debug(ctx):
component_deployer = RoleBuilder(ctx.obj['environment'])
mgr = extension.ExtensionManager(
namespace='calyptos.debugger',
invoke_args=(component_deployer,),
invoke_on_load=True,
propagate_map_exceptions=False
)
results = mgr.map_method('debug')
total_failures = 0
total_passed = 0
for passed, failed in results:
total_passed += passed
total_failures += failed
print yellow('Total passed: ' + str(total_passed))
print yellow('Total failed: ' + str(total_failures))
exit(total_failures)

if __name__ == '__main__':
cli.add_command(validate)
cli.add_command(prepare)
cli.add_command(bootstrap)
cli.add_command(provision)
cli.add_command(debug)
cli.add_command(execute)
cli(obj={})
30 changes: 0 additions & 30 deletions bin/euca-deploy

This file was deleted.

93 changes: 93 additions & 0 deletions calyptos.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

%define name calyptos
%define version 0.1
%define unmangled_version 0.1
%define unmangled_version 0.1
%define release 1

Summary: Tool for managing Eucalyptus
Name: %{name}
Version: %{version}
Release: %{release}
Source0: %{tarball_basedir}.tar.xz
License: UNKNOWN
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix: %{_prefix}
BuildArch: noarch
Vendor: Vic Iglesias <[email protected]>
Url: https://github.com/eucalyptus/calyptos/

BuildRequires: python2-devel
BuildRequires: python-setuptools

Requires: fabric PyYAML git python-stevedore

%description
# Calyptos

This is a tool for managing your Eucalyptus deployments

## Install

### On a CentOS 6 system:

yum install -y python-devel gcc git python-setuptools
easy_install fabric PyYAML
curl -L https://www.opscode.com/chef/install.sh | sudo bash -s -- -P chefdk
git clone https://github.com/eucalyptus/calyptos
cd calyptos
python setup.py install

## Lifecycle Actions
The cloud lifecycle is broken down into many phases:

### Configure
The configuration is written in YAML and uses the Chef environment structure. Examples can be found in the examples directory. For a full list of attributes that can be set look at the [Eucalyptus Cookbook attributes](https://github.com/eucalyptus/eucalyptus-cookbook/blob/testing/attributes/default.rb). Edit the etc/environment.yml file to match your deployment topology and configuration.

### Validate
#### Not yet implemented!!!
In this stage we run validations against the configuration file to ensure that the deployment will succeed as we expect.

### Prepare
This step ensures that Chef is installed on all servers and that we can SSH to all of them. It is nice to know that we are on good footing before we get going with the deployment.

calyptos prepare -p <root-ssh-password-for-deployment-systems>

### Bootstrap
This step deploys the CLC and initializes the database. Here we are getting a bit deeper and if complete, we can assume that we've are on good footing to continue deploying the rest of the cloud.

calyptos bootstrap -p <root-ssh-password-for-deployment-systems>

### Provision
Provisions the rest of the system or update the configuration of an existing system. If you change anything in your environment.yml, you can use this to push that change out to your cloud.

calyptos provision -p <root-ssh-password-for-deployment-systems>

### Debug
#### Not yet implemented!!!
This step will grab all necessary information from a system in order to provide artifacts for use in debugging a problem.



%prep
%setup -q -n %{tarball_basedir}

%build
%{__python2} setup.py build

%install
%{__python2} setup.py install --skip-build --root=$RPM_BUILD_ROOT --single-version-externally-managed

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/bin/calyptos
%{python_sitelib}/calyptos/*
%{python_sitelib}/*.egg-info
/usr/share/calyptos/config.yml
/usr/share/calyptos/examples/*
File renamed without changes.
Loading