private SelectorName getSelectorNameWithProvider(SecurityRule secRule, Neutron neutron) { ClauseName clauseName = SecRuleNameDecoder.getClauseName(secRule); Uuid providerSecGroupId = secRule.getSecurityGroupId(); // we cannot use name of security group in selector, because name can be changed // therefore name is used only in debug mode if (NeutronMapperModule.isDebugEnabled()) { Optional<SecurityGroup> potentialProviderSecGroup = SecurityGroupUtils.findSecurityGroup(secRule.getSecurityGroupId(), neutron.getSecurityGroups()); if (!potentialProviderSecGroup.isPresent()) { LOG.error("Neutron Security Group with UUID {} does not exist but it is in {}", providerSecGroupId.getValue(), secRule); throw new IllegalStateException( "Neutron Security Group with UUID " + providerSecGroupId.getValue() + " does not exist."); } String selectorName = new StringBuilder().append(clauseName.getValue()) .append(MappingUtils.NAME_DOUBLE_DELIMETER) .append(PROVIDED_BY) .append(SecurityGroupUtils.getNameOrUuid(potentialProviderSecGroup.get())) .toString(); return new SelectorName(selectorName); } String selectorName = new StringBuilder().append(clauseName.getValue()) .append(MappingUtils.NAME_DOUBLE_DELIMETER) .append(PROVIDED_BY) .append(providerSecGroupId.getValue()) .toString(); return new SelectorName(selectorName); }
private SelectorName getSelectorNameWithConsumer(SecurityRule secRule, Neutron neutron) { ClauseName clauseName = SecRuleNameDecoder.getClauseName(secRule); StringBuilder selectorNameBuilder = new StringBuilder().append(clauseName.getValue()); Uuid consumerSecGroupId = secRule.getRemoteGroupId(); if (consumerSecGroupId == null) { return new SelectorName(selectorNameBuilder.toString()); } // we cannot use name of security group in selector, because name can be changed // therefore name is used only in debug mode if (NeutronMapperModule.isDebugEnabled()) { Optional<SecurityGroup> potentialConsumerSecGroup = SecurityGroupUtils.findSecurityGroup(secRule.getRemoteGroupId(), neutron.getSecurityGroups()); if (!potentialConsumerSecGroup.isPresent()) { LOG.error("Neutron Security Group with UUID {} does not exist but it is in {}", consumerSecGroupId.getValue(), secRule); throw new IllegalStateException( "Neutron Security Group with UUID " + consumerSecGroupId.getValue() + " does not exist."); } selectorNameBuilder.append(MappingUtils.NAME_DOUBLE_DELIMETER) .append(POSSIBLE_CONSUMER) .append(SecurityGroupUtils.getNameOrUuid(potentialConsumerSecGroup.get())); return new SelectorName(selectorNameBuilder.toString()); } selectorNameBuilder.append(MappingUtils.NAME_DOUBLE_DELIMETER) .append(POSSIBLE_CONSUMER) .append(consumerSecGroupId.getValue()); return new SelectorName(selectorNameBuilder.toString()); }
LOG.debug("Clause {} in contract {} has no Subject Ref", clause.getName().getValue(), contract.getId() .getValue()); continue;