Commit d8bb9163 authored by Łukasz Nowak's avatar Łukasz Nowak

slapos_cloud: Improve OSS instance destruction

Improvements:

 * allow to destroy any kind of instance
 * damage software release to avoid change propagation
 * provide more information in the UI for the OSS Operator
 * stabilise field and action naming
parent a33cb93b
......@@ -40,7 +40,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_request_destroy</string> </value>
<value> <string>view_rename_and_request_destroy</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
......@@ -60,7 +60,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Destroy</string> </value>
<value> <string>Rename and Request Destroy</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
......@@ -77,7 +77,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/SoftwareInstance_viewRequestDestroyDialog</string> </value>
<value> <string>string:${object_url}/SoftwareInstance_viewRenameAndRequestDestroyDialog</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_rename_and_request_destroy</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Modify portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Rename and Request Destroy</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/SoftwareInstance_viewRenameAndRequestDestroyDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -80,17 +80,23 @@ def SoftwareInstance_renameAndRequestDestroy(self, REQUEST=None):
raise Unauthorized
assert self.getPortalType() in ["Software Instance", "Slave Instance"]
suffix = "_renamed_and_destroyed_%s" % (DateTime().strftime("%Y%m%d_%H%M%S"))
title = self.getTitle()
new_title = title + "_renamed_and_destroyed_%s" % (DateTime().strftime("%Y%m%d_%H%M%S"))
new_title = title + suffix
self.rename(new_name=new_title,
comment="Rename %s into %s" % (title, new_title))
comment="Renamed %s into %s" % (title, new_title))
# Change desired state
promise_kw = {
'instance_xml': self.getTextContent(),
'software_type': self.getSourceReference(),
'sla_xml': self.getSlaXml(),
'software_release': self.getUrlString(),
# "damage" software release, as this will minimise the chance of the
# instance content being processed by the node with error message like
# "Software Release ... is not present on system.", so no side effects of
# this operation will be seen in the Instance Tree and that's the
# expected situation
'software_release': self.getUrlString() + suffix,
'shared': self.getPortalType()=="Slave Instance",
}
......
""" By default we don't allow any user to individurally destroy anything
"""
return False
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_isUserAllowedToDestroy</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_requestDestroy</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -5,9 +5,6 @@ portal = context.getPortalObject()
if portal.portal_membership.isAnonymousUser():
raise Unauthorized("You cannot invoke this API as Annonymous")
if not context.SoftwareInstance_isUserAllowedToDestroy():
raise Unauthorized("You cannot destroy this %s." % context.getPortalType())
if context.getSlapState() not in ["start_requested", "stop_requested"]:
return context.Base_redirect(keep_items={"portal_status_message": "This %s is on %s state and cannot be destroyed." \
% (context.getPortalType(), context.getSlapState())})
......
......@@ -35,7 +35,7 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>SoftwareInstance_requestDestroy</string> </value>
<value> <string>SoftwareInstance_viewRenameAndRequestDestroyAction</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
......@@ -97,7 +97,7 @@
<key> <string>left</string> </key>
<value>
<list>
<string>Warnning</string>
<string>warning</string>
<string>my_title</string>
<string>my_reference</string>
<string>my_description</string>
......@@ -115,7 +115,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_viewRequestDestroyDialog</string> </value>
<value> <string>SoftwareInstance_viewRenameAndRequestDestroyDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
......@@ -139,7 +139,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Request Destroy</string> </value>
<value> <string>Rename and Request Destroy</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>Warnning</string> </value>
<value> <string>warning</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -219,8 +219,8 @@
<key> <string>default</string> </key>
<value> <string encoding="cdata"><![CDATA[
<h1> BE CAREFULL, you are destroying one instance.</h1>\n
<h3> There is no way to revert this change. If you do a mistake you risk on cause data lost!!! </h3>
<h1> BEWARE! Instance DESTROY will happen!</h1>\n
<h3> This will result with destruction of the instance. This is dangerous operation, which shall be use only by properly trained Rapid.Space OSS Operator. If the instance contains data, they will be removed. If the instance has Slave Instance related, they will be destroyed too, including the data. </h3>
]]></string> </value>
</item>
......@@ -274,7 +274,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Warnning</string> </value>
<value> <string>Warning</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
......
......@@ -18,6 +18,7 @@ Slave Instance | jump_to_instance_tree
Slave Instance | jump_to_software_instance
Slave Instance | unfiltered_tracking_list
Slave Instance | view
Slave Instance | view_rename_and_request_destroy
Slave Instance | view_rename_and_request_stop
Software Installation Module | view
Software Installation | request_destroy
......@@ -28,9 +29,8 @@ Software Instance | jump_to_instance_tree
Software Instance | jump_to_software_instance
Software Instance | unfiltered_tracking_list
Software Instance | view
Software Instance | view_rename_and_request_destroy
Software Instance | view_rename_and_request_stop
Software Instance | view_request_destroy
Software Instance | view_request_destroy
Software Release | usable_compute_node
Software Release | usable_network
Software Release | view_capacity
......
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