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:
.
- ppa:myteam/ppa
- cloud:folsom-proposed
- cloud:precise-proposed/folsom
- http://my.archive.com/ubuntu main
.
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
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:
type: string
description: |

View File

@ -90,6 +90,11 @@ def get_conf(name):
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')
if e_mountpoint != "":
subprocess.call(['umount', e_mountpoint])
@ -105,8 +110,7 @@ def osdize(dev):
'Looks like {} is in use, skipping.'.format(dev))
return
if os.path.exists(dev):
subprocess.call(['ceph-disk-prepare', dev])
subprocess.call(['ceph-disk-prepare', dev])
def mon_relation():

View File

@ -50,24 +50,38 @@ def render_template(template_name, context, template_dir=TEMPLATES_DIR):
return template.render(context)
CLOUD_ARCHIVE = \
""" # Ubuntu Cloud Archive
deb http://ubuntu-cloud.archive.canonical.com/ubuntu {} main
"""
def configure_source():
source = config_get('source')
if (source.startswith('ppa:') or
source.startswith('cloud:') or
source.startswith('http:')):
source = str(config_get('source'))
if not source:
return
if source.startswith('ppa:'):
cmd = [
'add-apt-repository',
source
]
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:'):
with open('/etc/apt/sources.list.d/quantum.list', 'w') as apt:
apt.write("deb " + source + "\n")
key = config_get('key')
cmd = [
'apt-key',
'import',
key
]
subprocess.check_call(cmd)
if key:
cmd = [
'apt-key',
'adv', '--keyserver keyserver.ubuntu.com',
'--recv-keys', key
]
subprocess.check_call(cmd)
cmd = [
'apt-get',
'update'
@ -129,8 +143,14 @@ def relation_set(**kwargs):
cmd = [
'relation-set'
]
args = []
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)

View File

@ -1 +1 @@
4
5