[PATCH 2/2] V2: exts: modified openstackssh.write, vdaboot.configure
by Pedro Alvarez
modified: openstackssh.write, fix indentation, removing tabs, wraping and
cleaning the code.
modified: vdaboot.configure, wraping and cleaning code.
Repo: git://git.baserock.org/baserock/baserock/morph.git
Branch: baserock/pedroalvarez/S8631/openstack-configure-write
Sha1: 788a5a10482c8a17136e40f991ecbb9722e98a14
---
morphlib/exts/openstackssh.write | 164 ++++++++++++++++----------------------
morphlib/exts/vdaboot.configure | 6 +-
2 files changed, 71 insertions(+), 99 deletions(-)
diff --git a/morphlib/exts/openstackssh.write b/morphlib/exts/openstackssh.write
index 9e2a5ff..c363b76 100755
--- a/morphlib/exts/openstackssh.write
+++ b/morphlib/exts/openstackssh.write
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (C) 2012-2013 Codethink Limited
+# Copyright (C) 2013 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,8 +20,6 @@
import cliapp
import os
-import re
-import sys
import tempfile
import urlparse
@@ -30,13 +28,14 @@ import morphlib.writeexts
class OpenStackWriteExtension(morphlib.writeexts.WriteExtension):
- '''Create a raw disk image during Morph's deployment and upload it
- to an OpenStack host creating the image on the system using Glance.
+ '''Create a raw disk and upload it to an OpenStack host.
+ The raw disk image is created during Morph's deployment and the
+ image is deployed in OpenStack using Glance.
The location command line argument is the ssh path to upload the
image file into OpenStack using the following syntax:
- ssh://[USER@]HOST/PATH/TO/FILE
+ ssh://[USER@]HOST/PATH/TO/FILE
where
@@ -50,8 +49,8 @@ class OpenStackWriteExtension(morphlib.writeexts.WriteExtension):
* OPENSTACK_USER is the username to use in the deployment.
* OPENSTACK_TENANT is the project name to use in the deployment.
* OPENSTACK_IMAGENAME is the name of the image to create.
- *
- *
+ * OPENSTACK_PASSWORD is the password of the user.
+ * OPENSTACK_AUTH_URL is the url for authentification in OpenStack.
The extension will connect to HOST via ssh to push the image and then
@@ -64,106 +63,79 @@ class OpenStackWriteExtension(morphlib.writeexts.WriteExtension):
raise cliapp.AppException('Wrong number of command line args')
temp_root, location = args
- ssh_host, ssh_path = self.parse_location(location)
+ ssh_host, ssh_path = self.parse_location(location)
- self.check_openstack_requirements()
+ os_parameters = self.get_openstack_parameters()
fd, raw_disk = tempfile.mkstemp()
os.close(fd)
self.create_local_system(temp_root, raw_disk)
- self.status(msg='Temporal disk image has been created at %s' % raw_disk)
+ self.status(msg='Temporary disk image has been created at %s'
+ % raw_disk)
- self.upgrade_extlinux(raw_disk)
+ self.set_extlinux_root_to_virtio(raw_disk)
-
- self.upload_openstack(raw_disk, ssh_host, ssh_path)
-
- os.remove(raw_disk)
- self.status(msg='Temporal image has been deleted')
-
- self.deploy_image_openstack(ssh_host, ssh_path)
-
- def upgrade_extlinux(self, raw_disk):
- mp = self.mount(raw_disk)
- '''Updating extlinux to use virtio disks'''
-
- self.status(msg='Updating extlinux.conf')
-
- config = os.path.join(mp, 'extlinux.conf')
- with open(config, 'w') as f:
- f.write('default linux\n')
- f.write('timeout 1\n')
- f.write('label linux\n')
- f.write('kernel /systems/default/kernel\n')
- f.write('append root=/dev/vda '
- 'rootflags=subvol=systems/default/run '
- 'init=/sbin/int rw\n')
-
-# Working without this:
-# cliapp.runcmd(['extlinux', '--install', mp])
-# cliapp.runcmd(['sync'])
-# time.sleep(2)
-
- self.unmount(mp)
-
-
- def check_openstack_requirements(self):
- os_user = os.environ.get('OPENSTACK_USER')
- os_tenant = os.environ.get('OPENSTACK_TENANT')
- os_imagename = os.environ.get('OPENSTACK_IMAGENAME')
- os_password = os.environ.get('OPENSTACK_PASSWORD')
- os_authurl = os.environ.get('OPENSTACK_AUTH_URL')
-
- if os_user is None:
- raise cliapp.AppException('OPENSTACK_USER was not given')
- if os_tenant is None:
- raise cliapp.AppException('OPENSTACK_TENANT was not given')
- if os_imagename is None:
- raise cliapp.AppException('OPENSTACK_IMAGENAME was not given')
- if os_password is None:
- raise cliapp.AppException('OPENSTACK_PASSWORD was not given')
- if os_authurl is None:
- raise cliapp.AppException('OPENSTACK_AUTH_URL was not given')
-
- def upload_openstack(self, raw_disk, ssh_host, ssh_path):
- self.status(msg='Uploading raw image to OpenStack via ssh...')
- ssh_fullpath = ssh_host + ':' + ssh_path
- cliapp.runcmd(['rsync', '-szS', raw_disk, ssh_fullpath ])
- self.status(msg='Raw image uploaded.')
+ self.upload_to_openstack(raw_disk, ssh_host, ssh_path)
+
+ self.configure_openstack_image(ssh_host, ssh_path, os_parameters)
+
+ def set_extlinux_root_to_virtio(self, raw_disk):
+ '''Updating extlinux to use virtio disks'''
+ self.status(msg='Updating extlinux.conf')
+ mp = self.mount(raw_disk)
+ try:
+ path = os.path.join(mp, 'extlinux.conf')
+ with open(path) as f:
+ extlinux_conf = f.read()
+ with open(path, "w") as f:
+ f.write(extlinux_conf.replace('root=/dev/sda',
+ 'root=/dev/vda'))
+ finally:
+ self.unmount(mp)
+
+ def get_openstack_parameters(self):
+ '''Check the environment variables needed and returns all'''
+
+ keys = ('OPENSTACK_USER', 'OPENSTACK_TENANT',
+ 'OPENSTACK_IMAGENAME', 'OPENSTACK_PASSWORD',
+ 'OPENSTACK_AUTH_URL')
+ for key in keys:
+ if key not in os.environ:
+ raise cliapp.AppException(key + ' was not given')
+ return (os.environ[key] for key in keys)
+
+ def upload_to_openstack(self, raw_disk, ssh_host, ssh_path):
+ '''Upload a disk image to OpenStack using rsync'''
+ self.status(msg='Uploading raw image to OpenStack via ssh...')
+ ssh_fullpath = '%s:%s' % (ssh_host, ssh_path)
+ cliapp.runcmd(['rsync', '-szS', raw_disk, ssh_fullpath ])
+ self.status(msg='Raw image uploaded.')
def parse_location(self, location):
- x = urlparse.urlparse(location)
- if x.scheme != 'ssh':
- raise cliapp.AppException('URL schema must be ssh in %s' % location)
- return x.netloc, x.path
-
- def deploy_image_openstack(self, ssh_host, ssh_path):
- self.status(msg='Creating image into OpenStack...')
-# os_user='demo'
-# os_tenant='demo'
-# os_imagename='sshimagenamewrite'
-# os_password='horizonpass'
-# os_authurl='http://localhost:5000/v2.0'
-
- os_user = os.environ['OPENSTACK_USER']
- os_tenant = os.environ['OPENSTACK_TENANT']
- os_imagename = os.environ['OPENSTACK_IMAGENAME']
- os_password = os.environ['OPENSTACK_PASSWORD']
- os_authurl = os.environ['OPENSTACK_AUTH_URL']
+ x = urlparse.urlparse(location)
+ if x.scheme != 'ssh':
+ raise cliapp.AppException('URL schema must be ssh in %s' \
+ % location)
+ return x.netloc, x.path
+
+ def configure_openstack_image(self, ssh_host, ssh_path, os_parameters):
+ '''Configure the image in OpenStack using Glance through ssh'''
+ self.status(msg='Creating image into OpenStack...')
+ os_parameters = list(os_parameters)
cmdline = ['glance',
- '--os-username', os_user,
- '--os-tenant-name', os_tenant,
- '--os-password', os_password,
- '--os-auth-url', os_authurl,
- 'image-create',
- '--name=%s' % os_imagename,
- '--disk-format=raw',
- '--container-format', 'bare',
- '--file', ssh_path]
+ '--os-username', os_parameters[0],
+ '--os-tenant-name', os_parameters[1],
+ '--os-password', os_parameters[3],
+ '--os-auth-url', os_parameters[4],
+ 'image-create',
+ '--name=%s' % os_parameters[2],
+ '--disk-format=raw',
+ '--container-format', 'bare',
+ '--file', ssh_path]
cliapp.ssh_runcmd(ssh_host, cmdline)
- self.status(msg='Image created.'
- )
+ self.status(msg='Image created.')
+
OpenStackWriteExtension().run()
diff --git a/morphlib/exts/vdaboot.configure b/morphlib/exts/vdaboot.configure
index a21269d..cb54bf0 100755
--- a/morphlib/exts/vdaboot.configure
+++ b/morphlib/exts/vdaboot.configure
@@ -15,7 +15,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# Change the "/" mount ponit to /dev/vda to use virtio disks.
+# Change the "/" mount point to /dev/vda to use virtio disks.
set -e
@@ -25,9 +25,9 @@ then
if [ -f "$1/etc/fstab" ]
then
mv "$1/etc/fstab" "$1/etc/fstab.old"
- awk 'BEGIN {print "/dev/vda / btrfs defaults,rw,noatime 0 1"}; $2 != "/" {print $0 };' "$1/etc/fstab.old" > "$1/etc/fstab"
+ awk 'BEGIN {print "/dev/vda / btrfs defaults,rw,noatime 0 1"};
+ $2 != "/" {print $0 };' "$1/etc/fstab.old" > "$1/etc/fstab"
rm "$1/etc/fstab.old"
- cp "$1/etc/fstab" "$1/etc/fstab.modified"
else
echo "/dev/vda / btrfs defaults,rw,noatime 0 1"> "$1/etc/fstab"
fi
--
1.7.10.4
9 years, 5 months
[PATCH] V2: busybix: Run NTP continuously
by Lars Wirzenius
repo: git://git.baserock.org/delta/busybox
branch: baserock/liw/S8704-always-ntpd
commit: 0cbca4c5ddd57bb6201b9547a9e1fd3cd75b2008
land: baserock/build-essential
card: S8704
(Force-pushed, sorry.)
Changed from the previous set: Use the ntpd wrapper script to parse
/etc/ntpd.conf in the systemd units. Also, install the wrapper in
/usr/sbin. Further, the script runs ntpd with exec, so the script
doesn't stay as a separate process, unnecessarily.
Lars Wirzenius (1):
Make NTP run continuously
busybox.morph | 17 +++++++++++++----
scripts/ntpd-set.sh | 31 -------------------------------
scripts/run-ntpd-with-config | 23 +++++++++++++++++++++++
systemd-units/ntpd-boot.service.in | 10 ++++++++++
systemd-units/ntpd.service.in | 10 ++++++----
5 files changed, 52 insertions(+), 39 deletions(-)
delete mode 100755 scripts/ntpd-set.sh
create mode 100755 scripts/run-ntpd-with-config
create mode 100644 systemd-units/ntpd-boot.service.in
--
1.7.10.4
9 years, 5 months
[PATCH] Ask for support in OpenStack deployment.
by Pedro Alvarez
Repo: git://git.baserock.org/baserock/baserock/morph.git
Branch: baserock/pedroalvarez/S8631/openstack-configure-write
Sha1: ce8f5fb4aace8d8e6ca5c1fd4316df680b36d81d
Pedro Alvarez (1):
exts: Add openstack configure/write exts
morphlib/exts/openstackssh.write | 169 ++++++++++++++++++++++++++++++++++++++
morphlib/exts/vdaboot.configure | 34 ++++++++
2 files changed, 203 insertions(+)
create mode 100755 morphlib/exts/openstackssh.write
create mode 100755 morphlib/exts/vdaboot.configure
--
1.7.10.4
9 years, 5 months
"ERROR: Conflicting versions of stratum 'foo' appear in build'
by Paul Sherwood
I've hit this a few times recently, and wanted to provide some thoughts:
1) you can use 'grep -C5 foo *morph' to see context and check that
all refs for foo point to the same SHA1 or branch.
2) note that if you are working in branch bar and have edited
the foo stratum, then all refs for foo will need to point to your
working bar branch.
It would be helpful if the ERROR message could be more explicit,
stating which conflicting versions it has found.
I believe branch+merge code is up for a re-write so it's probably
worth considering if this can be be fixed. for example maybe morph
should force all refs for foo to bar.
9 years, 5 months