Commit b3b2ac28 authored by Łukasz Nowak's avatar Łukasz Nowak

Import slapos.core code.

parent 44a31a37
this is libslap for Java.
More informations at http://www.slapos.org.
Dependencies :
=============
In order to use this library, please also install the following libraries :
jackson-core-asl
jackson-jaxrs
jackson-mapper-asl
jersey-client
jersey-core
You can find those libraries in this archive :
http://download.java.net/maven/2/com/sun/jersey/jersey-archive/1.6/jersey-archive-1.6.zip
Future releases of libslap-java may be provided with Maven pom.
How to use it :
This library should be used in conjunction with the "rest-json" branch of
libslap-python
(https://gitorious.org/slapos/slapos-libslap-python/commits/rest-json) and with
the "rest" branch of slapproxy
(https://gitorious.org/slapos/slapos-tool-proxy/commits/rest).
When using slapproxy, a special Buildout profile should be used :
[buildout]
extends =
https://gitorious.org/slapos/slapos/blobs/raw/master/bootstrap/software.cfg
extensions +=
mr.developer
auto-checkout = *
parts +=
pyflakes
[sources]
# mr.developer sources definition
slapos.slap = git http://git.gitorious.org/slapos/slapos-libslap-python.git branch=rest-json
slapos.tool.proxy = git git@gitorious.org:slapos/slapos-tool-proxy.git branch=rest
[pyflakes]
recipe = zc.recipe.egg
scripts =
pyflakes
eggs =
pyflakes
setuptools
entry-points = pyflakes=pkg_resources:run_script
arguments = 'pyflakes', 'pyflakes'
[slapos]
interpreter = python
eggs +=
# develop helper eggs
ipython
ipdb
pyflakes
pep8
rstctl
This profile will install the needed special branches of slapproxy and
libslap-python.
Known bugs :
=============
* Ugly, first implementation of libslap-java from python
* We should not define a computer when using slap for requesting instances, but
only to install softwares.
* Implement Destroy for ComputerPartition
* Currently, two separate notions have been interchanged. computer_partition_id
represents the internal name of the computer partition from the point of view
of slapgrid. partition_reference is the human name set by the person requesting
an instance. A bug is preventing us to separate those notions, either in the
libslap-java or in the slapproxy implementation.
Changelog :
=============
2011/05/20
===
Initial release
(Cedric de Saint Martin)
2011/05/24
===
Slap is no longer a singleton, several instances can be used at the same time with several masters.
(Cedric de Saint Martin)
\ No newline at end of file
package org.slapos.slap;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
import javax.ws.rs.core.MediaType;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
/**
* Simple Jersey Client wrapper, including url of the slapos master.
*/
class ClientWrapper {
private Client client;
private final String masterUri;
public ClientWrapper(String masterUri) {
//TODO check uri validity (http and https)
//TODO check presence of end /
this.masterUri = masterUri;
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(JacksonJsonProvider.class);
client = Client.create(config);
}
/**
* Creates a WebResource with master url + given uri.
* @param uri
*/
public WebResource resource(String uri) {
return client.resource(masterUri + uri);
}
public static String object2Json(Object parameterList, String type) {
String parameterListJson = null;
StringWriter sw = new StringWriter();
//TODO correct encoding handling, maybe do not use Writer. see javadoc for JsonEncoding
ObjectMapper mapper = new ObjectMapper();
try {
if (type.equalsIgnoreCase("ComputerPartition")) {
mapper.writeValue(sw, (ComputerPartition) parameterList);
} else {
mapper.writeValue(sw, (Map<String, Object>) parameterList);
}
parameterListJson = sw.toString();
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return parameterListJson;
}
public String get(String uri) {
WebResource webResource = resource(uri);
String response = webResource.accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
//TODO check that exception is thrown when !200
return response;
}
/**
* Takes a Map<String, Object>, converts it to json, and send it to URI.
* @param uri
* @param parameterList
* @return
* @throws Exception
*/
public String post(String uri, Map<String, Object> parameterList) throws Exception {
// Converts it to JSON
// TODO better automatic marshalling with jackson.
String parameterListJson = ClientWrapper.object2Json(parameterList, "map");
return post(uri, parameterListJson);
}
/**
* Makes a POST request to the specified URI with the corresponding string as parameter to send
* @param uri
* @param JsonObject
* @return
* @throws Exception
*/
// TODO content type?
public String post(String uri, String JsonObject) throws Exception {
WebResource webResource = resource(uri);
// FIXME there must exist a way to send a generic object as parameter and have it converted automatically to json.
ClientResponse response = webResource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, JsonObject); //new GenericType<List<StatusBean>>() {}
//TODO automatic unmarshal
if (response.getStatus() == 200) {
return response.getEntity(String.class);
}
//TODO correct exception
throw new Exception("Server responded with wrong code : " + response.getStatus() + " when requesting " + uri);
}
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap;
import java.util.ArrayList;
import org.slapos.slap.interfaces.IComputer;
import org.slapos.slap.interfaces.IComputerPartition;
public class Computer extends SlapDocument implements IComputer {
private String computerId;
private ArrayList<String> softwareReleaseList;
private ArrayList<ComputerPartition> computerPartitionList;
private ClientWrapper connection;
public Computer(ClientWrapper connection, String computerId) {
this.computerId = computerId;
this.connection = connection;
}
/**
* Synchronize computer object with server information
*/
private void syncComputerInformation() {
/* def _syncComputerInformation(func):
def decorated(self, *args, **kw):
computer = self._connection_helper.getComputerInformation(self._computer_id)
for key, value in computer.__dict__.items():
if isinstance(value, unicode):
# convert unicode to utf-8
setattr(self, key, value.encode('utf-8'))
else:
setattr(self, key, value)
return func(self, *args, **kw)
return decorated */
}
/**
* Returns the list of software release which has to be supplied by the
* computer.
* Raise an INotFoundError if computer_guid doesn't exist.
*/
public ArrayList<String> getSoftwareReleaseList() {
syncComputerInformation();
return this.softwareReleaseList;
}
public ArrayList<IComputerPartition> getComputerPartitionList() {
syncComputerInformation();
ArrayList<IComputerPartition> partitionToModifyList = new ArrayList<IComputerPartition>();
for (ComputerPartition partition : computerPartitionList) {
if (partition.need_modification) {
partitionToModifyList.add(partition);
}
}
return partitionToModifyList;
}
public void reportUsage(ArrayList<ComputerPartition> computer_partition_list) {
//FIXME implement this method
/* if computer_partition_list == []:
return;
computer = Computer(self._computer_id);
computer.computer_partition_usage_list = computer_partition_list;
marshalled_slap_usage = xml_marshaller.dumps(computer);
self._connection_helper.POST('/useComputer', {
'computer_id': self._computer_id,
'use_string': marshalled_slap_usage});
*/
}
public void updateConfiguration(String xml) {/*
self.connectionHelper.POST(
"/loadComputerConfigurationFromXML", { "xml" : xml });
return this.connectionHelper.response.read();*/
}
@Override
public void reportUsage(String[] computer_partition_list) {
// FIXME Not implemented
}
}
\ No newline at end of file
This diff is collapsed.
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap;
import java.util.HashMap;
import java.util.Map;
import org.slapos.slap.interfaces.IOpenOrder;
public class OpenOrder extends SlapDocument implements IOpenOrder {
private ClientWrapper connection;
public OpenOrder(ClientWrapper connection) {
this.connection = connection;
}
//FIXME Java conventions
public ComputerPartition request(String softwareRelease, String partition_reference,
Map<String, Object> partition_parameter_kw, String software_type) {
if (partition_parameter_kw == null) {
partition_parameter_kw = new HashMap<String, Object>();
}
ComputerPartition cp = new ComputerPartition(connection);
cp.setSoftware_release(softwareRelease);
cp.setPartition_reference(partition_reference);
cp.setParameter_dict(partition_parameter_kw);
if (software_type != null) {
cp.setSoftware_type(software_type);
}
// Sends it, reads response
return cp.sendRequest(cp);
}
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap;
import java.io.IOException;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.slapos.slap.interfaces.ISlap;
/*
Simple, easy to (un)marshall classes for slap client/server communication
*/
//TODO : https connection
//TODO : correct encoding?
class SlapDocument {}
class ResourceNotReady extends Exception {
/**
*
*/
private static final long serialVersionUID = -6398370634661469874L;}
class ServerError extends Exception {
/**
*
*/
private static final long serialVersionUID = 8414085299597106973L;}
/*
class ConnectionHelper:
error_message_connect_fail = "Couldn't connect to the server. Please double \
check given master-url argument, and make sure that IPv6 is enabled on \
your machine and that the server is available. The original error was:"
def getComputerInformation(self, computer_id):
self.GET('/getComputerInformation?computer_id=%s' % computer_id)
return xml_marshaller.loads(self.response.read())
*/
public class Slap implements ISlap {
private String computerGuid;
private ClientWrapper slaposMasterRestClient;
public void initializeConnection(String slaposMasterUri) {
if (slaposMasterRestClient != null) {
System.out.println("Warning : Slap has already been initialized. Reinitializing..."); // TODO logger
}
this.slaposMasterRestClient = new ClientWrapper(slaposMasterUri);
this.computerGuid = null;
}
@Override
public void initializeConnection(String slapgridUri,
String authentificationKey) {
// TODO Auto-generated method stub
}
@Override
public Computer registerComputer(String computerGuid) {
this.computerGuid = computerGuid;
return new Computer(getConnectionWrapper(), computerGuid);
}
/*
* Registers connected representation of software release and
* returns SoftwareRelease class object(non-Javadoc)
* @see org.slapos.slap.interfaces.ISlap#registerSoftwareRelease(java.lang.String)
*/
@Override
public SoftwareRelease registerSoftwareRelease(String softwareReleaseUrl) throws Exception {
//TODO Correct exception
if (computerGuid == null) {
throw new Exception("Computer has not been registered. Please use registerComputer before.");
}
return new SoftwareRelease(softwareReleaseUrl, computerGuid);
}
public ComputerPartition registerComputerPartition(String computerGuid, String partitionId) {
String jsonobj = slaposMasterRestClient.get("/" + computerGuid + "/partition/" + partitionId);
ObjectMapper mapper = new ObjectMapper();
ComputerPartition computerPartition = null;
try {
computerPartition = mapper.readValue(jsonobj, ComputerPartition.class);
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return computerPartition;
}
@Override
public OpenOrder registerOpenOrder() {
return new OpenOrder(getConnectionWrapper());
}
@Override
public Supply registerSupply() {
return new Supply(getConnectionWrapper());
}
public ClientWrapper getConnectionWrapper() {
return slaposMasterRestClient;
}
}
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap;
import org.slapos.slap.interfaces.ISoftwareRelease;
/**
* Contains Software Release information
**/
public class SoftwareRelease extends SlapDocument implements ISoftwareRelease {
//FIXME change and use this class when manipulating softwarereleases. Currently only String are used.
private String softwareReleaseUri;
private String computerGuid;
public SoftwareRelease(String softwareReleaseUri, String computerGuid) {
this.softwareReleaseUri = softwareReleaseUri;
this.computerGuid = computerGuid;
}
public String getURI() {
return softwareReleaseUri;
}
@Override
public void available() {
// TODO Auto-generated method stub
}
@Override
public void building() {
// TODO Auto-generated method stub
}
@Override
public void error(String error_log) {
// TODO Auto-generated method stub
}
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap;
import java.util.HashMap;
import java.util.Map;
import org.slapos.slap.interfaces.ISupply;
public class Supply extends SlapDocument implements ISupply {
private ClientWrapper connection;
public Supply(ClientWrapper connection) {
this.connection = connection;
}
public void supply(String softwareRelease, String computerGuid) {
Map<String, Object> request = new HashMap<String, Object>();
request.put("url", softwareRelease);
try {
connection.post("/" + computerGuid + "/software", request);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void supply(String software_release) {
// TODO Auto-generated method stub
}
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap.exception;
/**
* public interfacees which implement INotFoundError are used to report missing
* informations on the slap server.
**/
public class NotFoundException extends Exception {
public NotFoundException(String string) {
super(string);
}
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap.exception;
/**
* public interfacees which implement IUnauthorized are used to report missing
* permissions on the slap server.
*/
public class UnauthorizedException extends Exception {
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
*****************************************************************************/
package org.slapos.slap.interfaces;
/**
* public interfacees which implement IBuildoutController can report the buildout run
* status to the slapgrid server.
*/
public interface IBuildoutController {
/**
* Notify (to the slapgrid server) that the software instance is
* available.
*/
public void available();
/**
* Notify (to the slapgrid server) that the buildout is not
* available and under creation.
*/
public void building();
/**
* Notify (to the slapgrid server) that the buildout is not available
* and reports an error.
*
* error_log -- a text describing the error
* It can be a traceback for example.
*/
public void error(String error_log);
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
*****************************************************************************/
package org.slapos.slap.interfaces;
import java.util.ArrayList;
/**
* Computer interface specification
*
* public interfacees which implement IComputer can fetch informations from the slapgrid
* server to know which Software Releases and Software Instances have to be
* installed.
*/
public interface IComputer {
/**
* Returns the list of software release which has to be supplied by the
* computer.
*
* Raise an INotFoundError if computer_guid doesn't exist.
*/
public ArrayList<String> getSoftwareReleaseList();
/**
* Returns the list of configured computer partitions associated to this
* computer.
*
* Raise an INotFoundError if computer_guid doesn't exist.
*/
public ArrayList<IComputerPartition> getComputerPartitionList();
/**
* Report the computer usage to the slapgrid server.
* IComputerPartition.setUsage has to be called on each computer partition to
* public functionine each usage.
*
* computer_partition_list -- a list of computer partition for which the usage
* needs to be reported.
*/
public void reportUsage(String[] computer_partition_list);
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
*****************************************************************************/
package org.slapos.slap.interfaces;
import java.util.Map;
/**
* Computer Partition interface specification
* public interfacees which implement IComputerPartition can propagate the computer
* partition state to the SLAPGRID server and request new computer partition
* creation.
*/
public interface IComputerPartition extends IBuildoutController {
/**
* Request software release instanciation to slapgrid server.
*
* Returns a new computer partition document, where this sofware release will
* be installed.
*
* software_release -- uri of the software release
* which has to be instanciated
*
* software_type -- type of component provided by software_release
*
* partition_reference -- local reference of the instance used by the recipe
* to identify the instances.
*
* shared -- boolean to use a shared service
*
* partition_parameter_kw -- dictionary of parameter used to fill the
* parameter dict of newly created partition.
*
* filter_kw -- dictionary of filtering parameter to select the requested
* computer partition.
*
* computer_reference - computer of the requested partition
* partition_type - virtio, slave, full, limited
* port - port provided by the requested partition
*
* Example:
* request('http://example.com/toto/titi', 'mysql_1')
*/
public IComputerPartition request(String softwareRelease, String softwareType,
String partitionReference,
boolean shared, // = false
Map<String, Object> partitionParameter, // = null
Map<String, String> filter); // = null
/**
* Notify (to the slapgrid server) that the software instance is
* available and stopped.
*/
public void stopped();
/**
* Notify (to the slapgrid server) that the software instance is
* available and started.
*/
public void started();
/**
* Returns a string representing the identifier of the computer partition
* inside the slapgrid server.
*/
public String getId();
/**
* Returns a string representing the expected state of the computer partition.
* The result can be: started, stopped, destroyed
*/
public String getState();
/**
* Returns the software release associate to the computer partition.
* Raise an INotFoundError if no software release is associated.
*/
public String getSoftwareRelease();
/**
* Returns a dictionary of instance parameters.
*
* The contained values can be used to fill the software instanciation
* profile.
*/
public Map<String, String> getInstanceParameterDict();
/**
* Set instance parameter informations on the slagrid server.
*
* partition_parameter_kw -- dictionary of parameters.
*
* This method can be used to propagate connection informations (like
* service's port).
*/
public void setInstanceParameterDict(Map<String, String> partition_parameter_kw);
/**
* Associate a usage log to the computer partition.
* This method does not report the usage to the slapgrid server. See
* IComputer.report.
*
* usage_log -- a text describing the computer partition usage.
* It can be an XML for example.
*/
public void setUsage(String usage_log);
}
/******************************************************************************
*
* 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.
*
******************************************************************************/
package org.slapos.slap.interfaces;
import java.util.Map;
/**
* Open Order interface specification
*
* public interfacees which implement Open Order describe which kind of software instances
* is requested by a given client.
*/
public interface IOpenOrder {
/**
* Request the instanciation of a given software release to the slapgrid
* server.
*
* Returns a new computer partition document, where this software release will
* be installed.
*
* software_release -- uri of the software release
* which has to be instanciated
*/
public IComputerPartition request(String software_release, String partition_reference,
Map<String, Object> partition_parameter_kw, String software_type);
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
*****************************************************************************/
package org.slapos.slap.interfaces;
import org.slapos.slap.exception.NotFoundException;
/**
* Note: all strings accepted/returned by the slap library are encoded in UTF-8.
* Initialise slap connection to the slapgrid server
*
* Slapgrid server URL is public functionined during the slap library
* installation, as recipes should not use another server.
*/
public interface ISlap {
/**
* Initialize the connection parameters to the slapgrid servers.
*
* slapgrid_uri -- uri the slapgrid server connector
*
* authentification_key -- string the authentificate the agent.
*
* Example: https://slapos.server/slap_interface
*/
public void initializeConnection(String slapgridUri,
String authentificationKey);
/**
* Initialize the connection parameters to the slapgrid servers.
*
* slapgrid_uri -- uri the slapgrid server connector
*
* authentification_key -- string the authentificate the agent.
*
* Example: https://slapos.server/slap_interface
*/
public void initializeConnection(String slapgridUri);
/**
* Instanciate a computer in the slap library.
*
* computer_guid -- the identifier of the computer inside the slapgrid
* server.
*/
public IComputer registerComputer(String computerGuid);
/**
* Instanciate a computer partition in the slap library, fetching
* informations from master server.
*
* @param computerGuid
* -- the identifier of the computer inside the slapgrid server.
*
* @param partitionId
* -- the identifier of the computer partition inside the
* slapgrid server.
*
* Raise a NotFoundError if computer_guid doesn't exist.
*/
public IComputerPartition registerComputerPartition(String computerGuid,
String partitionId) throws NotFoundException;
/**
* Instanciate a software release in the slap library.
*
* @param softwareRelease
* -- uri of the software release public functioninition
* @throws Exception
*/
public ISoftwareRelease registerSoftwareRelease(String softwareReleaseUrl) throws Exception;
/**
* Instanciate an open order in the slap library.
* @return
*/
public IOpenOrder registerOpenOrder();
/**
* Instanciate a supply in the slap library.
*/
public ISupply registerSupply();
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
*****************************************************************************/
package org.slapos.slap.interfaces;
/**
* Software release interface specification
*/
public interface ISoftwareRelease extends IBuildoutController {
/**
* Returns a string representing the uri of the software release.
*/
public String getURI();
}
\ No newline at end of file
/******************************************************************************
*
* 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.
*
*****************************************************************************/
package org.slapos.slap.interfaces;
/**
* Supply interface specification
*
* public interfacees which implement Supply describe which kind of software releases
* a given client is ready to supply.
*/
public interface ISupply {
/**
* Tell that given client is ready to supply given sofware release
*
* software_release -- uri of the software release
* which has to be instanciated
*
* computer_guid -- the identifier of the computer inside the slapgrid
* server.
*/
public void supply(String software_release, String computer_guid);
/**
* Tell that given client is ready to supply given sofware release
*
* software_release -- uri of the software release
* which has to be instanciated
*/
public void supply(String software_release);
}
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Define the XML Schema of a transaction -->
<xs:element name="instance">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType mixed="true">
<xs:attribute name="id" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="unique_instance_parameter_id">
<xs:selector xpath="./parameter"/>
<xs:field xpath="@id"/>
</xs:unique>
</xs:element>
</xs:schema>
import java.util.HashMap;
import java.util.Map;
import org.slapos.slap.*;
/**
* This class is a simple example or test for libslap-java, showing how to request instances or fetch parameters.
* @author cedricdesaintmartin
*
*/
public class test {
public static void main(String[] args) {
// Should not be a singleton
Slap slap = new Slap();
slap.initializeConnection("http://localhost:5000");
// We should not have to require
slap.registerComputer("computer");
String software = "https://gitorious.org/slapos/slapos-software-proactive/blobs/raw/master/software.cfg";
// Installs a software in the computer
Supply supply = slap.registerSupply();
supply.supply(software, "computer");
// Asks an instance of the installed software
OpenOrder oo = slap.registerOpenOrder();
Map<String, Object> parameterDict = new HashMap<String, Object>();
parameterDict.put("credentials", "bububu");
parameterDict.put("rmURL", "bububu");
parameterDict.put("nsName", "bububu");
ComputerPartition cp = oo.request(software, "slappart0", parameterDict, null);
String helloworld = "https://gitorious.org/slapos/slapos-software-helloworld/blobs/raw/master/software.cfg";
// Installs a software in the computer
Supply supply2 = slap.registerSupply();
supply2.supply(helloworld, "computer");
OpenOrder oo2 = slap.registerOpenOrder();
ComputerPartition cp2 = oo2.request(helloworld, "slappart1", null, null);
while (true) {
try {
System.out.println((String) cp.getConnectionParameter("useless_parameter"));
} catch (Exception e) {
System.out.println(e.getMessage());
}
try {
Thread.sleep(30000);
} catch (InterruptedException e) {}
}
}
}
1.2 (unreleased)
----------------
1.1 (2011/01/04)
----------------
- Update MANIFEST file
1.0 (2011/01/04)
----------------
include CHANGES.txt
include src/slapos/slap/doc/software_instance.xsd
slap
====
Simple Language for Accounting and Provisioning python library.
Developer note - python version
===============================
This library is used on client (slapgrid) and server side.
Server is using python2.4 and client is using python2.6
Having this in mind, code of this library *have* to work
on python2.4
How it works
============
The SLAP main server which is in charge of service coordination receives from participating servers the number of computer paritions which are available, the type of resource which a party is ready provide, and request from parties for resources which are needed.
Each participating server is identified by a unique ID and runs a slap-server daemon. This dameon collects from the main server the installation tasks and does the installation of resources, then notifies the main server of completion whenever a resource is configured, installed and available.
The data structure on the main server is the following:
A - Action: an action which can happen to provide a resource or account its usage
CP - Computer Partition: provides a URL to Access a Cloud Resource
RI - Resource Item: describes a resource
CI - Contract Item: describes the contract to attach the DL to (This is unclear still)
R - Resource: describes a type of cloud resource (ex. MySQL Table) is published on slapgrid.org
DL - Delivery Line: Describes an action happening on a resource item on a computer partition
D - Delivery: groups multiple Delivery Lines
[egg_info]
tag_build = .dev
tag_svn_revision = 1
from setuptools import setup, find_packages
name="slapos.slap"
version='1.2'
def read(name):
return open(name).read()
long_description=(
read('README.txt')
+ '\n' +
read('CHANGES.txt')
)
setup(
name=name,
version=version,
description="slap - Simple Language for Accounting and Provisioning"
" python library",
long_description=long_description,
license="GPLv3",
keywords="slap library",
classifiers=[
],
py_modules = ["slapos.slap.interface.slap"],
namespace_packages = ['slapos'],
packages=find_packages('src'),
include_package_data=True,
package_dir={'':'src'},
install_requires=[
'lxml',
'setuptools',
'xml_marshaller>=0.9.3',
'zope.interface',
],
zip_safe=True,
)
# 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.
#
##############################################################################
from slapos.slap import slap, ComputerPartition, ResourceNotReady
import sys
import MySQLDB
class Recipe:
def __init__(self, buildout, options):
self.buildout, self.options = buildout, options
def install(self):
# register self on slap
# online computer partition, slap gave connector
computer_partition = slap(self.options['vifib_server_url']).register(
ComputerPartition,
coordinate_kw=dict(
computer_id=self.options['computer_id'], # c09fba86-b690-493d-b2b5-03a0df580b28
partition_id=self.options['partition_id'], # 007
resource_url=self.options['resource_url'], # http://slapgrid.org/resource/mysqldatabase-5.4.5
)
)
# request mysql server instance in version 5.4.5
mysql_server_partition = computer_partition.request(
self.options['parent_resource_url'], # http://slapgrid.org/resource/mysqlserver-5.4.5
self.options['parent_resource_id'], # main_server
)
# invoke installation
try:
connect = MySQLDB(mysql_server_partition.getIP(),
mysql_server_partition.getPort(), mysql_server_partition.getUser(),
mysql_server_partition.getPassword()).connect()
except ResourceNotReady:
# accept asynchronous mode
self.logger.info('Not yet available, postponing...')
return []
if not connect.isDatabaseCreated(self.options['database_name']):
computer_partition.building()
try:
connect.query('CREATE DATABASE IF NOT EXISTS %s' %
self.options['database_name'])
except:
# issue during installation
message = 'Issue during creation %s:%s' % sys.traceback_info_as_list()
computer_partition.error(message)
self.logger.error(message)
if connect.isDatabaseCreated(self.options['database_name']):
computer_partition.available()
return []
update = install
##############################################################################
#
# 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 sys
if sys.version_info < (2, 6):
import warnings
warnings.warn('Used python version (%s) is old and have problems with'
' IPv6 connections' % '.'.join([str(q) for q in sys.version_info[:3]]))
from slap import *
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Define the XML Schema of a transaction -->
<xs:element name="instance">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType mixed="true">
<xs:attribute name="id" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="unique_instance_parameter_id">
<xs:selector xpath="./parameter"/>
<xs:field xpath="@id"/>
</xs:unique>
</xs:element>
</xs:schema>
##############################################################################
#
# 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.
#
##############################################################################
##############################################################################
#
# 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.
#
##############################################################################
from zope.interface import Interface
"""
Note: all strings accepted/returned by the slap library are encoded in UTF-8.
"""
class IException(Interface):
"""
Classes which implement IException are used to report errors.
"""
class INotFoundError(IException):
"""
Classes which implement INotFoundError are used to report missing
informations on the slap server.
"""
class IUnauthorized(IException):
"""
Classes which implement IUnauthorized are used to report missing
permissions on the slap server.
"""
class IBuildoutController(Interface):
"""
Classes which implement IBuildoutController can report the buildout run
status to the slapgrid server.
"""
def available():
"""
Notify (to the slapgrid server) that the software instance is
available.
"""
def building():
"""
Notify (to the slapgrid server) that the buildout is not
available and under creation.
"""
def error(error_log):
"""
Notify (to the slapgrid server) that the buildout is not available
and reports an error.
error_log -- a text describing the error
It can be a traceback for example.
"""
class ISoftwareRelease(IBuildoutController):
"""
Software release interface specification
"""
def getURI():
"""
Returns a string representing the uri of the software release.
"""
class IComputerPartition(IBuildoutController):
"""
Computer Partition interface specification
Classes which implement IComputerPartition can propagate the computer
partition state to the SLAPGRID server and request new computer partition
creation.
"""
def request(software_release, software_type, partition_reference,
shared=False, partition_parameter_kw=None, filter_kw=None):
"""
Request software release instanciation to slapgrid server.
Returns a new computer partition document, where this sofware release will
be installed.
software_release -- uri of the software release
which has to be instanciated
software_type -- type of component provided by software_release
partition_reference -- local reference of the instance used by the recipe
to identify the instances.
shared -- boolean to use a shared service
partition_parameter_kw -- dictionary of parameter used to fill the
parameter dict of newly created partition.
filter_kw -- dictionary of filtering parameter to select the requested
computer partition.
computer_reference - computer of the requested partition
partition_type - virtio, slave, full, limited
port - port provided by the requested partition
Example:
request('http://example.com/toto/titi', 'mysql_1')
"""
def stopped():
"""
Notify (to the slapgrid server) that the software instance is
available and stopped.
"""
def started():
"""
Notify (to the slapgrid server) that the software instance is
available and started.
"""
def getId():
"""
Returns a string representing the identifier of the computer partition
inside the slapgrid server.
"""
def getState():
"""
Returns a string representing the expected state of the computer partition.
The result can be: started, stopped, destroyed
"""
def getSoftwareRelease():
"""
Returns the software release associate to the computer partition.
Raise an INotFoundError if no software release is associated.
"""
def getInstanceParameterDict():
"""
Returns a dictionary of instance parameters.
The contained values can be used to fill the software instanciation
profile.
"""
def setInstanceParameterDict(partition_parameter_kw):
"""
Set instance parameter informations on the slagrid server.
partition_parameter_kw -- dictionary of parameters.
This method can be used to propagate connection informations (like
service's port).
"""
def setUsage(usage_log):
"""
Associate a usage log to the computer partition.
This method does not report the usage to the slapgrid server. See
IComputer.report.
usage_log -- a text describing the computer partition usage.
It can be an XML for example.
"""
class IComputer(Interface):
"""
Computer interface specification
Classes which implement IComputer can fetch informations from the slapgrid
server to know which Software Releases and Software Instances have to be
installed.
"""
def getSoftwareReleaseList():
"""
Returns the list of software release which has to be supplied by the
computer.
Raise an INotFoundError if computer_guid doesn't exist.
"""
def getComputerPartitionList():
"""
Returns the list of configured computer partitions associated to this
computer.
Raise an INotFoundError if computer_guid doesn't exist.
"""
def reportUsage(computer_partition_list):
"""
Report the computer usage to the slapgrid server.
IComputerPartition.setUsage has to be called on each computer partition to
define each usage.
computer_partition_list -- a list of computer partition for which the usage
needs to be reported.
"""
class IOpenOrder(Interface):
"""
Open Order interface specification
Classes which implement Open Order describe which kind of software instances
is requested by a given client.
"""
def request(software_release):
"""
Request the instanciation of a given software release to the slapgrid
server.
Returns a new computer partition document, where this software release will
be installed.
software_release -- uri of the software release
which has to be instanciated
"""
class ISupply(Interface):
"""
Supply interface specification
Classes which implement Supply describe which kind of software releases
a given client is ready to supply.
"""
def supply(software_release, computer_guid=None):
"""
Tell that given client is ready to supply given sofware release
software_release -- uri of the software release
which has to be instanciated
computer_guid -- the identifier of the computer inside the slapgrid
server.
"""
class slap(Interface):
"""
Initialise slap connection to the slapgrid server
Slapgrid server URL is defined during the slap library installation,
as recipes should not use another server.
"""
def initializeConnection(slapgrid_uri, authentification_key=None):
"""
Initialize the connection parameters to the slapgrid servers.
slapgrid_uri -- uri the slapgrid server connector
authentification_key -- string the authentificate the agent.
Example: https://slapos.server/slap_interface
"""
def registerComputer(computer_guid):
"""
Instanciate a computer in the slap library.
computer_guid -- the identifier of the computer inside the slapgrid server.
"""
def registerComputerPartition(computer_guid, partition_id):
"""
Instanciate a computer partition in the slap library.
computer_guid -- the identifier of the computer inside the slapgrid server.
partition_id -- the identifier of the computer partition inside the
slapgrid server.
Raise an INotFoundError if computer_guid doesn't exist.
"""
def registerSoftwareRelease(software_release):
"""
Instanciate a software release in the slap library.
software_release -- uri of the software release definition
"""
def registerOpenOrder():
"""
Instanciate an open order in the slap library.
"""
def registerSupply():
"""
Instanciate a supply in the slap library.
"""
This diff is collapsed.
##############################################################################
#
# 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.
#
##############################################################################
##############################################################################
#
# 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 unittest
from zope.interface.verify import verifyClass
import zope.interface
import types
from slapos import slap
def getOnlyImplementationAssertionMethod(klass, method_list):
"""Returns method which verifies if a klass only implements its interfaces"""
def testMethod(self):
implemented_method_list = [x for x in dir(klass) \
if ((not x.startswith('_')) and callable(getattr(klass, x)))]
for interface_method in method_list:
if interface_method in implemented_method_list:
implemented_method_list.remove(interface_method)
if implemented_method_list:
raise AssertionError("Unexpected methods %s" % implemented_method_list)
return testMethod
def getImplementationAssertionMethod(klass, interface):
"""Returns method which verifies if interface is properly implemented by klass"""
def testMethod(self):
verifyClass(interface, klass)
return testMethod
def getDeclarationAssertionMethod(klass):
"""Returns method which verifies if klass is declaring interface"""
def testMethod(self):
self.assertNotEqual(0, len(list(zope.interface.implementedBy(klass))))
return testMethod
def generateTestMethodListOnClass(klass, module):
"""Generate test method on klass"""
for class_id in dir(module):
implementing_class = getattr(module, class_id)
if type(implementing_class) not in (types.ClassType, types.TypeType):
continue
# add methods to assert that publicly available classes are defining
# interfaces
method_name = 'test_%s_declares_interface' % (class_id,)
setattr(klass, method_name, getDeclarationAssertionMethod(
implementing_class))
implemented_method_list = []
for interface in list(zope.interface.implementedBy(implementing_class)):
# for each interface which class declares add a method which verify
# implementation
method_name = 'test_%s_implements_%s' % (class_id,
interface.__identifier__)
setattr(klass, method_name, getImplementationAssertionMethod(
implementing_class, interface))
for interface_klass in interface.__iro__:
implemented_method_list.extend(interface_klass.names())
# for each interface which class declares, check that no other method are
# available
method_name = 'test_%s_only_implements' % class_id
setattr(klass, method_name, getOnlyImplementationAssertionMethod(
implementing_class,
implemented_method_list))
class TestInterface(unittest.TestCase):
"""Tests all publicly available classes of slap
Classes are checked *if* they implement interface and if the implementation
is correct.
"""
# add methods to test class
generateTestMethodListOnClass(TestInterface, slap)
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
1.0 (unreleased)
----------------
from setuptools import setup, find_packages
import os
name = "slapos.tool.console"
version = '1.1-dev'
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
long_description=(
read('README.txt')
+ '\n' +
read('CHANGES.txt')
)
setup(
name = name,
version = version,
description = "slapconsole - the slap library console",
long_description=long_description,
license = "GPLv3",
keywords = "vifib console slap",
classifiers=[
],
packages = find_packages('src'),
include_package_data = True,
package_dir = {'':'src'},
namespace_packages = ['slapos', 'slapos.tool'],
install_requires = [
'setuptools', # namespaces
'slapos.slap', # slapgrid uses slap to communicate with vifib
],
zip_safe=False,
entry_points = """
[console_scripts]
slapconsole = %(name)s.console:run
""" % dict(name=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.
#
##############################################################################
##############################################################################
#
# 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.
#
##############################################################################
def run():
__import__("code").interact(banner="", local=globals())
1.1 (unreleased)
----------------
include CHANGES.txt
include slapos.xsd
SlapOS Formatter
================
slapformat is an application to prepare SlapOS ready node (machine).
It "formats" the machine by:
- creating users and groups
- creating bridge interface
- creating needed tap interfaces
- creating needed directories with proper ownership and permissions
In the end special report is generated and information are posted to
configured SlapOS server.
This program shall be only run by root.
Requirements
============
Linux with IPv6, bridging and tap interface support.
Binaries:
* brctl
* groupadd
* ip
* tunctl
* useradd
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import os
name = 'slapos.tool.format'
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
long_description=(
read('README.txt')
+ '\n' +
read('CHANGES.txt')
)
setup(
name = name,
version = '1.1-dev-2',
description = "slapos - partitioning tools for servers",
long_description=long_description,
license = "GPLv3",
keywords = "vifib server partitioning",
include_package_data = True,
packages = find_packages('src'),
package_dir = {'':'src'},
namespace_packages = ['slapos'],
# slapgos use this to create a clean ouput
install_requires = [
'netaddr', # to play safely with IPv6 prefixes
'netifaces', # to fetch information about network devices
'setuptools', # namespace
'slapos.slap', # for posting data to vifib master
'xml_marshaller', # to generate data
],
entry_points = """
[console_scripts]
slapformat = %s:main
""" % name,
)
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="marshal">
<xs:complexType>
<xs:sequence>
<xs:element ref="dictionary"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dictionary">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="dictionary"/>
<xs:element ref="list"/>
<xs:element ref="string"/>
</xs:choice>
<xs:attribute name="id" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="list">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="dictionary"/>
</xs:choice>
<xs:attribute name="id" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="string" type="xs:NCName"/>
</xs:schema>
# 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__)
This diff is collapsed.
1.0 (unreleased)
----------------
include CHANGES.txt
recursive-include src/slapos/tool/grid/templates *.in
slapgrid
========
slapgrid is a client of SLAPos. SLAPos provides support for deploying a SaaS
system in a minute.
Slapgrid allows you to easily deploy instances of softwares based on buildout
profiles.
For more informations about SLAP and SLAPos, please see the SLAP documentation.
Requirements
============
A working SLAP server with informations about your computer, in order to
retrieve them.
As Vifib servers use IPv6 only, we strongly recommend an IPv6 enabled UNIX
box.
For the same reasons, Python >= 2.6 with development headers is also strongly
recommended (IPv6 support is not complete in previous releases).
For now, gcc and glibc development headers are required to build most software
releases.
Concepts
========
Here are the fundamental concepts of slapgrid :
A Software Release (SR) is just a software.
A Computer Partition (CP) is an instance of a Software Release.
Imagine you want to install with slapgrid some software and run it. You will
have to install the software as a Software Release, and then instantiate it,
i.e configuring it for your needs, as a Computer Partition.
How it works
============
When run, slapgrid will authenticate to the SLAP library with a computer_id and
fetch the list of Software Releases to install or remove and Computer
Partitions to start or stop.
Then, it will process each Software Release, and each Computer Partition.
It will also periodically send to SLAP the usage report of each Computer
Partition.
Installation
============
With easy_install :
$ easy_install slapgrid
With buildout (for developers):
Checkout svn.erp5.org/repos/vifib/software_release/slapgrid.development,
then read the README.txt.
slapgrid needs several directories to be created and configured before being
able to run : a software releases directory, and an instances directory with
configured computer partition directory(ies).
You should create for each Computer Partition directory created a specific user
and associate it with its Computer Partition directory. Each Computer Partition
directory should belongs to this specific user, with permissions of 0750.
Usage
=====
slapgrid needs several informations in order to run. You can specify them by
adding arguments to the slapgrid command line, or by putting then in a
configuration file.
Beware : you need a valid computer resource on server side.
Examples
========
simple example :
Just run slapgrid :
$ slapgrid --instance-root /path/to/instance/root --software-root
/path/to/software_root --master-url https://some.server/some.resource
--computer-id my.computer.id
configuration file example :
[slapgrid]
instance_root = /path/to/instance/root
software_root = /path/to/software/root
master_url = https://slapos.server/slap_service
computer_id = my.computer.id
then run slapgrid :
$ slapgrid --configuration-file = path/to/configuration/file
from setuptools import setup, find_packages
import os
name = "slapos.tool.grid"
version = '1.1-dev-2'
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
long_description=(
read('README.txt')
+ '\n' +
read('CHANGES.txt')
)
additional_install_requires = []
# Even if argparse is available in python2.7, some python2.7 installations
# do not have it, so checking python version is dangerous
try:
import argparse
except ImportError:
additional_install_requires.append('argparse')
setup(
name = name,
version = version,
description = "slapgrid - the vifib client with proposals server cannot"\
" refuse",
long_description=long_description,
license = "GPLv3",
keywords = "vifib server installation",
classifiers=[
],
packages = find_packages('src'),
include_package_data = True,
package_dir = {'':'src'},
namespace_packages = [ 'slapos' ],
install_requires = [
'setuptools', # namespaces
'zc.buildout>=1.5.0', # slapgrid uses buildout as its backend to do the job
'slapos.slap', # slapgrid uses slap to communicate with vifib
'supervisor', # slapgrid uses supervisor to manage processes
] + additional_install_requires,
zip_safe=False,
entry_points = """
[console_scripts]
slapgrid = %(name)s.slapgrid:run
slapgrid-sr = %(name)s.slapgrid:runSoftwareRelease
slapgrid-cp = %(name)s.slapgrid:runComputerPartition
slapgrid-ur = %(name)s.slapgrid:runUsageReport
slapgrid-supervisorctl = %(name)s.svcbackend:supervisorctl
slapgrid-supervisord = %(name)s.svcbackend:supervisord
""" % dict(name=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__)
This diff is collapsed.
##############################################################################
#
# 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.
#
##############################################################################
##############################################################################
#
# 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.
#
##############################################################################
"""Exposed exceptions"""
class PathDoesNotExistError(Exception):
pass
class WrongPermissionError(Exception):
pass
class BuildoutFailedError(Exception):
pass
This diff is collapsed.
##############################################################################
#
# 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.
#
##############################################################################
from supervisor import xmlrpc
from utils import SlapPopen
import logging
import os
import sys
import xmlrpclib
from optparse import OptionParser
import ConfigParser
def getSupervisorRPC(socket):
supervisor_transport = xmlrpc.SupervisorTransport('', '',
'unix://' + socket)
server_proxy = xmlrpclib.ServerProxy('http://127.0.0.1',
supervisor_transport)
return getattr(server_proxy, 'supervisor')
def launchSupervisord(socket, configuration_file):
logger = logging.getLogger('SVCBackend')
supervisor = getSupervisorRPC(socket)
if os.path.exists(socket):
try:
status = supervisor.getState()
except Exception:
# In case if there is problem with connection, assume that supervisord
# is not running and try to run it
pass
else:
if status['statename'] == 'RUNNING' and status['statecode'] == 1:
logger.info('Supervisord already running.')
return
else:
log_message = 'Unknown supervisord state %r. Will try to start.' % status
logger.warning(log_message)
logger.info("Launching supervisord with clean environment.")
# Extract python binary to prevent shebang size limit
invocation_list = ["supervisord", '-c']
invocation_list.append("import sys ; sys.path=" + str(sys.path) + " ; import "
"supervisor.supervisord ; sys.argv[1:1]=['-c','" +
configuration_file +
"'] ; supervisor.supervisord.main()")
supervisord_popen = SlapPopen(invocation_list,
env={},
executable=sys.executable)
result = supervisord_popen.communicate()[0]
if supervisord_popen.returncode == 0:
log_message = 'Supervisord command invoked with: %s' % result
logger.info(log_message)
status = supervisor.getState()
if status['statename'] == 'RUNNING' and status['statecode'] == 1:
logger.info('Supervisord started correctly.')
else:
log_message = 'Supervisord unknown problem: %s' % result
logger.info(log_message)
def getOptionDict(*argument_tuple):
usage = """
Typical usage:
* %prog CONFIGURATION_FILE [arguments passed to supervisor]
""".strip()
parser = OptionParser(usage=usage)
# Parses arguments
if argument_tuple == ():
# No arguments given to entry point : we parse sys.argv.
(argument_option_instance, argument_list) = parser.parse_args()
else:
(argument_option_instance, argument_list) = \
parser.parse_args(list(argument_tuple))
if len(argument_list) == 0:
parser.error("Configuration file is obligatory. Consult documentation by "
"calling with -h.")
configuration_file = argument_list[0]
if not os.path.exists(configuration_file):
parser.error("Could not read configuration file : %s" \
% configuration_file)
slapgrid_configuration = ConfigParser.SafeConfigParser()
slapgrid_configuration.read(configuration_file)
# Merges the two dictionnaries
option_dict = dict(slapgrid_configuration.items("slapos"))
# Supervisord configuration location
if not option_dict.get('supervisord_configuration_path'):
option_dict['supervisord_configuration_path'] = \
os.path.join(option_dict['instance_root'], 'etc', 'supervisord.conf')
# Supervisord socket
if not option_dict.get('supervisord_socket'):
option_dict['supervisord_socket'] = \
os.path.join(option_dict['instance_root'], 'supervisord.socket')
return option_dict, argument_list[1:]
def supervisorctl(*argument_tuple):
option_dict, args = getOptionDict(*argument_tuple)
import supervisor.supervisorctl
supervisor.supervisorctl.main(args=['-c',
option_dict['supervisord_configuration_path']] + args)
def supervisord(*argument_tuple):
option_dict, dummy = getOptionDict(*argument_tuple)
dummy = dummy
launchSupervisord(option_dict['supervisord_socket'],
option_dict['supervisord_configuration_path'])
# This is beginning of zc.builodout profile's tail added by slapgrid
[buildout]
# put buildout generated binaries in specific directory
bin-directory = ${buildout:directory}/sbin
# protect software and run parts offline
offline = true
[slap_connection]
computer_id = %(computer_id)s
partition_id = %(partition_id)s
server_url = %(server_url)s
software_release_url = %(software_release_url)s
key_file = %(key_file)s
cert_file = %(cert_file)s
# This is end of zc.builodout profile's tail added by slapgrid
[program:%(program_id)s]
directory=%(program_directory)s
command=%(program_command)s
process_name=%(program_name)s
autostart=false
autorestart=false
startsecs=0
startretries=0
exitcodes=0
stopsignal=TERM
stopwaitsecs=60
user=%(user_id)s
group=%(group_id)s
serverurl=AUTO
redirect_stderr=true
stdout_logfile=%(instance_path)s/.%(program_id)s.log
stdout_logfile_maxbytes=100KB
stdout_logfile_backups=1
stderr_logfile=%(instance_path)s/.%(program_id)s.log
stderr_logfile_maxbytes=100KB
stderr_logfile_backups=1
environment=USER="%(USER)s",LOGNAME="%(USER)s",HOME="%(HOME)s"
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[include]
files = %(supervisord_configuration_directory)s/*.conf
[supervisorctl]
serverurl = unix://%(supervisord_socket)s
[supervisord]
loglevel = %(supervisord_loglevel)s
logfile = %(supervisord_logfile)s
logfile_maxbytes = %(supervisord_logfile_maxbytes)s
nodaemon = %(supervisord_nodaemon)s
pidfile = %(supervisord_pidfile)s
logfile-backups = %(supervisord_logfile_backups)s
[unix_http_server]
file=%(supervisord_socket)s
chmod=0700
This diff is collapsed.
Introduction
==============
The goal of libnetworkcache python library is to abstract the REST calls.
It works as wrapper of python httplib to use the Networkcache HTTP Server.
API
======
So, it must provide 2 methods:
put(file)
''' Upload the file to Networkcache HTTP Server using PUT as HTTP method.'''
get(key)
''' Download the file from Networkcache HTTP Server using GET as HTTP method.'''
[egg_info]
tag_build = .dev
tag_svn_revision = 1
from setuptools import setup, find_packages
import os
name = "slapos.tool.libnetworkcache"
version = 'O.1'
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
long_description = (
read('README.txt')
+ '\n' +
read('CHANGES.txt')
)
setup(
name=name,
version=version,
description="libnetworkcache - Client for Networkcache HTTP Server",
long_description=long_description,
license="GPLv3",
keywords="vifib slapos networkcache",
classifiers=[
],
packages=find_packages('src'),
include_package_data=True,
package_dir={'': 'src'},
namespace_packages=['slapos', 'slapos.tool'],
install_requires=[
],
zip_safe=False,
entry_points=""" """,
)
# 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__)
1.0 (unreleased)
----------------
This diff is collapsed.
# 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__)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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