示例#1
0
    def get(self, request, *args, **kwargs):
        data_handler = DataHandler()
        HOSTS = ast.literal_eval(data_handler.get_config().get('Openstack', 'computenodes'))
        template_name = 'admin/graphs/host.html'
        times_begin = request.GET.get('timestamp_begin')
        times_end = request.GET.get('timestamp_end')
        meter = request.GET.get('meter')

        json_graf = None
        if(meter == 'cpu'):
            json_graf = data_handler.points_reduction_by_server_cpu(timestamp_begin=times_begin, timestamp_end=times_end,hosts=HOSTS)
        elif(meter == 'disk'):
            json_graf = data_handler.points_reduction_by_server_disk(timestamp_begin=times_begin, timestamp_end=times_end,hosts=HOSTS)
        elif(meter == 'memory'):
            json_graf = data_handler.points_reduction_by_server_memory(timestamp_begin=times_begin, timestamp_end=times_end,hosts=HOSTS)
        elif(meter == 'network'):
            json_graf = data_handler.points_reduction_by_server_network(timestamp_begin=times_begin, timestamp_end=times_end,hosts=HOSTS)

        return HttpResponse(json.dumps(json_graf), content_type='application/json')
示例#2
0
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from django import template
from django.utils.translation import ugettext_lazy as _ # noqa

from openstack_dashboard.api.telemetry_api.telemetry_data import DataHandler
import ast

from horizon import tabs
from openstack_dashboard.dashboards.admin.availability import tables


data_handler = DataHandler()
HOSTS = ast.literal_eval(data_handler.get_config().get('Openstack', 'computenodes'))


class HostTab(tabs.Tab):
    name = _("Host")
    slug = "host"
    template_name = ("admin/availability/host.html")

    def get_context_data(self, request, *args, **kwargs):
        context_temp = {'name':'hosts','children':[]}
        for h in HOSTS:
            host = {'ip':h}
            context_temp['children'].append(host)
        host_list = context_temp['children']
        context = {'hosts_list': host_list}
        return context