You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by fr...@apache.org on 2017/05/31 14:09:57 UTC

[19/24] incubator-trafficcontrol git commit: moved the toolname and instance name back into seeds for postinstall simplicity

moved the toolname and instance name back into seeds for postinstall simplicity

(cherry picked from commit f868cae629d9513db66713ad3d89d443bd1c927a)


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/e6e7e822
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/e6e7e822
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/e6e7e822

Branch: refs/heads/2.0.x
Commit: e6e7e8221ad69a0cceb69e567020be860480cb4c
Parents: ac0df80
Author: Dewayne Richardson <de...@apache.org>
Authored: Mon May 22 13:56:54 2017 -0600
Committer: Eric Friedrich <fr...@apache.org>
Committed: Wed May 31 10:08:57 2017 -0400

----------------------------------------------------------------------
 traffic_ops/app/db/seeds.sql         | 15 +++++++
 traffic_ops/install/bin/_postinstall | 65 ++++++++++++++++++-------------
 2 files changed, 54 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6e7e822/traffic_ops/app/db/seeds.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/seeds.sql b/traffic_ops/app/db/seeds.sql
index 16a6964..908b4aa 100644
--- a/traffic_ops/app/db/seeds.sql
+++ b/traffic_ops/app/db/seeds.sql
@@ -90,6 +90,21 @@ insert into parameter (name, config_file, value) select * from (select 'DsStats'
 insert into parameter (name, config_file, value) select * from (select 'DsStats', 'traffic_stats.config', 'tps_4xx') as temp where not exists (select name from parameter where name = 'DsStats' and config_file = 'traffic_stats.config' and value = 'tps_4xx') limit 1 ON CONFLICT DO NOTHING;
 insert into parameter (name, config_file, value) select * from (select 'DsStats', 'traffic_stats.config', 'tps_5xx') as temp where not exists (select name from parameter where name = 'DsStats' and config_file = 'traffic_stats.config' and value = 'tps_5xx') limit 1 ON CONFLICT DO NOTHING;
 insert into parameter (name, config_file, value) select * from (select 'DsStats', 'traffic_stats.config', 'tps_total') as temp where not exists (select name from parameter where name = 'DsStats' and config_file = 'traffic_stats.config' and value = 'tps_total') limit 1 ON CONFLICT DO NOTHING;
+-- Moved into postinstall global parameters
+insert into profile (name, description) values ('GLOBAL', 'Global Traffic Ops profile, DO NOT DELETE') ON CONFLICT (name) DO NOTHING;
+
+---------------------------------
+
+-- profiles
+---------------------------------
+insert into parameter (name, config_file, value) values ('tm.instance_name', 'global', 'Traffic Ops CDN') ON CONFLICT DO NOTHING;
+insert into profile_parameter (profile, parameter) values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.instance_name' and config_file = 'global' and value = 'Traffic Ops CDN') ) ON CONFLICT (profile, parameter) DO NOTHING;
+
+insert into parameter (name, config_file, value) values ('tm.toolname', 'global', 'Traffic Ops') ON CONFLICT DO NOTHING;
+insert into profile_parameter (profile, parameter) values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.toolname' and config_file = 'global' and value = 'Traffic Ops') ) ON CONFLICT (profile, parameter) DO NOTHING;
+
+
+
 
 -- profiles
 insert into profile (name, description) values ('RIAK_ALL', 'Riak profile for all CDNs') ON CONFLICT DO NOTHING;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6e7e822/traffic_ops/install/bin/_postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/_postinstall b/traffic_ops/install/bin/_postinstall
index 1ecda45..b5f12da 100755
--- a/traffic_ops/install/bin/_postinstall
+++ b/traffic_ops/install/bin/_postinstall
@@ -567,6 +567,7 @@ QUERY
 ADMIN
     $dbh->do($insert_admin);
 
+    insert_cdn($dbh, $paramconf);
     insert_parameters($dbh, $paramconf);
     insert_profiles($dbh, $paramconf);
 
@@ -642,41 +643,59 @@ sub setupCertificates {
 }
 
 #------------------------------------
-sub insert_parameters {
+sub insert_cdn {
+
     my $dbh = shift;
     my $paramconf = shift;
 
-    InstallUtils::logger( "=========== Setting up parameters", "info" );
+    InstallUtils::logger( "=========== Setting up cdn", "info" );
 
     # Enable multiple inserts into one commit
     $dbh->{pg_server_prepare} = 0;
 
-    my $insert_stmt = <<'INSERTS';
+	my $cdn_name = $paramconf->{"cdn_name"};
+	my $dns_subdomain = $paramconf->{"dns_subdomain"};
+
+    my $insert_stmt = <<INSERTS;
 
     -- global parameters
-    insert into parameter (name, config_file, value) 
-                values ('tm.url', 'global', '$paramconf->{"tm.url"}') 
-                ON CONFLICT DO NOTHING;
+    insert into cdn (name, dnssec_enabled)
+                values ('$cdn_name', false) 
+                ON CONFLICT (name) DO NOTHING;
 
-    insert into parameter (name, config_file, value) 
-                values ('tm.instance_name', 'global', '$paramconf->{"tm.instance_name"}') 
-                ON CONFLICT DO NOTHING;
+INSERTS
+    doInsert($dbh, $insert_stmt);
+}
 
+#------------------------------------
+sub insert_parameters {
+    my $dbh = shift;
+    my $paramconf = shift;
+
+    InstallUtils::logger( "=========== Setting up parameters", "info" );
+
+    # Enable multiple inserts into one commit
+    $dbh->{pg_server_prepare} = 0;
+
+	my $tm_url = $paramconf->{"tm.url"};
+
+    my $insert_stmt = <<INSERTS;
+    -- global parameters
     insert into parameter (name, config_file, value) 
-                values ('tm.toolname', 'global', '$paramconf->{"tm.toolname"}') 
+                values ('tm.url', 'global', '$tm_url') 
                 ON CONFLICT DO NOTHING;
 
     insert into parameter (name, config_file, value) 
-                values ('tm.infourl', 'global', '$paramconf->{"tm.url"}/doc') 
+                values ('tm.infourl', 'global', '$tm_url/doc') 
                 ON CONFLICT DO NOTHING;
 
     -- CRConfig.json parameters
     insert into parameter (name, config_file, value) 
-                values ('geolocation.polling.url', 'CRConfig.json', '$paramconf->{"tm.url"}/routing/GeoLite2-City.mmdb.gz') 
+                values ('geolocation.polling.url', 'CRConfig.json', '$tm_url/routing/GeoLite2-City.mmdb.gz') 
                 ON CONFLICT DO NOTHING;
 
     insert into parameter (name, config_file, value) 
-                values ('geolocation6.polling.url', 'CRConfig.json', '$paramconf->{"tm.url"}/routing/GeoLiteCityv6.dat.gz') 
+                values ('geolocation6.polling.url', 'CRConfig.json', '$tm_url/routing/GeoLiteCityv6.dat.gz') 
                 ON CONFLICT DO NOTHING;
 
 INSERTS
@@ -689,7 +708,9 @@ sub insert_profiles {
     my $paramconf = shift;
 
     InstallUtils::logger( "\n=========== Setting up profiles", "info" );
-    my $insert_stmt = <<'INSERTS';
+	my $tm_url = $paramconf->{"tm.url"};
+
+    my $insert_stmt = <<INSERTS;
 
     -- global parameters
     insert into profile (name, description) 
@@ -697,27 +718,19 @@ sub insert_profiles {
                 ON CONFLICT (name) DO NOTHING;
 
     insert into profile_parameter (profile, parameter) 
-                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.url' and config_file = 'global' and value = '$paramconf->{"tm.url"}') ) 
-                ON CONFLICT (profile, parameter) DO NOTHING;
-
-    insert into profile_parameter (profile, parameter) 
-                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.instance_name' and config_file = 'global' and value = '$paramconf->{"tm.instance_name"}') ) 
-                ON CONFLICT (profile, parameter) DO NOTHING;
-
-    insert into profile_parameter (profile, parameter) 
-                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.toolname' and config_file = 'global' and value = '$paramconf->{"tm.toolname"}') ) 
+                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.url' and config_file = 'global' and value = '$tm_url') ) 
                 ON CONFLICT (profile, parameter) DO NOTHING;
 
     insert into profile_parameter (profile, parameter) 
-                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.infourl' and config_file = 'global' and value = '$paramconf->{"tm.url"}/doc') ) 
+                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'tm.infourl' and config_file = 'global' and value = '$tm_url/doc') ) 
                 ON CONFLICT (profile, parameter) DO NOTHING;
 
     insert into profile_parameter (profile, parameter) 
-                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'geolocation.polling.url' and config_file = 'CRConfig.json' and value = 'https://$paramconf->{"dns_subdomain"}/routing/GeoLite2-City.mmdb.gz') ) 
+                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'geolocation.polling.url' and config_file = 'CRConfig.json' and value = '$tm_url/routing/GeoLite2-City.mmdb.gz') ) 
                 ON CONFLICT (profile, parameter) DO NOTHING;
 
     insert into profile_parameter (profile, parameter) 
-                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'geolocation6.polling.url' and config_file = 'CRConfig.json' and value = 'https://$paramconf->{"dns_subdomain"}/routing/GeoLiteCityv6.dat.gz') ) 
+                values ( (select id from profile where name = 'GLOBAL'), (select id from parameter where name = 'geolocation6.polling.url' and config_file = 'CRConfig.json' and value = '$tm_url/routing/GeoLiteCityv6.dat.gz') ) 
                 ON CONFLICT (profile, parameter) DO NOTHING;
 
 INSERTS