예제 #1
0
def _verify_for_delete(exist, delete=None, delete_type="InstanceDeletes"):

    if not delete and exist.delete:
        # We know we have a delete and we have it's id
        delete = exist.delete
    elif not delete:
        if exist.deleted_at:
            # We received this exists before the delete, go find it
            deletes = models.InstanceDeletes.find(exist.instance, dt.dt_from_decimal(exist.launched_at))
            if deletes.count() == 1:
                delete = deletes[0]
            else:
                query = {"instance": exist.instance, "launched_at": exist.launched_at}
                raise NotFound(delete_type, query)
        else:
            # We don't know if this is supposed to have a delete or not.
            # Thus, we need to check if we have a delete for this instance.
            # We need to be careful though, since we could be verifying an
            # exist event that we got before the delete. So, we restrict the
            # search to only deletes before this exist's audit period ended.
            # If we find any, we fail validation
            launched_at = dt.dt_from_decimal(exist.launched_at)
            deleted_at_max = dt.dt_from_decimal(exist.audit_period_ending)
            deletes = models.InstanceDeletes.find(exist.instance, launched_at, deleted_at_max)
            if deletes.count() > 0:
                reason = "Found %s for non-delete exist" % delete_type
                raise VerificationException(reason)

    if delete:
        if not base_verifier._verify_date_field(delete.launched_at, exist.launched_at, same_second=True):
            raise FieldMismatch("launched_at", exist.launched_at, delete.launched_at, exist.instance)

        if not base_verifier._verify_date_field(delete.deleted_at, exist.deleted_at, same_second=True):
            raise FieldMismatch("deleted_at", exist.deleted_at, delete.deleted_at, exist.instance)
예제 #2
0
def _verify_for_delete(exist, delete=None, delete_type="InstanceDeletes"):

    if not delete and exist.delete:
        # We know we have a delete and we have it's id
        delete = exist.delete
    elif not delete:
        if exist.deleted_at:
            # We received this exists before the delete, go find it
            deletes = models.InstanceDeletes.find(
                exist.instance, dt.dt_from_decimal(exist.launched_at))
            if deletes.count() == 1:
                delete = deletes[0]
            else:
                query = {
                    'instance': exist.instance,
                    'launched_at': exist.launched_at
                }
                raise NotFound(delete_type, query)
        else:
            # We don't know if this is supposed to have a delete or not.
            # Thus, we need to check if we have a delete for this instance.
            # We need to be careful though, since we could be verifying an
            # exist event that we got before the delete. So, we restrict the
            # search to only deletes before this exist's audit period ended.
            # If we find any, we fail validation
            launched_at = dt.dt_from_decimal(exist.launched_at)
            deleted_at_max = dt.dt_from_decimal(exist.audit_period_ending)
            deletes = models.InstanceDeletes.find(exist.instance, launched_at,
                                                  deleted_at_max)
            if deletes.count() > 0:
                reason = 'Found %s for non-delete exist' % delete_type
                raise VerificationException(reason)

    if delete:
        if not base_verifier._verify_date_field(
                delete.launched_at, exist.launched_at, same_second=True):
            raise FieldMismatch('launched_at', {
                'name': 'exists',
                'value': exist.launched_at
            }, {
                'name': 'deletes',
                'value': delete.launched_at
            }, exist.instance)

        if not base_verifier._verify_date_field(
                delete.deleted_at, exist.deleted_at, same_second=True):
            raise FieldMismatch('deleted_at', {
                'name': 'exists',
                'value': exist.deleted_at
            }, {
                'name': 'deletes',
                'value': delete.deleted_at
            }, exist.instance)
예제 #3
0
def _verify_field_mismatch(exists, launch):
    flavor_field_name = config.flavor_field_name()
    if not base_verifier._verify_date_field(
            launch.launched_at, exists.launched_at, same_second=True):
        raise FieldMismatch('launched_at', exists.launched_at,
                            launch.launched_at, exists.instance)

    if getattr(launch, flavor_field_name) != \
            getattr(exists, flavor_field_name):
        raise FieldMismatch(flavor_field_name,
                            getattr(exists, flavor_field_name),
                            getattr(launch, flavor_field_name),
                            exists.instance)

    if launch.tenant != exists.tenant:
        raise FieldMismatch('tenant', exists.tenant, launch.tenant,
                            exists.instance)

    if launch.rax_options != exists.rax_options:
        raise FieldMismatch('rax_options', exists.rax_options,
                            launch.rax_options, exists.instance)

    if launch.os_architecture != exists.os_architecture:
        raise FieldMismatch('os_architecture', exists.os_architecture,
                            launch.os_architecture, exists.instance)

    if launch.os_version != exists.os_version:
        raise FieldMismatch('os_version', exists.os_version, launch.os_version,
                            exists.instance)

    if launch.os_distro != exists.os_distro:
        raise FieldMismatch('os_distro', exists.os_distro, launch.os_distro,
                            exists.instance)
