Commit b84b7359 authored by Cédric de Saint Martin's avatar Cédric de Saint Martin

Merge branch 'slapgrid_only'

parents 7684152a d2d044d4
......@@ -156,11 +156,11 @@ slapos-request allows you to request slapos instances.""" % sys.argv[0]
config = Config()
options, arguments = RequestParser(usage=usage).check_args()
config.setConfig(options, arguments[0])
local = init(config)
# Request instance
# XXX-Cedric : support things like :
# XXX-Cedric : support things like :
# --instance-type std --configuration-size 23 --computer-region europe/france
# XXX-Cedric : add support for xml_parameter
software_url = arguments[1]
......@@ -196,6 +196,6 @@ examples :
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")""" % sys.argv[0]
config = Config()
config.setConfig(*Parser(usage=usage).check_args())
local = init(config)
__import__("code").interact(banner="", local=local)
......@@ -211,7 +211,7 @@ class Computer(object):
return self.interface.addAddr()
# Can't find address
raise NoAddressOnInterface('No valid IPv6 found on %s.' %
raise NoAddressOnInterface('No valid IPv6 found on %s.' %
self.interface.name)
def send(self, config):
......@@ -237,7 +237,7 @@ class Computer(object):
raise slap.NotFoundError("%s\nERROR : This SlapOS node is not recognised by "
"SlapOS Master. Please make sure computer_id of slapos.cfg looks "
"like 'COMP-123' and is correct.\nError is : 404 Not Found." % error)
return
return
def dump(self, path_to_xml):
"""
......@@ -311,7 +311,7 @@ class Computer(object):
if alter_network and self.address is not None:
self.interface.addAddr(self.address, self.netmask)
for path in self.instance_root, self.software_root:
for path in self.instance_root, self.software_root:
if not os.path.exists(path):
os.makedirs(path, 0755)
else:
......@@ -677,7 +677,7 @@ class Interface(object):
def _addSystemAddress(self, address, netmask, ipv6=True):
"""Adds system address to interface
Returns True if address was added successfully.
Returns False if there was issue.
......@@ -870,7 +870,7 @@ class Parser(OptionParser):
help="Shall slapformat alter user database [default: True]"),
Option('--alter_network', choices=['True', 'False'],
help="Shall slapformat alter network configuration [default: True]"),
Option('--now',
Option('--now',
help="Launch slapformat without delay",
default=False,
action="store_true"),
......@@ -1138,7 +1138,7 @@ class Config(object):
root_needed = True
else:
root_needed = False
# check root
if root_needed and os.getuid() != 0:
message = "Root rights are needed"
......
......@@ -123,7 +123,7 @@ class Software(object):
self.shadir_cert_file,
self.shadir_key_file)
shutil.rmtree(cache_dir)
def _install_from_buildout(self):
""" Fetches buildout configuration from the server, run buildout with
it. If it fails, we notify the server.
......
......@@ -24,4 +24,4 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
\ No newline at end of file
##############################################################################
......@@ -123,6 +123,20 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
help="Launch slapgrid without delay.")
parser.add_argument("--develop", action="store_true", default=False,
help="Launch slapgrid in develop mode. In develop mode, slapgrid-sr ignores .completed file")
parser.add_argument("--only_sr",
help="Force the update of a single software release (use url hash)," + \
"event if is already installed. This option will make all others " + \
"sofware releases be ignored")
parser.add_argument("--only_cp",
help="Update a single or a list of computer partition (ie.:slappartX, slappartY)," + \
"this option will make all others sofware releases be ignored")
parser.add_argument("--only_sr",
help="Force the update of a single software release (use url hash)," + \
"event if is already installed. This option will make all others " + \
"sofware releases be ignored")
parser.add_argument("--only_cp",
help="Update a single or a list of computer partitions (ie.:slappartX, slappartY)," + \
"this option will make all others computer partitions be ignored")
# Parses arguments
if argument_tuple == ():
......@@ -354,7 +368,9 @@ class Slapgrid(object):
shacache_key_file=None,
shadir_cert_file=None,
shadir_key_file=None,
develop=False):
develop=False,
software_release_filter_list=None,
computer_partition_filter_list=None):
"""Makes easy initialisation of class parameters"""
# Parses arguments
self.software_root = os.path.abspath(software_root)
......@@ -707,7 +723,7 @@ class Slapgrid(object):
"<source></source>" \
"<destination></destination>" \
"</arrow>" \
% (strftime("%Y-%m-%d at %H:%M:%S"),
% (strftime("%Y-%m-%d at %H:%M:%S"),
self.computer_id)
for computer_partition_usage in computer_partition_usage_list:
......@@ -733,7 +749,7 @@ class Slapgrid(object):
xml_movements += "<%s>%s</%s>" % (children.tag, computer_partition_usage.getId(), children.tag)
else:
xml_movements += "<%s>%s</%s>" % (children.tag, children.text, children.tag)
xml_movements += "</movement>"
xml_movements += "</movement>"
xml_foot = "</transaction>" \
"</journal>"
......@@ -758,7 +774,7 @@ class Slapgrid(object):
except IOError:
computer_consumption_model = \
pkg_resources.resource_string(
__name__,
__name__,
'../../../../slapos/slap/doc/computer_consumption.xsd')
try:
......@@ -769,7 +785,7 @@ class Slapgrid(object):
except IOError:
partition_consumption_model = \
pkg_resources.resource_string(
__name__,
__name__,
'../../../../slapos/slap/doc/partition_consumption.xsd')
clean_run = True
......
......@@ -52,7 +52,7 @@ class IRequester(Interface):
slapgrid server.
"""
def request(software_release, software_type, partition_reference,
def request(software_release, software_type, partition_reference,
shared=False, partition_parameter_kw=None, filter_kw=None):
"""
Request software release instanciation to slapgrid server.
......@@ -92,13 +92,13 @@ class IBuildoutController(Interface):
def available():
"""
Notify (to the slapgrid server) that the software instance is
Notify (to the slapgrid server) that the software instance is
available.
"""
def building():
"""
Notify (to the slapgrid server) that the buildout is not
Notify (to the slapgrid server) that the buildout is not
available and under creation.
"""
......@@ -146,13 +146,13 @@ class IComputerPartition(IBuildoutController, IRequester):
def stopped():
"""
Notify (to the slapgrid server) that the software instance is
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
Notify (to the slapgrid server) that the software instance is
available and started.
"""
......@@ -217,7 +217,7 @@ class IComputerPartition(IBuildoutController, IRequester):
def getCertificate():
"""
Returns a dictionnary containing the authentification certificates
Returns a dictionnary containing the authentification certificates
associated to the computer partition.
The dictionnary keys are:
key -- value is a SSL key
......@@ -273,7 +273,7 @@ class IComputer(Interface):
installed.
"""
def getSoftwareReleaseList():
def getSoftwareReleaseList():
"""
Returns the list of software release which has to be supplied by the
computer.
......@@ -281,7 +281,7 @@ class IComputer(Interface):
Raise an INotFoundError if computer_guid doesn't exist.
"""
def getComputerPartitionList():
def getComputerPartitionList():
"""
Returns the list of configured computer partitions associated to this
computer.
......@@ -291,7 +291,7 @@ class IComputer(Interface):
def reportUsage(computer_partition_list):
"""
Report the computer usage to the slapgrid server.
Report the computer usage to the slapgrid server.
IComputerPartition.setUsage has to be called on each computer partition to
define each usage.
......@@ -338,7 +338,7 @@ class ISupply(Interface):
software_release -- uri of the software release
which has to be instanciated
computer_guid -- the identifier of the computer inside the slapgrid
computer_guid -- the identifier of the computer inside the slapgrid
server.
"""
......@@ -346,7 +346,7 @@ class slap(Interface):
"""
Initialise slap connection to the slapgrid server
Slapgrid server URL is defined during the slap library installation,
Slapgrid server URL is defined during the slap library installation,
as recipes should not use another server.
"""
......@@ -374,7 +374,7 @@ class slap(Interface):
computer_guid -- the identifier of the computer inside the slapgrid server.
partition_id -- the identifier of the computer partition inside the
partition_id -- the identifier of the computer partition inside the
slapgrid server.
Raise an INotFoundError if computer_guid doesn't exist.
......@@ -391,8 +391,8 @@ class slap(Interface):
"""
Instanciate an open order in the slap library.
"""
def registerSupply():
"""
"""
Instanciate a supply in the slap library.
"""
......@@ -107,17 +107,17 @@ class SoftwareRelease(SlapDocument):
def available(self):
self._connection_helper.POST('/availableSoftwareRelease', {
'url': self._software_release,
'url': self._software_release,
'computer_id': self._computer_guid})
def building(self):
self._connection_helper.POST('/buildingSoftwareRelease', {
'url': self._software_release,
'url': self._software_release,
'computer_id': self._computer_guid})
def destroyed(self):
self._connection_helper.POST('/destroyedSoftwareRelease', {
'url': self._software_release,
'url': self._software_release,
'computer_id': self._computer_guid})
def getState(self):
......@@ -230,7 +230,7 @@ def _syncComputerInformation(func):
for computer_partition in self.getComputerPartitionList():
setattr(computer_partition, '_synced', True)
return func(self, *args, **kw)
return decorated
return decorated
class Computer(SlapDocument):
......@@ -532,7 +532,7 @@ class ComputerPartition(SlapDocument):
# result = func(self, *args, **kw)
# setattr(self, key, result)
# return result
# return decorated
# return decorated
class ConnectionHelper:
error_message_timeout = "\nThe connection timed out. Please try again later."
......
......@@ -82,7 +82,7 @@ class TestSlap(SlapMixin):
def test_slap_initialisation(self):
"""
Asserts that slap initialisation works properly in case of
Asserts that slap initialisation works properly in case of
passing correct url
"""
slap_instance = slapos.slap.slap()
......@@ -92,17 +92,17 @@ class TestSlap(SlapMixin):
def test_slap_initialisation_wrong_url(self):
"""
Asserts that slap initialisation raises exception when passed url
Asserts that slap initialisation raises exception when passed url
is not correct
"""
server_url = 'https://user:pass@server/path/path?parameter=notAcceptable'
slap_instance = slapos.slap.slap()
self.assertRaises(AttributeError,
self.assertRaises(AttributeError,
slap_instance.initializeConnection, server_url)
def test_registerComputer_with_new_guid(self):
"""
Asserts that calling slap.registerComputer with new guid returns
Asserts that calling slap.registerComputer with new guid returns
Computer object
"""
computer_guid = self._getTestComputerId()
......@@ -113,7 +113,7 @@ class TestSlap(SlapMixin):
def test_registerComputer_with_existing_guid(self):
"""
Asserts that calling slap.registerComputer with already used guid
Asserts that calling slap.registerComputer with already used guid
returns Computer object
"""
computer_guid = self._getTestComputerId()
......@@ -129,7 +129,7 @@ class TestSlap(SlapMixin):
# SoftwareRelease is currently used as suboject of Slap transmission object
def test_registerSoftwareRelease_with_new_uri(self):
"""
Asserts that calling slap.registerSoftwareRelease with new guid
Asserts that calling slap.registerSoftwareRelease with new guid
returns SoftwareRelease object
"""
software_release_uri = 'http://server/' + self._getTestComputerId()
......@@ -141,7 +141,7 @@ class TestSlap(SlapMixin):
def test_registerSoftwareRelease_with_existing_uri(self):
"""
Asserts that calling slap.registerSoftwareRelease with already
Asserts that calling slap.registerSoftwareRelease with already
used guid returns SoftwareRelease object
"""
software_release_uri = 'http://server/' + self._getTestComputerId()
......@@ -157,7 +157,7 @@ class TestSlap(SlapMixin):
def test_registerComputerPartition_new_partition_id_known_computer_guid(self):
"""
Asserts that calling slap.registerComputerPartition on known computer
Asserts that calling slap.registerComputerPartition on known computer
returns ComputerPartition object
"""
self.computer_guid = self._getTestComputerId()
......@@ -166,13 +166,13 @@ class TestSlap(SlapMixin):
self.partition_id = 'PARTITION_01'
self.slap.registerComputer(self.computer_guid)
partition = self.slap.registerComputerPartition(self.computer_guid,
partition = self.slap.registerComputerPartition(self.computer_guid,
self.partition_id)
self.assertTrue(isinstance(partition, slapos.slap.ComputerPartition))
def test_registerComputerPartition_existing_partition_id_known_computer_guid(self):
"""
Asserts that calling slap.registerComputerPartition on known computer
Asserts that calling slap.registerComputerPartition on known computer
returns ComputerPartition object
"""
self.test_registerComputerPartition_new_partition_id_known_computer_guid()
......@@ -182,7 +182,7 @@ class TestSlap(SlapMixin):
def test_registerComputerPartition_unknown_computer_guid(self):
"""
Asserts that calling slap.registerComputerPartition on unknown
Asserts that calling slap.registerComputerPartition on unknown
computer raises (not defined yet) exception
"""
computer_guid = self._getTestComputerId()
......@@ -212,7 +212,7 @@ class TestComputer(SlapMixin):
def test_computer_getComputerPartitionList_only_partition(self):
"""
Asserts that calling Computer.getComputerPartitionList with only
Asserts that calling Computer.getComputerPartitionList with only
Computer Partitions returns empty list
"""
self.computer_guid = self._getTestComputerId()
......@@ -226,7 +226,7 @@ class TestComputer(SlapMixin):
def test_computer_reportUsage_non_valid_xml_raises(self):
"""
Asserts that calling Computer.reportUsage with non DTD
Asserts that calling Computer.reportUsage with non DTD
(not defined yet) XML raises (not defined yet) exception
"""
self.computer_guid = self._getTestComputerId()
......@@ -241,7 +241,7 @@ class TestComputer(SlapMixin):
def test_computer_reportUsage_valid_xml_invalid_partition_raises(self):
"""
Asserts that calling Computer.reportUsage with DTD (not defined
Asserts that calling Computer.reportUsage with DTD (not defined
yet) XML which refers to invalid partition raises (not defined yet)
exception
"""
......@@ -430,7 +430,7 @@ class TestComputerPartition(SlapMixin):
def _test_new_computer_partition_state(self, state):
"""
Helper method to automate assertions of failing states on new Computer
Helper method to automate assertions of failing states on new Computer
Partition
"""
self.computer_guid = self._getTestComputerId()
......@@ -444,28 +444,28 @@ class TestComputerPartition(SlapMixin):
def test_available_new_ComputerPartition_raises(self):
"""
Asserts that calling ComputerPartition.available on new partition
Asserts that calling ComputerPartition.available on new partition
raises (not defined yet) exception
"""
self._test_new_computer_partition_state('available')
def test_building_new_ComputerPartition_raises(self):
"""
Asserts that calling ComputerPartition.building on new partition raises
Asserts that calling ComputerPartition.building on new partition raises
(not defined yet) exception
"""
self._test_new_computer_partition_state('building')
def test_started_new_ComputerPartition_raises(self):
"""
Asserts that calling ComputerPartition.started on new partition raises
Asserts that calling ComputerPartition.started on new partition raises
(not defined yet) exception
"""
self._test_new_computer_partition_state('started')
def test_stopped_new_ComputerPartition_raises(self):
"""
Asserts that calling ComputerPartition.stopped on new partition raises
Asserts that calling ComputerPartition.stopped on new partition raises
(not defined yet) exception
"""
self._test_new_computer_partition_state('stopped')
......@@ -490,7 +490,7 @@ class TestSoftwareRelease(SlapMixin):
def _test_new_software_release_state(self, state):
"""
Helper method to automate assertions of failing states on new Software
Helper method to automate assertions of failing states on new Software
Release
"""
self.software_release_uri = 'http://server/' + self._getTestComputerId()
......@@ -503,14 +503,14 @@ class TestSoftwareRelease(SlapMixin):
def test_available_new_SoftwareRelease_raises(self):
"""
Asserts that calling SoftwareRelease.available on new software release
Asserts that calling SoftwareRelease.available on new software release
raises (not defined yet) exception
"""
self._test_new_software_release_state('available')
def test_building_new_SoftwareRelease_raises(self):
"""
Asserts that calling SoftwareRelease.building on new software release
Asserts that calling SoftwareRelease.building on new software release
raises (not defined yet) exception
"""
self._test_new_software_release_state('building')
......
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