def fix_private_images_without_repr(private_images, prov, accounts):
    """
    See if image has a machine request
    See if we can 'piece it together'
    """
    for img in private_images:
        machine_requests = MachineRequest.objects.filter(
            new_machine_provider=prov,
            new_application_name=img.name)
        for mr in machine_requests:
            print "Machine Request found matching name %s of image %s" \
                % (img.name, img.id)
            if mr.status != 'completed':
                print "Processing machine with image %s" % img.id
                process_machine_request(mr, img.id)
            pm = mr.new_machine
            if mr.new_application_visibility.lower() == 'public':
                make_public(accounts.image_manager, img, pm)
                continue
            # Private or selected access..
            access_list = parse_list(mr.access_list, prov.id)
            # Fix on the image
            tenant_list = sync_image_access_list(
                accounts, img, names=access_list)
            # Fix on the database
            make_private(accounts.image_manager, img, pm, tenant_list)
def fix_public_images(public_images, prov, accounts):
    """
    Potential problems with public images:
    * 1. Openstack shows public and has users listed as 'image_members'
      Solution: mark image as private, and then update PMs and APPs
    * 2. MachineRequest shows this public image should be private
      Solution: mark image as private, share image with everyone in access list
    """
    image_total = len(public_images)
    print "Checking %s public images to see if they should be 'private' in openstack: %s"\
        % (image_total, prov)
    for idx, img in enumerate(public_images):
        # Check if this image has any 'shared users'
        pm = ProviderMachine.objects.filter(identifier=img.id,
                                            provider=prov)
        if not pm:
            continue
        pm = pm[0]
        machine_requests = MachineRequest.objects.filter(
            Q(new_machine=pm) &
            ~Q(new_application_visibility__exact="public"))
        for mr in machine_requests:
            access_list = parse_list(mr.access_list, prov.id)
            # Fix on the image
            print "Syncing image access list for %s<%s>" % (img.name, img.id)
            tenant_list = sync_image_access_list(
                accounts, img, names=access_list)
            # Fix on the database
            print "Syncing database models for %s<%s>" % (img.name, img.id)
            make_private(accounts.image_manager, img, pm, tenant_list)
        if (idx % 5 == 0):
            print "Processed %s of %s machines" % (idx + 1, image_total)
Esempio n. 3
0
def fix_private_images_without_repr(private_images, prov, accounts):
    """
    See if image has a machine request
    See if we can 'piece it together'
    """
    for img in private_images:
        machine_requests = MachineRequest.objects.filter(
            new_machine_provider=prov, new_application_name=img.name)
        for mr in machine_requests:
            print "Machine Request found matching name %s of image %s" \
                % (img.name, img.id)
            if mr.status != 'completed':
                print "Processing machine with image %s" % img.id
                process_machine_request(mr, img.id)
            pm = mr.new_machine
            if mr.new_application_visibility.lower() == 'public':
                make_public(accounts.image_manager, img, pm)
                continue
            # Private or selected access..
            access_list = parse_list(mr.access_list, prov.id)
            # Fix on the image
            tenant_list = sync_image_access_list(accounts,
                                                 img,
                                                 names=access_list)
            # Fix on the database
            make_private(accounts.image_manager, img, pm, tenant_list)
Esempio n. 4
0
def fix_public_images(public_images, prov, accounts):
    """
    Potential problems with public images:
    * 1. Openstack shows public and has users listed as 'image_members'
      Solution: mark image as private, and then update PMs and APPs
    * 2. MachineRequest shows this public image should be private
      Solution: mark image as private, share image with everyone in access list
    """
    image_total = len(public_images)
    print "Checking %s public images to see if they should be 'private' in openstack: %s"\
        % (image_total, prov)
    for idx, img in enumerate(public_images):
        # Check if this image has any 'shared users'
        pm = ProviderMachine.objects.filter(identifier=img.id, provider=prov)
        if not pm:
            continue
        pm = pm[0]
        machine_requests = MachineRequest.objects.filter(
            Q(new_machine=pm) & ~Q(new_application_visibility__exact="public"))
        for mr in machine_requests:
            access_list = parse_list(mr.access_list, prov.id)
            # Fix on the image
            print "Syncing image access list for %s<%s>" % (img.name, img.id)
            tenant_list = sync_image_access_list(accounts,
                                                 img,
                                                 names=access_list)
            # Fix on the database
            print "Syncing database models for %s<%s>" % (img.name, img.id)
            make_private(accounts.image_manager, img, pm, tenant_list)
        if (idx % 5 == 0):
            print "Processed %s of %s machines" % (idx + 1, image_total)
Esempio n. 5
0
def fix_private_images(private_images, prov, accounts):
    """
    Potential problems with private images:
    * 1. MachineRequest contains this image and has more users on access_list
      Solution: add users on access_list to the image, update PMs and APPs
    * 2. Image has 0/1 user and is marked private
      Solution: Probably hidden on purpose.. Leave it there
    """
    image_total = len(private_images)
    print "Checking %s private images to see if they should be 'private' in openstack: %s"\
        % (image_total, prov)
    for idx, img in enumerate(private_images):
        # Check if this image has any 'shared users'
        pm = ProviderMachine.objects.filter(identifier=img.id, provider=prov)
        if not pm:
            continue
        pm = pm[0]
        machine_requests = MachineRequest.objects.filter(new_machine=pm)
        for mr in machine_requests:
            if mr.new_application_visibility.lower() == 'public':
                print "Machine Request says image %s should be public" % img.id
                make_public(accounts.image_manager, img, pm)
                continue
            # Private or selected access..
            access_list = parse_list(mr.access_list, prov.id)
            # Fix on the image
            tenant_list = sync_image_access_list(accounts,
                                                 img,
                                                 names=access_list)
            # Fix on the database
            make_private(accounts.image_manager, img, pm, tenant_list)
        if not machine_requests:
            if pm.application.private:
                print "Application says %s<%s> should be private" % (img.name,
                                                                     img.id)
                make_private(accounts.image_manager, img, pm)
        if (idx % 5 == 0):
            print "Processed %s of %s machines" % (idx + 1, image_total)
def fix_private_images(private_images, prov, accounts):
    """
    Potential problems with private images:
    * 1. MachineRequest contains this image and has more users on access_list
      Solution: add users on access_list to the image, update PMs and APPs
    * 2. Image has 0/1 user and is marked private
      Solution: Probably hidden on purpose.. Leave it there
    """
    image_total = len(private_images)
    print "Checking %s private images to see if they should be 'private' in openstack: %s"\
        % (image_total, prov)
    for idx, img in enumerate(private_images):
        # Check if this image has any 'shared users'
        pm = ProviderMachine.objects.filter(identifier=img.id,
                                            provider=prov)
        if not pm:
            continue
        pm = pm[0]
        machine_requests = MachineRequest.objects.filter(new_machine=pm)
        for mr in machine_requests:
            if mr.new_application_visibility.lower() == 'public':
                print "Machine Request says image %s should be public" % img.id
                make_public(accounts.image_manager, img, pm)
                continue
            # Private or selected access..
            access_list = parse_list(mr.access_list, prov.id)
            # Fix on the image
            tenant_list = sync_image_access_list(
                accounts, img, names=access_list)
            # Fix on the database
            make_private(accounts.image_manager, img, pm, tenant_list)
        if not machine_requests:
            if pm.application.private:
                print "Application says %s<%s> should be private" % (img.name, img.id)
                make_private(accounts.image_manager, img, pm)
        if (idx % 5 == 0):
            print "Processed %s of %s machines" % (idx + 1, image_total)