Commit de958007 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: fixup Unauthorized error when stopping/destroying a slave instance

parent 4fd22597
...@@ -54,7 +54,7 @@ def cloneDocumentWithANewPortalType(obj, portal_type): ...@@ -54,7 +54,7 @@ def cloneDocumentWithANewPortalType(obj, portal_type):
def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None, def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
comment=None): bang_tree=True, comment=None):
"""Call bang on self.""" """Call bang on self."""
# Caller check # Caller check
if relative_url is None: if relative_url is None:
...@@ -72,7 +72,7 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None, ...@@ -72,7 +72,7 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
sm = getSecurityManager() sm = getSecurityManager()
try: try:
newSecurityManager(None, user) newSecurityManager(None, user)
software_instance.bang(bang_tree=True, comment=comment) software_instance.bang(bang_tree=bang_tree, comment=comment)
finally: finally:
setSecurityManager(sm) setSecurityManager(sm)
......
...@@ -12,5 +12,9 @@ if instance.getSlapState() != 'destroy_requested': ...@@ -12,5 +12,9 @@ if instance.getSlapState() != 'destroy_requested':
if partition is not None: if partition is not None:
software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance") software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance")
if software_instance is not None: if software_instance is not None:
software_instance.bang(bang_tree=False, software_instance.SoftwareInstance_bangAsSelf(
comment="State changed from %s (shared) to destroy_requested" % instance.getSlapState()) relative_url=software_instance.getRelativeUrl(),
reference=software_instance.getReference(),
bang_tree=False,
comment="State changed from %s (shared) to destroy_requested" % instance.getSlapState()
)
...@@ -52,6 +52,14 @@ ...@@ -52,6 +52,14 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -12,5 +12,9 @@ if instance.getSlapState() != 'stop_requested': ...@@ -12,5 +12,9 @@ if instance.getSlapState() != 'stop_requested':
if partition is not None: if partition is not None:
software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance") software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance")
if software_instance is not None: if software_instance is not None:
software_instance.bang(bang_tree=False, software_instance.SoftwareInstance_bangAsSelf(
comment="State changed from %s (shared) to stop_requested" % instance.getSlapState()) relative_url=software_instance.getRelativeUrl(),
reference=software_instance.getReference(),
bang_tree=False,
comment="State changed from %s (shared) to stop_requested" % instance.getSlapState()
)
...@@ -52,6 +52,14 @@ ...@@ -52,6 +52,14 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <value>
......
...@@ -1110,10 +1110,16 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -1110,10 +1110,16 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
public_reference = 'public-%s' % self.generateNewId() public_reference = 'public-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, public_reference) self.joinSlapOS(self.web_site, public_reference)
shared_public_reference = 'shared_public-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, shared_public_reference)
self.login() self.login()
public_person = self.portal.portal_catalog.getResultValue( public_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login", portal_type="ERP5 Login",
reference=public_reference).getParentValue() reference=public_reference).getParentValue()
shared_public_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=shared_public_reference).getParentValue()
with PinnedDateTime(self, DateTime('2024/02/17 00:05')): with PinnedDateTime(self, DateTime('2024/02/17 00:05')):
public_instance_title = 'Public title %s' % self.generateNewId() public_instance_title = 'Public title %s' % self.generateNewId()
...@@ -1140,24 +1146,18 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -1140,24 +1146,18 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
software_release, software_type) software_release, software_type)
self.login() self.login()
public_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=public_reference).getParentValue()
slave_instance_title = 'Slave title %s' % self.generateNewId() slave_instance_title = 'Slave title %s' % self.generateNewId()
self.checkSlaveInstanceAllocation(public_person.getUserId(), self.checkSlaveInstanceAllocation(shared_public_person.getUserId(),
public_reference, slave_instance_title, shared_public_reference, slave_instance_title,
slave_server_software, slave_instance_type, slave_server_software, slave_instance_type,
public_server, project.getReference()) public_server, project.getReference())
self.login()
public_person = self.portal.portal_catalog.getResultValue(
portal_type='ERP5 Login', reference=public_reference).getParentValue()
self.login(owner_person.getUserId()) self.login(owner_person.getUserId())
# and the instances # and the instances
self.checkSlaveInstanceUnallocation(public_person.getUserId(), self.checkSlaveInstanceUnallocation(shared_public_person.getUserId(),
public_reference, slave_instance_title, shared_public_reference, slave_instance_title,
slave_server_software, slave_instance_type, public_server, slave_server_software, slave_instance_type, public_server,
project.getReference()) project.getReference())
...@@ -1178,10 +1178,10 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -1178,10 +1178,10 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 6 allocation supply/line/cell # 6 allocation supply/line/cell
# 2 compute/instance node # 2 compute/instance node
# 1 credential request # 2 credential request
# 2 instance tree # 2 instance tree
# 9 open sale order / line # 9 open sale order / line
# 3 assignment # 4 assignment
# 4 simulation movement # 4 simulation movement
# 4 sale packing list # 4 sale packing list
# 2 sale trade condition # 2 sale trade condition
...@@ -1189,7 +1189,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -1189,7 +1189,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 2 software instance # 2 software instance
# 2 software product # 2 software product
# 4 subscription request # 4 subscription request
self.assertRelatedObjectCount(project, 42) self.assertRelatedObjectCount(project, 44)
self.checkERP5StateBeforeExit() self.checkERP5StateBeforeExit()
......
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