Ejemplo n.º 1
0
def store_cloud_details(app, type, apphost, id, location):
    print "Details %s %s " % (apphost, type)
    if apphost == "Public":
        new_image = ApplicationEC2Images(application=app, image_id=id, zone_name="", zone_url=location, image_type=type)
        print "Going to save EC2 %s image %s" % (type, str(new_image))
        new_image.save()
    elif apphost == "Private":
        # Store Openstack details
        new_image = ApplicationOpenstackImages(
            application=app, image_id=id, zone_name="", zone_url=location, image_type=type
        )
        print "Going to save Openstack %s image %s" % (type, str(new_image))
        new_image.save()
    else:
        pass
    def create(self, request, *args, **kwargs):
        print "Creating OpenStack images"
        data = request.DATA
        with transaction.atomic():
            # add credentials api
            app = ApplicationBasicInfo.objects.filter(id=int(data.get('application')))[0]
            print app
            new_image = ApplicationOpenstackImages(application=app,
                                                   image_id=str(data.get('image_id')),
                                                   zone_name=str(data.get('zone_name')),
                                                   zone_url=str(data.get('zone_url')),
                                                   image_type=str(data.get('image_type')))
            new_image.save()

        serializer = ApplicationOsImagesSerializer(data)
        headers = self.get_success_headers(serializer.data)
        return Response(serializer.data, status=201, headers=headers)
Ejemplo n.º 3
0
    def create(self, request, *args, **kwargs):
        print "Creating OpenStack images"
        data = request.DATA
        with transaction.atomic():
            # add credentials api
            app = ApplicationBasicInfo.objects.filter(
                id=int(data.get('application')))[0]
            print app
            new_image = ApplicationOpenstackImages(
                application=app,
                image_id=str(data.get('image_id')),
                zone_name=str(data.get('zone_name')),
                zone_url=str(data.get('zone_url')),
                image_type=str(data.get('image_type')))
            new_image.save()

        serializer = ApplicationOsImagesSerializer(data)
        headers = self.get_success_headers(serializer.data)
        return Response(serializer.data, status=201, headers=headers)
Ejemplo n.º 4
0
def store_cloud_details(app,type,apphost,id,location):
    print "Details %s %s " %(apphost,type)
    if apphost =='Public':
        new_image = ApplicationEC2Images(application = app,
                                         image_id = id,
                                         zone_name = '',
                                         zone_url = location,
                                         image_type=type)
        print "Going to save EC2 %s image %s" %(type,str(new_image))
        new_image.save()
    elif apphost =='Private':
        #Store Openstack details
        new_image = ApplicationOpenstackImages(application=app,
                                           image_id=id,
                                           zone_name='',
                                           zone_url=location,
                                           image_type=type)
        print "Going to save Openstack %s image %s" %(type,str(new_image))
        new_image.save()
    else:
        pass