Пример #1
0
def _check_port_bound_sg(context, sg_id, port_id):
    try:
        db_utils.model_query(context, sg_db.SecurityGroupPortBinding)\
            .filter_by(security_group_id=sg_id, port_id=port_id).one()
    except orm_exc.NoResultFound:
        raise log_exc.InvalidResourceConstraint(resource='security_group',
                                                resource_id=sg_id,
                                                target_resource='port',
                                                target_id=port_id)
Пример #2
0
def _check_target_resource_bound_fwg(context, fwg_id, target_id):
    ports = fwg_plugin.driver.firewall_db.get_ports_in_firewall_group(
        context=context, firewall_group_id=fwg_id)
    if target_id not in ports:
        raise log_exc.InvalidResourceConstraint(
            resource=log_const.FIREWALL_GROUP,
            resource_id=fwg_id,
            target_resource=log_const.TARGET_RESOURCE,
            target_id=target_id)