diff --git a/pkg/apis/compute/modelarts_pool.go b/pkg/apis/compute/modelarts_pool.go index 6e490a8401..dd12e9d329 100644 --- a/pkg/apis/compute/modelarts_pool.go +++ b/pkg/apis/compute/modelarts_pool.go @@ -15,19 +15,20 @@ package compute import ( - "yunion.io/x/cloudmux/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/apis" ) const ( - MODELARTS_POOL_STATUS_RUNNING = compute.MODELARTS_POOL_STATUS_RUNNING - MODELARTS_POOL_STATUS_ABNORMAL = "abnormal" - MODELARTS_POOL_STATUS_CREATING = compute.MODELARTS_POOL_STATUS_CREATING - MODELARTS_POOL_STATUS_DELETING = "deleting" - MODELARTS_POOL_STATUS_CHANGE_CONFIG = "change_config" - MODELARTS_POOL_STATUS_ERROR = "error" - MODELARTS_POOL_STATUS_UNKNOWN = "unknown" + MODELARTS_POOL_STATUS_RUNNING = "running" + MODELARTS_POOL_STATUS_ABNORMAL = "abnormal" + MODELARTS_POOL_STATUS_CREATING = "creating" + MODELARTS_POOL_STATUS_CREATE_FAILED = "create_failed" + MODELARTS_POOL_STATUS_DELETING = "deleting" + MODELARTS_POOL_STATUS_DELETE_FAILED = "delete_failed" + MODELARTS_POOL_STATUS_CHANGE_CONFIG = "change_config" + MODELARTS_POOL_STATUS_CHANGE_CONFIG_FAILED = "change_config_failed" + MODELARTS_POOL_STATUS_ERROR = "error" + MODELARTS_POOL_STATUS_UNKNOWN = "unknown" ) type ModelartsPoolCreateInput struct { diff --git a/pkg/compute/tasks/modelarts_pool_change_config_task.go b/pkg/compute/tasks/modelarts_pool_change_config_task.go index afb9a6d79d..a4d7356fd3 100644 --- a/pkg/compute/tasks/modelarts_pool_change_config_task.go +++ b/pkg/compute/tasks/modelarts_pool_change_config_task.go @@ -39,7 +39,7 @@ func init() { } func (self *ModelartsPoolChangeConfigTask) taskFailed(ctx context.Context, mp *models.SModelartsPool, err error) { - mp.SetStatus(self.UserCred, api.MODELARTS_POOL_STATUS_UNKNOWN, err.Error()) + mp.SetStatus(self.UserCred, api.MODELARTS_POOL_STATUS_CHANGE_CONFIG_FAILED, err.Error()) db.OpsLog.LogEvent(mp, db.ACT_CHANGE_CONFIG, err, self.UserCred) logclient.AddActionLogWithStartable(self, mp, logclient.ACT_CHANGE_CONFIG, err, self.UserCred, false) self.SetStageFailed(ctx, jsonutils.NewString(err.Error())) diff --git a/pkg/compute/tasks/modelarts_pool_create_task.go b/pkg/compute/tasks/modelarts_pool_create_task.go index 62f239b05b..51127ebbd3 100644 --- a/pkg/compute/tasks/modelarts_pool_create_task.go +++ b/pkg/compute/tasks/modelarts_pool_create_task.go @@ -39,7 +39,7 @@ func init() { } func (self *ModelartsPoolCreateTask) taskFailed(ctx context.Context, pool *models.SModelartsPool, err error) { - pool.SetStatus(self.UserCred, api.MODELARTS_POOL_STATUS_UNKNOWN, err.Error()) + pool.SetStatus(self.UserCred, api.MODELARTS_POOL_STATUS_CREATE_FAILED, err.Error()) logclient.AddActionLogWithStartable(self, pool, logclient.ACT_ALLOCATE, err, self.UserCred, false) self.SetStageFailed(ctx, jsonutils.NewString(err.Error())) } diff --git a/pkg/compute/tasks/modelarts_pool_delete_task.go b/pkg/compute/tasks/modelarts_pool_delete_task.go index a1441eb80a..401e9828a0 100644 --- a/pkg/compute/tasks/modelarts_pool_delete_task.go +++ b/pkg/compute/tasks/modelarts_pool_delete_task.go @@ -22,7 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - apis "yunion.io/x/onecloud/pkg/apis" + api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" @@ -39,7 +39,7 @@ func init() { } func (self *ModelartsPoolDeleteTask) taskFailed(ctx context.Context, mp *models.SModelartsPool, err error) { - mp.SetStatus(self.UserCred, apis.STATUS_DELETE_FAILED, err.Error()) + mp.SetStatus(self.UserCred, api.MODELARTS_POOL_STATUS_DELETE_FAILED, err.Error()) db.OpsLog.LogEvent(mp, db.ACT_DELETE_FAIL, err, self.UserCred) logclient.AddActionLogWithStartable(self, mp, logclient.ACT_DELOCATE, err, self.UserCred, false) self.SetStageFailed(ctx, jsonutils.NewString(err.Error())) diff --git a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/modelarts_pool.go b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/modelarts_pool.go deleted file mode 100644 index 10d0ee8c39..0000000000 --- a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/modelarts_pool.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2019 Yunion -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package compute - -const ( - MODELARTS_POOL_STATUS_RUNNING = "running" - MODELARTS_POOL_STATUS_CREATING = "creating" -) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go index ec0cbedfc4..cdf1ed3f23 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go @@ -22,9 +22,9 @@ import ( "yunion.io/x/pkg/errors" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" - "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" + api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/util/billing" ) @@ -288,8 +288,12 @@ func (self *SModelartsPool) GetName() string { func (self *SModelartsPool) GetStatus() string { res := strings.ToLower(self.Status.Phase) switch { - case res == compute.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0: - res = compute.MODELARTS_POOL_STATUS_CREATING + case res == api.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0: + res = api.MODELARTS_POOL_STATUS_CREATING + case self.Status.Phase == "CreationFailed": + res = api.MODELARTS_POOL_STATUS_CREATE_FAILED + case self.Status.Phase == "SeclingFailed": + res = api.MODELARTS_POOL_STATUS_CHANGE_CONFIG_FAILED } return res } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go index 05387b26c8..dfb6b50902 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go @@ -22,9 +22,9 @@ import ( "yunion.io/x/pkg/errors" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" - "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" + api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/util/billing" ) @@ -287,8 +287,12 @@ func (self *SModelartsPool) GetName() string { func (self *SModelartsPool) GetStatus() string { res := strings.ToLower(self.Status.Phase) switch { - case res == compute.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0: - res = compute.MODELARTS_POOL_STATUS_CREATING + case res == api.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0: + res = api.MODELARTS_POOL_STATUS_CREATING + case self.Status.Phase == "CreationFailed": + res = api.MODELARTS_POOL_STATUS_CREATE_FAILED + case self.Status.Phase == "SeclingFailed": + res = api.MODELARTS_POOL_STATUS_CHANGE_CONFIG_FAILED } return res }