Commit 6f39b716 authored by Rafael Monnerat's avatar Rafael Monnerat

[slapos_web] Verify if request is possible before really request the instance

This change aims prevent flood of request and looking for partitions ghosts when hosting has full capacity or allocation is not possible.
parent 2d98d30f
...@@ -77,10 +77,23 @@ request_kw.update(\n ...@@ -77,10 +77,23 @@ request_kw.update(\n
state="started",\n state="started",\n
)\n )\n
\n \n
person.requestSoftwareInstance(**request_kw)\n result = person.Person_restrictMethodAsShadowUser(\n
shadow_document=person,\n
callable_object=person.Person_findPartition,\n
argument_list=[\n
url,\n
software_type,\n
\'Software Instance\', {}],\n
argument_dict={\'test_mode\': True})\n
\n \n
message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n if result:\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n person.requestSoftwareInstance(**request_kw)\n
\n
message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n
else:\n
message = context.Base_translateString("We are sorry. We cannot allocate your request because we are out of capacity for the software choose, please try again later!")\n
return context.myspace.Base_redirect(keep_items={\'portal_status_message\': message})\n
]]></string> </value> ]]></string> </value>
......
...@@ -79,10 +79,23 @@ request_kw.update(\n ...@@ -79,10 +79,23 @@ request_kw.update(\n
state="started",\n state="started",\n
)\n )\n
\n \n
person.requestSoftwareInstance(**request_kw)\n result = person.Person_restrictMethodAsShadowUser(\n
shadow_document=person,\n
callable_object=person.Person_findPartition,\n
argument_list=[\n
url,\n
software_type,\n
\'Software Instance\', {}],\n
argument_dict={\'test_mode\': True})\n
\n \n
message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n if result:\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n person.requestSoftwareInstance(**request_kw)\n
\n
message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n
else:\n
message = context.Base_translateString("We are sorry. We cannot allocate your request because we are out of capacity for the software choose, please try again later!")\n
return context.myspace.Base_redirect(keep_items={\'portal_status_message\': message})\n
]]></string> </value> ]]></string> </value>
......
...@@ -142,10 +142,23 @@ request_kw.update(\n ...@@ -142,10 +142,23 @@ request_kw.update(\n
state="started",\n state="started",\n
)\n )\n
\n \n
person.requestSoftwareInstance(**request_kw)\n result = person.Person_restrictMethodAsShadowUser(\n
shadow_document=person,\n
callable_object=person.Person_findPartition,\n
argument_list=[\n
url,\n
software_type,\n
\'Software Instance\', {}],\n
argument_dict={\'test_mode\': True})\n
\n \n
message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n if result:\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n person.requestSoftwareInstance(**request_kw)\n
\n
message = context.Base_translateString("Your instance is under creation. Please wait few minutes for partitions to appear.")\n
return context.REQUEST.get(\'request_hosting_subscription\').Base_redirect(keep_items={\'portal_status_message\': message})\n
else:\n
message = context.Base_translateString("We are sorry. We cannot allocate your request because we are out of capacity for the software choose, please try again later!")\n
return context.myspace.Base_redirect(keep_items={\'portal_status_message\': message})\n
]]></string> </value> ]]></string> </value>
......
53 55
\ No newline at end of file \ No newline at end of file
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