From 7c2c692475f347f9c74648d4df25c0112fbe6aa2 Mon Sep 17 00:00:00 2001 From: Rawlin Peters Date: Mon, 30 Mar 2020 18:14:26 -0600 Subject: [PATCH 01/20] Add topology field to deliveryservice --- docs/source/api/v2/deliveryservices.rst | 11 +++++++++-- docs/source/api/v2/deliveryservices_id.rst | 1 + docs/source/api/v2/deliveryservices_id_safe.rst | 4 +++- .../api/v2/servers_id_deliveryservices.rst | 4 +++- lib/go-tc/deliveryservices.go | 13 +++++++++++-- .../deliveryservice/deliveryservices.go | 17 +++++++++++++---- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/docs/source/api/v2/deliveryservices.rst b/docs/source/api/v2/deliveryservices.rst index afda15b665..be5841f603 100644 --- a/docs/source/api/v2/deliveryservices.rst +++ b/docs/source/api/v2/deliveryservices.rst @@ -44,6 +44,8 @@ Request Structure +--------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+ | tenant | no | Show only the :term:`Delivery Services` belonging to the :term:`Tenant` identified by this integral, unique identifier | +--------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+ + | topology | no | Show only the :term:`Delivery Services` assigned to the Topology identified by this unique identifier | + +--------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+ | type | no | Return only :term:`Delivery Services` of the :term:`Delivery Service` :ref:`ds-types` identified by this integral, unique identifier | +--------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------+ | accessibleTo | no | Return the :term:`Delivery Services` accessible from a :term:`Tenant` *or it's children* identified by this integral, unique identifier | @@ -133,6 +135,7 @@ Response Structure :rangeSliceBlockSize: An integer that defines the byte block size for the ATS Slice Plugin. It can only and must be set if ``rangeRequestHandling`` is set to 3. :sslKeyVersion: This integer indicates the :ref:`ds-ssl-key-version` :tenantId: The integral, unique identifier of the :ref:`ds-tenant` who owns this :term:`Delivery Service` +:topology: The unique identifier of the Topology that this :term:`Delivery Service` is assigned to :trRequestHeaders: If defined, this defines the :ref:`ds-tr-req-headers` used by Traffic Router for this :term:`Delivery Service` :trResponseHeaders: If defined, this defines the :ref:`ds-tr-resp-headers` used by Traffic Router for this :term:`Delivery Service` :type: The :ref:`ds-types` of this :term:`Delivery Service` @@ -234,7 +237,8 @@ Response Structure ], "maxOriginConnections": 0, "ecsEnabled": false, - "rangeSliceBlockSize": null + "rangeSliceBlockSize": null, + "topology": null }]} @@ -304,6 +308,7 @@ Request Structure :rangeSliceBlockSize: An integer that defines the byte block size for the ATS Slice Plugin. It can only and must be set if ``rangeRequestHandling`` is set to 3. It can only be between (inclusive) 262144 (256KB) - 33554432 (32MB). :sslKeyVersion: This integer indicates the :ref:`ds-ssl-key-version` :tenantId: The integral, unique identifier of the :ref:`ds-tenant` who owns this :term:`Delivery Service` +:topology: The unique identifier of the Topology that this :term:`Delivery Service` is assigned to :trRequestHeaders: If defined, this defines the :ref:`ds-tr-req-headers` used by Traffic Router for this :term:`Delivery Service` :trResponseHeaders: If defined, this defines the :ref:`ds-tr-resp-headers` used by Traffic Router for this :term:`Delivery Service` :type: The :ref:`ds-types` of this :term:`Delivery Service` @@ -423,6 +428,7 @@ Response Structure :rangeSliceBlockSize: An integer that defines the byte block size for the ATS Slice Plugin. It can only and must be set if ``rangeRequestHandling`` is set to 3. :sslKeyVersion: This integer indicates the :ref:`ds-ssl-key-version` :tenantId: The integral, unique identifier of the :ref:`ds-tenant` who owns this :term:`Delivery Service` +:topology: The unique identifier of the Topology that this :term:`Delivery Service` is assigned to :trRequestHeaders: If defined, this defines the :ref:`ds-tr-req-headers` used by Traffic Router for this :term:`Delivery Service` :trResponseHeaders: If defined, this defines the :ref:`ds-tr-resp-headers` used by Traffic Router for this :term:`Delivery Service` :type: The :ref:`ds-types` of this :term:`Delivery Service` @@ -520,7 +526,8 @@ Response Structure "signingAlgorithm": null, "tenant": "root", "ecsEnabled": true, - "rangeSliceBlockSize": null + "rangeSliceBlockSize": null, + "topology": null } ]} diff --git a/docs/source/api/v2/deliveryservices_id.rst b/docs/source/api/v2/deliveryservices_id.rst index 9a2a9e6aae..8886808c37 100644 --- a/docs/source/api/v2/deliveryservices_id.rst +++ b/docs/source/api/v2/deliveryservices_id.rst @@ -86,6 +86,7 @@ Request Structure :rangeSliceBlockSize: An integer that defines the byte block size for the ATS Slice Plugin. It can only and must be set if ``rangeRequestHandling`` is set to 3. It can only be between (inclusive) 262144 (256KB) - 33554432 (32MB). :sslKeyVersion: This integer indicates the :ref:`ds-ssl-key-version` :tenantId: The integral, unique identifier of the :ref:`ds-tenant` who owns this :term:`Delivery Service` +:topology: The unique identifier of the Topology that this :term:`Delivery Service` is assigned to :trRequestHeaders: If defined, this defines the :ref:`ds-tr-req-headers` used by Traffic Router for this :term:`Delivery Service` :trResponseHeaders: If defined, this defines the :ref:`ds-tr-resp-headers` used by Traffic Router for this :term:`Delivery Service` :typeId: The integral, unique identifier of the :ref:`ds-types` of this :term:`Delivery Service` diff --git a/docs/source/api/v2/deliveryservices_id_safe.rst b/docs/source/api/v2/deliveryservices_id_safe.rst index 7a4f828089..3394e6b67d 100644 --- a/docs/source/api/v2/deliveryservices_id_safe.rst +++ b/docs/source/api/v2/deliveryservices_id_safe.rst @@ -129,6 +129,7 @@ Response Structure :rangeSliceBlockSize: An integer that defines the byte block size for the ATS Slice Plugin. It can only and must be set if ``rangeRequestHandling`` is set to 3. :sslKeyVersion: This integer indicates the :ref:`ds-ssl-key-version` :tenantId: The integral, unique identifier of the :ref:`ds-tenant` who owns this :term:`Delivery Service` +:topology: The unique identifier of the Topology that this :term:`Delivery Service` is assigned to :trRequestHeaders: If defined, this defines the :ref:`ds-tr-req-headers` used by Traffic Router for this :term:`Delivery Service` :trResponseHeaders: If defined, this defines the :ref:`ds-tr-resp-headers` used by Traffic Router for this :term:`Delivery Service` :type: The :ref:`ds-types` of this :term:`Delivery Service` @@ -233,7 +234,8 @@ Response Structure ], "maxOriginConnections": 0, "ecsEnabled": false, - "rangeSliceBlockSize": null + "rangeSliceBlockSize": null, + "topology": null } ]} diff --git a/docs/source/api/v2/servers_id_deliveryservices.rst b/docs/source/api/v2/servers_id_deliveryservices.rst index bc4794534a..24863de06a 100644 --- a/docs/source/api/v2/servers_id_deliveryservices.rst +++ b/docs/source/api/v2/servers_id_deliveryservices.rst @@ -135,6 +135,7 @@ Response Structure :rangeSliceBlockSize: An integer that defines the byte block size for the ATS Slice Plugin. It can only and must be set if ``rangeRequestHandling`` is set to 3. :sslKeyVersion: This integer indicates the :ref:`ds-ssl-key-version` :tenantId: The integral, unique identifier of the :ref:`ds-tenant` who owns this :term:`Delivery Service` +:topology: The unique identifier of the Topology that this :term:`Delivery Service` is assigned to :trRequestHeaders: If defined, this defines the :ref:`ds-tr-req-headers` used by Traffic Router for this :term:`Delivery Service` :trResponseHeaders: If defined, this defines the :ref:`ds-tr-resp-headers` used by Traffic Router for this :term:`Delivery Service` :type: The :ref:`ds-types` of this :term:`Delivery Service` @@ -236,7 +237,8 @@ Response Structure ], "maxOriginConnections": 0, "ecsEnabled": false, - "rangeSliceBlockSize": null + "rangeSliceBlockSize": null, + "topology": null }]} diff --git a/lib/go-tc/deliveryservices.go b/lib/go-tc/deliveryservices.go index bb1a54dc84..1288a69b8c 100644 --- a/lib/go-tc/deliveryservices.go +++ b/lib/go-tc/deliveryservices.go @@ -163,8 +163,9 @@ type DeliveryServiceNullableV15 DeliveryServiceNullable // this type alias shoul type DeliveryServiceNullable struct { DeliveryServiceNullableV14 - EcsEnabled bool `json:"ecsEnabled" db:"ecs_enabled"` - RangeSliceBlockSize *int `json:"rangeSliceBlockSize" db:"range_slice_block_size"` + EcsEnabled bool `json:"ecsEnabled" db:"ecs_enabled"` + RangeSliceBlockSize *int `json:"rangeSliceBlockSize" db:"range_slice_block_size"` + Topology *string `json:"topology" db:"topology"` } type DeliveryServiceNullableV14 struct { @@ -415,6 +416,14 @@ func (ds *DeliveryServiceNullable) validateTypeFields(tx *sql.Tx) error { validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName))), "rangeRequestHandling": validation.Validate(ds.RangeRequestHandling, validation.By(requiredIfMatchesTypeName([]string{DNSRegexType, HTTPRegexType}, typeName))), + "topology": validation.Validate(ds, + validation.By(func(dsi interface{}) error { + ds := dsi.(*DeliveryServiceNullable) + if ds.Topology != nil && DSType(typeName).IsSteering() { + return fmt.Errorf("steering deliveryservice types cannot be assigned to a topology") + } + return nil + })), } toErrs := tovalidate.ToErrors(errs) if len(toErrs) > 0 { diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go index c8db101212..3aa7d44f19 100644 --- a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go +++ b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go @@ -283,6 +283,7 @@ func createV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS t &ds.SigningAlgorithm, &ds.SSLKeyVersion, &ds.TenantID, + &ds.Topology, &ds.TRRequestHeaders, &ds.TRResponseHeaders, &ds.TypeID, @@ -615,7 +616,8 @@ func updateV14(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS * query := ` SELECT ds.ecs_enabled, - ds.range_slice_block_size + ds.range_slice_block_size, + ds.topology FROM deliveryservice ds WHERE @@ -623,6 +625,7 @@ WHERE if err := inf.Tx.Tx.QueryRow(query, *reqDS.ID).Scan( &dsV15.EcsEnabled, &dsV15.RangeSliceBlockSize, + &dsV15.Topology, ); err != nil { if err == sql.ErrNoRows { return nil, http.StatusNotFound, fmt.Errorf("delivery service ID %d not found", *dsV15.ID), nil @@ -738,6 +741,7 @@ func updateV15(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, reqDS * &ds.MaxOriginConnections, &ds.EcsEnabled, &ds.RangeSliceBlockSize, + &ds.Topology, &ds.ID) if err != nil { @@ -906,6 +910,7 @@ func readGetDeliveryServices(params map[string]string, tx *sqlx.Tx, user *auth.C "logsEnabled": dbhelpers.WhereColumnInfo{"ds.logs_enabled", api.IsBool}, "tenant": dbhelpers.WhereColumnInfo{"ds.tenant_id", api.IsInt}, "signingAlgorithm": dbhelpers.WhereColumnInfo{"ds.signing_algorithm", nil}, + "topology": dbhelpers.WhereColumnInfo{"ds.topology", nil}, } where, orderBy, pagination, queryValues, errs := dbhelpers.BuildWhereAndOrderByAndPagination(params, queryParamsToSQLCols) @@ -1135,6 +1140,7 @@ func GetDeliveryServices(query string, queryValues map[string]interface{}, tx *s &ds.SSLKeyVersion, &ds.TenantID, &ds.Tenant, + &ds.Topology, &ds.TRRequestHeaders, &ds.TRResponseHeaders, &ds.Type, @@ -1655,6 +1661,7 @@ ds.range_slice_block_size, ds.ssl_key_version, ds.tenant_id, tenant.name, +ds.topology, ds.tr_request_headers, ds.tr_response_headers, type.name, @@ -1726,8 +1733,9 @@ anonymous_blocking_enabled=$50, consistent_hash_regex=$51, max_origin_connections=$52, ecs_enabled=$53, -range_slice_block_size=$54 -WHERE id=$55 +range_slice_block_size=$54, +topology=$55 +WHERE id=$56 RETURNING last_updated ` } @@ -1783,6 +1791,7 @@ routing_name, signing_algorithm, ssl_key_version, tenant_id, +topology, tr_request_headers, tr_response_headers, type, @@ -1790,7 +1799,7 @@ xml_id, ecs_enabled, range_slice_block_size ) -VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54) +VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55) RETURNING id, last_updated ` } From 9d858bdca6338a67c785df3e9cfbbf047aaaec38 Mon Sep 17 00:00:00 2001 From: Jeremy Mitchell Date: Wed, 22 Apr 2020 08:26:27 -0600 Subject: [PATCH 02/20] adds topology field to dns/http forms and to all ds tables --- .../FormDeliveryServiceController.js | 6 ++++-- .../edit/FormEditDeliveryServiceController.js | 6 +++--- .../form.deliveryService.DNS.tpl.html | 17 +++++++++++++++++ .../form.deliveryService.HTTP.tpl.html | 17 +++++++++++++++++ .../new/FormNewDeliveryServiceController.js | 6 +++--- .../table.cdnDeliveryServices.tpl.html | 2 ++ .../TableDeliveryServicesController.js | 13 +++++++------ .../table.deliveryServices.tpl.html | 2 ++ .../table.profileDeliveryServices.tpl.html | 2 ++ .../table.serverDeliveryServices.tpl.html | 2 ++ .../table.tenantDeliveryServices.tpl.html | 2 ++ .../table.typeDeliveryServices.tpl.html | 2 ++ .../FormEditDeliveryServiceRequestController.js | 6 +++--- .../deliveryServiceRequests/edit/index.js | 4 ++++ .../private/deliveryServices/edit/index.js | 4 ++++ .../private/deliveryServices/new/index.js | 4 ++++ 16 files changed, 78 insertions(+), 17 deletions(-) diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js index 66209da419..bbb8deee14 100644 --- a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js +++ b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js @@ -17,7 +17,7 @@ * under the License. */ -var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin, type, types, $scope, $location, $uibModal, $window, formUtils, locationUtils, tenantUtils, deliveryServiceUtils, cdnService, profileService, tenantService, propertiesModel, userModel) { +var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin, topologies, type, types, $scope, $location, $uibModal, $window, formUtils, locationUtils, tenantUtils, deliveryServiceUtils, cdnService, profileService, tenantService, propertiesModel, userModel) { var getCDNs = function() { cdnService.getCDNs() @@ -58,6 +58,8 @@ var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin, $scope.origin = origin[0]; + $scope.topologies = topologies; + $scope.showChartsButton = propertiesModel.properties.deliveryServices.charts.customLink.show; $scope.openCharts = deliveryServiceUtils.openCharts; @@ -312,5 +314,5 @@ var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin, }; -FormDeliveryServiceController.$inject = ['deliveryService', 'dsCurrent', 'origin', 'type', 'types', '$scope', '$location', '$uibModal', '$window', 'formUtils', 'locationUtils', 'tenantUtils', 'deliveryServiceUtils', 'cdnService', 'profileService', 'tenantService', 'propertiesModel', 'userModel']; +FormDeliveryServiceController.$inject = ['deliveryService', 'dsCurrent', 'origin', 'topologies', 'type', 'types', '$scope', '$location', '$uibModal', '$window', 'formUtils', 'locationUtils', 'tenantUtils', 'deliveryServiceUtils', 'cdnService', 'profileService', 'tenantService', 'propertiesModel', 'userModel']; module.exports = FormDeliveryServiceController; diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js b/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js index 40bf5600d9..2c03d25baf 100644 --- a/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js +++ b/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js @@ -17,10 +17,10 @@ * under the License. */ -var FormEditDeliveryServiceController = function(deliveryService, origin, type, types, $scope, $state, $controller, $uibModal, $anchorScroll, locationUtils, deliveryServiceService, deliveryServiceRequestService, messageModel, propertiesModel, userModel) { +var FormEditDeliveryServiceController = function(deliveryService, origin, topologies, type, types, $scope, $state, $controller, $uibModal, $anchorScroll, locationUtils, deliveryServiceService, deliveryServiceRequestService, messageModel, propertiesModel, userModel) { // extends the FormDeliveryServiceController to inherit common methods - angular.extend(this, $controller('FormDeliveryServiceController', { deliveryService: deliveryService, dsCurrent: deliveryService, origin: origin, type: type, types: types, $scope: $scope })); + angular.extend(this, $controller('FormDeliveryServiceController', { deliveryService: deliveryService, dsCurrent: deliveryService, origin: origin, topologies: topologies, type: type, types: types, $scope: $scope })); var createDeliveryServiceDeleteRequest = function(deliveryService) { var params = { @@ -273,5 +273,5 @@ var FormEditDeliveryServiceController = function(deliveryService, origin, type, }; -FormEditDeliveryServiceController.$inject = ['deliveryService', 'origin', 'type', 'types', '$scope', '$state', '$controller', '$uibModal', '$anchorScroll', 'locationUtils', 'deliveryServiceService', 'deliveryServiceRequestService', 'messageModel', 'propertiesModel', 'userModel']; +FormEditDeliveryServiceController.$inject = ['deliveryService', 'origin', 'topologies', 'type', 'types', '$scope', '$state', '$controller', '$uibModal', '$anchorScroll', 'locationUtils', 'deliveryServiceService', 'deliveryServiceRequestService', 'messageModel', 'propertiesModel', 'userModel']; module.exports = FormEditDeliveryServiceController; diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html index d6d18a747f..c945ce23ad 100644 --- a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html +++ b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html @@ -228,6 +228,23 @@

Current Value

+
+ +
+ + View Details   + +
+
+
+ +
+ + View Details   + +
+