Merge pull request #367 from nbaoping/1.1.2-geolimit

add geolimit support for Canada #366
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index 4230a1f..3c8e7be 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -576,6 +576,12 @@
 			$delivery_service->{'coverageZoneOnly'} = \0;
 			$delivery_service->{'geoEnabled'} = [ { 'countryCode' => 'US' } ];
 		}
+		elsif ( $geo_limit == 3 ) {
+
+			# Ref to 0 or 1 makes JSON bool value
+			$delivery_service->{'coverageZoneOnly'} = \0;
+			$delivery_service->{'geoEnabled'} = [ { 'countryCode' => 'CA' } ];
+		}
 		else {
 			# Ref to 0 or 1 makes JSON bool value
 			$delivery_service->{'coverageZoneOnly'} = \0;
diff --git a/traffic_ops/app/lib/API/Topology.pm b/traffic_ops/app/lib/API/Topology.pm
index 93fd823..68156fb 100644
--- a/traffic_ops/app/lib/API/Topology.pm
+++ b/traffic_ops/app/lib/API/Topology.pm
@@ -234,6 +234,10 @@
 			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'coverageZoneOnly'} = 'false';
 			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'geoEnabled'} = [ { 'countryCode' => 'US' } ];
 		}
+		elsif ( $geo_limit == 3 ) {
+			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'coverageZoneOnly'} = 'false';
+			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'geoEnabled'} = [ { 'countryCode' => 'CA' } ];
+		}
 		else {
 			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'coverageZoneOnly'} = 'false';
 		}
diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm
index 82dafe8..6be229b 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -209,7 +209,7 @@
 sub adeliveryservice {
 	my $self       = shift;
 	my %data       = ( "aaData" => undef );
-	my %geo_limits = ( 0 => "none", 1 => "CZF", 2 => "CZF + US" );
+	my %geo_limits = ( 0 => "none", 1 => "CZF", 2 => "CZF + US", 3 => "CZF + CA" );
 	my %protocol   = ( 0 => "http", 1 => "https", 2 => "http/https" );
 
 	my $rs = $self->db->resultset('Deliveryservice')->search(
diff --git a/traffic_ops/app/lib/UI/Topology.pm b/traffic_ops/app/lib/UI/Topology.pm
index 3ee9f8f..8a32573 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -245,6 +245,10 @@
 			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'coverageZoneOnly'} = 'false';
 			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'geoEnabled'} = [ { 'countryCode' => 'US' } ];
 		}
+		elsif ( $geo_limit == 3 ) {
+			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'coverageZoneOnly'} = 'false';
+			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'geoEnabled'} = [ { 'countryCode' => 'CA' } ];
+		}
 		else {
 			$data_obj->{'deliveryServices'}->{ $row->xml_id }->{'coverageZoneOnly'} = 'false';
 		}
diff --git a/traffic_ops/app/templates/delivery_service/_form.html.ep b/traffic_ops/app/templates/delivery_service/_form.html.ep
index b46817b..3280109 100644
--- a/traffic_ops/app/templates/delivery_service/_form.html.ep
+++ b/traffic_ops/app/templates/delivery_service/_form.html.ep
@@ -141,14 +141,16 @@
 		<% } %>
 		%= label_for 'geo_limit' => 'Geo Limit?', class => 'label'
 		<% if ($priv_level >= 20) { %>
-		%= field('ds.geo_limit')->select([[None => 0], ["CZF only" => 1], ["CZF + US" => 2]]);
+		%= field('ds.geo_limit')->select([[None => 0], ["CZF only" => 1], ["CZF + US" => 2], ["CZF + CA" => 3]]);
 		<% } else { %>
 			<% if ($ds->geo_limit == 0) { %>
 				%= field('ds.geo_limit')->text(class => 'field', value =>  'None', readonly => 'readonly');
 			<% } elsif($ds->geo_limit == 1) { %>
 				%= field('ds.geo_limit')->text(class => 'field', value =>  'CZF only', readonly => 'readonly');
+			<% } elsif($ds->geo_limit == 2) { %>
+                %= field('ds.geo_limit')->text(class => 'field', value =>  'CZF + US', readonly => 'readonly');
 			<% } else { %>
-			%= field('ds.geo_limit')->text(class => 'field', value =>  'CZF + US', readonly => 'readonly');
+                %= field('ds.geo_limit')->text(class => 'field', value =>  'CZF + CA', readonly => 'readonly');
 			<% } %>
 		<% } %>
 	</div><br>