Commit b7dbd184 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

web: slapgrid update instance getCertificate

parent 74feb1de
......@@ -424,6 +424,7 @@ class Partition(object):
instance_storage_home='',
ipv4_global_network='',
buildout_debug=False,
api_backward_compatibility=False,
):
"""Initialisation of class parameters"""
self.buildout = buildout
......@@ -444,6 +445,7 @@ class Partition(object):
self.software_release_url = software_release_url
self.instance_storage_home = instance_storage_home
self.ipv4_global_network = ipv4_global_network
self.api_backward_compatibility = api_backward_compatibility
self.key_file = ''
self.cert_file = ''
......@@ -488,16 +490,20 @@ class Partition(object):
# Certificate files are unset, skip.
return
try:
partition_certificate = self.computer_partition.getCertificate()
except NotFoundError:
raise NotFoundError('Partition %s is not known by SlapOS Master.' %
self.partition_id)
if self.api_backward_compatibility:
try:
partition_certificate = self.computer_partition["slap_partition"].getCertificate()
self.computer_partition["X509"] = {}
self.computer_partition["X509"]["certificate"] = partition_certificate["certificate"]
self.computer_partition["X509"]["key"] = partition_certificate["key"]
except NotFoundError:
raise NotFoundError('Partition %s is not known by SlapOS Master.' %
self.partition_id)
uid, gid = self.getUserGroupId()
for name, path in [('certificate', self.cert_file), ('key', self.key_file)]:
new_content = partition_certificate[name]
new_content = self.computer_partition["X509"][name]
old_content = None
if os.path.exists(path):
old_content = open(path).read()
......
......@@ -1142,6 +1142,7 @@ stderr_logfile_backups=1
instance_min_free_space=self.instance_min_free_space,
instance_storage_home=self.instance_storage_home,
ipv4_global_network=self.ipv4_global_network,
api_backward_compatibility=self.api_backward_compatibility,
)
self.logger.info('Processing Promises for Computer Partition %s.', computer_partition_id)
......
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