summaryrefslogtreecommitdiffstats
path: root/packages/base/src/files/install/mysql
diff options
context:
space:
mode:
authorGuo Ruijing <ruijing.guo@intel.com>2017-07-31 08:47:35 +0000
committerPamela Dragosh <pdragosh@research.att.com>2017-07-31 15:51:10 -0400
commit073cc188efe9abb4c010cf674e34e2cf46ef1c52 (patch)
tree155c23fbdf3a838ecb5f4183fc3bb6b09aac41eb /packages/base/src/files/install/mysql
parent4ca818fdfb9b807562166800a086b413593d6894 (diff)
[POLICY-73] replace openecomp for policy-engine
Change-Id: I54072f6bcd388c0e05562614ee89b4ae7ad67004 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'packages/base/src/files/install/mysql')
-rw-r--r--packages/base/src/files/install/mysql/bin/cleanup_policy.sh2
-rw-r--r--packages/base/src/files/install/mysql/bin/db_backup.sh6
-rw-r--r--packages/base/src/files/install/mysql/bin/db_backup_data.sh2
-rw-r--r--packages/base/src/files/install/mysql/bin/db_backup_remote.sh6
-rw-r--r--packages/base/src/files/install/mysql/bin/db_restore.sh8
-rw-r--r--packages/base/src/files/install/mysql/bin/db_restore_data.sh2
-rw-r--r--packages/base/src/files/install/mysql/bin/db_upgrade.sh2
-rw-r--r--packages/base/src/files/install/mysql/bin/db_upgrade_remote.sh2
-rwxr-xr-xpackages/base/src/files/install/mysql/data/161000_upgrade_script.sql80
-rw-r--r--packages/base/src/files/install/mysql/data/170204_downgrade_script.sql4
-rw-r--r--packages/base/src/files/install/mysql/data/170204_upgrade_script.sql4
-rw-r--r--packages/base/src/files/install/mysql/data/170701_downgrade_script.sql4
-rw-r--r--packages/base/src/files/install/mysql/data/170701_upgrade_script.sql6
-rw-r--r--packages/base/src/files/install/mysql/data/171001_downgrade_script.sql4
-rw-r--r--packages/base/src/files/install/mysql/data/171001_upgrade_script.sql8
15 files changed, 70 insertions, 70 deletions
diff --git a/packages/base/src/files/install/mysql/bin/cleanup_policy.sh b/packages/base/src/files/install/mysql/bin/cleanup_policy.sh
index 1eec53f96..1841d3c57 100644
--- a/packages/base/src/files/install/mysql/bin/cleanup_policy.sh
+++ b/packages/base/src/files/install/mysql/bin/cleanup_policy.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
diff --git a/packages/base/src/files/install/mysql/bin/db_backup.sh b/packages/base/src/files/install/mysql/bin/db_backup.sh
index 896c4ff2d..dca2017ff 100644
--- a/packages/base/src/files/install/mysql/bin/db_backup.sh
+++ b/packages/base/src/files/install/mysql/bin/db_backup.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
@@ -23,7 +23,7 @@
# db_backup.sh: Run this script to back database to a file
#
# Usage : db_backup.sh db_user db_user_password database
-# Example: db_backup.sh policy_user password ecomp_sdk
+# Example: db_backup.sh policy_user password onap_sdk
#
# Note: mysqldump requires at least the SELECT privilege for dumped tables
#
@@ -79,6 +79,6 @@ if [ $# -eq 3 ]; then
echo "db_backup.sh completed ... `date`" | tee -a $LOG
else
echo "Usage : db_backup.sh db_user_id db_user_password database"
- echo "Example: db_backup.sh policy_user password ecomp_sdk"
+ echo "Example: db_backup.sh policy_user password onap_sdk"
fi
diff --git a/packages/base/src/files/install/mysql/bin/db_backup_data.sh b/packages/base/src/files/install/mysql/bin/db_backup_data.sh
index 39df9e272..ee0b44732 100644
--- a/packages/base/src/files/install/mysql/bin/db_backup_data.sh
+++ b/packages/base/src/files/install/mysql/bin/db_backup_data.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
diff --git a/packages/base/src/files/install/mysql/bin/db_backup_remote.sh b/packages/base/src/files/install/mysql/bin/db_backup_remote.sh
index 00ee95269..212896942 100644
--- a/packages/base/src/files/install/mysql/bin/db_backup_remote.sh
+++ b/packages/base/src/files/install/mysql/bin/db_backup_remote.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
@@ -23,7 +23,7 @@
# db_backup_remote.sh: Perform database backup from remote
#
# Usage : db_backup_remote.sh db_user db_user_password database db_hostname
-# Example: db_backup_remote.sh policy_user password ecomp_sdk localhost.com
+# Example: db_backup_remote.sh policy_user password onap_sdk localhost.com
#
# Note: 1. mysqldump utility must be available in the env where this script intend to run
# 2. db_user requires at least the SELECT privilege for dumped tables
@@ -84,5 +84,5 @@ if [ $# -eq 4 ]; then
echo "db_backup_remote.sh for [$DATABASE]@[${DB_HOSTNAME}] completed ... `date`" | tee -a $LOG
else
echo "Usage : db_backup_remote.sh db_user_id db_user_password database db_hostname"
- echo "Example: db_backup_remote.sh policy_user password ecomp_sdk localhost.com"
+ echo "Example: db_backup_remote.sh policy_user password onap_sdk localhost.com"
fi
diff --git a/packages/base/src/files/install/mysql/bin/db_restore.sh b/packages/base/src/files/install/mysql/bin/db_restore.sh
index b0e32dac3..d6e21df79 100644
--- a/packages/base/src/files/install/mysql/bin/db_restore.sh
+++ b/packages/base/src/files/install/mysql/bin/db_restore.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
@@ -23,8 +23,8 @@
# db_restore.sh: Restore database table(s) from database backup file
#
# Usage : db_restore.sh db_user db_password backup_file database table_name
-# Example: db_restore.sh policy_user password /opt/app/policy/data/mysql/20150901/backup_ecomp_sdk_20150910102030.sql ecomp_sdk attribute
-# db_restore.sh policy_user password /opt/app/policy/data/mysql/20150901/backup_ecomp_sdk_20150910102030.sql ecomp_sdk all
+# Example: db_restore.sh policy_user password /opt/app/policy/data/mysql/20150901/backup_onap_sdk_20150910102030.sql onap_sdk attribute
+# db_restore.sh policy_user password /opt/app/policy/data/mysql/20150901/backup_onap_sdk_20150910102030.sql onap_sdk all
#
# Assumption: Database backup_file is created from mysqldump utility
#
@@ -90,7 +90,7 @@ if [ $# -eq 5 ]; then
fi
else
echo "Usage : db_restore.sh db_user_id db_password backup_file database table_name"
- echo "Example: db_restore.sh policy_user password /opt/app/policy/data/mysql/20150901/backup_ecomp_sdk_20150901102030.sql ecomp_sdk attribute"
+ echo "Example: db_restore.sh policy_user password /opt/app/policy/data/mysql/20150901/backup_onap_sdk_20150901102030.sql onap_sdk attribute"
fi
rm -f $TEMP_FILE
diff --git a/packages/base/src/files/install/mysql/bin/db_restore_data.sh b/packages/base/src/files/install/mysql/bin/db_restore_data.sh
index 926755996..c4fec027f 100644
--- a/packages/base/src/files/install/mysql/bin/db_restore_data.sh
+++ b/packages/base/src/files/install/mysql/bin/db_restore_data.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
diff --git a/packages/base/src/files/install/mysql/bin/db_upgrade.sh b/packages/base/src/files/install/mysql/bin/db_upgrade.sh
index 41b79e1ef..87d5d9bd7 100644
--- a/packages/base/src/files/install/mysql/bin/db_upgrade.sh
+++ b/packages/base/src/files/install/mysql/bin/db_upgrade.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
diff --git a/packages/base/src/files/install/mysql/bin/db_upgrade_remote.sh b/packages/base/src/files/install/mysql/bin/db_upgrade_remote.sh
index a5b6e77da..a10ac2173 100644
--- a/packages/base/src/files/install/mysql/bin/db_upgrade_remote.sh
+++ b/packages/base/src/files/install/mysql/bin/db_upgrade_remote.sh
@@ -1,7 +1,7 @@
#!/bin/bash
###
# ============LICENSE_START=======================================================
-# ECOMP Policy Engine
+# ONAP Policy Engine
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
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 a75e7981a..70dae61f1 100755
--- a/packages/base/src/files/install/mysql/data/161000_upgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/161000_upgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-- ---------------------------------------------------------------------------------------------------------------
--- This is for the 1610 Version of SDK database called ecomp_sdk for Open Source
+-- This is for the 1610 Version of SDK database called onap_sdk for Open Source
-- Note to : Database Admin, set the MySQL system variable called lower_case_table_names
@@ -39,9 +39,9 @@
-- All versions newer or older than these DO NOT necessarily mean they are compatible.
-- ------------------------------------------------------------------------------------------------------------------
-CREATE DATABASE IF NOT EXISTS `ecomp_sdk`;
+CREATE DATABASE IF NOT EXISTS `onap_sdk`;
-USE `ecomp_sdk`;
+USE `onap_sdk`;
set foreign_key_checks=0;
--
@@ -784,20 +784,20 @@ primary key (`id`)
);
--
--- Table structure for table `ecompname`
+-- Table structure for table `onapname`
--
-drop table if exists `ecompname`;
-create table `ecompname` (
+drop table if exists `onapname`;
+create table `onapname` (
`id` int(11) not null auto_increment,
`created_by` varchar(255) not null,
`created_date` timestamp not null default current_timestamp,
`description` varchar(2048) default null,
-`ecomp_name` varchar(767) not null,
+`onap_name` varchar(767) not null,
`modified_by` varchar(255) not null,
`modified_date` timestamp not null default '0000-00-00 00:00:00',
primary key (`id`),
-unique key `ecomp_name` (`ecomp_name`)
+unique key `onap_name` (`onap_name`)
);
--
@@ -1806,7 +1806,7 @@ drop view if exists `match_functions`;
create table `match_functions` (
`id` tinyint not null,
`shortname` tinyint not null,
-`ecomp_sdkid` tinyint not null,
+`onap_sdkid` tinyint not null,
`return_datatype` tinyint not null,
`is_bag_return` tinyint not null,
`arg_lb` tinyint not null,
@@ -2048,7 +2048,7 @@ create table `policy_management` (
`config_name` varchar(1024) not null,
`create_date_time` timestamp not null default current_timestamp on update current_timestamp,
`creted_by` varchar(45) not null,
-`ecomp_name` varchar(1024) not null,
+`onap_name` varchar(1024) not null,
`policy_name` varchar(1024) not null,
`scope` varchar(1024) not null,
`update_date_time` timestamp not null default '0000-00-00 00:00:00',
@@ -2067,7 +2067,7 @@ create table `policy_manangement` (
`config_name` varchar(1024) not null,
`create_date_time` timestamp not null default current_timestamp on update current_timestamp,
`created_by` varchar(45) not null,
-`ecomp_name` varchar(1024) not null,
+`onap_name` varchar(1024) not null,
`policy_name` varchar(1024) not null,
`scope` varchar(1024) not null,
`update_date_time` timestamp not null default '0000-00-00 00:00:00',
@@ -2629,10 +2629,10 @@ primary key (`id`)
);
--
--- Current Database: `ecomp_sdk`
+-- Current Database: `onap_sdk`
--
-use `ecomp_sdk`;
+use `onap_sdk`;
--
-- Final view structure for view `function_flattener`
@@ -2656,7 +2656,7 @@ create view `higherorder_bag_functions` as select `function_flattener`.`id` as `
drop table if exists `match_functions`;
drop view if exists `match_functions`;
-create view `match_functions` as select `d`.`id` as `id`,`d`.`short_name` as `shortname`,`d`.`xacml_id` as `ecomp_sdkid`,`d`.`return_datatype` as `return_datatype`,`d`.`is_bag_return` as `is_bag_return`,`d`.`arg_lb` as `arg_lb`,`d`.`arg_ub` as `arg_ub`,`a1`.`is_bag` as `arg1_isbag`,`a1`.`datatype_id` as `arg1_datatype`,`a2`.`is_bag` as `arg2_isbag`,`a2`.`datatype_id` as `arg2_datatype` from ((`functiondefinition` `d` left join `functionarguments` `a1` on(((`a1`.`function_id` = `d`.`id`) and (`a1`.`arg_index` = 1)))) left join `functionarguments` `a2` on(((`a2`.`function_id` = `d`.`id`) and (`a2`.`arg_index` = 2)))) where ((`d`.`arg_lb` = 2) and (`d`.`arg_ub` = 2) and (`d`.`return_datatype` = 18) and (`a1`.`is_bag` = 0)) order by `d`.`short_name`;
+create view `match_functions` as select `d`.`id` as `id`,`d`.`short_name` as `shortname`,`d`.`xacml_id` as `onap_sdkid`,`d`.`return_datatype` as `return_datatype`,`d`.`is_bag_return` as `is_bag_return`,`d`.`arg_lb` as `arg_lb`,`d`.`arg_ub` as `arg_ub`,`a1`.`is_bag` as `arg1_isbag`,`a1`.`datatype_id` as `arg1_datatype`,`a2`.`is_bag` as `arg2_isbag`,`a2`.`datatype_id` as `arg2_datatype` from ((`functiondefinition` `d` left join `functionarguments` `a1` on(((`a1`.`function_id` = `d`.`id`) and (`a1`.`arg_index` = 1)))) left join `functionarguments` `a2` on(((`a2`.`function_id` = `d`.`id`) and (`a2`.`arg_index` = 2)))) where ((`d`.`arg_lb` = 2) and (`d`.`arg_ub` = 2) and (`d`.`return_datatype` = 18) and (`a1`.`is_bag` = 0)) order by `d`.`short_name`;
--
-- Final view structure for view `v_url_access`
@@ -2687,10 +2687,10 @@ primary key (`id`)
);
--
--- This is for the default data for 1610 Version of SDK database for Open Source called ecomp_sdk
+-- This is for the default data for 1610 Version of SDK database for Open Source called onap_sdk
--
-USE ecomp_sdk;
+USE onap_sdk;
-- fn_function
Insert into fn_function (FUNCTION_CD,FUNCTION_NAME) values ('menu_process','Process List');
@@ -2798,14 +2798,14 @@ INSERT INTO fn_menu (MENU_ID, LABEL, PARENT_ID, SORT_ORDER, ACTION, FUNCTION_CD,
INSERT INTO fn_menu (MENU_ID, LABEL, PARENT_ID, SORT_ORDER, ACTION, FUNCTION_CD, ACTIVE_YN, SERVLET, QUERY_STRING, EXTERNAL_URL, TARGET, MENU_SET_CD, SEPARATOR_YN, IMAGE_SRC) VALUES (121, 'Collaboration', 5000, 100, 'collaborate_list.htm', 'menu_sample', 'N', NULL, NULL, NULL, NULL, 'APP', 'N', '/static/fusion/images/bubble.png');
INSERT INTO fn_menu (MENU_ID, LABEL, PARENT_ID, SORT_ORDER, ACTION, FUNCTION_CD, ACTIVE_YN, SERVLET, QUERY_STRING, EXTERNAL_URL, TARGET, MENU_SET_CD, SEPARATOR_YN, IMAGE_SRC) VALUES (930, 'Search', 9, 15, 'userProfile', 'menu_admin', 'N', NULL, NULL, NULL, NULL, 'APP', 'N', '/static/fusion/images/search_profile.png');
INSERT INTO fn_menu (MENU_ID, LABEL, PARENT_ID, SORT_ORDER, ACTION, FUNCTION_CD, ACTIVE_YN, SERVLET, QUERY_STRING, EXTERNAL_URL, TARGET, MENU_SET_CD, SEPARATOR_YN, IMAGE_SRC) VALUES (150038,'Notebook',5000,135,'notebook.htm','menu_sample','N',NULL,NULL,NULL,NULL,'APP','N',NULL);
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150004', 'Policy', '1', '1000', 'menu_policy', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150005', 'Editor', '150004', '1000', 'policy#/Editor', 'policy_editor', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150006', 'Dictionary', '150004', '1000', 'policy#/Dictionary', 'policy_dictionary', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150007', 'PDP', '150004', '1000', 'policy#/Pdp', 'policy_pdp', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150008', 'Push', '150004', '1000', 'policy#/Push', 'policy_push', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150009', 'Roles', '150004', '1000', 'policy#/Roles', 'policy_roles', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150010', 'Admin', '150004', '1000', 'policy#/Admin', 'policy_admin', 'Y', 'APP', 'N');
-INSERT INTO `ecomp_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150011', 'Dashboard', '150004', '1000', 'policy#/Dashboard', 'policy_dashboard', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150004', 'Policy', '1', '1000', 'menu_policy', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150005', 'Editor', '150004', '1000', 'policy#/Editor', 'policy_editor', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150006', 'Dictionary', '150004', '1000', 'policy#/Dictionary', 'policy_dictionary', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150007', 'PDP', '150004', '1000', 'policy#/Pdp', 'policy_pdp', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150008', 'Push', '150004', '1000', 'policy#/Push', 'policy_push', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150009', 'Roles', '150004', '1000', 'policy#/Roles', 'policy_roles', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150010', 'Admin', '150004', '1000', 'policy#/Admin', 'policy_admin', 'Y', 'APP', 'N');
+INSERT INTO `onap_sdk`.`fn_menu` (`menu_id`, `label`, `parent_id`, `sort_order`, `action`, `function_cd`, `active_yn`, `menu_set_cd`, `separator_yn`) VALUES ('150011', 'Dashboard', '150004', '1000', 'policy#/Dashboard', 'policy_dashboard', 'Y', 'APP', 'N');
-- fn_restricted_url
INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('attachment.htm','menu_admin');
@@ -2942,7 +2942,7 @@ Insert into cr_raptor_action_img (IMAGE_ID, IMAGE_LOC) Values ('DELETE', '/stati
Insert into cr_raptor_action_img (IMAGE_ID, IMAGE_LOC) Values ('CALENDAR', '/static/fusion/raptor/img/Calendar-16x16.png');
-- fn_app
-Insert into fn_app (APP_ID,APP_NAME,APP_IMAGE_URL,APP_DESCRIPTION,APP_NOTES,APP_URL,APP_ALTERNATE_URL,APP_REST_ENDPOINT,ML_APP_NAME,ML_APP_ADMIN_ID,MOTS_ID,APP_PASSWORD,OPEN,ENABLED,THUMBNAIL,APP_USERNAME,UEB_KEY,UEB_SECRET,UEB_TOPIC_NAME) VALUES (1,'Default',null,'Some Default Description','Some Default Note',null,null,null,'ECPP','?','1','okYTaDrhzibcbGVq5mjkVQ==','N','N',null,'Default',null,null,'ECOMP-PORTAL-INBOX');
+Insert into fn_app (APP_ID,APP_NAME,APP_IMAGE_URL,APP_DESCRIPTION,APP_NOTES,APP_URL,APP_ALTERNATE_URL,APP_REST_ENDPOINT,ML_APP_NAME,ML_APP_ADMIN_ID,MOTS_ID,APP_PASSWORD,OPEN,ENABLED,THUMBNAIL,APP_USERNAME,UEB_KEY,UEB_SECRET,UEB_TOPIC_NAME) VALUES (1,'Default',null,'Some Default Description','Some Default Note',null,null,null,'ECPP','?','1','okYTaDrhzibcbGVq5mjkVQ==','N','N',null,'Default',null,null,'ONAP-PORTAL-INBOX');
-- fn_user_role
Insert into fn_user_role (USER_ID,ROLE_ID,PRIORITY,APP_ID) values (1,1,null,1);
@@ -6328,20 +6328,20 @@ INSERT INTO PIPType VALUES (500,'SQL'), (501,'LDAP'), (502,'CSV'), (503,'Hyper-C
INSERT INTO GlobalRoleSettings (role, lockdown) values ('super-admin', '0');
-INSERT INTO `ecomp_sdk`.`roles` (`id`, `loginid`, `role`) VALUES ('2', 'API', 'super-admin');
-INSERT INTO `ecomp_sdk`.`roles` (`id`, `loginid`, `role`) VALUES ('3', 'demo', 'super-admin');
+INSERT INTO `onap_sdk`.`roles` (`id`, `loginid`, `role`) VALUES ('2', 'API', 'super-admin');
+INSERT INTO `onap_sdk`.`roles` (`id`, `loginid`, `role`) VALUES ('3', 'demo', 'super-admin');
-INSERT INTO `ecomp_sdk`.`USERINFO` (`loginid`, `NAME`) VALUES ('API', 'API');
-INSERT INTO `ecomp_sdk`.`USERINFO` (`loginid`, `NAME`) VALUES ('demo', 'Demo');
+INSERT INTO `onap_sdk`.`USERINFO` (`loginid`, `NAME`) VALUES ('API', 'API');
+INSERT INTO `onap_sdk`.`USERINFO` (`loginid`, `NAME`) VALUES ('demo', 'Demo');
-INSERT INTO `ecomp_sdk`.`dcaeuuid` (`ID`, `name`, `description`) VALUES ('2', '/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer', 'vLoadBalancer');
-INSERT INTO `ecomp_sdk`.`dcaeuuid` (`ID`, `name`, `description`) VALUES ('3', '/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall', 'vFirewall');
+INSERT INTO `onap_sdk`.`dcaeuuid` (`ID`, `name`, `description`) VALUES ('2', '/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vLoadBalancer', 'vLoadBalancer');
+INSERT INTO `onap_sdk`.`dcaeuuid` (`ID`, `name`, `description`) VALUES ('3', '/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall', 'vFirewall');
-INSERT INTO `ecomp_sdk`.`microservicemodels` (`id`, `modelname`, `description`, `dependency`, `imported_by`, `attributes`, `ref_attributes`, `sub_attributes`, `version`) VALUES ('1', 'TcaMetrics', 'TCA Metrics test', '[NamedEntity, DcaePolicyEntity]', 'API', 'functionalRole=java.lang.String:defaultValue-NA:required-false:MANY-false, name=java.lang.String:defaultValue-NA:required-false:MANY-false', 'thresholds=TcaThreshold:MANY-true', '{\"TcaThreshold\":{\"severity\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"fieldPath\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"thresholdValue\":\"java.lang.Integer:defaultValue-NA:required-false:MANY-false\",\"closedLoopControlName\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"version\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"direction\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\"}}', '1.0.0.5');
-INSERT INTO `ecomp_sdk`.`microservicemodels` (`id`, `modelname`, `description`, `dependency`, `imported_by`, `ref_attributes`, `sub_attributes`, `version`) VALUES ('2', 'StringMatchingConfiguration', 'StringMatchingConfiguration', '[CdapServiceInstanceConfiguration]', 'API', 'serviceConfigurations=StringMatchingServiceConfiguration:MANY-true', '{\"StringMatchingServiceConfiguration\":{\"ageLimit\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"timeWindow\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"createClosedLoopEventId\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"aaiSendFields\":\"java.lang.String:defaultValue-NA:required-false:MANY-true\",\"stringSet\":\"java.lang.String:defaultValue-NA:required-false:MANY-true\",\"outputEventName\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"aaiMatchingFields\":\"java.lang.String:defaultValue-NA:required-false:MANY-true\"}}', '1.0.0.3');
+INSERT INTO `onap_sdk`.`microservicemodels` (`id`, `modelname`, `description`, `dependency`, `imported_by`, `attributes`, `ref_attributes`, `sub_attributes`, `version`) VALUES ('1', 'TcaMetrics', 'TCA Metrics test', '[NamedEntity, DcaePolicyEntity]', 'API', 'functionalRole=java.lang.String:defaultValue-NA:required-false:MANY-false, name=java.lang.String:defaultValue-NA:required-false:MANY-false', 'thresholds=TcaThreshold:MANY-true', '{\"TcaThreshold\":{\"severity\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"fieldPath\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"thresholdValue\":\"java.lang.Integer:defaultValue-NA:required-false:MANY-false\",\"closedLoopControlName\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"version\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"direction\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\"}}', '1.0.0.5');
+INSERT INTO `onap_sdk`.`microservicemodels` (`id`, `modelname`, `description`, `dependency`, `imported_by`, `ref_attributes`, `sub_attributes`, `version`) VALUES ('2', 'StringMatchingConfiguration', 'StringMatchingConfiguration', '[CdapServiceInstanceConfiguration]', 'API', 'serviceConfigurations=StringMatchingServiceConfiguration:MANY-true', '{\"StringMatchingServiceConfiguration\":{\"ageLimit\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"timeWindow\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"createClosedLoopEventId\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"aaiSendFields\":\"java.lang.String:defaultValue-NA:required-false:MANY-true\",\"stringSet\":\"java.lang.String:defaultValue-NA:required-false:MANY-true\",\"outputEventName\":\"java.lang.String:defaultValue-NA:required-false:MANY-false\",\"aaiMatchingFields\":\"java.lang.String:defaultValue-NA:required-false:MANY-true\"}}', '1.0.0.3');
-INSERT INTO `ecompname` VALUES (1,'demo','2016-12-28 14:23:31','DCAE','DCAE','demo','2016-12-28 14:23:31');
-INSERT INTO `ecompname` VALUES (2,'demo','2016-12-28 14:23:31','test','SampleDemo','demo','2016-12-28 14:23:31');
+INSERT INTO `onapname` VALUES (1,'demo','2016-12-28 14:23:31','DCAE','DCAE','demo','2016-12-28 14:23:31');
+INSERT INTO `onapname` VALUES (2,'demo','2016-12-28 14:23:31','test','SampleDemo','demo','2016-12-28 14:23:31');
INSERT INTO `safepolicywarning` VALUES (1,'demo','SampleRiskType','SampleSafePolicyWarning');
@@ -6361,15 +6361,15 @@ 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 `brmsparamtemplate` VALUES (2,'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.onap.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.onap.policy.controlloop.VirtualControlLoopEvent;\nimport org.onap.policy.controlloop.ControlLoopEventStatus;\nimport org.onap.policy.controlloop.VirtualControlLoopNotification;\nimport org.onap.policy.controlloop.ControlLoopNotificationType;\nimport org.onap.policy.controlloop.ControlLoopOperation;\nimport org.onap.policy.controlloop.ControlLoopOperationWrapper;\nimport org.onap.policy.template.demo.ControlLoopException;\n\nimport org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Request;\nimport org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Response;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.onap.policy.aai.util.Serialization;\n\nimport org.onap.policy.appc.CommonHeader;\nimport org.onap.policy.appc.Request;\nimport org.onap.policy.appc.Response;\nimport org.onap.policy.appc.ResponseCode;\nimport org.onap.policy.appc.ResponseStatus;\nimport org.onap.policy.appc.ResponseValue;\n\nimport org.onap.policy.template.demo.EventManager;\nimport org.onap.policy.vnf.trafficgenerator.PGRequest;\nimport org.onap.policy.vnf.trafficgenerator.PGStream;\nimport org.onap.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.onap.policy.mso.MSOManager;\nimport org.onap.policy.mso.MSORequest;\nimport org.onap.policy.mso.MSORequestStatus;\nimport org.onap.policy.mso.MSORequestDetails;\nimport org.onap.policy.mso.MSOModelInfo;\nimport org.onap.policy.mso.MSOCloudConfiguration;\nimport org.onap.policy.mso.MSORequestInfo;\nimport org.onap.policy.mso.MSORequestParameters;\nimport org.onap.policy.mso.MSORelatedInstanceListElement;\nimport org.onap.policy.mso.MSORelatedInstance;\nimport org.onap.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(\"COMPLETE\")) {\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-14 19:55:47','demo');
+INSERT INTO `brmsparamtemplate` VALUES (2,'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.onap.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.onap.policy.controlloop.VirtualControlLoopEvent;\nimport org.onap.policy.controlloop.ControlLoopEventStatus;\nimport org.onap.policy.controlloop.VirtualControlLoopNotification;\nimport org.onap.policy.controlloop.ControlLoopNotificationType;\nimport org.onap.policy.controlloop.ControlLoopOperation;\nimport org.onap.policy.controlloop.ControlLoopOperationWrapper;\nimport org.onap.policy.template.demo.ControlLoopException;\n\nimport org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Request;\nimport org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Response;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.onap.policy.aai.util.Serialization;\n\nimport org.onap.policy.appc.CommonHeader;\nimport org.onap.policy.appc.Request;\nimport org.onap.policy.appc.Response;\nimport org.onap.policy.appc.ResponseCode;\nimport org.onap.policy.appc.ResponseStatus;\nimport org.onap.policy.appc.ResponseValue;\n\nimport org.onap.policy.template.demo.EventManager;\nimport org.onap.policy.vnf.trafficgenerator.PGRequest;\nimport org.onap.policy.vnf.trafficgenerator.PGStream;\nimport org.onap.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.onap.policy.mso.MSOManager;\nimport org.onap.policy.mso.MSORequest;\nimport org.onap.policy.mso.MSORequestStatus;\nimport org.onap.policy.mso.MSORequestDetails;\nimport org.onap.policy.mso.MSOModelInfo;\nimport org.onap.policy.mso.MSOCloudConfiguration;\nimport org.onap.policy.mso.MSORequestInfo;\nimport org.onap.policy.mso.MSORequestParameters;\nimport org.onap.policy.mso.MSORelatedInstanceListElement;\nimport org.onap.policy.mso.MSORelatedInstance;\nimport org.onap.policy.mso.MSOResponse;\n\nimport org.onap.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 ONAP 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(\"COMPLETE\")) {\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-14 19:55:47','demo');
-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 `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.onap.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.onap.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=\"ONAPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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:ONAPName\" 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.onap.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.onap.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=\"ONAPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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:ONAPName\" 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 `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 `configurationdataentity` VALUES (3201,'/* 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.onap.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.onap.policy.controlloop.VirtualControlLoopEvent;\nimport org.onap.policy.controlloop.ControlLoopEventStatus;\nimport org.onap.policy.controlloop.VirtualControlLoopNotification;\nimport org.onap.policy.controlloop.ControlLoopNotificationType;\nimport org.onap.policy.controlloop.ControlLoopOperation;\nimport org.onap.policy.controlloop.ControlLoopOperationWrapper;\nimport org.onap.policy.template.demo.ControlLoopException;\n\nimport org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Request;\nimport org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Response;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.onap.policy.aai.util.Serialization;\n\nimport org.onap.policy.appc.CommonHeader;\nimport org.onap.policy.appc.Request;\nimport org.onap.policy.appc.Response;\nimport org.onap.policy.appc.ResponseCode;\nimport org.onap.policy.appc.ResponseStatus;\nimport org.onap.policy.appc.ResponseValue;\n\nimport org.onap.policy.template.demo.EventManager;\nimport org.onap.policy.vnf.trafficgenerator.PGRequest;\nimport org.onap.policy.vnf.trafficgenerator.PGStream;\nimport org.onap.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.onap.policy.mso.MSOManager;\nimport org.onap.policy.mso.MSORequest;\nimport org.onap.policy.mso.MSORequestStatus;\nimport org.onap.policy.mso.MSORequestDetails;\nimport org.onap.policy.mso.MSOModelInfo;\nimport org.onap.policy.mso.MSOCloudConfiguration;\nimport org.onap.policy.mso.MSORequestInfo;\nimport org.onap.policy.mso.MSORequestParameters;\nimport org.onap.policy.mso.MSORelatedInstanceListElement;\nimport org.onap.policy.mso.MSORelatedInstance;\nimport org.onap.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(\"COMPLETE\")) {\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 \"com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.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-14 19:58:19',0,'','doACPolicyPut','2017-03-14 19:58:19',1),(3203,'/* 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.onap.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.onap.policy.controlloop.VirtualControlLoopEvent;\nimport org.onap.policy.controlloop.ControlLoopEventStatus;\nimport org.onap.policy.controlloop.VirtualControlLoopNotification;\nimport org.onap.policy.controlloop.ControlLoopNotificationType;\nimport org.onap.policy.controlloop.ControlLoopOperation;\nimport org.onap.policy.controlloop.ControlLoopOperationWrapper;\nimport org.onap.policy.template.demo.ControlLoopException;\n\nimport org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Request;\nimport org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Response;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.onap.policy.aai.util.Serialization;\n\nimport org.onap.policy.appc.CommonHeader;\nimport org.onap.policy.appc.Request;\nimport org.onap.policy.appc.Response;\nimport org.onap.policy.appc.ResponseCode;\nimport org.onap.policy.appc.ResponseStatus;\nimport org.onap.policy.appc.ResponseValue;\n\nimport org.onap.policy.template.demo.EventManager;\nimport org.onap.policy.vnf.trafficgenerator.PGRequest;\nimport org.onap.policy.vnf.trafficgenerator.PGStream;\nimport org.onap.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.onap.policy.mso.MSOManager;\nimport org.onap.policy.mso.MSORequest;\nimport org.onap.policy.mso.MSORequestStatus;\nimport org.onap.policy.mso.MSORequestDetails;\nimport org.onap.policy.mso.MSOModelInfo;\nimport org.onap.policy.mso.MSOCloudConfiguration;\nimport org.onap.policy.mso.MSORequestInfo;\nimport org.onap.policy.mso.MSORequestParameters;\nimport org.onap.policy.mso.MSORelatedInstanceListElement;\nimport org.onap.policy.mso.MSORelatedInstance;\nimport org.onap.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(\"COMPLETE\")) {\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 \"com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.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-14 20:00:56',0,'','doACPolicyPut','2017-03-14 20:00:56',1);
+INSERT INTO `configurationdataentity` VALUES (3201,'/* 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.onap.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.onap.policy.controlloop.VirtualControlLoopEvent;\nimport org.onap.policy.controlloop.ControlLoopEventStatus;\nimport org.onap.policy.controlloop.VirtualControlLoopNotification;\nimport org.onap.policy.controlloop.ControlLoopNotificationType;\nimport org.onap.policy.controlloop.ControlLoopOperation;\nimport org.onap.policy.controlloop.ControlLoopOperationWrapper;\nimport org.onap.policy.template.demo.ControlLoopException;\n\nimport org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Request;\nimport org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Response;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.onap.policy.aai.util.Serialization;\n\nimport org.onap.policy.appc.CommonHeader;\nimport org.onap.policy.appc.Request;\nimport org.onap.policy.appc.Response;\nimport org.onap.policy.appc.ResponseCode;\nimport org.onap.policy.appc.ResponseStatus;\nimport org.onap.policy.appc.ResponseValue;\n\nimport org.onap.policy.template.demo.EventManager;\nimport org.onap.policy.vnf.trafficgenerator.PGRequest;\nimport org.onap.policy.vnf.trafficgenerator.PGStream;\nimport org.onap.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.onap.policy.mso.MSOManager;\nimport org.onap.policy.mso.MSORequest;\nimport org.onap.policy.mso.MSORequestStatus;\nimport org.onap.policy.mso.MSORequestDetails;\nimport org.onap.policy.mso.MSOModelInfo;\nimport org.onap.policy.mso.MSOCloudConfiguration;\nimport org.onap.policy.mso.MSORequestInfo;\nimport org.onap.policy.mso.MSORequestParameters;\nimport org.onap.policy.mso.MSORelatedInstanceListElement;\nimport org.onap.policy.mso.MSORelatedInstance;\nimport org.onap.policy.mso.MSOResponse;\n\nimport org.onap.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 ONAP 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(\"COMPLETE\")) {\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 \"com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.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-14 19:58:19',0,'','doACPolicyPut','2017-03-14 19:58:19',1),(3203,'/* 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.onap.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.onap.policy.controlloop.VirtualControlLoopEvent;\nimport org.onap.policy.controlloop.ControlLoopEventStatus;\nimport org.onap.policy.controlloop.VirtualControlLoopNotification;\nimport org.onap.policy.controlloop.ControlLoopNotificationType;\nimport org.onap.policy.controlloop.ControlLoopOperation;\nimport org.onap.policy.controlloop.ControlLoopOperationWrapper;\nimport org.onap.policy.template.demo.ControlLoopException;\n\nimport org.onap.policy.aai.AAINQF199.AAINQF199CloudRegion;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperties;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ExtraProperty;\nimport org.onap.policy.aai.AAINQF199.AAINQF199GenericVNF;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InstanceFilters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;\nimport org.onap.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Manager;\nimport org.onap.policy.aai.AAINQF199.AAINQF199NamedQuery;\nimport org.onap.policy.aai.AAINQF199.AAINQF199QueryParameters;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Request;\nimport org.onap.policy.aai.AAINQF199.AAINQF199RequestWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Response;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;\nimport org.onap.policy.aai.AAINQF199.AAINQF199ServiceInstance;\nimport org.onap.policy.aai.AAINQF199.AAINQF199Tenant;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VfModule;\nimport org.onap.policy.aai.AAINQF199.AAINQF199VServer;\nimport org.onap.policy.aai.util.Serialization;\n\nimport org.onap.policy.appc.CommonHeader;\nimport org.onap.policy.appc.Request;\nimport org.onap.policy.appc.Response;\nimport org.onap.policy.appc.ResponseCode;\nimport org.onap.policy.appc.ResponseStatus;\nimport org.onap.policy.appc.ResponseValue;\n\nimport org.onap.policy.template.demo.EventManager;\nimport org.onap.policy.vnf.trafficgenerator.PGRequest;\nimport org.onap.policy.vnf.trafficgenerator.PGStream;\nimport org.onap.policy.vnf.trafficgenerator.PGStreams;\n\nimport org.onap.policy.mso.MSOManager;\nimport org.onap.policy.mso.MSORequest;\nimport org.onap.policy.mso.MSORequestStatus;\nimport org.onap.policy.mso.MSORequestDetails;\nimport org.onap.policy.mso.MSOModelInfo;\nimport org.onap.policy.mso.MSOCloudConfiguration;\nimport org.onap.policy.mso.MSORequestInfo;\nimport org.onap.policy.mso.MSORequestParameters;\nimport org.onap.policy.mso.MSORelatedInstanceListElement;\nimport org.onap.policy.mso.MSORelatedInstance;\nimport org.onap.policy.mso.MSOResponse;\n\nimport org.onap.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 ONAP 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/onap/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(\"COMPLETE\")) {\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 \"com.Config_BRMS_Param_BRMSParamvLBDemoPolicy.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/onap/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-14 20:00:56',0,'','doACPolicyPut','2017-03-14 20:00:56',1);
-INSERT INTO `policyentity` VALUES (3202,'doACPolicyPut','2017-03-14 19:58:19',0,'BRMSParam vFW Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-14 19:58:19','<?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:256f4712-a965-4817-a851-a71bdeb9fb49\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>BRMSParam vFW 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_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:8cdb88aa-448b-4ed1-bce5-6a037651e73c\" 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,3201),(3204,'doACPolicyPut','2017-03-14 20:00:56',0,'BRMSParam vLB Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-14 20:00:56','<?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:ace93d23-7a21-450a-87b4-5ff11e01d4b1\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>BRMSParam 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:9d472f3a-bab1-4bee-8bfc-0ee1b4e11ad6\" 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,3203);
+INSERT INTO `policyentity` VALUES (3202,'doACPolicyPut','2017-03-14 19:58:19',0,'BRMSParam vFW Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-14 19:58:19','<?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:256f4712-a965-4817-a851-a71bdeb9fb49\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>BRMSParam vFW Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.onap.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.onap.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=\"ONAPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.onap.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.onap.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.onap.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.onap.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.onap.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:8cdb88aa-448b-4ed1-bce5-6a037651e73c\" 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:ONAPName\" 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,3201),(3204,'doACPolicyPut','2017-03-14 20:00:56',0,'BRMSParam vLB Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:','doACPolicyPut','2017-03-14 20:00:56','<?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:ace93d23-7a21-450a-87b4-5ff11e01d4b1\" Version=\"1\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides\">\n <Description>BRMSParam vLB Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>\n <Target>\n <AnyOf>\n <AllOf>\n <Match MatchId=\"org.onap.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.onap.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=\"ONAPName\" DataType=\"http://www.w3.org/2001/XMLSchema#string\" MustBePresent=\"false\"/>\n </Match>\n <Match MatchId=\"org.onap.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.onap.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.onap.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.onap.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.onap.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:9d472f3a-bab1-4bee-8bfc-0ee1b4e11ad6\" 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:ONAPName\" 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,3203);
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');
diff --git a/packages/base/src/files/install/mysql/data/170204_downgrade_script.sql b/packages/base/src/files/install/mysql/data/170204_downgrade_script.sql
index 8fead9cce..842f6e994 100644
--- a/packages/base/src/files/install/mysql/data/170204_downgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/170204_downgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-use ecomp_sdk;
+use onap_sdk;
drop table if exists brmsgroup_info;
drop table if exists brmsgroup_policy;
drop table if exists operationshistory10;
diff --git a/packages/base/src/files/install/mysql/data/170204_upgrade_script.sql b/packages/base/src/files/install/mysql/data/170204_upgrade_script.sql
index c474f1b7e..32868b909 100644
--- a/packages/base/src/files/install/mysql/data/170204_upgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/170204_upgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-use ecomp_sdk;
+use onap_sdk;
set foreign_key_checks=0;
drop table if exists brmsgroup_info;
CREATE TABLE brmsgroup_info
diff --git a/packages/base/src/files/install/mysql/data/170701_downgrade_script.sql b/packages/base/src/files/install/mysql/data/170701_downgrade_script.sql
index d81fa1535..2609634a6 100644
--- a/packages/base/src/files/install/mysql/data/170701_downgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/170701_downgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-use ecomp_sdk;
+use onap_sdk;
ALTER TABLE fwtagpicker drop networkRole;
alter table microservicemodels drop column enumValues, drop column annotation;
drop table if exists FWTag;
diff --git a/packages/base/src/files/install/mysql/data/170701_upgrade_script.sql b/packages/base/src/files/install/mysql/data/170701_upgrade_script.sql
index 9091d9fa1..acfdd008a 100644
--- a/packages/base/src/files/install/mysql/data/170701_upgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/170701_upgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -17,13 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-use ecomp_sdk;
+use onap_sdk;
INSERT INTO policyeditorscopes (`id`, `scopename`, `created_date`, `created_by`, `modified_date`, `modified_by`) VALUES ('1', 'com', '2017-06-01 11:45:36', 'demo', '2017-06-01 11:45:36', 'demo');
alter table IntegrityAuditEntity modify jdbcUrl varchar(200) not null;
-alter table `ecomp_sdk`.`microservicemodels`
+alter table `onap_sdk`.`microservicemodels`
add column `enumValues` longtext null default null after `version`,
add column `annotation` longtext null after `enumValues`;
diff --git a/packages/base/src/files/install/mysql/data/171001_downgrade_script.sql b/packages/base/src/files/install/mysql/data/171001_downgrade_script.sql
index c7c74284c..469e951b2 100644
--- a/packages/base/src/files/install/mysql/data/171001_downgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/171001_downgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -17,5 +17,5 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-use ecomp_sdk;
+use onap_sdk;
drop table if exists rainydaytreatments; \ No newline at end of file
diff --git a/packages/base/src/files/install/mysql/data/171001_upgrade_script.sql b/packages/base/src/files/install/mysql/data/171001_upgrade_script.sql
index 6be2f25c5..c6f6303bd 100644
--- a/packages/base/src/files/install/mysql/data/171001_upgrade_script.sql
+++ b/packages/base/src/files/install/mysql/data/171001_upgrade_script.sql
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
-* ECOMP Policy Engine
+* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-use ecomp_sdk;
-drop table if exists `ecomp_sdk`.`rainydaytreatments`;
+use onap_sdk;
+drop table if exists `onap_sdk`.`rainydaytreatments`;
-CREATE TABLE `ecomp_sdk`.`rainydaytreatments` (
+CREATE TABLE `onap_sdk`.`rainydaytreatments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bbid` varchar(250) DEFAULT NULL,
`workstep` varchar(250) DEFAULT NULL,