diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2017-03-03 12:51:13 -0500 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2017-03-03 12:57:20 -0500 |
commit | 2e87b3421f826b345e4422524c312cc88e2e10d7 (patch) | |
tree | 56fcbf6dc45b5bb35dc86461fff7ca240de410a7 | |
parent | 828fb05f1efb4e022dd6dc6b9e5d3ac4136371e5 (diff) |
update hardcoded policies with latest template.
Change-Id: Ic57aae242f8a038527e3b4eeac98f3cf3f7f1b0b
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
8 files changed, 89 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore index 0a3f5aeef..3852641d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store .project .settings .classpath diff --git a/packages/base/src/files/install/mysql/data/161000_upgrade_script.sql b/packages/base/src/files/install/mysql/data/161000_upgrade_script.sql index 94e371649..45effa503 100644 --- a/packages/base/src/files/install/mysql/data/161000_upgrade_script.sql +++ b/packages/base/src/files/install/mysql/data/161000_upgrade_script.sql @@ -6429,13 +6429,19 @@ INSERT INTO `microservicelocation` VALUES (1,'SampleServiceLocation','demo'); INSERT INTO `risktype` VALUES (1,'demo','2016-12-29 20:20:48','demo','SampleRiskType','demo','2016-12-29 20:20:48'); -INSERT INTO `policyentity` VALUES (3153,'doACPolicyPut','2017-02-09 17:13:37',0,'vFW Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:','doACPolicyPut','2017-02-09 17:13:37','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:708de148-2cfb-4211-930a-44b446c2d781\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>vFW Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:817128cd-2880-4e85-997b-1abff0eae822\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"BRMSPARAMID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"key:controller\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">vFW</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml',0,'com',1,NULL,3152),(3155,'doACPolicyPut','2017-02-09 17:16:17',0,'vLB Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:','doACPolicyPut','2017-02-09 17:16:17','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:95afb43f-13f2-475c-9501-7e022d15b8a7\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>vLB Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:69f687f8-1f6e-485f-a4e8-5cb9beb28ba4\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"BRMSPARAMID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"key:controller\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">vDNS</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml',0,'com',1,NULL,3154),(3157,'doACPolicyPut','2017-02-09 17:19:38',0,'Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:','doACPolicyPut','2017-02-09 17:19:38','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:a1c91d9b-b5d2-4b04-b3a9-afcac74a8161\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vFirewall.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"service\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"uuid\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"location\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:2af7b2a1-6427-4765-ac5f-0d5e3c7d059f\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"MSID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_MS_vFirewall.1.json</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vFirewall.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:service\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:uuid\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:Location\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"Priority\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_MS_vFirewall.1.xml',0,'com',1,NULL,3156),(3159,'doACPolicyPut','2017-02-09 17:21:15',0,'Micro Service vLoadBalancer Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:','doACPolicyPut','2017-02-09 17:21:15','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:4fd0d4bd-729b-42dd-9c39-d63fea7c9655\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>Micro Service vLoadBalancer Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vLoadBalancer.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"service\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"uuid\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"location\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:69d31737-09d4-429f-9e1d-6bcf39da90a1\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"MSID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_MS_vLoadBalancer.1.json</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vLoadBalancer.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:service\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:uuid\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:Location\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"Priority\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_MS_vLoadBalancer.1.xml',0,'com',1,NULL,3158); +INSERT INTO `policyentity` VALUES (3152,'doACPolicyPut','2017-03-03 17:16:27',0,'BRMSParamvFWDemoPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-03 17:16:27','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:f8ba1b97-fea0-431b-9c5b-8f0fa572b337\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>BRMSParamvFWDemoPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:9a371467-7775-47de-afa7-e1dbcdaf6594\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"BRMSPARAMID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"key:controller\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">vFW</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml',0,'com',1,NULL,3151),(3154,'doACPolicyPut','2017-03-03 17:20:01',0,'vLB Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-03 17:20:01','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:8b7dd2ad-00d0-4e85-97ce-f915322c9023\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>vLB Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:d35c6a55-3fc2-420e-b426-080a680bce62\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"BRMSPARAMID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DROOLS</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">BRMS_PARAM_RULE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"key:controller\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">vDNS</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml',0,'com',1,NULL,3153); -INSERT INTO `configurationdataentity` VALUES (3152,'/* Autogenerated Code Please Don\'t change/remove this comment section. This is for the UI purpose. \n <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$> \n */ \n\r\n\r\n/*-\r\n * ============LICENSE_START=======================================================\r\n * archetype-closed-loop-demo-rules\r\n * ================================================================================\r\n * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r\n * ================================================================================\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n * \r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n * \r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n * ============LICENSE_END=========================================================\r\n */\r\n\r\npackage org.openecomp.policy.controlloop;\r\n\r\nimport java.util.LinkedList;\r\nimport java.util.Map;\r\nimport java.util.HashMap;\r\nimport java.util.UUID;\r\n\r\nimport org.openecomp.policy.controlloop.VirtualControlLoopEvent;\r\nimport org.openecomp.policy.controlloop.ControlLoopEventStatus;\r\nimport org.openecomp.policy.controlloop.VirtualControlLoopNotification;\r\nimport org.openecomp.policy.controlloop.ControlLoopNotificationType;\r\nimport org.openecomp.policy.controlloop.ControlLoopOperation;\r\nimport org.openecomp.policy.controlloop.ControlLoopOperationWrapper;\r\nimport org.openecomp.policy.template.demo.ControlLoopException;\r\n\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Request;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Response;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;\r\nimport org.openecomp.policy.aai.util.Serialization;\r\n\r\nimport org.openecomp.policy.appc.CommonHeader;\r\nimport org.openecomp.policy.appc.Request;\r\nimport org.openecomp.policy.appc.Response;\r\nimport org.openecomp.policy.appc.ResponseCode;\r\nimport org.openecomp.policy.appc.ResponseStatus;\r\nimport org.openecomp.policy.appc.ResponseValue;\r\n\r\nimport org.openecomp.policy.template.demo.EventManager;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGRequest;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGStream;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGStreams;\r\n\r\nimport org.openecomp.policy.mso.MSOManager;\r\nimport org.openecomp.policy.mso.MSORequest;\r\nimport org.openecomp.policy.mso.MSORequestStatus;\r\nimport org.openecomp.policy.mso.MSORequestDetails;\r\nimport org.openecomp.policy.mso.MSOModelInfo;\r\nimport org.openecomp.policy.mso.MSOCloudConfiguration;\r\nimport org.openecomp.policy.mso.MSORequestInfo;\r\nimport org.openecomp.policy.mso.MSORequestParameters;\r\nimport org.openecomp.policy.mso.MSORelatedInstanceListElement;\r\nimport org.openecomp.policy.mso.MSORelatedInstance;\r\nimport org.openecomp.policy.mso.MSOResponse;\r\n\r\nimport org.openecomp.policy.drools.system.PolicyEngine;\r\n\r\n//\r\n// These parameters are required to build the runtime policy\r\n//\r\ndeclare Params\r\n closedLoopControlName : String\r\n actor : String\r\n aaiURL : String\r\n aaiUsername : String\r\n aaiPassword : String\r\n msoURL : String\r\n msoUsername : String\r\n msoPassword : String\r\n aaiNamedQueryUUID : String\r\n aaiPatternMatch : int \r\n notificationTopic : String\r\n appcTopic : String\r\nend\r\n\r\n/*\r\n*\r\n* Called once and only once to insert the parameters into working memory for this Closed Loop policy.\r\n* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)\r\n*\r\n*\r\n*rule \"BRMSParamvFWDemoPolicy.SETUP\"\r\n* when\r\n* then\r\n* System.out.println(\"rule SETUP is triggered.\");\r\n* Params params = new Params();\r\n* params.setClosedLoopControlName(\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\r\n* params.setActor(\"APPC\");\r\n* params.setAaiURL(\"null\");\r\n* params.setAaiUsername(\"null\");\r\n* params.setAaiPassword(\"null\");\r\n* params.setMsoURL(\"null\");\r\n* params.setMsoUsername(\"null\");\r\n* params.setMsoPassword(\"null\");\r\n* params.setAaiNamedQueryUUID(\"null\");\r\n* params.setAaiPatternMatch(1);\r\n* params.setNotificationTopic(\"POLICY-CL-MGT\");\r\n* params.setAppcTopic(\"APPC-CL\");\r\n* //\r\n* // This stays in memory as long as the rule is alive and running\r\n* //\r\n* insert(params);\r\n*end\r\n*/\r\n/*\r\n*\r\n* This rule responds to DCAE Events\r\n*\r\n*/\r\nrule \"BRMSParamvFWDemoPolicy.EVENT\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))\r\n then\r\n System.out.println(\"rule EVENT is triggered.\");\r\n try {\r\n // \r\n // Check the requestID in the event to make sure it is not null before we create the EventManager. \r\n // The EventManager will do extra syntax checking as well check if the closed loop is disabled/\r\n //\r\n if ($event.requestID == null) {\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.from = \"policy\";\r\n notification.message = \"Missing requestID from DCAE event\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n }\r\n //\r\n // Retract it from memory\r\n //\r\n retract($event);\r\n System.out.println(\"Event with requestID=null has been retracted.\");\r\n } else {\r\n //\r\n // Create an EventManager\r\n //\r\n EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);\r\n //\r\n // Determine if EventManager can actively process the event (i.e. syntax)\r\n //\r\n VirtualControlLoopNotification notification = manager.activate($event);\r\n notification.from = \"policy\"; \r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n // Are we actively pursuing this event?\r\n //\r\n if (notification.notification == ControlLoopNotificationType.ACTIVE) {\r\n //\r\n // Insert Event Manager into memory, this will now kick off processing.\r\n //\r\n insert(manager);\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n } \r\n } else {\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n }\r\n //\r\n // Retract it from memory\r\n //\r\n retract($event);\r\n }\r\n //\r\n // Now that the manager is inserted into Drools working memory, we\'ll wait for\r\n // another rule to fire in order to continue processing. This way we can also\r\n // then screen for additional ONSET and ABATED events for this same RequestIDs \r\n // and for different RequestIDs but with the same closedLoopControlName and target.\r\n //\r\n }\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.message = \"Exception occurred \" + e.getMessage();\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n //\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n // Retract the event\r\n //\r\n retract($event);\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager\r\n* is created. We can start the operations for this closed loop.\r\n*\r\n*/\r\nrule \"BRMSParamvFWDemoPolicy.EVENT.MANAGER\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER is triggered.\");\r\n //\r\n // Check which event this is.\r\n //\r\n EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);\r\n //\r\n // We only want the initial ONSET event in memory,\r\n // all the other events need to be retracted to support\r\n // cleanup and avoid the other rules being fired for this event.\r\n //\r\n if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {\r\n System.out.println(\"Retracting \"+eventStatus+\" Event.\");\r\n retract($event);\r\n return;\r\n }\r\n //\r\n // Now the event in memory is first onset event\r\n //\r\n try {\r\n //\r\n // Pull the known AAI field from the Event\r\n //\r\n // generic-vnf is needed for vFirewall case\r\n // vserver-name is needed for vLoadBalancer case\r\n //\r\n String genericVNF = $event.AAI.get(\"generic-vnf.vnf-id\");\r\n String vserver = $event.AAI.get(\"vserver.vserver-name\");\r\n //\r\n // Check if we are implementing a simple pattern match.\r\n //\r\n if ($params.getAaiPatternMatch() == 1) {\r\n //\r\n // Yes\r\n //\r\n //Basic naming characteristics:\r\n //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)\r\n //Example: \r\n //VF Name (9 characters): cscf0001v\r\n //VM Name(13 characters): cscf0001vm001\r\n //VFC name(19 characters): cscf0001vm001cfg001\r\n //\r\n // zdfw1fwl01fwl02 or zdfw1fwl01fwl01 \r\n // replaced with\r\n // zdfw1fwl01pgn02 or zdfw1fwl01pgn01\r\n //\r\n int index = genericVNF.lastIndexOf(\"fwl\");\r\n if (index == -1) {\r\n System.err.println(\"The generic-vnf.vnf-id from DCAE Event is not valid.\");\r\n } else {\r\n genericVNF = genericVNF.substring(0, index) + \"pgn\" + genericVNF.substring(index+\"fwl\".length());\r\n }\r\n //\r\n // Construct an APPC request\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"ModifyConfig\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // insert operationWrapper into memory\r\n //\r\n insert(operationWrapper);\r\n //\r\n Request request = new Request();\r\n request.CommonHeader = new CommonHeader();\r\n request.CommonHeader.RequestID = $event.requestID;\r\n request.Action = operation.operation;\r\n request.Payload = new HashMap<String, Object>();\r\n //\r\n // Fill in the payload\r\n //\r\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\r\n //\r\n PGRequest pgRequest = new PGRequest();\r\n pgRequest.pgStreams = new PGStreams();\r\n \r\n PGStream pgStream;\r\n for(int i = 0; i < 5; i++){\r\n pgStream = new PGStream();\r\n pgStream.streamId = \"fw_udp\"+(i+1);\r\n pgStream.isEnabled = \"true\";\r\n pgRequest.pgStreams.pgStream.add(pgStream);\r\n }\r\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\r\n \r\n if (request != null) {\r\n //\r\n // Insert request into memory\r\n //\r\n insert(request);\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n // message and history ??\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Now send the operation request\r\n //\r\n if (request instanceof Request) {\r\n try {\r\n System.out.println(\"APPC request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver request: \" + request);\r\n }\r\n }\r\n } else {\r\n //\r\n // what happens if it is null\r\n //\r\n }\r\n //\r\n } else {\r\n //\r\n // create AAI named-query request with UUID started with \"F199\"\r\n //\r\n AAINQF199Request aainqf199request = new AAINQF199Request();\r\n AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();\r\n AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();\r\n AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();\r\n //\r\n // queryParameters\r\n //\r\n aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); \r\n aainqf199queryparam.namedQuery = aainqf199namedquery;\r\n aainqf199request.queryParameters = aainqf199queryparam;\r\n //\r\n // instanceFilters\r\n //\r\n Map aainqf199instancefiltermap = new HashMap();\r\n Map aainqf199instancefiltermapitem = new HashMap();\r\n aainqf199instancefiltermapitem.put(\"vserver-name\", vserver); \r\n aainqf199instancefiltermap.put(\"vserver\", aainqf199instancefiltermapitem);\r\n aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);\r\n aainqf199request.instanceFilters = aainqf199instancefilter;\r\n //\r\n // print aainqf199request for debug\r\n //\r\n System.out.println(\"AAI Request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(aainqf199request));\r\n //\r\n // Create AAINQF199RequestWrapper\r\n //\r\n AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);\r\n //\r\n // insert aainqf199request into memory\r\n //\r\n insert(aainqf199RequestWrapper);\r\n }\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager\r\n* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.\r\n*\r\n*/\r\nrule \"BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER.AAINQF199REQUEST is triggered.\");\r\n //\r\n // send the request\r\n //\r\n AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),\r\n $aainqf199RequestWrapper.aainqf199request, $event.requestID);\r\n //\r\n // Check AAI response\r\n //\r\n if (aainqf199response == null) {\r\n System.err.println(\"Failed to get AAI response\");\r\n //\r\n // Fail and retract everything\r\n //\r\n retract($event);\r\n retract($manager);\r\n retract($aainqf199RequestWrapper);\r\n } else {\r\n //\r\n // Create AAINQF199ResponseWrapper\r\n //\r\n AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);\r\n //\r\n // insert aainqf199ResponseWrapper to memeory\r\n //\r\n insert(aainqf199ResponseWrapper);\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.\r\n*\r\n*/\r\nrule \"BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE\"\r\n when \r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\r\n $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.\");\r\n //\r\n // Extract related fields out of AAINQF199RESPONSE\r\n //\r\n String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, \r\n vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,\r\n serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,\r\n vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, \r\n vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;\r\n try {\r\n //\r\n // vnfItem\r\n //\r\n vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;\r\n vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;\r\n vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf(\"/\")+1);\r\n vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;\r\n vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;\r\n vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\r\n vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;\r\n vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // serviceItem\r\n //\r\n serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;\r\n serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;\r\n serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\r\n serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;\r\n serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;\r\n serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // This comes from the base module\r\n //\r\n vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;\r\n vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace(\"Vfmodule\", \"vDNS\");\r\n //\r\n // vfModuleItem - NOT the base module\r\n //\r\n vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;\r\n vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;\r\n vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;\r\n vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // tenantItem\r\n //\r\n tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;\r\n //\r\n // cloudRegionItem\r\n //\r\n cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.message = \"Exception occurred \" + e.getMessage();\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n notification.message = \"Invalid named-query response from AAI\";\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n // Retract everything\r\n //\r\n retract($aainqf199RequestWrapper);\r\n retract($aainqf199ResponseWrapper);\r\n retract($manager);\r\n retract($event);\r\n return;\r\n } \r\n //\r\n // Extracted fields should not be null\r\n //\r\n if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||\r\n (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||\r\n (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||\r\n (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||\r\n (serviceItemModelType == null) || (serviceItemModelVersion == null) ||\r\n (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||\r\n (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||\r\n (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||\r\n (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {\r\n //\r\n System.err.println(\"some fields are missing from AAI response.\");\r\n //\r\n // Fail and retract everything\r\n //\r\n retract($aainqf199RequestWrapper);\r\n retract($aainqf199ResponseWrapper);\r\n retract($manager);\r\n retract($event);\r\n return;\r\n }\r\n //\r\n // We don\'t need them any more\r\n //\r\n retract($aainqf199ResponseWrapper);\r\n retract($aainqf199RequestWrapper); \r\n //\r\n // check the actor of this closed loop\r\n //\r\n switch ($params.getActor()) {\r\n case \"APPC\":\r\n {\r\n //\r\n // Construct an APPC request\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"ModifyConfig\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // insert operationWrapper into memory\r\n //\r\n insert(operationWrapper);\r\n //\r\n Request request = new Request();\r\n request.CommonHeader = new CommonHeader();\r\n request.CommonHeader.RequestID = $event.requestID;\r\n request.Action = operation.operation;\r\n request.Payload = new HashMap<String, Object>();\r\n //\r\n // Fill in the payload\r\n // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case\r\n //\r\n String genericVNF = \"zdfw1fwl01pgn02\";\r\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\r\n //\r\n PGRequest pgRequest = new PGRequest();\r\n pgRequest.pgStreams = new PGStreams();\r\n \r\n PGStream pgStream;\r\n for(int i = 0; i < 5; i++){\r\n pgStream = new PGStream();\r\n pgStream.streamId = \"fw_udp\"+(i+1);\r\n pgStream.isEnabled = \"true\";\r\n pgRequest.pgStreams.pgStream.add(pgStream);\r\n }\r\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\r\n \r\n if (request != null) {\r\n //\r\n // Insert request into memory\r\n //\r\n insert(request);\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n // message and history ??\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Now send the operation request\r\n //\r\n if (request instanceof Request) {\r\n try {\r\n System.out.println(\"APPC request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver request: \" + request);\r\n }\r\n }\r\n } else {\r\n //\r\n // what happens if it is null\r\n //\r\n }\r\n }\r\n break;\r\n case \"MSO\":\r\n {\r\n //\r\n // Construct an operation\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"createModuleInstance\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // Construct an MSO request\r\n //\r\n MSORequest request = new MSORequest();\r\n request.requestDetails = new MSORequestDetails();\r\n request.requestDetails.modelInfo = new MSOModelInfo();\r\n request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();\r\n request.requestDetails.requestInfo = new MSORequestInfo();\r\n request.requestDetails.requestParameters = new MSORequestParameters();\r\n request.requestDetails.requestParameters.userParams = null;\r\n //\r\n // cloudConfiguration\r\n //\r\n request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;\r\n request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;\r\n //\r\n // modelInfo\r\n //\r\n request.requestDetails.modelInfo.modelType = \"vfModule\";\r\n request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;\r\n request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;\r\n request.requestDetails.modelInfo.modelName = vfModuleItemModelName;\r\n request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;\r\n //\r\n // requestInfo\r\n //\r\n request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;\r\n request.requestDetails.requestInfo.source = \"POLICY\";\r\n request.requestDetails.requestInfo.suppressRollback = false;\r\n //\r\n // relatedInstanceList\r\n //\r\n MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();\r\n MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();\r\n relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();\r\n relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();\r\n //\r\n relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelType = \"service\";\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;\r\n //\r\n relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelType = \"vnf\";\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;\r\n // \r\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);\r\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);\r\n //\r\n // print MSO request for debug\r\n //\r\n System.out.println(\"MSO request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n //\r\n //\r\n //\r\n if (request != null) {\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL\r\n //\r\n String MSOUrl = $params.getMsoURL() + \"/serviceInstances/v2/\" + serviceItemServiceInstanceId + \"/vnfs/\" + vnfItemVnfId + \"/vfModules\";\r\n //\r\n // Call MSO\r\n //\r\n MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);\r\n //\r\n if (response != null) {\r\n //\r\n // Assign requestId\r\n //\r\n request.requestId = $event.requestID.toString(); \r\n response.request.requestId = $event.requestID.toString();\r\n //\r\n // Insert facts\r\n //\r\n insert(operationWrapper);\r\n insert(request);\r\n insert(response);\r\n } else {\r\n //\r\n // MSO request not even accepted\r\n //\r\n notification.message = operationWrapper.operation.toMessage();\r\n operationWrapper.operation.message = operationWrapper.operation.toMessage();\r\n operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n notification.history.add(operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Retract everything\r\n //\r\n retract($event);\r\n retract($manager);\r\n }\r\n } else {\r\n System.err.println(\"constructed MSO request is invalid.\");\r\n }\r\n }\r\n break; \r\n } \r\nend\r\n \r\n/*\r\n*\r\n* This rule responds to APPC Response Events\r\n*\r\n*/\r\nrule \"BRMSParamvFWDemoPolicy.APPC.RESPONSE\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\r\n $request : Request( getCommonHeader().RequestID == $event.requestID )\r\n $response : Response( getCommonHeader().RequestID == $event.requestID ) \r\n then\r\n System.out.println(\"rule APPC.RESPONSE is triggered.\");\r\n if ($response.Status == null) {\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n } \r\n //\r\n // Get the Response Code\r\n //\r\n ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);\r\n if (code == null) {\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n }\r\n //\r\n // Construct notification\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n notification.message = $operationWrapper.operation.toMessage();\r\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\r\n //\r\n // Ok, let\'s figure out what APP-C\'s response is\r\n //\r\n switch (code) {\r\n case ACCEPT:\r\n $operationWrapper.operation.outcome = \"PROCESSING\";\r\n break;\r\n case ERROR:\r\n case REJECT:\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n break;\r\n case SUCCESS:\r\n $operationWrapper.operation.outcome = \"SUCCESS\";\r\n $manager.setControlLoopResult(\"SUCCESS\");\r\n break;\r\n case FAILURE:\r\n $operationWrapper.operation.outcome = \"FAILURE\";\r\n $manager.setControlLoopResult(\"FAILURE\");\r\n break;\r\n }\r\n if ($operationWrapper.operation.outcome.equals(\"SUCCESS\")) {\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n } else if ($operationWrapper.operation.outcome.equals(\"PROCESSING\")) {\r\n retract($response);\r\n } else {\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n }\r\n \r\nend \r\n\r\n/*\r\n*\r\n* This rule is used to clean up APPC response\r\n*\r\n*/ \r\nrule \"BRMSParamvFWDemoPolicy.APPC.RESPONSE.CLEANUP\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $response : Response($id : getCommonHeader().RequestID )\r\n not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) \r\n then\r\n System.out.println(\"rule APPC.RESPONSE.CLEANUP is triggered.\");\r\n retract($response);\r\nend\r\n\r\n/*\r\n*\r\n* This rule responds to MSO Response Events\r\n*\r\n*/\r\nrule \"BRMSParamvFWDemoPolicy.MSO.RESPONSE\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\r\n $request : MSORequest( requestId == $event.requestID.toString() )\r\n $response : MSOResponse( request.requestId == $event.requestID.toString() ) \r\n then\r\n System.out.println(\"rule MSO.RESPONSE is triggered.\");\r\n //\r\n // Construct notification\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n notification.message = $operationWrapper.operation.toMessage();\r\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\r\n //\r\n // The operation can either be succeeded or failed\r\n // \r\n if($response.request.requestStatus.requestState.equals(\"Completed\")) {\r\n $operationWrapper.operation.outcome = \"SUCCESS\";\r\n $manager.setControlLoopResult(\"SUCCESS\");\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n } else {\r\n $operationWrapper.operation.outcome = \"FAILURE\";\r\n $manager.setControlLoopResult(\"FAILURE\");\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n }\r\n \r\nend \nrule \"Params\" \n salience 1000 \n when\n then\n Params params = new Params();\n params.setAaiPatternMatch(1);\n params.setAppcTopic(\"APPC-CL\");\n params.setAaiURL(\"null\");\n params.setMsoPassword(\"null\");\n params.setClosedLoopControlName(\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\n params.setAaiUsername(\"null\");\n params.setMsoURL(\"null\");\n params.setActor(\"APPC\");\n params.setMsoUsername(\"null\");\n params.setAaiNamedQueryUUID(\"null\");\n params.setAaiPassword(\"null\");\n params.setNotificationTopic(\"POLICY-CL-MGT\");\n insert(params);\nend\r\n','OTHER','com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt','doACPolicyPut','2017-02-09 17:13:37',0,'','doACPolicyPut','2017-02-09 17:13:37',1),(3154,'/* Autogenerated Code Please Don\'t change/remove this comment section. This is for the UI purpose. \n <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$> \n */ \n\r\n\r\n/*-\r\n * ============LICENSE_START=======================================================\r\n * archetype-closed-loop-demo-rules\r\n * ================================================================================\r\n * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r\n * ================================================================================\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n * \r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n * \r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n * ============LICENSE_END=========================================================\r\n */\r\n\r\npackage org.openecomp.policy.controlloop;\r\n\r\nimport java.util.LinkedList;\r\nimport java.util.Map;\r\nimport java.util.HashMap;\r\nimport java.util.UUID;\r\n\r\nimport org.openecomp.policy.controlloop.VirtualControlLoopEvent;\r\nimport org.openecomp.policy.controlloop.ControlLoopEventStatus;\r\nimport org.openecomp.policy.controlloop.VirtualControlLoopNotification;\r\nimport org.openecomp.policy.controlloop.ControlLoopNotificationType;\r\nimport org.openecomp.policy.controlloop.ControlLoopOperation;\r\nimport org.openecomp.policy.controlloop.ControlLoopOperationWrapper;\r\nimport org.openecomp.policy.template.demo.ControlLoopException;\r\n\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Request;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Response;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;\r\nimport org.openecomp.policy.aai.util.Serialization;\r\n\r\nimport org.openecomp.policy.appc.CommonHeader;\r\nimport org.openecomp.policy.appc.Request;\r\nimport org.openecomp.policy.appc.Response;\r\nimport org.openecomp.policy.appc.ResponseCode;\r\nimport org.openecomp.policy.appc.ResponseStatus;\r\nimport org.openecomp.policy.appc.ResponseValue;\r\n\r\nimport org.openecomp.policy.template.demo.EventManager;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGRequest;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGStream;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGStreams;\r\n\r\nimport org.openecomp.policy.mso.MSOManager;\r\nimport org.openecomp.policy.mso.MSORequest;\r\nimport org.openecomp.policy.mso.MSORequestStatus;\r\nimport org.openecomp.policy.mso.MSORequestDetails;\r\nimport org.openecomp.policy.mso.MSOModelInfo;\r\nimport org.openecomp.policy.mso.MSOCloudConfiguration;\r\nimport org.openecomp.policy.mso.MSORequestInfo;\r\nimport org.openecomp.policy.mso.MSORequestParameters;\r\nimport org.openecomp.policy.mso.MSORelatedInstanceListElement;\r\nimport org.openecomp.policy.mso.MSORelatedInstance;\r\nimport org.openecomp.policy.mso.MSOResponse;\r\n\r\nimport org.openecomp.policy.drools.system.PolicyEngine;\r\n\r\n//\r\n// These parameters are required to build the runtime policy\r\n//\r\ndeclare Params\r\n closedLoopControlName : String\r\n actor : String\r\n aaiURL : String\r\n aaiUsername : String\r\n aaiPassword : String\r\n msoURL : String\r\n msoUsername : String\r\n msoPassword : String\r\n aaiNamedQueryUUID : String\r\n aaiPatternMatch : int \r\n notificationTopic : String\r\n appcTopic : String\r\nend\r\n\r\n/*\r\n*\r\n* Called once and only once to insert the parameters into working memory for this Closed Loop policy.\r\n* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)\r\n*\r\n*\r\n*rule \"BRMSParamvLBDemoPolicy.SETUP\"\r\n* when\r\n* then\r\n* System.out.println(\"rule SETUP is triggered.\");\r\n* Params params = new Params();\r\n* params.setClosedLoopControlName(\"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\r\n* params.setActor(\"MSO\");\r\n* params.setAaiURL(\"https://aai.api.simpledemo.openecomp.org:8443\");\r\n* params.setAaiUsername(\"POLICY\");\r\n* params.setAaiPassword(\"POLICY\");\r\n* params.setMsoURL(\"http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra\");\r\n* params.setMsoUsername(\"InfraPortalClient\");\r\n* params.setMsoPassword(\"password1$\");\r\n* params.setAaiNamedQueryUUID(\"f199cb88-5e69-4b1f-93e0-6f257877d066\");\r\n* params.setAaiPatternMatch(0);\r\n* params.setNotificationTopic(\"POLICY-CL-MGT\");\r\n* params.setAppcTopic(\"APPC-CL\");\r\n* //\r\n* // This stays in memory as long as the rule is alive and running\r\n* //\r\n* insert(params);\r\n*end\r\n*/\r\n/*\r\n*\r\n* This rule responds to DCAE Events\r\n*\r\n*/\r\nrule \"BRMSParamvLBDemoPolicy.EVENT\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))\r\n then\r\n System.out.println(\"rule EVENT is triggered.\");\r\n try {\r\n // \r\n // Check the requestID in the event to make sure it is not null before we create the EventManager. \r\n // The EventManager will do extra syntax checking as well check if the closed loop is disabled/\r\n //\r\n if ($event.requestID == null) {\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.from = \"policy\";\r\n notification.message = \"Missing requestID from DCAE event\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n }\r\n //\r\n // Retract it from memory\r\n //\r\n retract($event);\r\n System.out.println(\"Event with requestID=null has been retracted.\");\r\n } else {\r\n //\r\n // Create an EventManager\r\n //\r\n EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);\r\n //\r\n // Determine if EventManager can actively process the event (i.e. syntax)\r\n //\r\n VirtualControlLoopNotification notification = manager.activate($event);\r\n notification.from = \"policy\"; \r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n // Are we actively pursuing this event?\r\n //\r\n if (notification.notification == ControlLoopNotificationType.ACTIVE) {\r\n //\r\n // Insert Event Manager into memory, this will now kick off processing.\r\n //\r\n insert(manager);\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n } \r\n } else {\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n }\r\n //\r\n // Retract it from memory\r\n //\r\n retract($event);\r\n }\r\n //\r\n // Now that the manager is inserted into Drools working memory, we\'ll wait for\r\n // another rule to fire in order to continue processing. This way we can also\r\n // then screen for additional ONSET and ABATED events for this same RequestIDs \r\n // and for different RequestIDs but with the same closedLoopControlName and target.\r\n //\r\n }\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.message = \"Exception occurred \" + e.getMessage();\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n //\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n // Retract the event\r\n //\r\n retract($event);\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager\r\n* is created. We can start the operations for this closed loop.\r\n*\r\n*/\r\nrule \"BRMSParamvLBDemoPolicy.EVENT.MANAGER\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER is triggered.\");\r\n //\r\n // Check which event this is.\r\n //\r\n EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);\r\n //\r\n // We only want the initial ONSET event in memory,\r\n // all the other events need to be retracted to support\r\n // cleanup and avoid the other rules being fired for this event.\r\n //\r\n if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {\r\n System.out.println(\"Retracting \"+eventStatus+\" Event.\");\r\n retract($event);\r\n return;\r\n }\r\n //\r\n // Now the event in memory is first onset event\r\n //\r\n try {\r\n //\r\n // Pull the known AAI field from the Event\r\n //\r\n // generic-vnf is needed for vFirewall case\r\n // vserver-name is needed for vLoadBalancer case\r\n //\r\n String genericVNF = $event.AAI.get(\"generic-vnf.vnf-id\");\r\n String vserver = $event.AAI.get(\"vserver.vserver-name\");\r\n //\r\n // Check if we are implementing a simple pattern match.\r\n //\r\n if ($params.getAaiPatternMatch() == 1) {\r\n //\r\n // Yes\r\n //\r\n //Basic naming characteristics:\r\n //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)\r\n //Example: \r\n //VF Name (9 characters): cscf0001v\r\n //VM Name(13 characters): cscf0001vm001\r\n //VFC name(19 characters): cscf0001vm001cfg001\r\n //\r\n // zdfw1fwl01fwl02 or zdfw1fwl01fwl01 \r\n // replaced with\r\n // zdfw1fwl01pgn02 or zdfw1fwl01pgn01\r\n //\r\n int index = genericVNF.lastIndexOf(\"fwl\");\r\n if (index == -1) {\r\n System.err.println(\"The generic-vnf.vnf-id from DCAE Event is not valid.\");\r\n } else {\r\n genericVNF = genericVNF.substring(0, index) + \"pgn\" + genericVNF.substring(index+\"fwl\".length());\r\n }\r\n //\r\n // Construct an APPC request\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"ModifyConfig\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // insert operationWrapper into memory\r\n //\r\n insert(operationWrapper);\r\n //\r\n Request request = new Request();\r\n request.CommonHeader = new CommonHeader();\r\n request.CommonHeader.RequestID = $event.requestID;\r\n request.Action = operation.operation;\r\n request.Payload = new HashMap<String, Object>();\r\n //\r\n // Fill in the payload\r\n //\r\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\r\n //\r\n PGRequest pgRequest = new PGRequest();\r\n pgRequest.pgStreams = new PGStreams();\r\n \r\n PGStream pgStream;\r\n for(int i = 0; i < 5; i++){\r\n pgStream = new PGStream();\r\n pgStream.streamId = \"fw_udp\"+(i+1);\r\n pgStream.isEnabled = \"true\";\r\n pgRequest.pgStreams.pgStream.add(pgStream);\r\n }\r\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\r\n \r\n if (request != null) {\r\n //\r\n // Insert request into memory\r\n //\r\n insert(request);\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n // message and history ??\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Now send the operation request\r\n //\r\n if (request instanceof Request) {\r\n try {\r\n System.out.println(\"APPC request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver request: \" + request);\r\n }\r\n }\r\n } else {\r\n //\r\n // what happens if it is null\r\n //\r\n }\r\n //\r\n } else {\r\n //\r\n // create AAI named-query request with UUID started with \"F199\"\r\n //\r\n AAINQF199Request aainqf199request = new AAINQF199Request();\r\n AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();\r\n AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();\r\n AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();\r\n //\r\n // queryParameters\r\n //\r\n aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); \r\n aainqf199queryparam.namedQuery = aainqf199namedquery;\r\n aainqf199request.queryParameters = aainqf199queryparam;\r\n //\r\n // instanceFilters\r\n //\r\n Map aainqf199instancefiltermap = new HashMap();\r\n Map aainqf199instancefiltermapitem = new HashMap();\r\n aainqf199instancefiltermapitem.put(\"vserver-name\", vserver); \r\n aainqf199instancefiltermap.put(\"vserver\", aainqf199instancefiltermapitem);\r\n aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);\r\n aainqf199request.instanceFilters = aainqf199instancefilter;\r\n //\r\n // print aainqf199request for debug\r\n //\r\n System.out.println(\"AAI Request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(aainqf199request));\r\n //\r\n // Create AAINQF199RequestWrapper\r\n //\r\n AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);\r\n //\r\n // insert aainqf199request into memory\r\n //\r\n insert(aainqf199RequestWrapper);\r\n }\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager\r\n* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.\r\n*\r\n*/\r\nrule \"BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER.AAINQF199REQUEST is triggered.\");\r\n //\r\n // send the request\r\n //\r\n AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),\r\n $aainqf199RequestWrapper.aainqf199request, $event.requestID);\r\n //\r\n // Check AAI response\r\n //\r\n if (aainqf199response == null) {\r\n System.err.println(\"Failed to get AAI response\");\r\n //\r\n // Fail and retract everything\r\n //\r\n retract($event);\r\n retract($manager);\r\n retract($aainqf199RequestWrapper);\r\n } else {\r\n //\r\n // Create AAINQF199ResponseWrapper\r\n //\r\n AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);\r\n //\r\n // insert aainqf199ResponseWrapper to memeory\r\n //\r\n insert(aainqf199ResponseWrapper);\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.\r\n*\r\n*/\r\nrule \"BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE\"\r\n when \r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\r\n $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.\");\r\n //\r\n // Extract related fields out of AAINQF199RESPONSE\r\n //\r\n String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, \r\n vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,\r\n serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,\r\n vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, \r\n vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;\r\n try {\r\n //\r\n // vnfItem\r\n //\r\n vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;\r\n vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;\r\n vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf(\"/\")+1);\r\n vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;\r\n vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;\r\n vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\r\n vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;\r\n vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // serviceItem\r\n //\r\n serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;\r\n serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;\r\n serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\r\n serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;\r\n serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;\r\n serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // This comes from the base module\r\n //\r\n vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;\r\n vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace(\"Vfmodule\", \"vDNS\");\r\n //\r\n // vfModuleItem - NOT the base module\r\n //\r\n vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;\r\n vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;\r\n vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;\r\n vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // tenantItem\r\n //\r\n tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;\r\n //\r\n // cloudRegionItem\r\n //\r\n cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.message = \"Exception occurred \" + e.getMessage();\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n notification.message = \"Invalid named-query response from AAI\";\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n // Retract everything\r\n //\r\n retract($aainqf199RequestWrapper);\r\n retract($aainqf199ResponseWrapper);\r\n retract($manager);\r\n retract($event);\r\n return;\r\n } \r\n //\r\n // Extracted fields should not be null\r\n //\r\n if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||\r\n (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||\r\n (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||\r\n (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||\r\n (serviceItemModelType == null) || (serviceItemModelVersion == null) ||\r\n (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||\r\n (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||\r\n (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||\r\n (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {\r\n //\r\n System.err.println(\"some fields are missing from AAI response.\");\r\n //\r\n // Fail and retract everything\r\n //\r\n retract($aainqf199RequestWrapper);\r\n retract($aainqf199ResponseWrapper);\r\n retract($manager);\r\n retract($event);\r\n return;\r\n }\r\n //\r\n // We don\'t need them any more\r\n //\r\n retract($aainqf199ResponseWrapper);\r\n retract($aainqf199RequestWrapper); \r\n //\r\n // check the actor of this closed loop\r\n //\r\n switch ($params.getActor()) {\r\n case \"APPC\":\r\n {\r\n //\r\n // Construct an APPC request\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"ModifyConfig\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // insert operationWrapper into memory\r\n //\r\n insert(operationWrapper);\r\n //\r\n Request request = new Request();\r\n request.CommonHeader = new CommonHeader();\r\n request.CommonHeader.RequestID = $event.requestID;\r\n request.Action = operation.operation;\r\n request.Payload = new HashMap<String, Object>();\r\n //\r\n // Fill in the payload\r\n // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case\r\n //\r\n String genericVNF = \"zdfw1fwl01pgn02\";\r\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\r\n //\r\n PGRequest pgRequest = new PGRequest();\r\n pgRequest.pgStreams = new PGStreams();\r\n \r\n PGStream pgStream;\r\n for(int i = 0; i < 5; i++){\r\n pgStream = new PGStream();\r\n pgStream.streamId = \"fw_udp\"+(i+1);\r\n pgStream.isEnabled = \"true\";\r\n pgRequest.pgStreams.pgStream.add(pgStream);\r\n }\r\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\r\n \r\n if (request != null) {\r\n //\r\n // Insert request into memory\r\n //\r\n insert(request);\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n // message and history ??\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Now send the operation request\r\n //\r\n if (request instanceof Request) {\r\n try {\r\n System.out.println(\"APPC request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver request: \" + request);\r\n }\r\n }\r\n } else {\r\n //\r\n // what happens if it is null\r\n //\r\n }\r\n }\r\n break;\r\n case \"MSO\":\r\n {\r\n //\r\n // Construct an operation\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"createModuleInstance\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // Construct an MSO request\r\n //\r\n MSORequest request = new MSORequest();\r\n request.requestDetails = new MSORequestDetails();\r\n request.requestDetails.modelInfo = new MSOModelInfo();\r\n request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();\r\n request.requestDetails.requestInfo = new MSORequestInfo();\r\n request.requestDetails.requestParameters = new MSORequestParameters();\r\n request.requestDetails.requestParameters.userParams = null;\r\n //\r\n // cloudConfiguration\r\n //\r\n request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;\r\n request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;\r\n //\r\n // modelInfo\r\n //\r\n request.requestDetails.modelInfo.modelType = \"vfModule\";\r\n request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;\r\n request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;\r\n request.requestDetails.modelInfo.modelName = vfModuleItemModelName;\r\n request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;\r\n //\r\n // requestInfo\r\n //\r\n request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;\r\n request.requestDetails.requestInfo.source = \"POLICY\";\r\n request.requestDetails.requestInfo.suppressRollback = false;\r\n //\r\n // relatedInstanceList\r\n //\r\n MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();\r\n MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();\r\n relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();\r\n relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();\r\n //\r\n relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelType = \"service\";\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;\r\n //\r\n relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelType = \"vnf\";\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;\r\n // \r\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);\r\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);\r\n //\r\n // print MSO request for debug\r\n //\r\n System.out.println(\"MSO request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n //\r\n //\r\n //\r\n if (request != null) {\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL\r\n //\r\n String MSOUrl = $params.getMsoURL() + \"/serviceInstances/v2/\" + serviceItemServiceInstanceId + \"/vnfs/\" + vnfItemVnfId + \"/vfModules\";\r\n //\r\n // Call MSO\r\n //\r\n MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);\r\n //\r\n if (response != null) {\r\n //\r\n // Assign requestId\r\n //\r\n request.requestId = $event.requestID.toString(); \r\n response.request.requestId = $event.requestID.toString();\r\n //\r\n // Insert facts\r\n //\r\n insert(operationWrapper);\r\n insert(request);\r\n insert(response);\r\n } else {\r\n //\r\n // MSO request not even accepted\r\n //\r\n notification.message = operationWrapper.operation.toMessage();\r\n operationWrapper.operation.message = operationWrapper.operation.toMessage();\r\n operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n notification.history.add(operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Retract everything\r\n //\r\n retract($event);\r\n retract($manager);\r\n }\r\n } else {\r\n System.err.println(\"constructed MSO request is invalid.\");\r\n }\r\n }\r\n break; \r\n } \r\nend\r\n \r\n/*\r\n*\r\n* This rule responds to APPC Response Events\r\n*\r\n*/\r\nrule \"BRMSParamvLBDemoPolicy.APPC.RESPONSE\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\r\n $request : Request( getCommonHeader().RequestID == $event.requestID )\r\n $response : Response( getCommonHeader().RequestID == $event.requestID ) \r\n then\r\n System.out.println(\"rule APPC.RESPONSE is triggered.\");\r\n if ($response.Status == null) {\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n } \r\n //\r\n // Get the Response Code\r\n //\r\n ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);\r\n if (code == null) {\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n }\r\n //\r\n // Construct notification\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n notification.message = $operationWrapper.operation.toMessage();\r\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\r\n //\r\n // Ok, let\'s figure out what APP-C\'s response is\r\n //\r\n switch (code) {\r\n case ACCEPT:\r\n $operationWrapper.operation.outcome = \"PROCESSING\";\r\n break;\r\n case ERROR:\r\n case REJECT:\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n break;\r\n case SUCCESS:\r\n $operationWrapper.operation.outcome = \"SUCCESS\";\r\n $manager.setControlLoopResult(\"SUCCESS\");\r\n break;\r\n case FAILURE:\r\n $operationWrapper.operation.outcome = \"FAILURE\";\r\n $manager.setControlLoopResult(\"FAILURE\");\r\n break;\r\n }\r\n if ($operationWrapper.operation.outcome.equals(\"SUCCESS\")) {\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n } else if ($operationWrapper.operation.outcome.equals(\"PROCESSING\")) {\r\n retract($response);\r\n } else {\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n }\r\n \r\nend \r\n\r\n/*\r\n*\r\n* This rule is used to clean up APPC response\r\n*\r\n*/ \r\nrule \"BRMSParamvLBDemoPolicy.APPC.RESPONSE.CLEANUP\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $response : Response($id : getCommonHeader().RequestID )\r\n not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) \r\n then\r\n System.out.println(\"rule APPC.RESPONSE.CLEANUP is triggered.\");\r\n retract($response);\r\nend\r\n\r\n/*\r\n*\r\n* This rule responds to MSO Response Events\r\n*\r\n*/\r\nrule \"BRMSParamvLBDemoPolicy.MSO.RESPONSE\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\r\n $request : MSORequest( requestId == $event.requestID.toString() )\r\n $response : MSOResponse( request.requestId == $event.requestID.toString() ) \r\n then\r\n System.out.println(\"rule MSO.RESPONSE is triggered.\");\r\n //\r\n // Construct notification\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"com\";\r\n notification.policyVersion = \"1\";\r\n notification.message = $operationWrapper.operation.toMessage();\r\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\r\n //\r\n // The operation can either be succeeded or failed\r\n // \r\n if($response.request.requestStatus.requestState.equals(\"Completed\")) {\r\n $operationWrapper.operation.outcome = \"SUCCESS\";\r\n $manager.setControlLoopResult(\"SUCCESS\");\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n } else {\r\n $operationWrapper.operation.outcome = \"FAILURE\";\r\n $manager.setControlLoopResult(\"FAILURE\");\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n }\r\n \r\nend \nrule \"Params\" \n salience 1000 \n when\n then\n Params params = new Params();\n params.setAaiPatternMatch(0);\n params.setAppcTopic(\"APPC-CL\");\n params.setAaiURL(\"https://aai.api.simpledemo.openecomp.org:8443\");\n params.setMsoPassword(\"password1$\");\n params.setClosedLoopControlName(\"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\n params.setAaiUsername(\"POLICY\");\n params.setMsoURL(\"http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra\");\n params.setActor(\"MSO\");\n params.setMsoUsername(\"InfraPortalClient\");\n params.setAaiNamedQueryUUID(\"f199cb88-5e69-4b1f-93e0-6f257877d066\");\n params.setAaiPassword(\"POLICY\");\n params.setNotificationTopic(\"POLICY-CL-MGT\");\n insert(params);\nend\r\n','OTHER','com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt','doACPolicyPut','2017-02-09 17:16:17',0,'','doACPolicyPut','2017-02-09 17:16:17',1),(3156,'{\"service\":\"TcaMetrics\",\"location\":\"SampleServiceLocation\",\"uuid\":\"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall\",\"policyName\":\"vFirewall\",\"description\":\"Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:\",\"configName\":\"SampleConfigName\",\"templateVersion\":\"OpenSource.version.1\",\"version\":\"1.0.0.5\",\"priority\":\"1\",\"policyScope\":\"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop\",\"content\":{\"thresholds\":[{\"severity\":\"MAJOR\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn\",\"thresholdValue\":\"300\",\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\":\"1.0.2\",\"direction\":\"LESS_OR_EQUAL\"},{\"severity\":\"CRITICAL\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn\",\"thresholdValue\":\"700\",\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\":\"1.0.2\",\"direction\":\"GREATER_OR_EQUAL\"}],\"functionalRole\":\"vFirewall\",\"name\":\"0\"}}\r\n','JSON','com.Config_MS_vFirewall.1.json','doACPolicyPut','2017-02-09 17:19:38',0,'','doACPolicyPut','2017-02-09 17:19:38',1),(3158,'{\"service\":\"TcaMetrics\",\"location\":\"SampleServiceLocation\",\"uuid\":\"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer\",\"policyName\":\"vLoadBalancer\",\"description\":\"Micro Service vLoadBalancer Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:\",\"configName\":\"SampleConfigName\",\"templateVersion\":\"OpenSource.version.1\",\"version\":\"1.0.0.5\",\"priority\":\"1\",\"policyScope\":\"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop\",\"content\":{\"thresholds\":[{\"severity\":\"MAJOR\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn\",\"thresholdValue\":\"200\",\"closedLoopControlName\":\"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\":\"1.0.2\",\"direction\":\"GREATER_OR_EQUAL\"}],\"functionalRole\":\"vLoadBalancer\",\"name\":\"0\"}}\r\n','JSON','com.Config_MS_vLoadBalancer.1.json','doACPolicyPut','2017-02-09 17:21:15',0,'','doACPolicyPut','2017-02-09 17:21:15',1); +INSERT INTO `policyentity` VALUES (3156,'doACPolicyPut','2017-03-03 17:26:24',0,'Micro Service vFirewall Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-03 17:26:24','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:34928b05-b0f6-4974-8458-f4d34a2a1764\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>Micro Service vFirewall Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vFirewall.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"service\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"uuid\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"location\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:063161de-0534-4989-bd01-42f784daf21e\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"MSID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_MS_vFirewall.1.json</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vFirewall.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:service\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:uuid\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:Location\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"Priority\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_MS_vFirewall.1.xml',0,'com',1,NULL,3155),(3158,'doACPolicyPut','2017-03-03 17:28:10',0,'Micro Service vLoadBalancer Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-03 17:28:10','<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Policy xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\" PolicyId=\"urn:com:xacml:policy:id:c220802a-70ee-4ca8-9f1e-f8a515650381\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>Micro Service vLoadBalancer Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vLoadBalancer.1.xml</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"PolicyName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n <AllOf>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ECOMPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\" AttributeId=\"ConfigName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"service\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"uuid\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"location\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskType\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"RiskLevel\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">False</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"guard\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.openecomp.function.regex-match\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"TTLDate\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <Rule RuleId=\"urn:com:xacml:rule:id:fca27dab-6c09-4541-8136-328abaec2656\" Effect=\"Permit\">\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">ACCESS</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Config</AttributeValue>\n <AttributeDesignator Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n </AllOf>\n </AnyOf>\n </Target>\n <AdviceExpressions>\n <AdviceExpression AdviceId=\"MSID\" AppliesTo=\"Permit\">\n <AttributeAssignmentExpression AttributeId=\"type\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Configuration</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"URLID\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">$URL/Config/com.Config_MS_vLoadBalancer.1.json</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"PolicyName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">com.Config_MS_vLoadBalancer.1.xml</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"VersionNumber\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ECOMPName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">DCAE</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:ConfigName\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleConfigName</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:service\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TcaMetrics-v1.0.0.5</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:uuid\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"matching:Location\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleServiceLocation</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"Priority\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskType\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">SampleRiskType</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"RiskLevel\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"guard\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1</AttributeValue>\n </AttributeAssignmentExpression>\n <AttributeAssignmentExpression AttributeId=\"TTLDate\" Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\" Issuer=\"\">\n <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">NA</AttributeValue>\n </AttributeAssignmentExpression>\n </AdviceExpression>\n </AdviceExpressions>\n </Rule>\n</Policy>\n','Config_MS_vLoadBalancer.1.xml',0,'com',1,NULL,3157); -INSERT INTO `policyversion` VALUES (1,'com/Config_BRMS_Param_BRMSParamvFWDemoPolicy',1,1,'2017-02-09 17:13:43','demo','2017-02-09 17:13:43','demo'),(2,'com/Config_BRMS_Param_BRMSParamvLBDemoPolicy',1,1,'2017-02-09 17:16:19','demo','2017-02-09 17:16:19','demo'),(3,'com/Config_MS_vFirewall',1,1,'2017-02-09 17:19:40','demo','2017-02-09 17:19:40','demo'),(4,'com/Config_MS_vLoadBalancer',1,1,'2017-02-09 17:21:17','demo','2017-02-09 17:21:17','demo'); +INSERT INTO `configurationdataentity` VALUES (3151,'/* Autogenerated Code Please Don\'t change/remove this comment section. This is for the UI purpose. \n <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$> \n */ \n\r\n\r\n/*-\n * ============LICENSE_START=======================================================\n * archetype-closed-loop-demo-rules\n * ================================================================================\n * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ============LICENSE_END=========================================================\n */\n\npackage org.openecomp.policy.controlloop;\n\nimport java.util.List;\nimport java.util.LinkedList;\nimport java.util.Map;\nimport java.util.HashMap;\nimport java.util.UUID;\n\nimport org.openecomp.policy.controlloop.VirtualControlLoopEvent;\nimport org.openecomp.policy.controlloop.ControlLoopEventStatus;\nimport org.openecomp.policy.controlloop.VirtualControlLoopNotification;\nimport org.openecomp.policy.controlloop.ControlLoopNotificationType;\nimport org.openecomp.policy.controlloop.ControlLoopOperation;\nimport org.openecomp.policy.controlloop.ControlLoopOperationWrapper;\nimport org.openecomp.policy.template.demo.ControlLoopException;\n\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Request;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Response;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.openecomp.policy.aai.util.Serialization;\n\nimport org.openecomp.policy.appc.CommonHeader;\nimport org.openecomp.policy.appc.Request;\nimport org.openecomp.policy.appc.Response;\nimport org.openecomp.policy.appc.ResponseCode;\nimport org.openecomp.policy.appc.ResponseStatus;\nimport org.openecomp.policy.appc.ResponseValue;\n\nimport org.openecomp.policy.template.demo.EventManager;\nimport org.openecomp.policy.vnf.trafficgenerator.PGRequest;\nimport org.openecomp.policy.vnf.trafficgenerator.PGStream;\nimport org.openecomp.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.openecomp.policy.mso.MSOManager;\nimport org.openecomp.policy.mso.MSORequest;\nimport org.openecomp.policy.mso.MSORequestStatus;\nimport org.openecomp.policy.mso.MSORequestDetails;\nimport org.openecomp.policy.mso.MSOModelInfo;\nimport org.openecomp.policy.mso.MSOCloudConfiguration;\nimport org.openecomp.policy.mso.MSORequestInfo;\nimport org.openecomp.policy.mso.MSORequestParameters;\nimport org.openecomp.policy.mso.MSORelatedInstanceListElement;\nimport org.openecomp.policy.mso.MSORelatedInstance;\nimport org.openecomp.policy.mso.MSOResponse;\n\nimport org.openecomp.policy.drools.system.PolicyEngine;\n\n//\n// These parameters are required to build the runtime policy\n//\ndeclare Params\n closedLoopControlName : String\n actor : String\n aaiURL : String\n aaiUsername : String\n aaiPassword : String\n msoURL : String\n msoUsername : String\n msoPassword : String\n aaiNamedQueryUUID : String\n aaiPatternMatch : int \n notificationTopic : String\n appcTopic : String\nend\n\n/*\n*\n* Called once and only once to insert the parameters into working memory for this Closed Loop policy.\n* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)\n*\n*\n*rule \"BRMSParamvFWDemoPolicy.SETUP\"\n* when\n* then\n* System.out.println(\"rule SETUP is triggered.\");\n* Params params = new Params();\n* params.setClosedLoopControlName(\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\n* params.setActor(\"APPC\");\n* params.setAaiURL(\"null\");\n* params.setAaiUsername(\"null\");\n* params.setAaiPassword(\"null\");\n* params.setMsoURL(\"null\");\n* params.setMsoUsername(\"null\");\n* params.setMsoPassword(\"null\");\n* params.setAaiNamedQueryUUID(\"null\");\n* params.setAaiPatternMatch(1);\n* params.setNotificationTopic(\"POLICY-CL-MGT\");\n* params.setAppcTopic(\"APPC-CL\");\n* //\n* // This stays in memory as long as the rule is alive and running\n* //\n* insert(params);\n*end\n*/\n/*\n*\n* This rule responds to DCAE Events\n*\n*/\nrule \"BRMSParamvFWDemoPolicy.EVENT\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))\n then\n System.out.println(\"rule EVENT is triggered.\");\n try {\n // \n // Check the requestID in the event to make sure it is not null before we create the EventManager. \n // The EventManager will do extra syntax checking as well check if the closed loop is disabled/\n //\n if ($event.requestID == null) {\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.from = \"policy\";\n notification.message = \"Missing requestID from DCAE event\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n }\n //\n // Retract it from memory\n //\n retract($event);\n System.out.println(\"Event with requestID=null has been retracted.\");\n } else {\n //\n // Create an EventManager\n //\n EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);\n //\n // Determine if EventManager can actively process the event (i.e. syntax)\n //\n VirtualControlLoopNotification notification = manager.activate($event);\n notification.from = \"policy\"; \n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n // Are we actively pursuing this event?\n //\n if (notification.notification == ControlLoopNotificationType.ACTIVE) {\n //\n // Insert Event Manager into memory, this will now kick off processing.\n //\n insert(manager);\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n } \n } else {\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n }\n //\n // Retract it from memory\n //\n retract($event);\n }\n //\n // Now that the manager is inserted into Drools working memory, we\'ll wait for\n // another rule to fire in order to continue processing. This way we can also\n // then screen for additional ONSET and ABATED events for this same RequestIDs \n // and for different RequestIDs but with the same closedLoopControlName and target.\n //\n }\n //\n } catch (Exception e) {\n e.printStackTrace();\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.message = \"Exception occurred \" + e.getMessage();\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n //\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n // Retract the event\n //\n retract($event);\n }\nend\n\n/*\n*\n* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager\n* is created. We can start the operations for this closed loop.\n*\n*/\nrule \"BRMSParamvFWDemoPolicy.EVENT.MANAGER\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)\n then\n System.out.println(\"rule EVENT.MANAGER is triggered.\");\n //\n // Check which event this is.\n //\n EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);\n //\n // We only want the initial ONSET event in memory,\n // all the other events need to be retracted to support\n // cleanup and avoid the other rules being fired for this event.\n //\n if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {\n System.out.println(\"Retracting \"+eventStatus+\" Event.\");\n retract($event);\n return;\n }\n //\n // Now the event in memory is first onset event\n //\n try {\n //\n // Pull the known AAI field from the Event\n //\n // generic-vnf is needed for vFirewall case\n // vserver-name is needed for vLoadBalancer case\n //\n String genericVNF = $event.AAI.get(\"generic-vnf.vnf-id\");\n String vserver = $event.AAI.get(\"vserver.vserver-name\");\n //\n // Check if we are implementing a simple pattern match.\n //\n if ($params.getAaiPatternMatch() == 1) {\n //\n // Yes\n //\n //Basic naming characteristics:\n //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)\n //Example: \n //VF Name (9 characters): cscf0001v\n //VM Name(13 characters): cscf0001vm001\n //VFC name(19 characters): cscf0001vm001cfg001\n //\n // zdfw1fwl01fwl02 or zdfw1fwl01fwl01 \n // replaced with\n // zdfw1fwl01pgn02 or zdfw1fwl01pgn01\n //\n int index = genericVNF.lastIndexOf(\"fwl\");\n if (index == -1) {\n System.err.println(\"The generic-vnf.vnf-id from DCAE Event is not valid.\");\n } else {\n genericVNF = genericVNF.substring(0, index) + \"pgn\" + genericVNF.substring(index+\"fwl\".length());\n }\n //\n // Construct an APPC request\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"ModifyConfig\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // insert operationWrapper into memory\n //\n insert(operationWrapper);\n //\n Request request = new Request();\n request.CommonHeader = new CommonHeader();\n request.CommonHeader.RequestID = $event.requestID;\n request.Action = operation.operation;\n request.Payload = new HashMap<String, Object>();\n //\n // Fill in the payload\n //\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\n //\n PGRequest pgRequest = new PGRequest();\n pgRequest.pgStreams = new PGStreams();\n \n PGStream pgStream;\n for(int i = 0; i < 5; i++){\n pgStream = new PGStream();\n pgStream.streamId = \"fw_udp\"+(i+1);\n pgStream.isEnabled = \"true\";\n pgRequest.pgStreams.pgStream.add(pgStream);\n }\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\n \n if (request != null) {\n //\n // Insert request into memory\n //\n insert(request);\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n // message and history ??\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Now send the operation request\n //\n if (request instanceof Request) {\n try {\n System.out.println(\"APPC request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver request: \" + request);\n }\n }\n } else {\n //\n // what happens if it is null\n //\n }\n //\n } else {\n //\n // create AAI named-query request with UUID started with \"F199\"\n //\n AAINQF199Request aainqf199request = new AAINQF199Request();\n AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();\n AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();\n AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();\n //\n // queryParameters\n //\n aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); \n aainqf199queryparam.namedQuery = aainqf199namedquery;\n aainqf199request.queryParameters = aainqf199queryparam;\n //\n // instanceFilters\n //\n Map aainqf199instancefiltermap = new HashMap();\n Map aainqf199instancefiltermapitem = new HashMap();\n aainqf199instancefiltermapitem.put(\"vserver-name\", vserver); \n aainqf199instancefiltermap.put(\"vserver\", aainqf199instancefiltermapitem);\n aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);\n aainqf199request.instanceFilters = aainqf199instancefilter;\n //\n // print aainqf199request for debug\n //\n System.out.println(\"AAI Request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(aainqf199request));\n //\n // Create AAINQF199RequestWrapper\n //\n AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);\n //\n // insert aainqf199request into memory\n //\n insert(aainqf199RequestWrapper);\n }\n //\n } catch (Exception e) {\n e.printStackTrace();\n }\nend\n\n/*\n*\n* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager\n* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.\n*\n*/\nrule \"BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\n then\n System.out.println(\"rule EVENT.MANAGER.AAINQF199REQUEST is triggered.\");\n //\n // send the request\n //\n AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),\n $aainqf199RequestWrapper.aainqf199request, $event.requestID);\n //\n // Check AAI response\n //\n if (aainqf199response == null) {\n System.err.println(\"Failed to get AAI response\");\n //\n // Fail and retract everything\n //\n retract($event);\n retract($manager);\n retract($aainqf199RequestWrapper);\n } else {\n //\n // Create AAINQF199ResponseWrapper\n //\n AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);\n //\n // insert aainqf199ResponseWrapper to memeory\n //\n insert(aainqf199ResponseWrapper);\n }\nend\n\n/*\n*\n* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.\n*\n*/\nrule \"BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE\"\n when \n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\n $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)\n then\n System.out.println(\"rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.\");\n //\n // Extract related fields out of AAINQF199RESPONSE\n //\n String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, \n vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,\n serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,\n vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, \n vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;\n try {\n //\n // vnfItem\n //\n vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;\n vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;\n vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf(\"/\")+1);\n vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;\n vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;\n vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\n vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;\n vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\n //\n // serviceItem\n //\n serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;\n serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;\n serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\n serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;\n serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;\n serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\n //\n // Find the index for base vf module and non-base vf module\n //\n int baseIndex = -1;\n int nonBaseIndex = -1;\n List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;\n for (AAINQF199InventoryResponseItem m : inventoryItems) {\n if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {\n baseIndex = inventoryItems.indexOf(m);\n } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {\n nonBaseIndex = inventoryItems.indexOf(m);\n }\n //\n if (baseIndex != -1 && nonBaseIndex != -1) {\n break;\n }\n }\n //\n // Report the error if either base vf module or non-base vf module is not found\n //\n if (baseIndex == -1 || nonBaseIndex == -1) {\n System.err.println(\"Either base or non-base vf module is not found from AAI response.\");\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n }\n //\n // This comes from the base module\n //\n vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName;\n vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace(\"Vfmodule\", \"vDNS\");\n //\n // vfModuleItem - NOT the base module\n //\n vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId;\n vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion;\n vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue;\n vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue;\n //\n // tenantItem\n //\n tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;\n //\n // cloudRegionItem\n //\n cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;\n //\n } catch (Exception e) {\n e.printStackTrace();\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.message = \"Exception occurred \" + e.getMessage();\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n notification.message = \"Invalid named-query response from AAI\";\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n // Retract everything\n //\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n } \n //\n // Extracted fields should not be null\n //\n if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||\n (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||\n (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||\n (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||\n (serviceItemModelType == null) || (serviceItemModelVersion == null) ||\n (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||\n (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||\n (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||\n (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {\n //\n System.err.println(\"some fields are missing from AAI response.\");\n //\n // Fail and retract everything\n //\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n }\n //\n // We don\'t need them any more\n //\n retract($aainqf199ResponseWrapper);\n retract($aainqf199RequestWrapper); \n //\n // check the actor of this closed loop\n //\n switch ($params.getActor()) {\n case \"APPC\":\n {\n //\n // Construct an APPC request\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"ModifyConfig\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // insert operationWrapper into memory\n //\n insert(operationWrapper);\n //\n Request request = new Request();\n request.CommonHeader = new CommonHeader();\n request.CommonHeader.RequestID = $event.requestID;\n request.Action = operation.operation;\n request.Payload = new HashMap<String, Object>();\n //\n // Fill in the payload\n // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case\n //\n String genericVNF = \"zdfw1fwl01pgn02\";\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\n //\n PGRequest pgRequest = new PGRequest();\n pgRequest.pgStreams = new PGStreams();\n \n PGStream pgStream;\n for(int i = 0; i < 5; i++){\n pgStream = new PGStream();\n pgStream.streamId = \"fw_udp\"+(i+1);\n pgStream.isEnabled = \"true\";\n pgRequest.pgStreams.pgStream.add(pgStream);\n }\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\n \n if (request != null) {\n //\n // Insert request into memory\n //\n insert(request);\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n // message and history ??\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Now send the operation request\n //\n if (request instanceof Request) {\n try {\n System.out.println(\"APPC request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver request: \" + request);\n }\n }\n } else {\n //\n // what happens if it is null\n //\n }\n }\n break;\n case \"MSO\":\n {\n //\n // Construct an operation\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"createModuleInstance\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // Construct an MSO request\n //\n MSORequest request = new MSORequest();\n request.requestDetails = new MSORequestDetails();\n request.requestDetails.modelInfo = new MSOModelInfo();\n request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();\n request.requestDetails.requestInfo = new MSORequestInfo();\n request.requestDetails.requestParameters = new MSORequestParameters();\n request.requestDetails.requestParameters.userParams = null;\n //\n // cloudConfiguration\n //\n request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;\n request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;\n //\n // modelInfo\n //\n request.requestDetails.modelInfo.modelType = \"vfModule\";\n request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;\n request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;\n request.requestDetails.modelInfo.modelName = vfModuleItemModelName;\n request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;\n //\n // requestInfo\n //\n request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;\n request.requestDetails.requestInfo.source = \"POLICY\";\n request.requestDetails.requestInfo.suppressRollback = false;\n //\n // relatedInstanceList\n //\n MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();\n MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();\n relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();\n relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();\n //\n relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;\n relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();\n relatedInstanceListElement1.relatedInstance.modelInfo.modelType = \"service\";\n relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;\n //\n relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;\n relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();\n relatedInstanceListElement2.relatedInstance.modelInfo.modelType = \"vnf\";\n relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;\n // \n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);\n //\n // print MSO request for debug\n //\n System.out.println(\"MSO request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n //\n //\n //\n if (request != null) {\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL\n //\n String MSOUrl = $params.getMsoURL() + \"/serviceInstances/v2/\" + serviceItemServiceInstanceId + \"/vnfs/\" + vnfItemVnfId + \"/vfModules\";\n //\n // Call MSO\n //\n MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);\n //\n if (response != null) {\n //\n // Assign requestId\n //\n request.requestId = $event.requestID.toString(); \n response.request.requestId = $event.requestID.toString();\n //\n // Insert facts\n //\n insert(operationWrapper);\n insert(request);\n insert(response);\n } else {\n //\n // MSO request not even accepted\n //\n notification.message = operationWrapper.operation.toMessage();\n operationWrapper.operation.message = operationWrapper.operation.toMessage();\n operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n notification.history.add(operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Retract everything\n //\n retract($event);\n retract($manager);\n }\n } else {\n System.err.println(\"constructed MSO request is invalid.\");\n }\n }\n break; \n } \nend\n \n/*\n*\n* This rule responds to APPC Response Events\n*\n*/\nrule \"BRMSParamvFWDemoPolicy.APPC.RESPONSE\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\n $request : Request( getCommonHeader().RequestID == $event.requestID )\n $response : Response( getCommonHeader().RequestID == $event.requestID ) \n then\n System.out.println(\"rule APPC.RESPONSE is triggered.\");\n if ($response.Status == null) {\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n } \n //\n // Get the Response Code\n //\n ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);\n if (code == null) {\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n }\n //\n // Construct notification\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n notification.message = $operationWrapper.operation.toMessage();\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\n //\n // Ok, let\'s figure out what APP-C\'s response is\n //\n switch (code) {\n case ACCEPT:\n $operationWrapper.operation.outcome = \"PROCESSING\";\n break;\n case ERROR:\n case REJECT:\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n break;\n case SUCCESS:\n $operationWrapper.operation.outcome = \"SUCCESS\";\n $manager.setControlLoopResult(\"SUCCESS\");\n break;\n case FAILURE:\n $operationWrapper.operation.outcome = \"FAILURE\";\n $manager.setControlLoopResult(\"FAILURE\");\n break;\n }\n if ($operationWrapper.operation.outcome.equals(\"SUCCESS\")) {\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n } else if ($operationWrapper.operation.outcome.equals(\"PROCESSING\")) {\n retract($response);\n } else {\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n }\n \nend \n\n/*\n*\n* This rule is used to clean up APPC response\n*\n*/ \nrule \"BRMSParamvFWDemoPolicy.APPC.RESPONSE.CLEANUP\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $response : Response($id : getCommonHeader().RequestID )\n not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) \n then\n System.out.println(\"rule APPC.RESPONSE.CLEANUP is triggered.\");\n retract($response);\nend\n\n/*\n*\n* This rule responds to MSO Response Events\n*\n*/\nrule \"BRMSParamvFWDemoPolicy.MSO.RESPONSE\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\n $request : MSORequest( requestId == $event.requestID.toString() )\n $response : MSOResponse( request.requestId == $event.requestID.toString() ) \n then\n System.out.println(\"rule MSO.RESPONSE is triggered.\");\n //\n // Construct notification\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n notification.message = $operationWrapper.operation.toMessage();\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\n //\n // The operation can either be succeeded or failed\n // \n if($response.request.requestStatus.requestState.equals(\"Completed\")) {\n $operationWrapper.operation.outcome = \"SUCCESS\";\n $manager.setControlLoopResult(\"SUCCESS\");\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n } else {\n $operationWrapper.operation.outcome = \"FAILURE\";\n $manager.setControlLoopResult(\"FAILURE\");\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n }\n \nend \nrule \"Params\" \n salience 1000 \n when\n then\n Params params = new Params();\n params.setAaiPatternMatch(1);\n params.setAppcTopic(\"APPC-CL\");\n params.setAaiURL(\"null\");\n params.setMsoPassword(\"null\");\n params.setClosedLoopControlName(\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\n params.setMsoURL(\"null\");\n params.setAaiUsername(\"null\");\n params.setActor(\"APPC\");\n params.setMsoUsername(\"null\");\n params.setAaiNamedQueryUUID(\"null\");\n params.setAaiPassword(\"null\");\n params.setNotificationTopic(\"POLICY-CL-MGT\");\n insert(params);\nend\r\n','OTHER','com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt','doACPolicyPut','2017-03-03 17:16:27',0,'','doACPolicyPut','2017-03-03 17:16:27',1),(3153,'/* Autogenerated Code Please Don\'t change/remove this comment section. This is for the UI purpose. \n <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$> \n */ \n\r\n\r\n/*-\n * ============LICENSE_START=======================================================\n * archetype-closed-loop-demo-rules\n * ================================================================================\n * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ============LICENSE_END=========================================================\n */\n\npackage org.openecomp.policy.controlloop;\n\nimport java.util.List;\nimport java.util.LinkedList;\nimport java.util.Map;\nimport java.util.HashMap;\nimport java.util.UUID;\n\nimport org.openecomp.policy.controlloop.VirtualControlLoopEvent;\nimport org.openecomp.policy.controlloop.ControlLoopEventStatus;\nimport org.openecomp.policy.controlloop.VirtualControlLoopNotification;\nimport org.openecomp.policy.controlloop.ControlLoopNotificationType;\nimport org.openecomp.policy.controlloop.ControlLoopOperation;\nimport org.openecomp.policy.controlloop.ControlLoopOperationWrapper;\nimport org.openecomp.policy.template.demo.ControlLoopException;\n\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Request;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Response;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.openecomp.policy.aai.util.Serialization;\n\nimport org.openecomp.policy.appc.CommonHeader;\nimport org.openecomp.policy.appc.Request;\nimport org.openecomp.policy.appc.Response;\nimport org.openecomp.policy.appc.ResponseCode;\nimport org.openecomp.policy.appc.ResponseStatus;\nimport org.openecomp.policy.appc.ResponseValue;\n\nimport org.openecomp.policy.template.demo.EventManager;\nimport org.openecomp.policy.vnf.trafficgenerator.PGRequest;\nimport org.openecomp.policy.vnf.trafficgenerator.PGStream;\nimport org.openecomp.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.openecomp.policy.mso.MSOManager;\nimport org.openecomp.policy.mso.MSORequest;\nimport org.openecomp.policy.mso.MSORequestStatus;\nimport org.openecomp.policy.mso.MSORequestDetails;\nimport org.openecomp.policy.mso.MSOModelInfo;\nimport org.openecomp.policy.mso.MSOCloudConfiguration;\nimport org.openecomp.policy.mso.MSORequestInfo;\nimport org.openecomp.policy.mso.MSORequestParameters;\nimport org.openecomp.policy.mso.MSORelatedInstanceListElement;\nimport org.openecomp.policy.mso.MSORelatedInstance;\nimport org.openecomp.policy.mso.MSOResponse;\n\nimport org.openecomp.policy.drools.system.PolicyEngine;\n\n//\n// These parameters are required to build the runtime policy\n//\ndeclare Params\n closedLoopControlName : String\n actor : String\n aaiURL : String\n aaiUsername : String\n aaiPassword : String\n msoURL : String\n msoUsername : String\n msoPassword : String\n aaiNamedQueryUUID : String\n aaiPatternMatch : int \n notificationTopic : String\n appcTopic : String\nend\n\n/*\n*\n* Called once and only once to insert the parameters into working memory for this Closed Loop policy.\n* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)\n*\n*\n*rule \"BRMSParamvLBDemoPolicy.SETUP\"\n* when\n* then\n* System.out.println(\"rule SETUP is triggered.\");\n* Params params = new Params();\n* params.setClosedLoopControlName(\"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\n* params.setActor(\"MSO\");\n* params.setAaiURL(\"https://aai.api.simpledemo.openecomp.org:8443\");\n* params.setAaiUsername(\"POLICY\");\n* params.setAaiPassword(\"POLICY\");\n* params.setMsoURL(\"http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra\");\n* params.setMsoUsername(\"InfraPortalClient\");\n* params.setMsoPassword(\"password1$\");\n* params.setAaiNamedQueryUUID(\"f199cb88-5e69-4b1f-93e0-6f257877d066\");\n* params.setAaiPatternMatch(0);\n* params.setNotificationTopic(\"POLICY-CL-MGT\");\n* params.setAppcTopic(\"APPC-CL\");\n* //\n* // This stays in memory as long as the rule is alive and running\n* //\n* insert(params);\n*end\n*/\n/*\n*\n* This rule responds to DCAE Events\n*\n*/\nrule \"BRMSParamvLBDemoPolicy.EVENT\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))\n then\n System.out.println(\"rule EVENT is triggered.\");\n try {\n // \n // Check the requestID in the event to make sure it is not null before we create the EventManager. \n // The EventManager will do extra syntax checking as well check if the closed loop is disabled/\n //\n if ($event.requestID == null) {\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.from = \"policy\";\n notification.message = \"Missing requestID from DCAE event\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n }\n //\n // Retract it from memory\n //\n retract($event);\n System.out.println(\"Event with requestID=null has been retracted.\");\n } else {\n //\n // Create an EventManager\n //\n EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);\n //\n // Determine if EventManager can actively process the event (i.e. syntax)\n //\n VirtualControlLoopNotification notification = manager.activate($event);\n notification.from = \"policy\"; \n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n // Are we actively pursuing this event?\n //\n if (notification.notification == ControlLoopNotificationType.ACTIVE) {\n //\n // Insert Event Manager into memory, this will now kick off processing.\n //\n insert(manager);\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n } \n } else {\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n }\n //\n // Retract it from memory\n //\n retract($event);\n }\n //\n // Now that the manager is inserted into Drools working memory, we\'ll wait for\n // another rule to fire in order to continue processing. This way we can also\n // then screen for additional ONSET and ABATED events for this same RequestIDs \n // and for different RequestIDs but with the same closedLoopControlName and target.\n //\n }\n //\n } catch (Exception e) {\n e.printStackTrace();\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.message = \"Exception occurred \" + e.getMessage();\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n //\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n // Retract the event\n //\n retract($event);\n }\nend\n\n/*\n*\n* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager\n* is created. We can start the operations for this closed loop.\n*\n*/\nrule \"BRMSParamvLBDemoPolicy.EVENT.MANAGER\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)\n then\n System.out.println(\"rule EVENT.MANAGER is triggered.\");\n //\n // Check which event this is.\n //\n EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);\n //\n // We only want the initial ONSET event in memory,\n // all the other events need to be retracted to support\n // cleanup and avoid the other rules being fired for this event.\n //\n if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {\n System.out.println(\"Retracting \"+eventStatus+\" Event.\");\n retract($event);\n return;\n }\n //\n // Now the event in memory is first onset event\n //\n try {\n //\n // Pull the known AAI field from the Event\n //\n // generic-vnf is needed for vFirewall case\n // vserver-name is needed for vLoadBalancer case\n //\n String genericVNF = $event.AAI.get(\"generic-vnf.vnf-id\");\n String vserver = $event.AAI.get(\"vserver.vserver-name\");\n //\n // Check if we are implementing a simple pattern match.\n //\n if ($params.getAaiPatternMatch() == 1) {\n //\n // Yes\n //\n //Basic naming characteristics:\n //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)\n //Example: \n //VF Name (9 characters): cscf0001v\n //VM Name(13 characters): cscf0001vm001\n //VFC name(19 characters): cscf0001vm001cfg001\n //\n // zdfw1fwl01fwl02 or zdfw1fwl01fwl01 \n // replaced with\n // zdfw1fwl01pgn02 or zdfw1fwl01pgn01\n //\n int index = genericVNF.lastIndexOf(\"fwl\");\n if (index == -1) {\n System.err.println(\"The generic-vnf.vnf-id from DCAE Event is not valid.\");\n } else {\n genericVNF = genericVNF.substring(0, index) + \"pgn\" + genericVNF.substring(index+\"fwl\".length());\n }\n //\n // Construct an APPC request\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"ModifyConfig\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // insert operationWrapper into memory\n //\n insert(operationWrapper);\n //\n Request request = new Request();\n request.CommonHeader = new CommonHeader();\n request.CommonHeader.RequestID = $event.requestID;\n request.Action = operation.operation;\n request.Payload = new HashMap<String, Object>();\n //\n // Fill in the payload\n //\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\n //\n PGRequest pgRequest = new PGRequest();\n pgRequest.pgStreams = new PGStreams();\n \n PGStream pgStream;\n for(int i = 0; i < 5; i++){\n pgStream = new PGStream();\n pgStream.streamId = \"fw_udp\"+(i+1);\n pgStream.isEnabled = \"true\";\n pgRequest.pgStreams.pgStream.add(pgStream);\n }\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\n \n if (request != null) {\n //\n // Insert request into memory\n //\n insert(request);\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n // message and history ??\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Now send the operation request\n //\n if (request instanceof Request) {\n try {\n System.out.println(\"APPC request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver request: \" + request);\n }\n }\n } else {\n //\n // what happens if it is null\n //\n }\n //\n } else {\n //\n // create AAI named-query request with UUID started with \"F199\"\n //\n AAINQF199Request aainqf199request = new AAINQF199Request();\n AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();\n AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();\n AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();\n //\n // queryParameters\n //\n aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); \n aainqf199queryparam.namedQuery = aainqf199namedquery;\n aainqf199request.queryParameters = aainqf199queryparam;\n //\n // instanceFilters\n //\n Map aainqf199instancefiltermap = new HashMap();\n Map aainqf199instancefiltermapitem = new HashMap();\n aainqf199instancefiltermapitem.put(\"vserver-name\", vserver); \n aainqf199instancefiltermap.put(\"vserver\", aainqf199instancefiltermapitem);\n aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);\n aainqf199request.instanceFilters = aainqf199instancefilter;\n //\n // print aainqf199request for debug\n //\n System.out.println(\"AAI Request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(aainqf199request));\n //\n // Create AAINQF199RequestWrapper\n //\n AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);\n //\n // insert aainqf199request into memory\n //\n insert(aainqf199RequestWrapper);\n }\n //\n } catch (Exception e) {\n e.printStackTrace();\n }\nend\n\n/*\n*\n* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager\n* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.\n*\n*/\nrule \"BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\n then\n System.out.println(\"rule EVENT.MANAGER.AAINQF199REQUEST is triggered.\");\n //\n // send the request\n //\n AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),\n $aainqf199RequestWrapper.aainqf199request, $event.requestID);\n //\n // Check AAI response\n //\n if (aainqf199response == null) {\n System.err.println(\"Failed to get AAI response\");\n //\n // Fail and retract everything\n //\n retract($event);\n retract($manager);\n retract($aainqf199RequestWrapper);\n } else {\n //\n // Create AAINQF199ResponseWrapper\n //\n AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);\n //\n // insert aainqf199ResponseWrapper to memeory\n //\n insert(aainqf199ResponseWrapper);\n }\nend\n\n/*\n*\n* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.\n*\n*/\nrule \"BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE\"\n when \n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\n $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)\n then\n System.out.println(\"rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.\");\n //\n // Extract related fields out of AAINQF199RESPONSE\n //\n String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, \n vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,\n serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,\n vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, \n vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;\n try {\n //\n // vnfItem\n //\n vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;\n vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;\n vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf(\"/\")+1);\n vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;\n vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;\n vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\n vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;\n vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\n //\n // serviceItem\n //\n serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;\n serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;\n serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\n serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;\n serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;\n serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\n //\n // Find the index for base vf module and non-base vf module\n //\n int baseIndex = -1;\n int nonBaseIndex = -1;\n List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;\n for (AAINQF199InventoryResponseItem m : inventoryItems) {\n if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {\n baseIndex = inventoryItems.indexOf(m);\n } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {\n nonBaseIndex = inventoryItems.indexOf(m);\n }\n //\n if (baseIndex != -1 && nonBaseIndex != -1) {\n break;\n }\n }\n //\n // Report the error if either base vf module or non-base vf module is not found\n //\n if (baseIndex == -1 || nonBaseIndex == -1) {\n System.err.println(\"Either base or non-base vf module is not found from AAI response.\");\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n }\n //\n // This comes from the base module\n //\n vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName;\n vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace(\"Vfmodule\", \"vDNS\");\n //\n // vfModuleItem - NOT the base module\n //\n vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId;\n vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion;\n vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue;\n vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue;\n //\n // tenantItem\n //\n tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;\n //\n // cloudRegionItem\n //\n cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;\n //\n } catch (Exception e) {\n e.printStackTrace();\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.message = \"Exception occurred \" + e.getMessage();\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n notification.message = \"Invalid named-query response from AAI\";\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n // Retract everything\n //\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n } \n //\n // Extracted fields should not be null\n //\n if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||\n (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||\n (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||\n (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||\n (serviceItemModelType == null) || (serviceItemModelVersion == null) ||\n (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||\n (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||\n (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||\n (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {\n //\n System.err.println(\"some fields are missing from AAI response.\");\n //\n // Fail and retract everything\n //\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n }\n //\n // We don\'t need them any more\n //\n retract($aainqf199ResponseWrapper);\n retract($aainqf199RequestWrapper); \n //\n // check the actor of this closed loop\n //\n switch ($params.getActor()) {\n case \"APPC\":\n {\n //\n // Construct an APPC request\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"ModifyConfig\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // insert operationWrapper into memory\n //\n insert(operationWrapper);\n //\n Request request = new Request();\n request.CommonHeader = new CommonHeader();\n request.CommonHeader.RequestID = $event.requestID;\n request.Action = operation.operation;\n request.Payload = new HashMap<String, Object>();\n //\n // Fill in the payload\n // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case\n //\n String genericVNF = \"zdfw1fwl01pgn02\";\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\n //\n PGRequest pgRequest = new PGRequest();\n pgRequest.pgStreams = new PGStreams();\n \n PGStream pgStream;\n for(int i = 0; i < 5; i++){\n pgStream = new PGStream();\n pgStream.streamId = \"fw_udp\"+(i+1);\n pgStream.isEnabled = \"true\";\n pgRequest.pgStreams.pgStream.add(pgStream);\n }\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\n \n if (request != null) {\n //\n // Insert request into memory\n //\n insert(request);\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n // message and history ??\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Now send the operation request\n //\n if (request instanceof Request) {\n try {\n System.out.println(\"APPC request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver request: \" + request);\n }\n }\n } else {\n //\n // what happens if it is null\n //\n }\n }\n break;\n case \"MSO\":\n {\n //\n // Construct an operation\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"createModuleInstance\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // Construct an MSO request\n //\n MSORequest request = new MSORequest();\n request.requestDetails = new MSORequestDetails();\n request.requestDetails.modelInfo = new MSOModelInfo();\n request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();\n request.requestDetails.requestInfo = new MSORequestInfo();\n request.requestDetails.requestParameters = new MSORequestParameters();\n request.requestDetails.requestParameters.userParams = null;\n //\n // cloudConfiguration\n //\n request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;\n request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;\n //\n // modelInfo\n //\n request.requestDetails.modelInfo.modelType = \"vfModule\";\n request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;\n request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;\n request.requestDetails.modelInfo.modelName = vfModuleItemModelName;\n request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;\n //\n // requestInfo\n //\n request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;\n request.requestDetails.requestInfo.source = \"POLICY\";\n request.requestDetails.requestInfo.suppressRollback = false;\n //\n // relatedInstanceList\n //\n MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();\n MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();\n relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();\n relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();\n //\n relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;\n relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();\n relatedInstanceListElement1.relatedInstance.modelInfo.modelType = \"service\";\n relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;\n //\n relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;\n relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();\n relatedInstanceListElement2.relatedInstance.modelInfo.modelType = \"vnf\";\n relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;\n // \n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);\n //\n // print MSO request for debug\n //\n System.out.println(\"MSO request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n //\n //\n //\n if (request != null) {\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL\n //\n String MSOUrl = $params.getMsoURL() + \"/serviceInstances/v2/\" + serviceItemServiceInstanceId + \"/vnfs/\" + vnfItemVnfId + \"/vfModules\";\n //\n // Call MSO\n //\n MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);\n //\n if (response != null) {\n //\n // Assign requestId\n //\n request.requestId = $event.requestID.toString(); \n response.request.requestId = $event.requestID.toString();\n //\n // Insert facts\n //\n insert(operationWrapper);\n insert(request);\n insert(response);\n } else {\n //\n // MSO request not even accepted\n //\n notification.message = operationWrapper.operation.toMessage();\n operationWrapper.operation.message = operationWrapper.operation.toMessage();\n operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n notification.history.add(operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Retract everything\n //\n retract($event);\n retract($manager);\n }\n } else {\n System.err.println(\"constructed MSO request is invalid.\");\n }\n }\n break; \n } \nend\n \n/*\n*\n* This rule responds to APPC Response Events\n*\n*/\nrule \"BRMSParamvLBDemoPolicy.APPC.RESPONSE\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\n $request : Request( getCommonHeader().RequestID == $event.requestID )\n $response : Response( getCommonHeader().RequestID == $event.requestID ) \n then\n System.out.println(\"rule APPC.RESPONSE is triggered.\");\n if ($response.Status == null) {\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n } \n //\n // Get the Response Code\n //\n ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);\n if (code == null) {\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n }\n //\n // Construct notification\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n notification.message = $operationWrapper.operation.toMessage();\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\n //\n // Ok, let\'s figure out what APP-C\'s response is\n //\n switch (code) {\n case ACCEPT:\n $operationWrapper.operation.outcome = \"PROCESSING\";\n break;\n case ERROR:\n case REJECT:\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n break;\n case SUCCESS:\n $operationWrapper.operation.outcome = \"SUCCESS\";\n $manager.setControlLoopResult(\"SUCCESS\");\n break;\n case FAILURE:\n $operationWrapper.operation.outcome = \"FAILURE\";\n $manager.setControlLoopResult(\"FAILURE\");\n break;\n }\n if ($operationWrapper.operation.outcome.equals(\"SUCCESS\")) {\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n } else if ($operationWrapper.operation.outcome.equals(\"PROCESSING\")) {\n retract($response);\n } else {\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n }\n \nend \n\n/*\n*\n* This rule is used to clean up APPC response\n*\n*/ \nrule \"BRMSParamvLBDemoPolicy.APPC.RESPONSE.CLEANUP\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $response : Response($id : getCommonHeader().RequestID )\n not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) \n then\n System.out.println(\"rule APPC.RESPONSE.CLEANUP is triggered.\");\n retract($response);\nend\n\n/*\n*\n* This rule responds to MSO Response Events\n*\n*/\nrule \"BRMSParamvLBDemoPolicy.MSO.RESPONSE\"\n when\n $params : Params( getClosedLoopControlName() == \"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\n $request : MSORequest( requestId == $event.requestID.toString() )\n $response : MSOResponse( request.requestId == $event.requestID.toString() ) \n then\n System.out.println(\"rule MSO.RESPONSE is triggered.\");\n //\n // Construct notification\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"com\";\n notification.policyVersion = \"1\";\n notification.message = $operationWrapper.operation.toMessage();\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\n //\n // The operation can either be succeeded or failed\n // \n if($response.request.requestStatus.requestState.equals(\"Completed\")) {\n $operationWrapper.operation.outcome = \"SUCCESS\";\n $manager.setControlLoopResult(\"SUCCESS\");\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n } else {\n $operationWrapper.operation.outcome = \"FAILURE\";\n $manager.setControlLoopResult(\"FAILURE\");\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n }\n \nend \nrule \"Params\" \n salience 1000 \n when\n then\n Params params = new Params();\n params.setAaiPatternMatch(0);\n params.setAppcTopic(\"APPC-CL\");\n params.setAaiURL(\"https://aai.api.simpledemo.openecomp.org:8443\");\n params.setMsoPassword(\"password1$\");\n params.setClosedLoopControlName(\"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\");\n params.setAaiUsername(\"POLICY\");\n params.setMsoURL(\"http://vm1.mso.simpledemo.openecomp.org:8080/ecomp/mso/infra\");\n params.setActor(\"MSO\");\n params.setMsoUsername(\"InfraPortalClient\");\n params.setAaiNamedQueryUUID(\"f199cb88-5e69-4b1f-93e0-6f257877d066\");\n params.setAaiPassword(\"POLICY\");\n params.setNotificationTopic(\"POLICY-CL-MGT\");\n insert(params);\nend\r\n','OTHER','com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt','doACPolicyPut','2017-03-03 17:20:01',0,'','doACPolicyPut','2017-03-03 17:20:01',1); -INSERT INTO `brmsparamtemplate` VALUES (5,'ControlLoopDemo__closedLoopControlName','ControlLoopDemo__closedLoopControlName','\r\n\r\n/*-\r\n * ============LICENSE_START=======================================================\r\n * archetype-closed-loop-demo-rules\r\n * ================================================================================\r\n * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r\n * ================================================================================\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n * \r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n * \r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n * ============LICENSE_END=========================================================\r\n */\r\n\r\npackage org.openecomp.policy.controlloop;\r\n\r\nimport java.util.LinkedList;\r\nimport java.util.Map;\r\nimport java.util.HashMap;\r\nimport java.util.UUID;\r\n\r\nimport org.openecomp.policy.controlloop.VirtualControlLoopEvent;\r\nimport org.openecomp.policy.controlloop.ControlLoopEventStatus;\r\nimport org.openecomp.policy.controlloop.VirtualControlLoopNotification;\r\nimport org.openecomp.policy.controlloop.ControlLoopNotificationType;\r\nimport org.openecomp.policy.controlloop.ControlLoopOperation;\r\nimport org.openecomp.policy.controlloop.ControlLoopOperationWrapper;\r\nimport org.openecomp.policy.template.demo.ControlLoopException;\r\n\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Request;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Response;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;\r\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;\r\nimport org.openecomp.policy.aai.util.Serialization;\r\n\r\nimport org.openecomp.policy.appc.CommonHeader;\r\nimport org.openecomp.policy.appc.Request;\r\nimport org.openecomp.policy.appc.Response;\r\nimport org.openecomp.policy.appc.ResponseCode;\r\nimport org.openecomp.policy.appc.ResponseStatus;\r\nimport org.openecomp.policy.appc.ResponseValue;\r\n\r\nimport org.openecomp.policy.template.demo.EventManager;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGRequest;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGStream;\r\nimport org.openecomp.policy.vnf.trafficgenerator.PGStreams;\r\n\r\nimport org.openecomp.policy.mso.MSOManager;\r\nimport org.openecomp.policy.mso.MSORequest;\r\nimport org.openecomp.policy.mso.MSORequestStatus;\r\nimport org.openecomp.policy.mso.MSORequestDetails;\r\nimport org.openecomp.policy.mso.MSOModelInfo;\r\nimport org.openecomp.policy.mso.MSOCloudConfiguration;\r\nimport org.openecomp.policy.mso.MSORequestInfo;\r\nimport org.openecomp.policy.mso.MSORequestParameters;\r\nimport org.openecomp.policy.mso.MSORelatedInstanceListElement;\r\nimport org.openecomp.policy.mso.MSORelatedInstance;\r\nimport org.openecomp.policy.mso.MSOResponse;\r\n\r\nimport org.openecomp.policy.drools.system.PolicyEngine;\r\n\r\n//\r\n// These parameters are required to build the runtime policy\r\n//\r\ndeclare Params\r\n closedLoopControlName : String\r\n actor : String\r\n aaiURL : String\r\n aaiUsername : String\r\n aaiPassword : String\r\n msoURL : String\r\n msoUsername : String\r\n msoPassword : String\r\n aaiNamedQueryUUID : String\r\n aaiPatternMatch : int \r\n notificationTopic : String\r\n appcTopic : String\r\nend\r\n\r\n/*\r\n*\r\n* Called once and only once to insert the parameters into working memory for this Closed Loop policy.\r\n* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)\r\n*\r\n*\r\n*rule \"${policyName}.SETUP\"\r\n* when\r\n* then\r\n* System.out.println(\"rule SETUP is triggered.\");\r\n* Params params = new Params();\r\n* params.setClosedLoopControlName(\"${closedLoopControlName}\");\r\n* params.setActor(\"${actor}\");\r\n* params.setAaiURL(\"${aaiURL}\");\r\n* params.setAaiUsername(\"${aaiUsername}\");\r\n* params.setAaiPassword(\"${aaiPassword}\");\r\n* params.setMsoURL(\"${msoURL}\");\r\n* params.setMsoUsername(\"${msoUsername}\");\r\n* params.setMsoPassword(\"${msoPassword}\");\r\n* params.setAaiNamedQueryUUID(\"${aaiNamedQueryUUID}\");\r\n* params.setAaiPatternMatch(${aaiPatternMatch});\r\n* params.setNotificationTopic(\"${notificationTopic}\");\r\n* params.setAppcTopic(\"${appcTopic}\");\r\n* //\r\n* // This stays in memory as long as the rule is alive and running\r\n* //\r\n* insert(params);\r\n*end\r\n*/\r\n/*\r\n*\r\n* This rule responds to DCAE Events\r\n*\r\n*/\r\nrule \"${policyName}.EVENT\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))\r\n then\r\n System.out.println(\"rule EVENT is triggered.\");\r\n try {\r\n // \r\n // Check the requestID in the event to make sure it is not null before we create the EventManager. \r\n // The EventManager will do extra syntax checking as well check if the closed loop is disabled/\r\n //\r\n if ($event.requestID == null) {\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.from = \"policy\";\r\n notification.message = \"Missing requestID from DCAE event\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n }\r\n //\r\n // Retract it from memory\r\n //\r\n retract($event);\r\n System.out.println(\"Event with requestID=null has been retracted.\");\r\n } else {\r\n //\r\n // Create an EventManager\r\n //\r\n EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);\r\n //\r\n // Determine if EventManager can actively process the event (i.e. syntax)\r\n //\r\n VirtualControlLoopNotification notification = manager.activate($event);\r\n notification.from = \"policy\"; \r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n //\r\n // Are we actively pursuing this event?\r\n //\r\n if (notification.notification == ControlLoopNotificationType.ACTIVE) {\r\n //\r\n // Insert Event Manager into memory, this will now kick off processing.\r\n //\r\n insert(manager);\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n } \r\n } else {\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n }\r\n //\r\n // Retract it from memory\r\n //\r\n retract($event);\r\n }\r\n //\r\n // Now that the manager is inserted into Drools working memory, we\'ll wait for\r\n // another rule to fire in order to continue processing. This way we can also\r\n // then screen for additional ONSET and ABATED events for this same RequestIDs \r\n // and for different RequestIDs but with the same closedLoopControlName and target.\r\n //\r\n }\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.message = \"Exception occurred \" + e.getMessage();\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n //\r\n //\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n // Retract the event\r\n //\r\n retract($event);\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager\r\n* is created. We can start the operations for this closed loop.\r\n*\r\n*/\r\nrule \"${policyName}.EVENT.MANAGER\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER is triggered.\");\r\n //\r\n // Check which event this is.\r\n //\r\n EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);\r\n //\r\n // We only want the initial ONSET event in memory,\r\n // all the other events need to be retracted to support\r\n // cleanup and avoid the other rules being fired for this event.\r\n //\r\n if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {\r\n System.out.println(\"Retracting \"+eventStatus+\" Event.\");\r\n retract($event);\r\n return;\r\n }\r\n //\r\n // Now the event in memory is first onset event\r\n //\r\n try {\r\n //\r\n // Pull the known AAI field from the Event\r\n //\r\n // generic-vnf is needed for vFirewall case\r\n // vserver-name is needed for vLoadBalancer case\r\n //\r\n String genericVNF = $event.AAI.get(\"generic-vnf.vnf-id\");\r\n String vserver = $event.AAI.get(\"vserver.vserver-name\");\r\n //\r\n // Check if we are implementing a simple pattern match.\r\n //\r\n if ($params.getAaiPatternMatch() == 1) {\r\n //\r\n // Yes\r\n //\r\n //Basic naming characteristics:\r\n //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)\r\n //Example: \r\n //VF Name (9 characters): cscf0001v\r\n //VM Name(13 characters): cscf0001vm001\r\n //VFC name(19 characters): cscf0001vm001cfg001\r\n //\r\n // zdfw1fwl01fwl02 or zdfw1fwl01fwl01 \r\n // replaced with\r\n // zdfw1fwl01pgn02 or zdfw1fwl01pgn01\r\n //\r\n int index = genericVNF.lastIndexOf(\"fwl\");\r\n if (index == -1) {\r\n System.err.println(\"The generic-vnf.vnf-id from DCAE Event is not valid.\");\r\n } else {\r\n genericVNF = genericVNF.substring(0, index) + \"pgn\" + genericVNF.substring(index+\"fwl\".length());\r\n }\r\n //\r\n // Construct an APPC request\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"ModifyConfig\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // insert operationWrapper into memory\r\n //\r\n insert(operationWrapper);\r\n //\r\n Request request = new Request();\r\n request.CommonHeader = new CommonHeader();\r\n request.CommonHeader.RequestID = $event.requestID;\r\n request.Action = operation.operation;\r\n request.Payload = new HashMap<String, Object>();\r\n //\r\n // Fill in the payload\r\n //\r\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\r\n //\r\n PGRequest pgRequest = new PGRequest();\r\n pgRequest.pgStreams = new PGStreams();\r\n \r\n PGStream pgStream;\r\n for(int i = 0; i < 5; i++){\r\n pgStream = new PGStream();\r\n pgStream.streamId = \"fw_udp\"+(i+1);\r\n pgStream.isEnabled = \"true\";\r\n pgRequest.pgStreams.pgStream.add(pgStream);\r\n }\r\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\r\n \r\n if (request != null) {\r\n //\r\n // Insert request into memory\r\n //\r\n insert(request);\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n // message and history ??\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Now send the operation request\r\n //\r\n if (request instanceof Request) {\r\n try {\r\n System.out.println(\"APPC request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver request: \" + request);\r\n }\r\n }\r\n } else {\r\n //\r\n // what happens if it is null\r\n //\r\n }\r\n //\r\n } else {\r\n //\r\n // create AAI named-query request with UUID started with \"F199\"\r\n //\r\n AAINQF199Request aainqf199request = new AAINQF199Request();\r\n AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();\r\n AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();\r\n AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();\r\n //\r\n // queryParameters\r\n //\r\n aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); \r\n aainqf199queryparam.namedQuery = aainqf199namedquery;\r\n aainqf199request.queryParameters = aainqf199queryparam;\r\n //\r\n // instanceFilters\r\n //\r\n Map aainqf199instancefiltermap = new HashMap();\r\n Map aainqf199instancefiltermapitem = new HashMap();\r\n aainqf199instancefiltermapitem.put(\"vserver-name\", vserver); \r\n aainqf199instancefiltermap.put(\"vserver\", aainqf199instancefiltermapitem);\r\n aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);\r\n aainqf199request.instanceFilters = aainqf199instancefilter;\r\n //\r\n // print aainqf199request for debug\r\n //\r\n System.out.println(\"AAI Request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(aainqf199request));\r\n //\r\n // Create AAINQF199RequestWrapper\r\n //\r\n AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);\r\n //\r\n // insert aainqf199request into memory\r\n //\r\n insert(aainqf199RequestWrapper);\r\n }\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager\r\n* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.\r\n*\r\n*/\r\nrule \"${policyName}.EVENT.MANAGER.AAINQF199REQUEST\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER.AAINQF199REQUEST is triggered.\");\r\n //\r\n // send the request\r\n //\r\n AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),\r\n $aainqf199RequestWrapper.aainqf199request, $event.requestID);\r\n //\r\n // Check AAI response\r\n //\r\n if (aainqf199response == null) {\r\n System.err.println(\"Failed to get AAI response\");\r\n //\r\n // Fail and retract everything\r\n //\r\n retract($event);\r\n retract($manager);\r\n retract($aainqf199RequestWrapper);\r\n } else {\r\n //\r\n // Create AAINQF199ResponseWrapper\r\n //\r\n AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);\r\n //\r\n // insert aainqf199ResponseWrapper to memeory\r\n //\r\n insert(aainqf199ResponseWrapper);\r\n }\r\nend\r\n\r\n/*\r\n*\r\n* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.\r\n*\r\n*/\r\nrule \"${policyName}.EVENT.MANAGER.AAINQF199RESPONSE\"\r\n when \r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\r\n $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)\r\n then\r\n System.out.println(\"rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.\");\r\n //\r\n // Extract related fields out of AAINQF199RESPONSE\r\n //\r\n String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, \r\n vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,\r\n serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,\r\n vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, \r\n vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;\r\n try {\r\n //\r\n // vnfItem\r\n //\r\n vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;\r\n vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;\r\n vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf(\"/\")+1);\r\n vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;\r\n vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;\r\n vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\r\n vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;\r\n vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // serviceItem\r\n //\r\n serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;\r\n serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;\r\n serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\r\n serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;\r\n serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;\r\n serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // This comes from the base module\r\n //\r\n vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName;\r\n vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace(\"Vfmodule\", \"vDNS\");\r\n //\r\n // vfModuleItem - NOT the base module\r\n //\r\n vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId;\r\n vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion;\r\n vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue;\r\n vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue;\r\n //\r\n // tenantItem\r\n //\r\n tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;\r\n //\r\n // cloudRegionItem\r\n //\r\n cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;\r\n //\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.REJECTED;\r\n notification.message = \"Exception occurred \" + e.getMessage();\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n notification.message = \"Invalid named-query response from AAI\";\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e1) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e1.printStackTrace();\r\n }\r\n //\r\n // Retract everything\r\n //\r\n retract($aainqf199RequestWrapper);\r\n retract($aainqf199ResponseWrapper);\r\n retract($manager);\r\n retract($event);\r\n return;\r\n } \r\n //\r\n // Extracted fields should not be null\r\n //\r\n if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||\r\n (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||\r\n (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||\r\n (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||\r\n (serviceItemModelType == null) || (serviceItemModelVersion == null) ||\r\n (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||\r\n (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||\r\n (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||\r\n (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {\r\n //\r\n System.err.println(\"some fields are missing from AAI response.\");\r\n //\r\n // Fail and retract everything\r\n //\r\n retract($aainqf199RequestWrapper);\r\n retract($aainqf199ResponseWrapper);\r\n retract($manager);\r\n retract($event);\r\n return;\r\n }\r\n //\r\n // We don\'t need them any more\r\n //\r\n retract($aainqf199ResponseWrapper);\r\n retract($aainqf199RequestWrapper); \r\n //\r\n // check the actor of this closed loop\r\n //\r\n switch ($params.getActor()) {\r\n case \"APPC\":\r\n {\r\n //\r\n // Construct an APPC request\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"ModifyConfig\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // insert operationWrapper into memory\r\n //\r\n insert(operationWrapper);\r\n //\r\n Request request = new Request();\r\n request.CommonHeader = new CommonHeader();\r\n request.CommonHeader.RequestID = $event.requestID;\r\n request.Action = operation.operation;\r\n request.Payload = new HashMap<String, Object>();\r\n //\r\n // Fill in the payload\r\n // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case\r\n //\r\n String genericVNF = \"zdfw1fwl01pgn02\";\r\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\r\n //\r\n PGRequest pgRequest = new PGRequest();\r\n pgRequest.pgStreams = new PGStreams();\r\n \r\n PGStream pgStream;\r\n for(int i = 0; i < 5; i++){\r\n pgStream = new PGStream();\r\n pgStream.streamId = \"fw_udp\"+(i+1);\r\n pgStream.isEnabled = \"true\";\r\n pgRequest.pgStreams.pgStream.add(pgStream);\r\n }\r\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\r\n \r\n if (request != null) {\r\n //\r\n // Insert request into memory\r\n //\r\n insert(request);\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n // message and history ??\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Now send the operation request\r\n //\r\n if (request instanceof Request) {\r\n try {\r\n System.out.println(\"APPC request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n System.out.println(\"Can\'t deliver request: \" + request);\r\n }\r\n }\r\n } else {\r\n //\r\n // what happens if it is null\r\n //\r\n }\r\n }\r\n break;\r\n case \"MSO\":\r\n {\r\n //\r\n // Construct an operation\r\n //\r\n ControlLoopOperation operation = new ControlLoopOperation();\r\n operation.actor = $params.getActor();\r\n operation.operation = \"createModuleInstance\";\r\n operation.target = $event.target;\r\n //\r\n // Create operationWrapper\r\n //\r\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\r\n //\r\n // Construct an MSO request\r\n //\r\n MSORequest request = new MSORequest();\r\n request.requestDetails = new MSORequestDetails();\r\n request.requestDetails.modelInfo = new MSOModelInfo();\r\n request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();\r\n request.requestDetails.requestInfo = new MSORequestInfo();\r\n request.requestDetails.requestParameters = new MSORequestParameters();\r\n request.requestDetails.requestParameters.userParams = null;\r\n //\r\n // cloudConfiguration\r\n //\r\n request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;\r\n request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;\r\n //\r\n // modelInfo\r\n //\r\n request.requestDetails.modelInfo.modelType = \"vfModule\";\r\n request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;\r\n request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;\r\n request.requestDetails.modelInfo.modelName = vfModuleItemModelName;\r\n request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;\r\n //\r\n // requestInfo\r\n //\r\n request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;\r\n request.requestDetails.requestInfo.source = \"POLICY\";\r\n request.requestDetails.requestInfo.suppressRollback = false;\r\n //\r\n // relatedInstanceList\r\n //\r\n MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();\r\n MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();\r\n relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();\r\n relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();\r\n //\r\n relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelType = \"service\";\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;\r\n relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;\r\n //\r\n relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelType = \"vnf\";\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;\r\n relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;\r\n // \r\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);\r\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);\r\n //\r\n // print MSO request for debug\r\n //\r\n System.out.println(\"MSO request sent:\");\r\n System.out.println(Serialization.gsonPretty.toJson(request));\r\n //\r\n //\r\n //\r\n if (request != null) {\r\n //\r\n // Tell interested parties we are performing this Operation\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.notification = ControlLoopNotificationType.OPERATION;\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL\r\n //\r\n String MSOUrl = $params.getMsoURL() + \"/serviceInstances/v2/\" + serviceItemServiceInstanceId + \"/vnfs/\" + vnfItemVnfId + \"/vfModules\";\r\n //\r\n // Call MSO\r\n //\r\n MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);\r\n //\r\n if (response != null) {\r\n //\r\n // Assign requestId\r\n //\r\n request.requestId = $event.requestID.toString(); \r\n response.request.requestId = $event.requestID.toString();\r\n //\r\n // Insert facts\r\n //\r\n insert(operationWrapper);\r\n insert(request);\r\n insert(response);\r\n } else {\r\n //\r\n // MSO request not even accepted\r\n //\r\n notification.message = operationWrapper.operation.toMessage();\r\n operationWrapper.operation.message = operationWrapper.operation.toMessage();\r\n operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n notification.history.add(operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // Retract everything\r\n //\r\n retract($event);\r\n retract($manager);\r\n }\r\n } else {\r\n System.err.println(\"constructed MSO request is invalid.\");\r\n }\r\n }\r\n break; \r\n } \r\nend\r\n \r\n/*\r\n*\r\n* This rule responds to APPC Response Events\r\n*\r\n*/\r\nrule \"${policyName}.APPC.RESPONSE\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\r\n $request : Request( getCommonHeader().RequestID == $event.requestID )\r\n $response : Response( getCommonHeader().RequestID == $event.requestID ) \r\n then\r\n System.out.println(\"rule APPC.RESPONSE is triggered.\");\r\n if ($response.Status == null) {\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n } \r\n //\r\n // Get the Response Code\r\n //\r\n ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);\r\n if (code == null) {\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n }\r\n //\r\n // Construct notification\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n notification.message = $operationWrapper.operation.toMessage();\r\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\r\n //\r\n // Ok, let\'s figure out what APP-C\'s response is\r\n //\r\n switch (code) {\r\n case ACCEPT:\r\n $operationWrapper.operation.outcome = \"PROCESSING\";\r\n break;\r\n case ERROR:\r\n case REJECT:\r\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\r\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\r\n break;\r\n case SUCCESS:\r\n $operationWrapper.operation.outcome = \"SUCCESS\";\r\n $manager.setControlLoopResult(\"SUCCESS\");\r\n break;\r\n case FAILURE:\r\n $operationWrapper.operation.outcome = \"FAILURE\";\r\n $manager.setControlLoopResult(\"FAILURE\");\r\n break;\r\n }\r\n if ($operationWrapper.operation.outcome.equals(\"SUCCESS\")) {\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n } else if ($operationWrapper.operation.outcome.equals(\"PROCESSING\")) {\r\n retract($response);\r\n } else {\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n }\r\n \r\nend \r\n\r\n/*\r\n*\r\n* This rule is used to clean up APPC response\r\n*\r\n*/ \r\nrule \"${policyName}.APPC.RESPONSE.CLEANUP\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $response : Response($id : getCommonHeader().RequestID )\r\n not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) \r\n then\r\n System.out.println(\"rule APPC.RESPONSE.CLEANUP is triggered.\");\r\n retract($response);\r\nend\r\n\r\n/*\r\n*\r\n* This rule responds to MSO Response Events\r\n*\r\n*/\r\nrule \"${policyName}.MSO.RESPONSE\"\r\n when\r\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\r\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\r\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\r\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\r\n $request : MSORequest( requestId == $event.requestID.toString() )\r\n $response : MSOResponse( request.requestId == $event.requestID.toString() ) \r\n then\r\n System.out.println(\"rule MSO.RESPONSE is triggered.\");\r\n //\r\n // Construct notification\r\n //\r\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\r\n notification.from = \"policy\";\r\n notification.policyName = drools.getRule().getName();\r\n notification.policyScope = \"${policyScope}\";\r\n notification.policyVersion = \"${policyVersion}\";\r\n notification.message = $operationWrapper.operation.toMessage();\r\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\r\n //\r\n // The operation can either be succeeded or failed\r\n // \r\n if($response.request.requestStatus.requestState.equals(\"Completed\")) {\r\n $operationWrapper.operation.outcome = \"SUCCESS\";\r\n $manager.setControlLoopResult(\"SUCCESS\");\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n } else {\r\n $operationWrapper.operation.outcome = \"FAILURE\";\r\n $manager.setControlLoopResult(\"FAILURE\");\r\n notification.history.add($operationWrapper.operation);\r\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\r\n //\r\n // Let interested parties know\r\n //\r\n try {\r\n System.out.println(Serialization.gsonPretty.toJson(notification));\r\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\r\n } catch (Exception e) {\r\n System.out.println(\"Can\'t deliver notification: \" + notification);\r\n e.printStackTrace();\r\n }\r\n //\r\n // We are going to retract these objects from memory\r\n //\r\n System.out.println(\"Retracting everything\");\r\n retract($operationWrapper);\r\n retract($request);\r\n retract($response);\r\n retract($event);\r\n retract($manager);\r\n }\r\n \r\nend ','2017-02-09 17:11:42','demo'); +INSERT INTO `configurationdataentity` VALUES (3155,'{\"service\":\"TcaMetrics\",\"location\":\"SampleServiceLocation\",\"uuid\":\"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall\",\"policyName\":\"vFirewall\",\"description\":\"Micro Service vFirewall Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:\",\"configName\":\"SampleConfigName\",\"templateVersion\":\"OpenSource.version.1\",\"version\":\"1.0.0.5\",\"priority\":\"1\",\"policyScope\":\"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop\",\"content\":{\"thresholds\":[{\"severity\":\"MAJOR\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn\",\"thresholdValue\":\"300\",\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\":\"1.0.2\",\"direction\":\"LESS_OR_EQUAL\"},{\"severity\":\"CRITICAL\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn\",\"thresholdValue\":\"700\",\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\":\"1.0.2\",\"direction\":\"GREATER_OR_EQUAL\"}],\"functionalRole\":\"vFirewall\",\"name\":\"0\"}}\r\n','JSON','com.Config_MS_vFirewall.1.json','doACPolicyPut','2017-03-03 17:26:24',0,'','doACPolicyPut','2017-03-03 17:26:24',1),(3157,'{\"service\":\"TcaMetrics\",\"location\":\"SampleServiceLocation\",\"uuid\":\"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer\",\"policyName\":\"vLoadBalancer\",\"description\":\"Micro Service vLoadBalancer Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:\",\"configName\":\"SampleConfigName\",\"templateVersion\":\"OpenSource.version.1\",\"version\":\"1.0.0.5\",\"priority\":\"1\",\"policyScope\":\"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop\",\"content\":{\"thresholds\":[{\"severity\":\"MAJOR\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn\",\"thresholdValue\":\"200\",\"closedLoopControlName\":\"CL-DNS-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"version\":\"1.0.2\",\"direction\":\"GREATER_OR_EQUAL\"}],\"functionalRole\":\"vLoadBalancer\",\"name\":\"0\"}}\r\n','JSON','com.Config_MS_vLoadBalancer.1.json','doACPolicyPut','2017-03-03 17:28:10',0,'','doACPolicyPut','2017-03-03 17:28:10',1); + +INSERT INTO `brmsparamtemplate` VALUES (1,'ControlLoopDemo__closedLoopControlName','ControlLoopDemo__closedLoopControlName','\r\n\r\n/*-\n * ============LICENSE_START=======================================================\n * archetype-closed-loop-demo-rules\n * ================================================================================\n * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ============LICENSE_END=========================================================\n */\n\npackage org.openecomp.policy.controlloop;\n\nimport java.util.List;\nimport java.util.LinkedList;\nimport java.util.Map;\nimport java.util.HashMap;\nimport java.util.UUID;\n\nimport org.openecomp.policy.controlloop.VirtualControlLoopEvent;\nimport org.openecomp.policy.controlloop.ControlLoopEventStatus;\nimport org.openecomp.policy.controlloop.VirtualControlLoopNotification;\nimport org.openecomp.policy.controlloop.ControlLoopNotificationType;\nimport org.openecomp.policy.controlloop.ControlLoopOperation;\nimport org.openecomp.policy.controlloop.ControlLoopOperationWrapper;\nimport org.openecomp.policy.template.demo.ControlLoopException;\n\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Request;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Response;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.openecomp.policy.aai.util.Serialization;\n\nimport org.openecomp.policy.appc.CommonHeader;\nimport org.openecomp.policy.appc.Request;\nimport org.openecomp.policy.appc.Response;\nimport org.openecomp.policy.appc.ResponseCode;\nimport org.openecomp.policy.appc.ResponseStatus;\nimport org.openecomp.policy.appc.ResponseValue;\n\nimport org.openecomp.policy.template.demo.EventManager;\nimport org.openecomp.policy.vnf.trafficgenerator.PGRequest;\nimport org.openecomp.policy.vnf.trafficgenerator.PGStream;\nimport org.openecomp.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.openecomp.policy.mso.MSOManager;\nimport org.openecomp.policy.mso.MSORequest;\nimport org.openecomp.policy.mso.MSORequestStatus;\nimport org.openecomp.policy.mso.MSORequestDetails;\nimport org.openecomp.policy.mso.MSOModelInfo;\nimport org.openecomp.policy.mso.MSOCloudConfiguration;\nimport org.openecomp.policy.mso.MSORequestInfo;\nimport org.openecomp.policy.mso.MSORequestParameters;\nimport org.openecomp.policy.mso.MSORelatedInstanceListElement;\nimport org.openecomp.policy.mso.MSORelatedInstance;\nimport org.openecomp.policy.mso.MSOResponse;\n\nimport org.openecomp.policy.drools.system.PolicyEngine;\n\n//\n// These parameters are required to build the runtime policy\n//\ndeclare Params\n closedLoopControlName : String\n actor : String\n aaiURL : String\n aaiUsername : String\n aaiPassword : String\n msoURL : String\n msoUsername : String\n msoPassword : String\n aaiNamedQueryUUID : String\n aaiPatternMatch : int \n notificationTopic : String\n appcTopic : String\nend\n\n/*\n*\n* Called once and only once to insert the parameters into working memory for this Closed Loop policy.\n* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)\n*\n*\n*rule \"${policyName}.SETUP\"\n* when\n* then\n* System.out.println(\"rule SETUP is triggered.\");\n* Params params = new Params();\n* params.setClosedLoopControlName(\"${closedLoopControlName}\");\n* params.setActor(\"${actor}\");\n* params.setAaiURL(\"${aaiURL}\");\n* params.setAaiUsername(\"${aaiUsername}\");\n* params.setAaiPassword(\"${aaiPassword}\");\n* params.setMsoURL(\"${msoURL}\");\n* params.setMsoUsername(\"${msoUsername}\");\n* params.setMsoPassword(\"${msoPassword}\");\n* params.setAaiNamedQueryUUID(\"${aaiNamedQueryUUID}\");\n* params.setAaiPatternMatch(${aaiPatternMatch});\n* params.setNotificationTopic(\"${notificationTopic}\");\n* params.setAppcTopic(\"${appcTopic}\");\n* //\n* // This stays in memory as long as the rule is alive and running\n* //\n* insert(params);\n*end\n*/\n/*\n*\n* This rule responds to DCAE Events\n*\n*/\nrule \"${policyName}.EVENT\"\n when\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))\n then\n System.out.println(\"rule EVENT is triggered.\");\n try {\n // \n // Check the requestID in the event to make sure it is not null before we create the EventManager. \n // The EventManager will do extra syntax checking as well check if the closed loop is disabled/\n //\n if ($event.requestID == null) {\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.from = \"policy\";\n notification.message = \"Missing requestID from DCAE event\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n }\n //\n // Retract it from memory\n //\n retract($event);\n System.out.println(\"Event with requestID=null has been retracted.\");\n } else {\n //\n // Create an EventManager\n //\n EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);\n //\n // Determine if EventManager can actively process the event (i.e. syntax)\n //\n VirtualControlLoopNotification notification = manager.activate($event);\n notification.from = \"policy\"; \n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n //\n // Are we actively pursuing this event?\n //\n if (notification.notification == ControlLoopNotificationType.ACTIVE) {\n //\n // Insert Event Manager into memory, this will now kick off processing.\n //\n insert(manager);\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n } \n } else {\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver notification: \" + notification);\n }\n //\n // Retract it from memory\n //\n retract($event);\n }\n //\n // Now that the manager is inserted into Drools working memory, we\'ll wait for\n // another rule to fire in order to continue processing. This way we can also\n // then screen for additional ONSET and ABATED events for this same RequestIDs \n // and for different RequestIDs but with the same closedLoopControlName and target.\n //\n }\n //\n } catch (Exception e) {\n e.printStackTrace();\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.message = \"Exception occurred \" + e.getMessage();\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n //\n //\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n // Retract the event\n //\n retract($event);\n }\nend\n\n/*\n*\n* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager\n* is created. We can start the operations for this closed loop.\n*\n*/\nrule \"${policyName}.EVENT.MANAGER\"\n when\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)\n then\n System.out.println(\"rule EVENT.MANAGER is triggered.\");\n //\n // Check which event this is.\n //\n EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);\n //\n // We only want the initial ONSET event in memory,\n // all the other events need to be retracted to support\n // cleanup and avoid the other rules being fired for this event.\n //\n if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {\n System.out.println(\"Retracting \"+eventStatus+\" Event.\");\n retract($event);\n return;\n }\n //\n // Now the event in memory is first onset event\n //\n try {\n //\n // Pull the known AAI field from the Event\n //\n // generic-vnf is needed for vFirewall case\n // vserver-name is needed for vLoadBalancer case\n //\n String genericVNF = $event.AAI.get(\"generic-vnf.vnf-id\");\n String vserver = $event.AAI.get(\"vserver.vserver-name\");\n //\n // Check if we are implementing a simple pattern match.\n //\n if ($params.getAaiPatternMatch() == 1) {\n //\n // Yes\n //\n //Basic naming characteristics:\n //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)\n //Example: \n //VF Name (9 characters): cscf0001v\n //VM Name(13 characters): cscf0001vm001\n //VFC name(19 characters): cscf0001vm001cfg001\n //\n // zdfw1fwl01fwl02 or zdfw1fwl01fwl01 \n // replaced with\n // zdfw1fwl01pgn02 or zdfw1fwl01pgn01\n //\n int index = genericVNF.lastIndexOf(\"fwl\");\n if (index == -1) {\n System.err.println(\"The generic-vnf.vnf-id from DCAE Event is not valid.\");\n } else {\n genericVNF = genericVNF.substring(0, index) + \"pgn\" + genericVNF.substring(index+\"fwl\".length());\n }\n //\n // Construct an APPC request\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"ModifyConfig\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // insert operationWrapper into memory\n //\n insert(operationWrapper);\n //\n Request request = new Request();\n request.CommonHeader = new CommonHeader();\n request.CommonHeader.RequestID = $event.requestID;\n request.Action = operation.operation;\n request.Payload = new HashMap<String, Object>();\n //\n // Fill in the payload\n //\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\n //\n PGRequest pgRequest = new PGRequest();\n pgRequest.pgStreams = new PGStreams();\n \n PGStream pgStream;\n for(int i = 0; i < 5; i++){\n pgStream = new PGStream();\n pgStream.streamId = \"fw_udp\"+(i+1);\n pgStream.isEnabled = \"true\";\n pgRequest.pgStreams.pgStream.add(pgStream);\n }\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\n \n if (request != null) {\n //\n // Insert request into memory\n //\n insert(request);\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n // message and history ??\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Now send the operation request\n //\n if (request instanceof Request) {\n try {\n System.out.println(\"APPC request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver request: \" + request);\n }\n }\n } else {\n //\n // what happens if it is null\n //\n }\n //\n } else {\n //\n // create AAI named-query request with UUID started with \"F199\"\n //\n AAINQF199Request aainqf199request = new AAINQF199Request();\n AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();\n AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();\n AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();\n //\n // queryParameters\n //\n aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID()); \n aainqf199queryparam.namedQuery = aainqf199namedquery;\n aainqf199request.queryParameters = aainqf199queryparam;\n //\n // instanceFilters\n //\n Map aainqf199instancefiltermap = new HashMap();\n Map aainqf199instancefiltermapitem = new HashMap();\n aainqf199instancefiltermapitem.put(\"vserver-name\", vserver); \n aainqf199instancefiltermap.put(\"vserver\", aainqf199instancefiltermapitem);\n aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);\n aainqf199request.instanceFilters = aainqf199instancefilter;\n //\n // print aainqf199request for debug\n //\n System.out.println(\"AAI Request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(aainqf199request));\n //\n // Create AAINQF199RequestWrapper\n //\n AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);\n //\n // insert aainqf199request into memory\n //\n insert(aainqf199RequestWrapper);\n }\n //\n } catch (Exception e) {\n e.printStackTrace();\n }\nend\n\n/*\n*\n* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager\n* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.\n*\n*/\nrule \"${policyName}.EVENT.MANAGER.AAINQF199REQUEST\"\n when\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\n then\n System.out.println(\"rule EVENT.MANAGER.AAINQF199REQUEST is triggered.\");\n //\n // send the request\n //\n AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),\n $aainqf199RequestWrapper.aainqf199request, $event.requestID);\n //\n // Check AAI response\n //\n if (aainqf199response == null) {\n System.err.println(\"Failed to get AAI response\");\n //\n // Fail and retract everything\n //\n retract($event);\n retract($manager);\n retract($aainqf199RequestWrapper);\n } else {\n //\n // Create AAINQF199ResponseWrapper\n //\n AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);\n //\n // insert aainqf199ResponseWrapper to memeory\n //\n insert(aainqf199ResponseWrapper);\n }\nend\n\n/*\n*\n* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.\n*\n*/\nrule \"${policyName}.EVENT.MANAGER.AAINQF199RESPONSE\"\n when \n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)\n $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)\n then\n System.out.println(\"rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.\");\n //\n // Extract related fields out of AAINQF199RESPONSE\n //\n String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName, \n vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,\n serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,\n vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName, \n vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;\n try {\n //\n // vnfItem\n //\n vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;\n vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;\n vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf(\"/\")+1);\n vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;\n vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;\n vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\n vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;\n vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\n //\n // serviceItem\n //\n serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;\n serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;\n serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;\n serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;\n serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;\n serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;\n //\n // Find the index for base vf module and non-base vf module\n //\n int baseIndex = -1;\n int nonBaseIndex = -1;\n List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;\n for (AAINQF199InventoryResponseItem m : inventoryItems) {\n if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {\n baseIndex = inventoryItems.indexOf(m);\n } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {\n nonBaseIndex = inventoryItems.indexOf(m);\n }\n //\n if (baseIndex != -1 && nonBaseIndex != -1) {\n break;\n }\n }\n //\n // Report the error if either base vf module or non-base vf module is not found\n //\n if (baseIndex == -1 || nonBaseIndex == -1) {\n System.err.println(\"Either base or non-base vf module is not found from AAI response.\");\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n }\n //\n // This comes from the base module\n //\n vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName;\n vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace(\"Vfmodule\", \"vDNS\");\n //\n // vfModuleItem - NOT the base module\n //\n vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId;\n vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion;\n vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue;\n vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue;\n //\n // tenantItem\n //\n tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;\n //\n // cloudRegionItem\n //\n cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;\n //\n } catch (Exception e) {\n e.printStackTrace();\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.REJECTED;\n notification.message = \"Exception occurred \" + e.getMessage();\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n notification.message = \"Invalid named-query response from AAI\";\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e1) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e1.printStackTrace();\n }\n //\n // Retract everything\n //\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n } \n //\n // Extracted fields should not be null\n //\n if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||\n (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||\n (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||\n (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||\n (serviceItemModelType == null) || (serviceItemModelVersion == null) ||\n (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||\n (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||\n (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||\n (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {\n //\n System.err.println(\"some fields are missing from AAI response.\");\n //\n // Fail and retract everything\n //\n retract($aainqf199RequestWrapper);\n retract($aainqf199ResponseWrapper);\n retract($manager);\n retract($event);\n return;\n }\n //\n // We don\'t need them any more\n //\n retract($aainqf199ResponseWrapper);\n retract($aainqf199RequestWrapper); \n //\n // check the actor of this closed loop\n //\n switch ($params.getActor()) {\n case \"APPC\":\n {\n //\n // Construct an APPC request\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"ModifyConfig\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // insert operationWrapper into memory\n //\n insert(operationWrapper);\n //\n Request request = new Request();\n request.CommonHeader = new CommonHeader();\n request.CommonHeader.RequestID = $event.requestID;\n request.Action = operation.operation;\n request.Payload = new HashMap<String, Object>();\n //\n // Fill in the payload\n // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case\n //\n String genericVNF = \"zdfw1fwl01pgn02\";\n request.Payload.put(\"generic-vnf.vnf-id\", genericVNF);\n //\n PGRequest pgRequest = new PGRequest();\n pgRequest.pgStreams = new PGStreams();\n \n PGStream pgStream;\n for(int i = 0; i < 5; i++){\n pgStream = new PGStream();\n pgStream.streamId = \"fw_udp\"+(i+1);\n pgStream.isEnabled = \"true\";\n pgRequest.pgStreams.pgStream.add(pgStream);\n }\n request.Payload.put(\"pg-streams\", pgRequest.pgStreams);\n \n if (request != null) {\n //\n // Insert request into memory\n //\n insert(request);\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n // message and history ??\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Now send the operation request\n //\n if (request instanceof Request) {\n try {\n System.out.println(\"APPC request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n PolicyEngine.manager.deliver($params.getAppcTopic(), request);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Can\'t deliver request: \" + request);\n }\n }\n } else {\n //\n // what happens if it is null\n //\n }\n }\n break;\n case \"MSO\":\n {\n //\n // Construct an operation\n //\n ControlLoopOperation operation = new ControlLoopOperation();\n operation.actor = $params.getActor();\n operation.operation = \"createModuleInstance\";\n operation.target = $event.target;\n //\n // Create operationWrapper\n //\n ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);\n //\n // Construct an MSO request\n //\n MSORequest request = new MSORequest();\n request.requestDetails = new MSORequestDetails();\n request.requestDetails.modelInfo = new MSOModelInfo();\n request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();\n request.requestDetails.requestInfo = new MSORequestInfo();\n request.requestDetails.requestParameters = new MSORequestParameters();\n request.requestDetails.requestParameters.userParams = null;\n //\n // cloudConfiguration\n //\n request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;\n request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;\n //\n // modelInfo\n //\n request.requestDetails.modelInfo.modelType = \"vfModule\";\n request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;\n request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;\n request.requestDetails.modelInfo.modelName = vfModuleItemModelName;\n request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;\n //\n // requestInfo\n //\n request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;\n request.requestDetails.requestInfo.source = \"POLICY\";\n request.requestDetails.requestInfo.suppressRollback = false;\n //\n // relatedInstanceList\n //\n MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();\n MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();\n relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();\n relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();\n //\n relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;\n relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();\n relatedInstanceListElement1.relatedInstance.modelInfo.modelType = \"service\";\n relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;\n relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;\n //\n relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;\n relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();\n relatedInstanceListElement2.relatedInstance.modelInfo.modelType = \"vnf\";\n relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;\n relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;\n // \n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);\n request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);\n //\n // print MSO request for debug\n //\n System.out.println(\"MSO request sent:\");\n System.out.println(Serialization.gsonPretty.toJson(request));\n //\n //\n //\n if (request != null) {\n //\n // Tell interested parties we are performing this Operation\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.notification = ControlLoopNotificationType.OPERATION;\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL\n //\n String MSOUrl = $params.getMsoURL() + \"/serviceInstances/v2/\" + serviceItemServiceInstanceId + \"/vnfs/\" + vnfItemVnfId + \"/vfModules\";\n //\n // Call MSO\n //\n MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);\n //\n if (response != null) {\n //\n // Assign requestId\n //\n request.requestId = $event.requestID.toString(); \n response.request.requestId = $event.requestID.toString();\n //\n // Insert facts\n //\n insert(operationWrapper);\n insert(request);\n insert(response);\n } else {\n //\n // MSO request not even accepted\n //\n notification.message = operationWrapper.operation.toMessage();\n operationWrapper.operation.message = operationWrapper.operation.toMessage();\n operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n notification.history.add(operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // Retract everything\n //\n retract($event);\n retract($manager);\n }\n } else {\n System.err.println(\"constructed MSO request is invalid.\");\n }\n }\n break; \n } \nend\n \n/*\n*\n* This rule responds to APPC Response Events\n*\n*/\nrule \"${policyName}.APPC.RESPONSE\"\n when\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\n $request : Request( getCommonHeader().RequestID == $event.requestID )\n $response : Response( getCommonHeader().RequestID == $event.requestID ) \n then\n System.out.println(\"rule APPC.RESPONSE is triggered.\");\n if ($response.Status == null) {\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n } \n //\n // Get the Response Code\n //\n ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);\n if (code == null) {\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n }\n //\n // Construct notification\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n notification.message = $operationWrapper.operation.toMessage();\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\n //\n // Ok, let\'s figure out what APP-C\'s response is\n //\n switch (code) {\n case ACCEPT:\n $operationWrapper.operation.outcome = \"PROCESSING\";\n break;\n case ERROR:\n case REJECT:\n $operationWrapper.operation.outcome = \"FAILURE_EXCEPTION\";\n $manager.setControlLoopResult(\"FAILURE_EXCEPTION\");\n break;\n case SUCCESS:\n $operationWrapper.operation.outcome = \"SUCCESS\";\n $manager.setControlLoopResult(\"SUCCESS\");\n break;\n case FAILURE:\n $operationWrapper.operation.outcome = \"FAILURE\";\n $manager.setControlLoopResult(\"FAILURE\");\n break;\n }\n if ($operationWrapper.operation.outcome.equals(\"SUCCESS\")) {\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n } else if ($operationWrapper.operation.outcome.equals(\"PROCESSING\")) {\n retract($response);\n } else {\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n }\n \nend \n\n/*\n*\n* This rule is used to clean up APPC response\n*\n*/ \nrule \"${policyName}.APPC.RESPONSE.CLEANUP\"\n when\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $response : Response($id : getCommonHeader().RequestID )\n not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) \n then\n System.out.println(\"rule APPC.RESPONSE.CLEANUP is triggered.\");\n retract($response);\nend\n\n/*\n*\n* This rule responds to MSO Response Events\n*\n*/\nrule \"${policyName}.MSO.RESPONSE\"\n when\n $params : Params( getClosedLoopControlName() == \"${closedLoopControlName}\" )\n $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )\n $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )\n $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )\n $request : MSORequest( requestId == $event.requestID.toString() )\n $response : MSOResponse( request.requestId == $event.requestID.toString() ) \n then\n System.out.println(\"rule MSO.RESPONSE is triggered.\");\n //\n // Construct notification\n //\n VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);\n notification.from = \"policy\";\n notification.policyName = drools.getRule().getName();\n notification.policyScope = \"${policyScope}\";\n notification.policyVersion = \"${policyVersion}\";\n notification.message = $operationWrapper.operation.toMessage();\n $operationWrapper.operation.message = $operationWrapper.operation.toMessage();\n //\n // The operation can either be succeeded or failed\n // \n if($response.request.requestStatus.requestState.equals(\"Completed\")) {\n $operationWrapper.operation.outcome = \"SUCCESS\";\n $manager.setControlLoopResult(\"SUCCESS\");\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n } else {\n $operationWrapper.operation.outcome = \"FAILURE\";\n $manager.setControlLoopResult(\"FAILURE\");\n notification.history.add($operationWrapper.operation);\n notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n notification.notification = ControlLoopNotificationType.FINAL_FAILURE;\n //\n // Let interested parties know\n //\n try {\n System.out.println(Serialization.gsonPretty.toJson(notification));\n PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);\n } catch (Exception e) {\n System.out.println(\"Can\'t deliver notification: \" + notification);\n e.printStackTrace();\n }\n //\n // We are going to retract these objects from memory\n //\n System.out.println(\"Retracting everything\");\n retract($operationWrapper);\n retract($request);\n retract($response);\n retract($event);\n retract($manager);\n }\n \nend ','2017-03-03 17:11:30','demo'); + +INSERT INTO `policyversion` VALUES (1,'com/Config_BRMS_Param_BRMSParamvFWDemoPolicy',1,1,'2017-03-03 17:16:37','demo','2017-03-03 17:16:37','demo'),(2,'com/Config_BRMS_Param_BRMSParamvLBDemoPolicy',1,1,'2017-03-03 17:20:03','demo','2017-03-03 17:20:03','demo'); + +INSERT INTO `policyversion` VALUES (3,'com/Config_MS_vFirewall',1,1,'2017-03-03 17:26:26','demo','2017-03-03 17:26:26','demo'),(4,'com/Config_MS_vLoadBalancer',1,1,'2017-03-03 17:28:13','demo','2017-03-03 17:28:13','demo'); insert into sequence (seq_name, seq_count) values ('SEQ_GEN', 3050); diff --git a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml index d4bc19eaa..a21ed006f 100644 --- a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml +++ b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:708de148-2cfb-4211-930a-44b446c2d781" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> - <Description>vFW Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description> +<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:f8ba1b97-fea0-431b-9c5b-8f0fa572b337" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> + <Description>BRMSParamvFWDemoPolicy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description> <Target> <AnyOf> <AllOf> @@ -37,7 +37,7 @@ </AllOf> </AnyOf> </Target> - <Rule RuleId="urn:com:xacml:rule:id:817128cd-2880-4e85-997b-1abff0eae822" Effect="Permit"> + <Rule RuleId="urn:com:xacml:rule:id:9a371467-7775-47de-afa7-e1dbcdaf6594" Effect="Permit"> <Target> <AnyOf> <AllOf> diff --git a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml index f3bb31456..46b968298 100644 --- a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml +++ b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:95afb43f-13f2-475c-9501-7e022d15b8a7" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> +<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:8b7dd2ad-00d0-4e85-97ce-f915322c9023" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> <Description>vLB Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description> <Target> <AnyOf> @@ -37,7 +37,7 @@ </AllOf> </AnyOf> </Target> - <Rule RuleId="urn:com:xacml:rule:id:69f687f8-1f6e-485f-a4e8-5cb9beb28ba4" Effect="Permit"> + <Rule RuleId="urn:com:xacml:rule:id:d35c6a55-3fc2-420e-b426-080a680bce62" Effect="Permit"> <Target> <AnyOf> <AllOf> diff --git a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vFirewall.1.xml b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vFirewall.1.xml index 7081ebc67..6492b50ee 100644 --- a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vFirewall.1.xml +++ b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vFirewall.1.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:a1c91d9b-b5d2-4b04-b3a9-afcac74a8161" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> +<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:34928b05-b0f6-4974-8458-f4d34a2a1764" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> <Description>Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description> <Target> <AnyOf> @@ -49,7 +49,7 @@ </AllOf> </AnyOf> </Target> - <Rule RuleId="urn:com:xacml:rule:id:2af7b2a1-6427-4765-ac5f-0d5e3c7d059f" Effect="Permit"> + <Rule RuleId="urn:com:xacml:rule:id:063161de-0534-4989-bd01-42f784daf21e" Effect="Permit"> <Target> <AnyOf> <AllOf> diff --git a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vLoadBalancer.1.xml b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vLoadBalancer.1.xml index 8128ffbbd..0de9067a2 100644 --- a/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vLoadBalancer.1.xml +++ b/packages/base/src/files/install/servers/console/bin/workspace/admin/repository/com/Config_MS_vLoadBalancer.1.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:4fd0d4bd-729b-42dd-9c39-d63fea7c9655" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> +<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:c220802a-70ee-4ca8-9f1e-f8a515650381" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides"> <Description>Micro Service vLoadBalancer Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description> <Target> <AnyOf> @@ -49,7 +49,7 @@ </AllOf> </AnyOf> </Target> - <Rule RuleId="urn:com:xacml:rule:id:69d31737-09d4-429f-9e1d-6bcf39da90a1" Effect="Permit"> + <Rule RuleId="urn:com:xacml:rule:id:fca27dab-6c09-4541-8136-328abaec2656" Effect="Permit"> <Target> <AnyOf> <AllOf> diff --git a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt index 42b67999f..102c293e9 100644 --- a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt +++ b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt @@ -25,6 +25,7 @@ package org.openecomp.policy.controlloop; +import java.util.List; import java.util.LinkedList; import java.util.Map; import java.util.HashMap; @@ -522,17 +523,45 @@ rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE" serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion; serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue; // + // Find the index for base vf module and non-base vf module + // + int baseIndex = -1; + int nonBaseIndex = -1; + List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems; + for (AAINQF199InventoryResponseItem m : inventoryItems) { + if (m.vfModule != null && m.vfModule.isBaseVfModule == true) { + baseIndex = inventoryItems.indexOf(m); + } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) { + nonBaseIndex = inventoryItems.indexOf(m); + } + // + if (baseIndex != -1 && nonBaseIndex != -1) { + break; + } + } + // + // Report the error if either base vf module or non-base vf module is not found + // + if (baseIndex == -1 || nonBaseIndex == -1) { + System.err.println("Either base or non-base vf module is not found from AAI response."); + retract($aainqf199RequestWrapper); + retract($aainqf199ResponseWrapper); + retract($manager); + retract($event); + return; + } + // // This comes from the base module // - vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName; + vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName; vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS"); // // vfModuleItem - NOT the base module // - vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId; - vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion; - vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue; - vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue; + vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId; + vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion; + vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue; + vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue; // // tenantItem // @@ -1105,8 +1134,8 @@ rule "Params" params.setAaiURL("null"); params.setMsoPassword("null"); params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8"); - params.setAaiUsername("null"); params.setMsoURL("null"); + params.setAaiUsername("null"); params.setActor("APPC"); params.setMsoUsername("null"); params.setAaiNamedQueryUUID("null"); diff --git a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt index 2fdfa6736..25de49320 100644 --- a/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt +++ b/packages/base/src/files/install/servers/pap/webapps/Config/com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.1.txt @@ -25,6 +25,7 @@ package org.openecomp.policy.controlloop; +import java.util.List; import java.util.LinkedList; import java.util.Map; import java.util.HashMap; @@ -522,17 +523,45 @@ rule "BRMSParamvLBDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE" serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion; serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue; // + // Find the index for base vf module and non-base vf module + // + int baseIndex = -1; + int nonBaseIndex = -1; + List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems; + for (AAINQF199InventoryResponseItem m : inventoryItems) { + if (m.vfModule != null && m.vfModule.isBaseVfModule == true) { + baseIndex = inventoryItems.indexOf(m); + } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) { + nonBaseIndex = inventoryItems.indexOf(m); + } + // + if (baseIndex != -1 && nonBaseIndex != -1) { + break; + } + } + // + // Report the error if either base vf module or non-base vf module is not found + // + if (baseIndex == -1 || nonBaseIndex == -1) { + System.err.println("Either base or non-base vf module is not found from AAI response."); + retract($aainqf199RequestWrapper); + retract($aainqf199ResponseWrapper); + retract($manager); + retract($event); + return; + } + // // This comes from the base module // - vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).vfModule.vfModuleName; + vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName; vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS"); // // vfModuleItem - NOT the base module // - vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelId; - vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).vfModule.personaModelVersion; - vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(0).propertyValue; - vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(2).extraProperties.extraProperty.get(4).propertyValue; + vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId; + vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion; + vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue; + vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue; // // tenantItem // |