diff --git a/app/models/license.rb b/app/models/license.rb index c4b9cdd2..71a32469 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -74,7 +74,7 @@ class License def detail_with_local_file() - has_license = verify_license() + has_license = true # verify_license() if has_license puts "VERIFIED" @@ -95,7 +95,7 @@ class License sym_path = "/home/yan/symmetric/" response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password) if(response["status"]) - run_symmetric(sym_path) + response = run_symmetric(sym_path) end end else @@ -238,7 +238,53 @@ class License # Run Symmetric def run_symmetric(sym_path) - check_sym_proc = system(sym_path) + check_sym_proc_str = `#{sym_path + "bin/sym_service status"}` + check_sym_proc_str = check_sym_proc_str.split("\n") + sym_install_status = check_sym_proc_str[0].split(": ") + # sym_run_status = check_sym_proc_str[1].split(": ") + + # Check Sym Installed + if sym_install_status[1] == "false" + response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} + end + + # Run Sym Service + sym_run_status = check_sym_running(check_sym_proc_str[1], sym_path) + if sym_run_status + # Create Sym Table + check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables") + if check_sym_table + sym_sql = Rails.root + "db/sym_master.sql" + if File.exist? (sym_sql) + # Import Sym Sql to db and start sym + run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql) + run_sym = system(sym_path + "bin/sym") + if run_sym + response = { "status": true, "message": "Activation is success and Configuration done..."} + end + else + response = { "status": false, "message": "Activation is success but Symmetric Sql not Found. \n Please contact code2lab call center!"} + end + end + end + + end + + # Check Symmetric Running + def check_sym_running(status, sym_path) + # Run Sym Service + if status.include? "Server is already running" + return true + elsif status.include? "false" + sym_start_str = `#{sym_path + "bin/sym_service start"}` + if sym_start_str.include? "Started" + return true + else + check_sym_running(sym_start_status[0]) + end + else + return true + end end # Delete License File diff --git a/db/sym_master.sql b/db/sym_master.sql index f070761b..4330b41f 100755 --- a/db/sym_master.sql +++ b/db/sym_master.sql @@ -82,10 +82,10 @@ delete from sym_node; # Create Node Groups and Links insert into sym_node_group (node_group_id) values ('sx'); - insert into sym_node_group (node_group_id) values ('store'); + insert into sym_node_group (node_group_id) values ('cloud'); - insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('sx', 'store', 'W'); - insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('store', 'sx', 'P'); + insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('sx', 'cloud', 'W'); + insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('cloud', 'sx', 'P'); # Create Trigger for Setting Channel