Add full support for cloud archive use; add early check for device presens in osdize.

This commit is contained in:
James Page 2012-11-12 09:36:03 +00:00
parent 341e163456
commit e30f3f7b3c
4 changed files with 40 additions and 16 deletions

View File

@ -22,7 +22,7 @@ options:
Optional configuration to support use of additional sources such as: Optional configuration to support use of additional sources such as:
. .
- ppa:myteam/ppa - ppa:myteam/ppa
- cloud:folsom-proposed - cloud:precise-proposed/folsom
- http://my.archive.com/ubuntu main - http://my.archive.com/ubuntu main
. .
The last option should be used in conjunction with the key configuration The last option should be used in conjunction with the key configuration
@ -30,7 +30,7 @@ options:
. .
Note that a minimum ceph version of 0.48.2 is required for use with this Note that a minimum ceph version of 0.48.2 is required for use with this
charm which is NOT provided by the packages in the main Ubuntu archive charm which is NOT provided by the packages in the main Ubuntu archive
for precise. for precise but is provided in the Ubuntu cloud archive.
key: key:
type: string type: string
description: | description: |

View File

@ -90,6 +90,11 @@ def get_conf(name):
def osdize(dev): def osdize(dev):
if not os.path.exists(dev):
utils.juju_log('INFO',
'Path {} does not exist - bailing'.format(dev))
return
e_mountpoint = utils.config_get('ephemeral-unmount') e_mountpoint = utils.config_get('ephemeral-unmount')
if e_mountpoint != "": if e_mountpoint != "":
subprocess.call(['umount', e_mountpoint]) subprocess.call(['umount', e_mountpoint])
@ -105,8 +110,7 @@ def osdize(dev):
'Looks like {} is in use, skipping.'.format(dev)) 'Looks like {} is in use, skipping.'.format(dev))
return return
if os.path.exists(dev): subprocess.call(['ceph-disk-prepare', dev])
subprocess.call(['ceph-disk-prepare', dev])
def mon_relation(): def mon_relation():

View File

@ -50,24 +50,38 @@ def render_template(template_name, context, template_dir=TEMPLATES_DIR):
return template.render(context) return template.render(context)
CLOUD_ARCHIVE = \
""" # Ubuntu Cloud Archive
deb http://ubuntu-cloud.archive.canonical.com/ubuntu {} main
"""
def configure_source(): def configure_source():
source = config_get('source') source = str(config_get('source'))
if (source.startswith('ppa:') or if not source:
source.startswith('cloud:') or return
source.startswith('http:')): if source.startswith('ppa:'):
cmd = [ cmd = [
'add-apt-repository', 'add-apt-repository',
source source
] ]
subprocess.check_call(cmd) subprocess.check_call(cmd)
if source.startswith('cloud:'):
install('ubuntu-cloud-keyring')
pocket = source.split(':')[1]
with open('/etc/apt/sources.list.d/cloud-archive.list', 'w') as apt:
apt.write(CLOUD_ARCHIVE.format(pocket))
if source.startswith('http:'): if source.startswith('http:'):
with open('/etc/apt/sources.list.d/quantum.list', 'w') as apt:
apt.write("deb " + source + "\n")
key = config_get('key') key = config_get('key')
cmd = [ if key:
'apt-key', cmd = [
'import', 'apt-key',
key 'adv', '--keyserver keyserver.ubuntu.com',
] '--recv-keys', key
subprocess.check_call(cmd) ]
subprocess.check_call(cmd)
cmd = [ cmd = [
'apt-get', 'apt-get',
'update' 'update'
@ -129,8 +143,14 @@ def relation_set(**kwargs):
cmd = [ cmd = [
'relation-set' 'relation-set'
] ]
args = []
for k, v in kwargs.items(): for k, v in kwargs.items():
cmd.append('{}={}'.format(k, v)) if k == 'rid':
cmd.append('-r')
cmd.append(v)
else:
args.append('{}={}'.format(k, v))
cmd += args
subprocess.check_call(cmd) subprocess.check_call(cmd)

View File

@ -1 +1 @@
4 5