Skip to content

Commit

Permalink
ship config.yml to /usr/share and copy to user home ~/.calyptos
Browse files Browse the repository at this point in the history
This changes how we use the config.yml. Instead of placing in /etc
we will put it in /usr/share/calyptos/etc on install, then copy to
~/.calyptos in the user home dir when calyptos is executed.
  • Loading branch information
mbacchi committed Jun 1, 2015
1 parent 7225ccf commit b251390
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include MANIFEST.in
include README.md
include euca-deploy.spec
include calyptos.spec
include etc/config.yml
include examples/*
22 changes: 21 additions & 1 deletion bin/calyptos
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@ import argparse
from fabric.colors import yellow
from stevedore import driver, extension
from calyptos.rolebuilder import RoleBuilder
import os
import shutil

dot_dir = os.path.expanduser('~/.calyptos')
default_cfgfile = os.path.join(dot_dir + "/" + "config.yml")

def locate_cfgfile():
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:
shutil.copy('/usr/share/calyptos/etc/config.yml', default_cfgfile)
except shutil.Error as e:
print('Error: %s' % e)
except IOError as e:
print('Error: %s' % e.strerror)

if __name__ == '__main__':
locate_cfgfile()
parser = argparse.ArgumentParser()
default_repo = 'https://github.com/eucalyptus/eucalyptus-cookbook'
parser.add_argument('operation', choices=['validate',
Expand All @@ -13,7 +33,7 @@ if __name__ == '__main__':
'provision',
'debug',
'uninstall'])
parser.add_argument('-c', '--config', default='etc/config.yml')
parser.add_argument('-c', '--config', default=default_cfgfile)
parser.add_argument('-e', '--environment', default='etc/environment.yml')
parser.add_argument('-p', '--password', default='foobar')
parser.add_argument('-b', '--branch', default='euca-4.2')
Expand Down
10 changes: 4 additions & 6 deletions calyptos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ Provisions the rest of the system or update the configuration of an existing sys
### 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
Expand All @@ -81,15 +79,15 @@ This step will grab all necessary information from a system in order to provide
%{__python2} setup.py build

%install
%{__python2} setup.py install --skip-build --root=$RPM_BUILD_ROOT
%{__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}/eucadeploy/*
%{python_sitelib}/calyptos/*
%{python_sitelib}/*.egg-info
%config /etc/calyptos/config.yml
/usr/share/calyptos/etc/*
/usr/share/calyptos/examples/*
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ def make_release_tree(self, base_dir, files):
'build_py': build_py_with_git_version,
'sdist': sdist_with_git_version
},
#data_files=[('/etc/calyptos/', ['etc/config.yml']),
# ('/usr/share/calyptos/examples/', example_items)],
data_files=[('/usr/share/calyptos/etc', ['etc/config.yml']),
('/usr/share/calyptos/examples/', example_items)],
)

0 comments on commit b251390

Please sign in to comment.