def setUp(self):
     creds = Credentials()
     self.novaservice = NovaClient(creds.get_nova_creds())
     self.fc = FakeInstance()
     self.novaservice._check_keypair = mock.Mock(return_value=True)
     self.novaservice._check_image = Mock(return_value=DEF_IMAGE_ID)
     self.novaservice._check_flavor = Mock(return_value=DEF_FLAVOR_ID)
示例#2
0
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from NovaClientUI.customs.nova_client.client.nova_Client import NovaClient
from NovaClientUI.customs.nova_client.client.credentials import Credentials
from NovaClientUI.apps.Instances.forms import CreateForm

# Create your views here.
creds = Credentials()
nc = NovaClient(creds.get_nova_creds())


def get_instance_list(request):
    instances = nc.instance_list()
    context = {'instances': instances}
    return render_to_response('Instances/instances.html', context,
                              context_instance=RequestContext(request))


def instance_info(request, instance_id):
    if request.method == "GET":
        instance = nc.instance_info(instance_id)
        context = {'instance': instance}
        return render_to_response('Instances/info.html', context,
                                  context_instance=RequestContext(request))


def delete_instance(request, instance_id):
    if request.method == "GET":
        context = {'instance_id': instance_id}
        return render_to_response('Instances/instance_confirm_delete.html', context,