diff --git a/api/http/handler/endpoints/endpoint_create.go b/api/http/handler/endpoints/endpoint_create.go index cec3dfcf8..4aac20039 100644 --- a/api/http/handler/endpoints/endpoint_create.go +++ b/api/http/handler/endpoints/endpoint_create.go @@ -43,7 +43,7 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error { endpointType, err := request.RetrieveNumericMultiPartFormValue(r, "EndpointType", false) if err != nil || endpointType == 0 { - return portainer.Error("Invalid endpoint type value. Value must be one of: 1 (Docker environment), 2 (Agent environment), 3 (Azure environment) or 4 (Agent IoT environment)") + return portainer.Error("Invalid endpoint type value. Value must be one of: 1 (Docker environment), 2 (Agent environment), 3 (Azure environment) or 4 (Agent Edge environment)") } payload.EndpointType = endpointType @@ -152,7 +152,7 @@ func (handler *Handler) createEndpoint(payload *endpointCreatePayload) (*portain if portainer.EndpointType(payload.EndpointType) == portainer.AzureEnvironment { return handler.createAzureEndpoint(payload) } else if portainer.EndpointType(payload.EndpointType) == portainer.AgentEdgeEnvironment { - return handler.createAgentIoTEndpoint(payload) + return handler.createAgentEdgeEndpoint(payload) } if payload.TLS { @@ -199,11 +199,11 @@ func (handler *Handler) createAzureEndpoint(payload *endpointCreatePayload) (*po return endpoint, nil } -func (handler *Handler) createAgentIoTEndpoint(payload *endpointCreatePayload) (*portainer.Endpoint, *httperror.HandlerError) { +func (handler *Handler) createAgentEdgeEndpoint(payload *endpointCreatePayload) (*portainer.Endpoint, *httperror.HandlerError) { endpointType := portainer.AgentEdgeEnvironment endpointID := handler.EndpointService.GetNextIdentifier() - iotKey := base64.RawStdEncoding.EncodeToString([]byte(strings.TrimPrefix(payload.URL, "tcp://") + ":9999:7777:random_secret")) + edgeKey := base64.RawStdEncoding.EncodeToString([]byte(strings.TrimPrefix(payload.URL, "tcp://") + ":9999:7777:random_secret")) endpoint := &portainer.Endpoint{ ID: portainer.EndpointID(endpointID), @@ -220,7 +220,7 @@ func (handler *Handler) createAgentIoTEndpoint(payload *endpointCreatePayload) ( Tags: payload.Tags, Status: portainer.EndpointStatusUp, Snapshots: []portainer.Snapshot{}, - IoTKey: iotKey, + EdgeKey: edgeKey, } err := handler.EndpointService.CreateEndpoint(endpoint) diff --git a/api/portainer.go b/api/portainer.go index bd1d8944f..6f780a92e 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -242,7 +242,7 @@ type ( Tags []string `json:"Tags"` Status EndpointStatus `json:"Status"` Snapshots []Snapshot `json:"Snapshots"` - IoTKey string `json:"IoTKey"` + EdgeKey string `json:"EdgeKey"` // Deprecated fields // Deprecated in DBVersion == 4 diff --git a/app/portainer/views/endpoints/create/createEndpointController.js b/app/portainer/views/endpoints/create/createEndpointController.js index 1b67c9f55..b465022dd 100644 --- a/app/portainer/views/endpoints/create/createEndpointController.js +++ b/app/portainer/views/endpoints/create/createEndpointController.js @@ -94,9 +94,13 @@ function ($q, $scope, $state, $filter, clipboard, EndpointService, GroupService, function addEndpoint(name, type, URL, PublicURL, groupId, tags, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile) { $scope.state.actionInProgress = true; EndpointService.createRemoteEndpoint(name, type, URL, PublicURL, groupId, tags, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile) - .then(function success() { + .then(function success(data) { Notifications.success('Endpoint created', name); - $state.go('portainer.endpoints', {}, {reload: true}); + if (type === 4) { + $state.go('portainer.endpoints.endpoint', { id: data.Id }); + } else { + $state.go('portainer.endpoints', {}, {reload: true}); + } }) .catch(function error(err) { Notifications.error('Failure', err, 'Unable to create endpoint'); diff --git a/app/portainer/views/endpoints/edit/endpoint.html b/app/portainer/views/endpoints/edit/endpoint.html index de350d624..0dddc963e 100644 --- a/app/portainer/views/endpoints/edit/endpoint.html +++ b/app/portainer/views/endpoints/edit/endpoint.html @@ -10,7 +10,7 @@

- Deploy an agent on your remote Docker environment using the following command to enable this endpoint: + Deploy an agent on your remote Docker environment using the following command to enable this endpoint

@@ -19,15 +19,17 @@ -v /:/host \ --restart always \ -e TUNNELLING_MODE=1 \ - -e AGENT_SECRET={{ endpoint.IoTKey }} \ + -e AGENT_SECRET={{ endpoint.EdgeKey }} \ -e CAP_HOST_MANAGEMENT=1 \ --name portainer_agent_edge \ portainer/pagent:edge - Copy command - - - +
+ Copy command + +
diff --git a/app/portainer/views/endpoints/edit/endpointController.js b/app/portainer/views/endpoints/edit/endpointController.js index e4ad433cd..3299547da 100644 --- a/app/portainer/views/endpoints/edit/endpointController.js +++ b/app/portainer/views/endpoints/edit/endpointController.js @@ -18,9 +18,9 @@ function ($q, $scope, $state, $transition$, $filter, clipboard, EndpointService, }; $scope.copyAgentEdgeDeploymentCommand = function() { - clipboard.copyText('docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host --restart always -e TUNNELLING_MODE=1 -e AGENT_SECRET=' + $scope.endpoint.IoTKey + ' -e CAP_HOST_MANAGEMENT=1 --name portainer_agent_iot portainer/pagent:intel'); + clipboard.copyText('docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host --restart always -e TUNNELLING_MODE=1 -e AGENT_SECRET=' + $scope.endpoint.EdgeKey + ' -e CAP_HOST_MANAGEMENT=1 --name portainer_agent_iot portainer/pagent:intel'); $('#copyNotification').show(); - $('#copyNotification').fadeOut(2000); + $('#copyNotification').fadeOut(2500); }; $scope.updateEndpoint = function() {