Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

working with resize and instance terminate

  • Loading branch information...
commit 193a6bf07b3c4ab03664268a96caae163c8f3cad 1 parent 6a7128b
@buzztroll buzztroll authored
View
76 phantomweb/static/css/phantom_domain.css
@@ -75,12 +75,6 @@
padding-bottom: 5px;
}
-#phantom_domain_details_list_div
-{
- overflow-y: scroll;
- height: 80%;
- background-color: #f6f6ff;
-}
#phantom_domain_instance_details
{
@@ -139,6 +133,21 @@
{
}
+#phantom_domain_instance_context_menu
+{
+ display: none;
+ background: #5d78a5;
+ box-shadow: 0 0 12px rgba( 0, 0, 0, .3 );
+ border: 1px solid white;
+ position: absolute;
+ top: 0; left: 0;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ min-width: 100px;
+ z-index: 10000;
+}
+
#phantom_domain_instance_context_menu li
{
position: relative;
@@ -161,3 +170,58 @@
width: 80%;
text-align: center;
}
+
+#phantom_domain_details_list_div
+{
+ overflow-y: scroll;
+ height: 80%;
+ background-color: #f6f6ff;
+}
+
+#phantom_domain_details_list_div ul
+{
+ list-style-type: none;
+}
+
+#phantom_domain_details_list_div li:hover
+{
+ background-color: #e6e6fa;
+}
+
+#phantomInstanceContextMenu
+{
+ display: none;
+ background: #5d78a5;
+ box-shadow: 0 0 12px rgba( 0, 0, 0, .3 );
+ border: 1px solid white;
+ position: absolute;
+ top: 0; left: 0;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ min-width: 100px;
+ z-index: 10000;
+}
+
+#phantomInstanceContextMenu li
+{
+ position: relative;
+ border-bottom-color: white;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+}
+
+#phantomInstanceContextMenu li:hover
+{
+ background: #83a0d3;
+}
+
+#phantomInstanceContextMenu div
+{
+ color: #fffbef;
+ display: inline-block;
+ padding: 8px;
+ text-decoration: none;
+ width: 80%;
+ text-align: center;
+}
View
8 phantomweb/templates/phantom_domain.html
@@ -13,9 +13,15 @@
<script src="/static/js/phantom_common.js"></script>
<script src="/static/js/phantom_domain.js"></script>
{% endblock %}
-{% block bodytag %}onload="phantom_domain_load();"{% endblock %}
+{% block bodytag %}onload="phantom_domain_load();" onclick="phantom_domain_noncontext_mouse_down();"{% endblock %}
{% block nimbus_body %}
+<div id="phantom_instance_context_menu_div">
+ <ul id="phantom_domain_instance_context_menu">
+ <li><div>Terminate</div></li>
+ </ul>
+</div>
+
<div id="phantom_domain_content">
<div class="phantom_headings">
View
3  phantomweb/urls.py
@@ -35,8 +35,9 @@
url(r'^phantom/api/domain/start$', 'phantomweb.views.django_domain_start'),
url(r'^phantom/api/domain/terminate$', 'phantomweb.views.django_domain_terminate'),
url(r'^phantom/api/domain/resize$', 'phantomweb.views.django_domain_resize'),
- url(r'^phantom/api/domain/update$', 'phantomweb.views.django_domain_update'),
url(r'^phantom/api/domain/details$', 'phantomweb.views.django_domain_details'),
+
+ url(r'^phantom/api/instance/termiante$', 'phantomweb.views.django_instance_terminate'),
)
View
18 phantomweb/views.py
@@ -7,7 +7,7 @@
from django.contrib.auth.decorators import login_required
from phantomweb.phantom_web_exceptions import PhantomWebException, PhantomRedirectException
from phantomweb.util import PhantomWebDecorator, get_user_object, LogEntryDecorator
-from phantomweb.workload import terminate_iaas_instance, phantom_lc_load, phantom_sites_add, phantom_sites_delete, phantom_sites_load, phantom_lc_delete, phantom_lc_save, phantom_domain_load, phantom_domain_terminate, phantom_domain_resize, phantom_domain_start, phantom_domain_update, phantom_domain_details
+from phantomweb.workload import terminate_iaas_instance, phantom_lc_load, phantom_sites_add, phantom_sites_delete, phantom_sites_load, phantom_lc_delete, phantom_lc_save, phantom_domain_load, phantom_domain_terminate, phantom_domain_resize, phantom_domain_start, phantom_domain_details, phantom_instance_terminate
from django.contrib import admin
@@ -72,38 +72,40 @@ def django_domain_resize(request):
@LogEntryDecorator
@login_required
-def django_domain_update(request):
+def django_domain_details(request):
user_obj = get_user_object(request.user.username)
try:
- response_dict = phantom_domain_update(request.POST, user_obj)
+ response_dict = phantom_domain_details(request.POST, user_obj)
h = HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
finally:
user_obj.close()
return h
+
@LogEntryDecorator
@login_required
-def django_domain_details(request):
+def django_domain_terminate(request):
user_obj = get_user_object(request.user.username)
try:
- response_dict = phantom_domain_details(request.POST, user_obj)
+ response_dict = phantom_domain_terminate(request.POST, user_obj)
h = HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
finally:
user_obj.close()
return h
-
@LogEntryDecorator
@login_required
-def django_domain_terminate(request):
+def django_instance_terminate(request):
user_obj = get_user_object(request.user.username)
try:
- response_dict = phantom_domain_terminate(request.POST, user_obj)
+ response_dict = phantom_instance_terminate(request.POST, user_obj)
h = HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
finally:
user_obj.close()
return h
+
+
#
# launch configuration options
#
View
42 phantomweb/workload.py
@@ -464,7 +464,28 @@ def phantom_domain_start(request_params, userobj):
@PhantomWebDecorator
@LogEntryDecorator
def phantom_domain_resize(request_params, userobj):
- pass
+ params = ['name', "vm_count"]
+ for p in params:
+ if p not in request_params:
+ raise PhantomWebException('Missing parameter %s' % (p))
+
+ domain_name = request_params["name"]
+ new_size = request_params["vm_count"]
+
+ try:
+ phantom_con = _get_phantom_con(userobj)
+ asg = phantom_con.get_all_groups(names=[domain_name,])
+ if not asg:
+ raise PhantomWebException("domain %s not found" % (domain_name))
+ asg = asg[0]
+ asg.set_capacity(new_size)
+ except PhantomWebException:
+ raise
+ except Exception, ex:
+ raise PhantomWebException(str(ex))
+ response_dict = {}
+ return response_dict
+
@PhantomWebDecorator
@LogEntryDecorator
@@ -485,8 +506,23 @@ def phantom_domain_terminate(request_params, userobj):
@PhantomWebDecorator
@LogEntryDecorator
-def phantom_domain_update(request_params, userobj):
- pass
+def phantom_instance_terminate(request_params, userobj):
+ params = ['instance', "adjust"]
+ for p in params:
+ if p not in request_params:
+ raise PhantomWebException('Missing parameter %s' % (p))
+
+ instance_id = request_params["instance"]
+ adjust = request_params["adjust"]
+ adjust = adjust.lower() == "true"
+
+ g_general_log.debug("deleting %s" % (instance_id))
+ phantom_con = _get_phantom_con(userobj)
+
+ phantom_con.terminate_instance(instance_id, decrement_capacity=adjust)
+
+ response_dict = {}
+ return response_dict
@PhantomWebDecorator
@LogEntryDecorator
Please sign in to comment.
Something went wrong with that request. Please try again.