Commit 60b7e90d authored by Łukasz Nowak's avatar Łukasz Nowak

Avoid setting persistent object on portal type.

parent e8a079f5
...@@ -137,11 +137,12 @@ def extractInstance(fn): ...@@ -137,11 +137,12 @@ def extractInstance(fn):
return self.REQUEST.response return self.REQUEST.response
instance_path = self.REQUEST['traverse_subpath'][:2] instance_path = self.REQUEST['traverse_subpath'][:2]
try: try:
self.software_instance = self.restrictedTraverse(instance_path) software_instance = self.getPortalObject().restrictedTraverse(instance_path)
if getattr(self.software_instance, 'getPortalType', None) is None or \ if getattr(software_instance, 'getPortalType', None) is None or \
self.software_instance.getPortalType() not in ('Software Instance', software_instance.getPortalType() not in ('Software Instance',
'Slave Instance'): 'Slave Instance'):
raise WrongRequest('%r is not an instance' % instance_path) raise WrongRequest('%r is not an instance' % instance_path)
self.software_instance_url = software_instance.getRelativeUrl()
except WrongRequest: except WrongRequest:
LOG('VifibRestApiV1Tool', ERROR, LOG('VifibRestApiV1Tool', ERROR,
'Problem while trying to find instance:', error=True) 'Problem while trying to find instance:', error=True)
...@@ -184,7 +185,8 @@ class InstancePublisher(GenericPublisher): ...@@ -184,7 +185,8 @@ class InstancePublisher(GenericPublisher):
@extractInstance @extractInstance
def __bang(self): def __bang(self):
try: try:
self.software_instance.reportComputerPartitionBang(comment=self.jbody['log']) self.restrictedTraverse(self.software_instance_url
).reportComputerPartitionBang(comment=self.jbody['log'])
except Exception: except Exception:
LOG('VifibRestApiV1Tool', ERROR, LOG('VifibRestApiV1Tool', ERROR,
'Problem while trying to generate instance dict:', error=True) 'Problem while trying to generate instance dict:', error=True)
...@@ -241,27 +243,28 @@ class InstancePublisher(GenericPublisher): ...@@ -241,27 +243,28 @@ class InstancePublisher(GenericPublisher):
@extractInstance @extractInstance
def __instance_info(self): def __instance_info(self):
certificate = False certificate = False
software_instance = self.restrictedTraverse(self.software_instance_url)
if self.REQUEST['traverse_subpath'] and self.REQUEST[ if self.REQUEST['traverse_subpath'] and self.REQUEST[
'traverse_subpath'][-1] == 'certificate': 'traverse_subpath'][-1] == 'certificate':
certificate = True certificate = True
try: try:
if certificate: if certificate:
d = { d = {
"ssl_key": self.software_instance.getSslKey(), "ssl_key": software_instance.getSslKey(),
"ssl_certificate": self.software_instance.getSslCertificate() "ssl_certificate": software_instance.getSslCertificate()
} }
else: else:
d = { d = {
"title": self.software_instance.getTitle(), "title": software_instance.getTitle(),
"status": self.software_instance.getSlapState(), "status": software_instance.getSlapState(),
"software_release": "", # not ready yet "software_release": "", # not ready yet
"software_type": self.software_instance.getSourceReference(), "software_type": software_instance.getSourceReference(),
"slave": self.software_instance.getPortalType() == 'Slave Instance', "slave": software_instance.getPortalType() == 'Slave Instance',
"connection": self.software_instance.getConnectionXmlAsDict(), "connection": software_instance.getConnectionXmlAsDict(),
"parameter": self.software_instance.getInstanceXmlAsDict(), "parameter": software_instance.getInstanceXmlAsDict(),
"sla": self.software_instance.getSlaXmlAsDict(), "sla": software_instance.getSlaXmlAsDict(),
"children_list": [q.absolute_url() for q in \ "children_list": [q.absolute_url() for q in \
self.software_instance.getPredecessorValueList()], software_instance.getPredecessorValueList()],
"partition": { # not ready yet "partition": { # not ready yet
"public_ip": [], "public_ip": [],
"private_ip": [], "private_ip": [],
......
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