/** * Create a new NeutronSecurityGroup and create the NeutronSecurityRules passed in. This method will first create * teh NeutronSecurityRules and then the NeutronSecurityGroup in md-sal. * @param tenantId The tenant ID for both the rules and groups * @param rules NeutronSecurityRules. You can create them with buildNeutronSecurityRule. * @return A new NeutronSecurityGroup */ public NeutronSecurityGroup createNeutronSecurityGroup(String tenantId, NeutronSecurityRule... rules) { INeutronSecurityGroupCRUD groupCRUD = (INeutronSecurityGroupCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityGroupCRUD.class, this); INeutronSecurityRuleCRUD ruleCRUD = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this); String id = UUID.randomUUID().toString(); NeutronSecurityGroup sg = new NeutronSecurityGroup(); sg.setSecurityGroupName("SG-" + id); sg.setID(id); sg.setSecurityGroupTenantID(tenantId); List<NeutronSecurityRule> ruleList = new ArrayList<>(rules.length); for (NeutronSecurityRule rule : rules) { rule.setSecurityRuleTenantID(tenantId); rule.setSecurityRuleGroupID(id); ruleList.add(rule); ruleCRUD.addNeutronSecurityRule(rule); } groupCRUD.addNeutronSecurityGroup(sg); return sg; }
protected NeutronSecurityGroup fromMd(SecurityGroup group) { NeutronSecurityGroup answer = new NeutronSecurityGroup(); if (group.getName() != null) { answer.setSecurityGroupName(group.getName()); } if (group.getTenantId() != null) { answer.setSecurityGroupTenantID(group.getTenantId().getValue().replace("-","")); } if (group.getUuid() != null) { answer.setID(group.getUuid().getValue()); } return answer; }
private NeutronSecurityGroup fromMd(SecurityGroup group) { NeutronSecurityGroup answer = new NeutronSecurityGroup(); if (group.getName() != null) { answer.setSecurityGroupName(group.getName()); } if (group.getTenantId() != null) { answer.setSecurityGroupTenantID(group.getTenantId().getValue() .replace("-", "")); } if (group.getUuid() != null) { answer.setID(group.getUuid().getValue()); } return answer; }
public NeutronSecurityGroup extractFields(List<String> fields) { NeutronSecurityGroup ans = new NeutronSecurityGroup (); for (String s : fields) { switch (s) { case "id": ans.setID(this.getID()); break; case "name": ans.setSecurityGroupName(this.getSecurityGroupName()); break; case "description": ans.setSecurityGroupDescription(this.getSecurityGroupDescription()); break; case "tenant_id": ans.setSecurityGroupTenantID(this.getSecurityGroupTenantID()); break; } } return ans; }