예제 #4
0
def _verify_field_mismatch(exists, launch):
    flavor_field_name = config.flavor_field_name()
    if not base_verifier._verify_date_field(
            launch.launched_at, exists.launched_at, same_second=True):
        raise FieldMismatch('launched_at', exists.launched_at,
                            launch.launched_at)

    if getattr(launch, flavor_field_name) != \
            getattr(exists, flavor_field_name):
        raise FieldMismatch(flavor_field_name,
                            getattr(exists, flavor_field_name),
                            getattr(launch, flavor_field_name))

    if launch.tenant != exists.tenant:
        raise FieldMismatch('tenant', exists.tenant,
                            launch.tenant)

    if launch.rax_options != exists.rax_options:
        raise FieldMismatch('rax_options', exists.rax_options,
                            launch.rax_options)

    if launch.os_architecture != exists.os_architecture:
        raise FieldMismatch('os_architecture', exists.os_architecture,
                            launch.os_architecture)

    if launch.os_version != exists.os_version:
        raise FieldMismatch('os_version', exists.os_version,
                            launch.os_version)

    if launch.os_distro != exists.os_distro:
        raise FieldMismatch('os_distro', exists.os_distro,
                            launch.os_distro)
예제 #5
0
def _verify_field_mismatch(exists, usage):
    if not base_verifier._verify_date_field(
            usage.created_at, exists.created_at, same_second=True):
        raise FieldMismatch('created_at', {
            'name': 'exists',
            'value': exists.created_at
        }, {
            'name': 'launches',
            'value': usage.created_at
        }, exists.uuid)

    if usage.owner != exists.owner:
        raise FieldMismatch('owner', {
            'name': 'exists',
            'value': exists.owner
        }, {
            'name': 'launches',
            'value': usage.owner
        }, exists.uuid)

    if usage.size != exists.size:
        raise FieldMismatch('size', {
            'name': 'exists',
            'value': exists.size
        }, {
            'name': 'launches',
            'value': usage.size
        }, exists.uuid)
예제 #6
0
def _verify_field_mismatch(exists, launch):
    if not base_verifier._verify_date_field(
            launch.launched_at, exists.launched_at, same_second=True):
        raise FieldMismatch('launched_at', exists.launched_at,
                            launch.launched_at)

    if launch.instance_type_id != exists.instance_type_id:
        raise FieldMismatch('instance_type_id', exists.instance_type_id,
                            launch.instance_type_id)

    if launch.tenant != exists.tenant:
        raise FieldMismatch('tenant', exists.tenant,
                            launch.tenant)

    if launch.rax_options != exists.rax_options:
        raise FieldMismatch('rax_options', exists.rax_options,
                            launch.rax_options)

    if launch.os_architecture != exists.os_architecture:
        raise FieldMismatch('os_architecture', exists.os_architecture,
                            launch.os_architecture)

    if launch.os_version != exists.os_version:
        raise FieldMismatch('os_version', exists.os_version,
                            launch.os_version)

    if launch.os_distro != exists.os_distro:
        raise FieldMismatch('os_distro', exists.os_distro,
                            launch.os_distro)
예제 #7
0
def _verify_field_mismatch(exists, usage):
    if not base_verifier._verify_date_field(
            usage.created_at, exists.created_at, same_second=True):
        raise FieldMismatch('created_at', exists.created_at, usage.created_at)

    if usage.owner != exists.owner:
        raise FieldMismatch('owner', exists.owner, usage.owner)

    if usage.size != exists.size:
        raise FieldMismatch('size', exists.size, usage.size)
예제 #8
0
def _verify_field_mismatch(exists, usage):
    if not base_verifier._verify_date_field(
            usage.created_at, exists.created_at, same_second=True):
        raise FieldMismatch('created_at', exists.created_at, usage.created_at,
                            exists.uuid)

    if usage.owner != exists.owner:
        raise FieldMismatch('owner', exists.owner, usage.owner, exists.uuid)

    if usage.size != exists.size:
        raise FieldMismatch('size', exists.size, usage.size, exists.uuid)
예제 #9
0
def _verify_field_mismatch(exists, launch):
    flavor_field_name = config.flavor_field_name()
    if not base_verifier._verify_date_field(
            launch.launched_at, exists.launched_at, same_second=True):
        raise FieldMismatch(
            'launched_at',
            {'name': 'exists', 'value': exists.launched_at},
            {'name': 'launches', 'value': launch.launched_at},
            exists.instance)

    if getattr(launch, flavor_field_name) != \
            getattr(exists, flavor_field_name):
        raise FieldMismatch(
            flavor_field_name,
            {'name': 'exists', 'value': getattr(exists, flavor_field_name)},
            {'name': 'launches', 'value': getattr(launch, flavor_field_name)},
            exists.instance)

    if launch.tenant != exists.tenant:
        raise FieldMismatch(
            'tenant',
            {'name': 'exists', 'value': exists.tenant},
            {'name': 'launches', 'value': launch.tenant},
            exists.instance)

    if launch.rax_options != exists.rax_options:
        raise FieldMismatch(
            'rax_options',
            {'name': 'exists', 'value': exists.rax_options},
            {'name': 'launches', 'value': launch.rax_options},
            exists.instance)

    if launch.os_architecture != exists.os_architecture:
        raise FieldMismatch(
            'os_architecture',
            {'name': 'exists', 'value': exists.os_architecture},
            {'name': 'launches', 'value': launch.os_architecture},
            exists.instance)

    if launch.os_version != exists.os_version:
        raise FieldMismatch(
            'os_version',
            {'name': 'exists', 'value': exists.os_version},
            {'name': 'launches', 'value': launch.os_version},
            exists.instance)

    if launch.os_distro != exists.os_distro:
        raise FieldMismatch(
            'os_distro',
            {'name': 'exists', 'value': exists.os_distro},
            {'name': 'launches', 'value': launch.os_distro},
            exists.instance)
예제 #10
0
def _verify_field_mismatch(exists, usage):
    if not base_verifier._verify_date_field(usage.created_at, exists.created_at, same_second=True):
        raise FieldMismatch(
            "created_at",
            {"name": "exists", "value": exists.created_at},
            {"name": "launches", "value": usage.created_at},
            exists.uuid,
        )

    if usage.owner != exists.owner:
        raise FieldMismatch(
            "owner", {"name": "exists", "value": exists.owner}, {"name": "launches", "value": usage.owner}, exists.uuid
        )

    if usage.size != exists.size:
        raise FieldMismatch(
            "size", {"name": "exists", "value": exists.size}, {"name": "launches", "value": usage.size}, exists.uuid
        )
예제 #11
0
def _verify_field_mismatch(exists, usage):
    if not base_verifier._verify_date_field(
            usage.created_at, exists.created_at, same_second=True):
        raise FieldMismatch(
            'created_at',
            {'name': 'exists', 'value': exists.created_at},
            {'name': 'launches', 'value': usage.created_at},
            exists.uuid)

    if usage.owner != exists.owner:
        raise FieldMismatch(
            'owner',
            {'name': 'exists', 'value': exists.owner},
            {'name': 'launches', 'value': usage.owner},
            exists.uuid)

    if usage.size != exists.size:
        raise FieldMismatch(
            'size',
            {'name': 'exists', 'value': exists.size},
            {'name': 'launches', 'value': usage.size},
            exists.uuid)
예제 #12
0
def _verify_field_mismatch(exists, launch):
    flavor_field_name = config.flavor_field_name()
    if not base_verifier._verify_date_field(launch.launched_at, exists.launched_at, same_second=True):
        raise FieldMismatch("launched_at", exists.launched_at, launch.launched_at, exists.instance)

    if getattr(launch, flavor_field_name) != getattr(exists, flavor_field_name):
        raise FieldMismatch(
            flavor_field_name, getattr(exists, flavor_field_name), getattr(launch, flavor_field_name), exists.instance
        )

    if launch.tenant != exists.tenant:
        raise FieldMismatch("tenant", exists.tenant, launch.tenant, exists.instance)

    if launch.rax_options != exists.rax_options:
        raise FieldMismatch("rax_options", exists.rax_options, launch.rax_options, exists.instance)

    if launch.os_architecture != exists.os_architecture:
        raise FieldMismatch("os_architecture", exists.os_architecture, launch.os_architecture, exists.instance)

    if launch.os_version != exists.os_version:
        raise FieldMismatch("os_version", exists.os_version, launch.os_version, exists.instance)

    if launch.os_distro != exists.os_distro:
        raise FieldMismatch("os_distro", exists.os_distro, launch.os_distro, exists.instance)