Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.core
Commits
b3b2ac28
Commit
b3b2ac28
authored
May 26, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import slapos.core code.
parent
44a31a37
Changes
83
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
83 changed files
with
7197 additions
and
0 deletions
+7197
-0
README.md
java/slap/README.md
+95
-0
ClientWrapper.java
java/slap/src/org/slapos/slap/ClientWrapper.java
+112
-0
Computer.java
java/slap/src/org/slapos/slap/Computer.java
+108
-0
ComputerPartition.java
java/slap/src/org/slapos/slap/ComputerPartition.java
+391
-0
OpenOrder.java
java/slap/src/org/slapos/slap/OpenOrder.java
+60
-0
Slap.java
java/slap/src/org/slapos/slap/Slap.java
+142
-0
SoftwareRelease.java
java/slap/src/org/slapos/slap/SoftwareRelease.java
+66
-0
Supply.java
java/slap/src/org/slapos/slap/Supply.java
+59
-0
NotFoundException.java
...slap/src/org/slapos/slap/exception/NotFoundException.java
+39
-0
UnauthorizedException.java
.../src/org/slapos/slap/exception/UnauthorizedException.java
+35
-0
IBuildoutController.java
...p/src/org/slapos/slap/interfaces/IBuildoutController.java
+56
-0
IComputer.java
java/slap/src/org/slapos/slap/interfaces/IComputer.java
+67
-0
IComputerPartition.java
...ap/src/org/slapos/slap/interfaces/IComputerPartition.java
+133
-0
IOpenOrder.java
java/slap/src/org/slapos/slap/interfaces/IOpenOrder.java
+52
-0
ISlap.java
java/slap/src/org/slapos/slap/interfaces/ISlap.java
+107
-0
ISoftwareRelease.java
...slap/src/org/slapos/slap/interfaces/ISoftwareRelease.java
+39
-0
ISupply.java
java/slap/src/org/slapos/slap/interfaces/ISupply.java
+56
-0
software_instance.xsd
java/slap/src/org/slapos/slap/software_instance.xsd
+23
-0
test.java
java/slap/src/test.java
+54
-0
CHANGES.txt
slapos/slapos.slap/CHANGES.txt
+10
-0
MANIFEST.in
slapos/slapos.slap/MANIFEST.in
+2
-0
README.txt
slapos/slapos.slap/README.txt
+30
-0
setup.cfg
slapos/slapos.slap/setup.cfg
+3
-0
setup.py
slapos/slapos.slap/setup.py
+37
-0
__init__.py
slapos/slapos.slap/src/slapos/__init__.py
+6
-0
slap_recipe_mysqldatabase.py
...apos.slap/src/slapos/example/slap_recipe_mysqldatabase.py
+79
-0
__init__.py
slapos/slapos.slap/src/slapos/slap/__init__.py
+32
-0
software_instance.xsd
slapos/slapos.slap/src/slapos/slap/doc/software_instance.xsd
+23
-0
__init__.py
slapos/slapos.slap/src/slapos/slap/interface/__init__.py
+26
-0
slap.py
slapos/slapos.slap/src/slapos/slap/interface/slap.py
+314
-0
slap.py
slapos/slapos.slap/src/slapos/slap/slap.py
+550
-0
__init__.py
slapos/slapos.slap/src/slapos/slap/tests/__init__.py
+26
-0
testinterface.py
slapos/slapos.slap/src/slapos/slap/tests/testinterface.py
+101
-0
testslap.py
slapos/slapos.slap/src/slapos/slap/tests/testslap.py
+354
-0
CHANGES.txt
slapos/slapos.tool.console/CHANGES.txt
+2
-0
MANIFEST.in
slapos/slapos.tool.console/MANIFEST.in
+1
-0
README.txt
slapos/slapos.tool.console/README.txt
+3
-0
setup.py
slapos/slapos.tool.console/setup.py
+38
-0
__init__.py
slapos/slapos.tool.console/src/slapos/__init__.py
+7
-0
__init__.py
slapos/slapos.tool.console/src/slapos/tool/__init__.py
+7
-0
__init__.py
...s/slapos.tool.console/src/slapos/tool/console/__init__.py
+26
-0
console.py
...os/slapos.tool.console/src/slapos/tool/console/console.py
+29
-0
CHANGES.txt
slapos/slapos.tool.format/CHANGES.txt
+2
-0
MANIFEST.in
slapos/slapos.tool.format/MANIFEST.in
+2
-0
README.txt
slapos/slapos.tool.format/README.txt
+29
-0
setup.py
slapos/slapos.tool.format/setup.py
+39
-0
slapos.xsd
slapos/slapos.tool.format/slapos.xsd
+29
-0
__init__.py
slapos/slapos.tool.format/src/slapos/__init__.py
+7
-0
__init__.py
slapos/slapos.tool.format/src/slapos/tool/__init__.py
+7
-0
__init__.py
slapos/slapos.tool.format/src/slapos/tool/format/__init__.py
+957
-0
CHANGES.txt
slapos/slapos.tool.grid/CHANGES.txt
+2
-0
MANIFEST.in
slapos/slapos.tool.grid/MANIFEST.in
+2
-0
README.txt
slapos/slapos.tool.grid/README.txt
+95
-0
setup.py
slapos/slapos.tool.grid/setup.py
+55
-0
__init__.py
slapos/slapos.tool.grid/src/slapos/__init__.py
+7
-0
__init__.py
slapos/slapos.tool.grid/src/slapos/tool/__init__.py
+7
-0
SlapObject.py
slapos/slapos.tool.grid/src/slapos/tool/grid/SlapObject.py
+406
-0
__init__.py
slapos/slapos.tool.grid/src/slapos/tool/grid/__init__.py
+26
-0
exception.py
slapos/slapos.tool.grid/src/slapos/tool/grid/exception.py
+39
-0
slapgrid.py
slapos/slapos.tool.grid/src/slapos/tool/grid/slapgrid.py
+658
-0
svcbackend.py
slapos/slapos.tool.grid/src/slapos/tool/grid/svcbackend.py
+133
-0
buildout-tail.cfg.in
....grid/src/slapos/tool/grid/templates/buildout-tail.cfg.in
+16
-0
group_partition_supervisord.conf.in
...s/tool/grid/templates/group_partition_supervisord.conf.in
+2
-0
program_partition_supervisord.conf.in
...tool/grid/templates/program_partition_supervisord.conf.in
+22
-0
supervisord.conf.in
...l.grid/src/slapos/tool/grid/templates/supervisord.conf.in
+20
-0
utils.py
slapos/slapos.tool.grid/src/slapos/tool/grid/utils.py
+344
-0
zc.buildout-bootstap.py
...os.tool.grid/src/slapos/tool/grid/zc.buildout-bootstap.py
+260
-0
CHANGES.txt
slapos/slapos.tool.libnetworkcache/CHANGES.txt
+0
-0
README.txt
slapos/slapos.tool.libnetworkcache/README.txt
+14
-0
setup.cfg
slapos/slapos.tool.libnetworkcache/setup.cfg
+3
-0
setup.py
slapos/slapos.tool.libnetworkcache/setup.py
+35
-0
__init__.py
slapos/slapos.tool.libnetworkcache/src/slapos/__init__.py
+7
-0
__init__.py
...s/slapos.tool.libnetworkcache/src/slapos/tool/__init__.py
+7
-0
__init__.py
...bnetworkcache/src/slapos/tool/libnetworkcache/__init__.py
+68
-0
CHANGES.txt
slapos/slapos.tool.proxy/CHANGES.txt
+2
-0
MANIFEST.in
slapos/slapos.tool.proxy/MANIFEST.in
+1
-0
README.txt
slapos/slapos.tool.proxy/README.txt
+3
-0
setup.py
slapos/slapos.tool.proxy/setup.py
+41
-0
__init__.py
slapos/slapos.tool.proxy/src/slapos/__init__.py
+7
-0
__init__.py
slapos/slapos.tool.proxy/src/slapos/tool/__init__.py
+7
-0
__init__.py
slapos/slapos.tool.proxy/src/slapos/tool/proxy/__init__.py
+110
-0
schema.sql
slapos/slapos.tool.proxy/src/slapos/tool/proxy/schema.sql
+24
-0
views.py
slapos/slapos.tool.proxy/src/slapos/tool/proxy/views.py
+302
-0
No files found.
java/slap/README.md
0 → 100644
View file @
b3b2ac28
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
java/slap/src/org/slapos/slap/ClientWrapper.java
0 → 100644
View file @
b3b2ac28
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
java/slap/src/org/slapos/slap/Computer.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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
java/slap/src/org/slapos/slap/ComputerPartition.java
0 → 100644
View file @
b3b2ac28
This diff is collapsed.
Click to expand it.
java/slap/src/org/slapos/slap/OpenOrder.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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
java/slap/src/org/slapos/slap/Slap.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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
;
}
}
java/slap/src/org/slapos/slap/SoftwareRelease.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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
java/slap/src/org/slapos/slap/Supply.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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
java/slap/src/org/slapos/slap/exception/NotFoundException.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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
java/slap/src/org/slapos/slap/exception/UnauthorizedException.java
0 → 100644
View file @
b3b2ac28
/******************************************************************************
*
* 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