Commit e98e0734 authored by Alain Takoudjou's avatar Alain Takoudjou

get all ip addresses used in hosting subscription

parent 61c43669
......@@ -272,6 +272,42 @@ class SlapTool(BaseTool):
self._getSlapPartitionByPackingList(_assertACI(computer_partition.getObject())))
return xml_marshaller.xml_marshaller.dumps(slap_computer)
@UnrestrictedMethod
def _getHostingSubscriptionIpList(self, computer_id, computer_partition_id):
def getHostingSubscriptionInstanceList(software_instance):
pred_list = []
if software_instance is None or software_instance.getSlapState() == 'destroy_requested':
return pred_list
else:
if software_instance.getPortalType() == 'Software Instance':
pred_list.append(software_instance)
predecessor_list = software_instance.getPredecessorValueList(
portal_type="Software Instance")
for instance in predecessor_list:
pred_list.extend(getHostingSubscriptionInstanceList(instance))
return pred_list
software_instance = self._getSoftwareInstanceForComputerPartition(
computer_id, computer_partition_id)
# Search hosting subscription
hosting = software_instance.getSpecialiseValue()
while hosting and hosting.getPortalType() != "Hosting Subscription":
hosting = hosting.getSpecialiseValue()
ip_address_list = []
for instance in getHostingSubscriptionInstanceList(hosting):
computer_partition = instance.getAggregateValue(portal_type="Computer Partition")
if not computer_partition:
continue
for internet_protocol_address in computer_partition.contentValues(
portal_type='Internet Protocol Address'):
ip_address_list.append(
(internet_protocol_address.getNetworkInterface('').decode("UTF-8"),
internet_protocol_address.getIpAddress().decode("UTF-8"))
)
return xml_marshaller.xml_marshaller.dumps(ip_address_list)
security.declareProtected(Permissions.AccessContentsInformation,
'getFullComputerInformation')
def getFullComputerInformation(self, computer_id):
......@@ -298,6 +334,28 @@ class SlapTool(BaseTool):
else:
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getHostingSubscriptionIpList')
def getHostingSubscriptionIpList(self, computer_id, computer_partition_id):
"""
Search and return all Computer Partition IP address related to one
Hosting Subscription
"""
result = self._getHostingSubscriptionIpList(computer_id,
computer_partition_id)
if self.REQUEST.response.getStatus() == 200:
# Keep in cache server for 7 days
self.REQUEST.response.setHeader('Cache-Control',
'public, max-age=1, stale-if-error=604800')
self.REQUEST.response.setHeader('Vary',
'REMOTE_USER')
self.REQUEST.response.setHeader('Last-Modified', rfc1123_date(DateTime()))
self.REQUEST.response.setBody(result)
return self.REQUEST.response
else:
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getComputerPartitionCertificate')
def getComputerPartitionCertificate(self, computer_id, 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