Commit 7f469d08 authored by Łukasz Nowak's avatar Łukasz Nowak

NBD server instantiation recipe.

parent 732d0f94
Changelog
=========
1.1 (unreleased)
----------------
1.0.12 (2011/01/24)
-------------------
- Allow more than 1 connection
1.0.11 (2011/01/18)
-------------------
- Updated recipe to the new BaseSlapRecipe.py
[Davide Tammaro]
1.0.10 (2011/01/06)
-------------------
- Get IPV6 address
1.0.9 (2010/11/24)
------------------
- Fix kvm command line syntax
[Romain Courteaud]
1.0.8 (2010/11/10)
------------------
- Initial version
[Romain Courteaud]
include CHANGES.txt
recursive-include src/slapos/recipe/nbdserver *.in
from setuptools import setup, find_packages
name = "slapos.recipe.nbdserver"
version = '1.2-dev'
def read(name):
return open(name).read()
long_description=( read('README.txt')
+ '\n' +
read('CHANGES.txt')
)
setup(
name = name,
version = version,
description = "ZC Buildout recipe for create an nbd server ",
long_description=long_description,
license='GPLv3',
keywords = "buildout nbd server",
classifiers=[
"Framework :: Buildout :: Recipe",
"Programming Language :: Python",
],
packages = find_packages('src'),
package_dir = {'': 'src'},
include_package_data=True,
install_requires = [
'zc.recipe.egg',
'setuptools',
'slapos.lib.recipe',
],
namespace_packages = ['slapos', 'slapos.recipe'],
entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
)
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os
import binascii
from slapos.lib.recipe.BaseSlapRecipe import BaseSlapRecipe
import pkg_resources
class Recipe(BaseSlapRecipe):
def _install(self):
# Image path
cdrom_iso = os.path.join(self.data_root_directory, 'cdrom.iso')
#Get the IP list
ip = self.getGlobalIPv6Address()
http_port = 9999
nbd_port = 1024
# Instanciate onetimeupload
onetimeupload_config = {}
onetimeupload_config.update(self.options)
onetimeupload_config['port'] = http_port
onetimeupload_config['ip'] = ip
onetimeupload_config['image'] = cdrom_iso
onetimeupload_config['key'] = binascii.hexlify(os.urandom(24))
onetimeupload_config['log_path'] = os.path.join(self.log_directory,
'onetimeupload.log')
wrapper_template_location = pkg_resources.resource_filename(
__name__, os.path.join(
'template', 'onetimeupload_run.in'))
onetimeupload_runner_path = self.createRunningWrapper("onetimeupload",
self.substituteTemplate(wrapper_template_location,
onetimeupload_config))
# Instanciate qemu
qemu_config = {}
qemu_config.update(self.options)
qemu_config['ip'] = ip
qemu_config['port'] = nbd_port
qemu_config['image'] = cdrom_iso
wrapper_template_location = pkg_resources.resource_filename(
__name__, os.path.join(
'template', 'nbdserver_run.in'))
nbdserver_runner_path = self.createRunningWrapper("nbdserver",
self.substituteTemplate(wrapper_template_location, qemu_config))
# Publish connection dict
self.computer_partition.setConnectionDict(dict(
upload_connection_string="https://[%s]:%s/" % (ip, http_port),
upload_key=onetimeupload_config['key'],
nbd_connection_string="nbd:[%s]:%s" % (ip, nbd_port),
))
return [onetimeupload_runner_path, nbdserver_runner_path]
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
# 32767 is the maximum number of connections allowed by the nbd server
exec %(qemu_path)s -b %(ip)s %(image)s -r -t -p %(port)s -e 32767
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
exec %(onetimeupload_path)s -l %(log_path)s %(ip)s %(port)s %(image)s %(key)s
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment