Matteo Scandolo | eb3487c | 2017-08-08 13:05:26 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Pingping Lin | d28ab98 | 2016-08-29 18:42:52 +0000 | [diff] [blame] | 17 | from django.http import HttpResponse |
| 18 | from django.views.generic import TemplateView, View |
| 19 | from django import template |
| 20 | from core.models import * |
| 21 | import json |
| 22 | import os |
| 23 | import time |
| 24 | import tempfile |
| 25 | |
| 26 | |
| 27 | class MCordView(TemplateView): |
| 28 | head_template = r"""{% extends "admin/dashboard/dashboard_base.html" %} |
| 29 | {% load admin_static %} |
| 30 | {% block content %} |
| 31 | """ |
| 32 | |
| 33 | tail_template = r"{% endblock %}" |
| 34 | |
| 35 | def get(self, request, name="root", *args, **kwargs): |
| 36 | head_template = self.head_template |
| 37 | tail_template = self.tail_template |
| 38 | |
| 39 | title = request.GET.get('service', '') |
| 40 | url = "/mcord/?service=%s" % (title) |
| 41 | |
| 42 | form = """ |
| 43 | <h2 class="content-title">Change %s Service</h2> |
| 44 | <div id="content-main"> |
| 45 | <form class="form-horizontal"> |
| 46 | <div class="tab-content tab-content-main"> |
| 47 | <div class="suit-include suit-tab suit-tab-administration hide"> |
| 48 | <div class="left-nav"> |
| 49 | <ul> |
| 50 | <li><a href="/admin/ceilometer/monitoringchannel/">Monitoring Channels</a></li> |
| 51 | </ul> |
| 52 | </div> |
| 53 | </div> |
| 54 | <fieldset class="module aligned suit-tab suit-tab-general show"> |
| 55 | <div class="panel fieldset-body"> |
| 56 | <div class="form-group field-backend_status_text "> |
| 57 | <label class="control-label col-xs-12 col-sm-2"><label>Backend status text:</label></label> |
| 58 | <div class="form-column col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 59 | <p><img src="/static/admin/img/icon_clock.gif"> Pending sync, last_status = 0 - Provisioning in progress</p> |
| 60 | </div> |
| 61 | </div> |
| 62 | <div class="form-group field-name "> |
| 63 | <label class="control-label col-xs-12 col-sm-2"><label class="required" for="id_name">Name:</label></label> |
| 64 | <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 65 | <input class="vTextField form-control" id="id_name" maxlength="30" name="name" type="text" value="%s"> |
| 66 | <div class="help-block">Service Name</div> |
| 67 | </div> |
| 68 | </div> |
| 69 | <div class="form-group field-enabled "> |
| 70 | <label class="control-label col-xs-12 col-sm-2"><label class="vCheckboxLabel" for="id_enabled">Enabled</label></label> |
| 71 | <div class="form-column widget-CheckboxInput col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 72 | <input checked="checked" id="id_enabled" name="enabled" type="checkbox"> |
| 73 | </div> |
| 74 | </div> |
| 75 | <div class="form-group field-versionNumber "> |
| 76 | <label class="control-label col-xs-12 col-sm-2"><label class="required" for="id_versionNumber">VersionNumber:</label></label> |
| 77 | <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 78 | <input class="vTextField form-control" id="id_versionNumber" maxlength="30" name="versionNumber" type="text"> |
| 79 | <div class="help-block">Version of Service Definition</div> |
| 80 | </div> |
| 81 | </div> |
| 82 | <div class="form-group field-description "> |
| 83 | <label class="control-label col-xs-12 col-sm-2"><label for="id_description">Description:</label></label> |
| 84 | <div class="form-column widget-AdminTextareaWidget col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 85 | <textarea class="vLargeTextField form-control" cols="40" id="id_description" maxlength="254" name="description" rows="10"></textarea> |
| 86 | <div class="help-block">Description of Service</div> |
| 87 | </div> |
| 88 | </div> |
| 89 | <div class="form-group field-view_url "> |
| 90 | <label class="control-label col-xs-12 col-sm-2"><label for="id_view_url">View url:</label></label> |
| 91 | <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 92 | <input class="vTextField form-control" id="id_view_url" maxlength="1024" name="view_url" type="text" value="%s"> |
| 93 | </div> |
| 94 | </div> |
| 95 | <div class="form-group field-icon_url "> |
| 96 | <label class="control-label col-xs-12 col-sm-2"><label for="id_icon_url">Icon url:</label></label> |
| 97 | <div class="form-column widget-AdminTextInputWidget col-xs-12 col-sm-8 col-md-6 col-lg-4"> |
| 98 | <input class="vTextField form-control" id="id_icon_url" maxlength="1024" name="icon_url" type="text"> |
| 99 | </div> |
| 100 | </div> |
| 101 | </div> |
| 102 | </fieldset> |
| 103 | </div> |
| 104 | </form> |
| 105 | <div class="form-buttons clearfix"> |
| 106 | <button type="submit" class="btn btn-high btn-success" name="_save">Save</button> |
| 107 | <button type="submit" name="_continue" class=" btn btn-high btn-info">Save and continue editing</button> |
| 108 | <button type="submit" name="_addanother" class="btn btn-info">Save and add another</button> |
| 109 | <a href="delete/" class="text-error deletelink">Delete</a> |
| 110 | </div> |
| 111 | </div> |
| 112 | """ % (title, title, url) |
| 113 | |
| 114 | t = template.Template(head_template + form + tail_template) |
| 115 | |
| 116 | response_kwargs = {} |
| 117 | response_kwargs.setdefault('content_type', self.content_type) |
| 118 | return self.response_class( |
| 119 | request=request, |
| 120 | template=t, |
| 121 | **response_kwargs |
| 122 | ) |