You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/05/23 21:55:10 UTC

[2/5] 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


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

Branch: refs/heads/master
Commit: f868cae629d9513db66713ad3d89d443bd1c927a
Parents: 610c6c2
Author: Dewayne Richardson <de...@apache.org>
Authored: Mon May 22 13:56:54 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Mon May 22 13:56:54 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/db/seeds.sql         |  9 ++++-
 traffic_ops/install/bin/_postinstall | 65 ++++++++++++++++++-------------
 2 files changed, 47 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f868cae6/traffic_ops/app/db/seeds.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/seeds.sql b/traffic_ops/app/db/seeds.sql
index da696ba..8e725a1 100644
--- a/traffic_ops/app/db/seeds.sql
+++ b/traffic_ops/app/db/seeds.sql
@@ -26,14 +26,21 @@ insert into job_agent (name, description, active) values ('dummy', 'Description
 insert into job_status (name, description) values ('PENDING', 'Job is queued, but has not been picked up by any agents yet') ON CONFLICT (name) DO NOTHING;
 
 -- parameters
--- Move into postinstall global parameters
+-- Moved into postinstall global parameters
 insert into profile (name, description, type) values ('GLOBAL', 'Global Traffic Ops profile, DO NOT DELETE', 'UNK_PROFILE') ON CONFLICT (name) DO NOTHING;
+
 ---------------------------------
 
 -- profiles
 ---------------------------------
 insert into parameter (name, config_file, value) values ('tm.instance_name', 'global', 'Traffic Ops CDN') ON CONFLICT (name, config_file, value) 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 (name, config_file, value) 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
 ---------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f868cae6/traffic_ops/install/bin/_postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/_postinstall b/traffic_ops/install/bin/_postinstall
index d9d0f53..d028c68 100755
--- a/traffic_ops/install/bin/_postinstall
+++ b/traffic_ops/install/bin/_postinstall
@@ -551,6 +551,7 @@ QUERY
 ADMIN
     $dbh->do($insert_admin);
 
+    insert_cdn($dbh, $paramconf);
     insert_parameters($dbh, $paramconf);
     insert_profiles($dbh, $paramconf);
 
@@ -626,41 +627,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 (name, config_file, value) DO NOTHING;
+    insert into cdn (name, domain_name, dnssec_enabled)
+                values ('$cdn_name', '$dns_subdomain', false) 
+                ON CONFLICT (name) DO NOTHING;
 
-    insert into parameter (name, config_file, value) 
-                values ('tm.instance_name', 'global', '$paramconf->{"tm.instance_name"}') 
-                ON CONFLICT (name, config_file, value) 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 (name, config_file, value) 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 (name, config_file, value) 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 (name, config_file, value) 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 (name, config_file, value) DO NOTHING;
 
 INSERTS
@@ -673,7 +692,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, type) 
@@ -681,27 +702,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