Exemple #1
0
 def get_context_data(self, **kwargs):
     context = super(OpenStackNetStatus, self).get_context_data(**kwargs)
     agent= OpenStackAgent.objects.get(id=self.kwargs['pk'])
     client = OpenStackAgentClient(agent.hostname, agent.port)        
     context['instances'] = []
     net_dics = client.net_list()['object']
     net_infos = [HostNetInfo(info_dic) for info_dic in net_dics]
     context['instances'].extend(net_infos)
     return context
Exemple #2
0
    def get_context_data(self, **kwargs):
        context = super(OpenStackHypervisorDetailView, self).get_context_data(**kwargs)
        context['instances'] = []
        context['ops_agent'] = self.kwargs['pk']
        hypervisor_hostname = self.kwargs['hypervisor_hostname']
        agent = OpenStackAgent.objects.get(pk = self.kwargs['pk'])
        client = OpenStackAgentClient(agent.hostname, agent.port)
        instances = client.hypervisor_server_list(hypervisor_hostname)['servers']

        token = client.get_token()['token']
        for instance in instances:
            project_id = client.get_project_id()['project_id']

            instance = OpenStackServer(instance, project_id)
            instance.fill_instance(agent.guest_agent_base_url ,token)
            context['instances'].append(instance)

        return context
Exemple #3
0
    def get_context_data(self, **kwargs):
        context = super(OpenStackInstancesView, self).get_context_data(**kwargs)
        context['openstacks'] = OpenStackAgent.objects.all()
        context['tag'] = self.request.GET.get('tag')
        if context['tag']:
            context['tag'] = int(context['tag'])
            openstack = OpenStackAgent.objects.get(id = context['tag'])
        else:
            openstack = OpenStackAgent.objects.get(id = 1)

        client = OpenStackAgentClient(openstack.hostname, openstack.port)
        instances = client.instances_status_list()['object']

        context['instances_status'] = []
        for instance in instances:
            context['instances_status'].append(HostNetInfo(instance))

        return context
Exemple #4
0
    def get_context_data(self, **kwargs):
        context = super(OpenStackNovaServicesView, self).get_context_data(**kwargs)
        context['openstacks'] = OpenStackAgent.objects.all()
        context['tag'] = self.request.GET.get('tag')
        if context['tag']:
            context['tag'] = int(context['tag'])
            openstack = OpenStackAgent.objects.get(id=context['tag'])
        else:
            openstack = OpenStackAgent.objects.get(id=1)

        client = OpenStackAgentClient(openstack.hostname, openstack.port)
        services = client.nova_service_list()
        services_host = services.keys()

        context['nova_services'] = []
        for service in services_host:
            context['nova_services'].append(OpenStackNovaService(services[service]))

        return context
Exemple #5
0
    def get_context_data(self, **kwargs):
        context = super(OpenStackHypervisorsView, self).get_context_data(**kwargs)
        context['hypervisors'] = []
        hypervisors_tmp = []
        context['services'] = []

        context['agent_pk'] = self.kwargs['pk']
        agent = OpenStackAgent.objects.get(pk = self.kwargs['pk'])
        client = OpenStackAgentClient(agent.hostname, agent.port)
        hypervisors = client.hypervisor_list()
        services = client.nova_service_list()
        hypervisors_hostname = hypervisors.keys()
        services_host = services.keys()
        for hypervisor in hypervisors_hostname:
            hypervisors_tmp.append(OpenStackHypervisor( hypervisors[hypervisor] ))

        context['hypervisors'] = hypervisors_tmp
        for service in services_host:
            context['services'].append(OpenStackNovaService(services[service]))

        return context
Exemple #6
0
    def get_context_data(self, **kwargs):
        context = super(OpenStackHypervisorsView, self).get_context_data(**kwargs)
        hypervisors_tmp = []
        context['openstacks'] = OpenStackAgent.objects.all()
        context['tag'] = self.request.GET.get('tag')
        if context['tag']:
            context['tag'] = int(context['tag'])
            openstack = OpenStackAgent.objects.get(id=context['tag'])
        else:
            openstack = OpenStackAgent.objects.get(id=1)

        context['hypervisors'] = []
        client = OpenStackAgentClient(openstack.hostname, openstack.port)
        hypervisors = client.hypervisor_list()
        hypervisors_hostname = hypervisors.keys()

        for hypervisor in hypervisors_hostname:
            hypervisors_tmp.append(OpenStackHypervisor(hypervisors[hypervisor]))

        context['hypervisors'] = hypervisors_tmp

        return context