Commit 255ebd5f authored by Jérome Perrin's avatar Jérome Perrin

Remove broken "libcloud" and "siptester" recipes

This code seems not used, before nexedi/slapos@51c3773e and nexedi/slapos@b77d7bae it was not possible to import.

See merge request nexedi/slapos!869
parents 15936dc9 e6c862bb
Pipeline #12569 failed with stage
in 0 seconds
......@@ -116,8 +116,6 @@ setup(name=name,
'ipv6toipv4 = slapos.recipe.6tunnel:SixToFour',
'jsondump = slapos.recipe.jsondump:Recipe',
'kvm.frontend = slapos.recipe.kvm_frontend:Recipe',
'libcloud = slapos.recipe.libcloud:Recipe',
'libcloudrequest = slapos.recipe.libcloudrequest:Recipe',
'logrotate = slapos.recipe.logrotate:Recipe',
'logrotate.d = slapos.recipe.logrotate:Part',
'mkdirectory = slapos.recipe.mkdirectory:Recipe',
......@@ -159,7 +157,6 @@ setup(name=name,
'signalwrapper= slapos.recipe.signal_wrapper:Recipe',
'simplelogger = slapos.recipe.simplelogger:Recipe',
'simplehttpserver = slapos.recipe.simplehttpserver:Recipe',
'siptester = slapos.recipe.siptester:SipTesterRecipe',
'slapconfiguration = slapos.recipe.slapconfiguration:Recipe',
'slapconfiguration.serialised = slapos.recipe.slapconfiguration:Serialised',
'slapconfiguration.jsondump = slapos.recipe.slapconfiguration:JsonDump',
......
libcloud
========
Slapified recipe to interact with any libcloud supported IaaS system
from slapos.recipe.librecipe import BaseSlapRecipe
import os
import sys
import zc.buildout
import zc.recipe.egg
from slapos.slap.slap import ServerError
from pprint import pformat
class SlavePartitionError(Exception):
pass
class Recipe(BaseSlapRecipe):
SECURITY_GROUP_NAME = 'VifibEC2Security'
def __init__(self, buildout, name, options):
BaseSlapRecipe.__init__(self, buildout, name, options)
self.destroy_wrapper_location = os.path.join(self.bin_directory, 'destroy')
self.running_wrapper_location = os.path.join(self.bin_directory, 'run')
# wrapper parts
options['scripts'] = '''
run
destroy
'''
options['entry-points'] = '''
run=slapos.recipe.libcloud.run:run
destroy=slapos.recipe.libcloud.destroy:destroy
'''
self.egg = zc.recipe.egg.Egg(buildout, '', options)
self.configuration_file = os.path.join(self.etc_directory, 'cloudmgr.cnf')
def _loadSecretAndKey(self):
"""Loads security parameters for connection"""
self.secret = open(os.path.join(self.work_directory, 'secret.txt')
).read().strip()
self.key = open(os.path.join(self.work_directory, 'key.txt')
).read().strip()
def _updateConfigurationFile(self):
configuration_dict = dict(
key=self.key,
secret=self.secret,
node_list=self.slave_partition_configuration_dict_list
)
self._writeFile(self.configuration_file, pformat(configuration_dict))
def _install(self):
"""libcloud compatible machine is installed by creating wrapper, which
will run succesfully as long as the machine is available.
"""
self._loadSecretAndKey()
self.slave_partition_configuration_dict_list = []
self.egg.extra_paths = sys.path
for slave_partition in [self.slap.registerComputerPartition(
self.computer_id, slave_id) for slave_id in self.computer_partition\
.getInstanceParameterDict()['slave_id_list']]:
try:
self.slave_partition_configuration_dict_list.append(
self._installSlavePartition(slave_partition))
except SlavePartitionError as e:
self.logger.warning('Slave Parttion %r not installed, issue: %r'%(
slave_partition.getId(), e))
# Installs wrappers
self._updateConfigurationFile()
self.options['arguments'] = "server_binary = %r, configuration_file = %r"%(
self.options['server_binary'], self.configuration_file)
self.egg.install()
os.chmod(os.path.join(
self.running_wrapper_location), int('0700', 8))
os.chmod(os.path.join(
self.destroy_wrapper_location), int('0700', 8))
return []
def _installSlavePartition(self, slave_partition):
requested_dict = slave_partition.getInstanceParameterDict()
requested_dict.setdefault('service', 'EC2_EU_WEST')
requested_dict.setdefault('location', '0')
requested_dict.setdefault('image', 'ami-05cae171')
requested_dict.setdefault('size', 'm1.smal')
requested_dict.setdefault('security_group', 'VifibEC2Security')
connection_dict = slave_partition.getConnectionDict()
node_kw = dict(
key = self.key,
secret = self.secret,
service = requested_dict['service'],
location = requested_dict['location'],
node_uuid = connection_dict.get('node_uuid', None),
ssh_key = connection_dict.get('ssh_key', None)
)
# FIXME: this import no longer exist
from slapos.tool.cloudmgr.cloudinterface import NodeInterface
node = NodeInterface(**node_kw)
update_kw = dict(
image = requested_dict['image'],
size = requested_dict['size'],
security_group = requested_dict['security_group'],
)
self.logger.info('Updating %r' % slave_partition.getId())
connection_dict.update(node.update(**update_kw))
self.logger.info('Fetching public ip of %r' % slave_partition.getId())
connection_dict.update(node.getPublicIpList())
slave_partition.available()
connection_dict.setdefault('username', 'root')
slave_partition.setConnectionDict(connection_dict)
requested_dict.update(connection_dict)
slave_partition_state = slave_partition.getState()
# as cloudmgr is not related with slap and runs as async process to recipe
# assume that whatever came from slave is correctly done
if slave_partition_state in ['started', 'stopped']:
# stopped cannot be supported, because in case of libcloud it is equal
# to destroyed
# even worse: stopped is the first state for installed partition
try:
getattr(slave_partition, slave_partition_state)()
except ServerError:
# Recipe is becoming responsible for system state, so it have to
# not die in case of slap server error
pass
requested_dict['requested_state'] = 'started'
elif slave_partition_state == 'destroyed':
requested_dict['requested_state'] = slave_partition_state
try:
slave_partition.destroyed()
except ServerError:
# Recipe is becoming responsible for system state, so it have to
# not die in case of slap server error
pass
return requested_dict
from os import execl
import sys
def run(server_binary, configuration_file):
sys.stdout.flush()
execl(server_binary, server_binary, configuration_file)
from slapos.recipe.librecipe import BaseSlapRecipe
import zc.buildout
class Recipe(BaseSlapRecipe):
def _install(self):
amazon = self.request(
'https://svn.erp5.org/repos/public/slapos/trunk/software_release/libcloud/software.cfg',
'Amazon EC Image',
'Amazon EC Connector Partition',
True)
amazon_dict = amazon.getConnectionDict()
if amazon_dict == {}:
raise zc.buildout.UserError('Slave not installed yet')
self.computer_partition.setConnectionDict(amazon.getConnectionDict())
return []
import os
import pkg_resources
from slapos.recipe.librecipe import BaseSlapRecipe
class SipTesterRecipe(BaseSlapRecipe):
def __init__(self, buildout, name, options):
BaseSlapRecipe.__init__(self, buildout, name, options)
self.pjsua_configuration_file = os.path.join(self.etc_directory,
'pjsua.conf')
def _createPJSUAConfiguration(self, template_name):
pjsua_input = pkg_resources.resource_string(__name__, os.path.join(
'template', template_name))
if self._writeFile(self.pjsua_configuration_file,
pjsua_input % self.options):
# XXX: How to inform slap/slapgrid that something changed and it might
# be not bad idea to restart CP?
pass
return self.pjsua_configuration_file
def _install(self):
path = self._createPJSUAConfiguration(self.config_template)
d = {}
d.update(self.options)
d['pjsua_configuration_file'] = self.pjsua_configuration_file
# XXX Hardcoded path
d['pjsua_binary'] = os.path.join(self.buildout['software_definition'
]['software_home'].strip(), 'parts', 'pjproject-1.7', 'bin', 'pjsua')
d['siptester_binary'] = os.path.join(self.buildout['software_definition'
]['software_home'].strip(), 'bin', 'siptester')
self.running_wrapper_location = pkg_resources.resource_filename(__name__, os.path.join(
'template',
self.wrapper_template))
self._createRunningWrapper(d)
return [path, wrapper_path]
def update(self):
return self.install()
class ReceiverRecipe(SipTesterRecipe):
config_template = "pjsua_receiver.conf.in"
wrapper_template = "init_receiver.in"
class CallerRecipe(SipTesterRecipe):
config_template = "pjsua_caller.conf.in"
wrapper_template = "init_caller.in"
def _install(self):
# First of all, ask for a sipreceiver
self.request(self.software_release_url, 'sipreceiver')
return SipTesterRecipe._install(self)
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
exec %(siptester_binary)s %(pjsua_binary)s %(pjsua_configuration_file)s %(caller_destination)s
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
exec %(siptester_binary)s %(pjsua_binary)s %(pjsua_configuration_file)s
#
# Logging options:
#
--log-level 0
--app-log-level 0
#
# Account 0:
#
--id %(caller_id)s
--registrar %(caller_registrar)s
--realm %(caller_realm)s
--username %(caller_username)s
--password %(caller_password)s
--reg-timeout 300
#
# Network settings:
#
--local-port 5060
#
# Media settings:
#
--null-audio
--playback-lat 100
--rtp-port 4000
#
# User agent:
#
--max-calls 4
--duration 300
#
# Logging options:
#
--log-level 0
--app-log-level 0
#
# Account 0:
#
--id %(receiver_id)s
--registrar %(receiver_registrar)s
--realm %(receiver_realm)s
--username %(receiver_username)s
--password %(receiver_password)s
--reg-timeout 300
#
# Network settings:
#
--local-port 5060
#
# Media settings:
#
--null-audio
--auto-play
--play-file %(wav_path)s
--playback-lat 100
--rtp-port 4000
#
# User agent:
#
--auto-answer 200
--max-calls 4
# Version: 0.0.1
[buildout]
parts =
libcloud-requester
# instance shall be offline
offline = true
eggs-directory = ${software_definition:software_home}/eggs
develop-eggs-directory = ${software_definition:software_home}/develop-eggs
[libcloud-requester]
# slap connection information
slap_computer_id = ${slap_computer_id}
slap_computer_partition_id = ${slap_computer_partition_id}
slap_server_url = ${slap_server_url}
slap_software_release_url = ${slap_software_release_url}
# select recipe
recipe = slapos.recipe.libcloudrequest
# Version: 0.0.1
[buildout]
parts =
workaround-downloadcache
libcloudrequestertemplate
eggs
find-links =
http://www.nexedi.org/static/packages/source/slapos.buildout/
versions = versions
[workaround-downloadcache]
recipe = plone.recipe.command
command =
rm -rf ${buildout:directory}/downloads
update-command = ${:command}
[libcloudrequestertemplate]
recipe = slapos.recipe.hrdownload
url = ${:_profile_base_location_}/instance.cfg
filename = template.cfg
destination = ${buildout:directory}
download-only = true
[eggs]
recipe = zc.recipe.egg
eggs =
slapos.recipe.libcloudrequest
[versions]
zc.buildout = 1.5.3-dev-SlapOS-001
# Version: 0.0.4dev
[buildout]
parts =
libcloud-instance
# instance shall be offline
offline = true
eggs-directory = ${software_definition:software_home}/eggs
develop-eggs-directory = ${software_definition:software_home}/develop-eggs
[libcloud-instance]
# slap connection information
slap_computer_id = ${slap_computer_id}
slap_computer_partition_id = ${slap_computer_partition_id}
slap_server_url = ${slap_server_url}
slap_software_release_url = ${slap_software_release_url}
# select recipe
recipe = slapos.recipe.libcloud
server_binary = ${software_definition:software_home}/bin/cloudmgr
# Version: 0.0.5dev
[buildout]
parts =
workaround-downloadcache
libcloudtemplate
paramiko-wrokaround-dependency
paramiko-wrokaround
eggs
versions = paramiko-workaround-versions
[paramiko-workaround-versions]
paramiko = 1.7.6
[paramiko-wrokaround-dependency]
recipe = zc.recipe.egg
eggs =
pycrypto
[paramiko-wrokaround]
recipe = zc.recipe.egg
index =
eggs =
paramiko
[workaround-downloadcache]
recipe = plone.recipe.command
command =
rm -rf ${buildout:directory}/downloads
update-command = ${:command}
[libcloudtemplate]
recipe = slapos.recipe.hrdownload
url =
filename = template.cfg
destination = ${buildout:directory}
download-only = true
[eggs]
recipe = zc.recipe.egg
eggs =
slapos.tool.cloudmgr
slapos.recipe.libcloud
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