diff --git a/cmd/climc/shell/identity/organizations.go b/cmd/climc/shell/identity/organizations.go index 4e01e20e51..214204ac81 100644 --- a/cmd/climc/shell/identity/organizations.go +++ b/cmd/climc/shell/identity/organizations.go @@ -31,4 +31,5 @@ func init() { orgCmd.Delete(&identity_options.OrganizationIdOptions{}) orgCmd.Perform("add-level", &identity_options.OrganizationAddLevelOptions{}) orgCmd.Perform("add-node", &identity_options.OrganizationAddNodeOptions{}) + orgCmd.Perform("clean", &identity_options.OrganizationIdOptions{}) } diff --git a/pkg/apis/identity/organization.go b/pkg/apis/identity/organization.go index 617fcdba28..9c43101764 100644 --- a/pkg/apis/identity/organization.go +++ b/pkg/apis/identity/organization.go @@ -205,3 +205,6 @@ type SOrganizationNodeDetails struct { Type TOrgType `json:"type"` } + +type OrganizationPerformCleanInput struct { +} diff --git a/pkg/keystone/models/organization_nodes.go b/pkg/keystone/models/organization_nodes.go index 2127e60cb9..1c34dcc357 100644 --- a/pkg/keystone/models/organization_nodes.go +++ b/pkg/keystone/models/organization_nodes.go @@ -117,6 +117,10 @@ func (manager *SOrganizationNodeManager) ensureNode(ctx context.Context, orgId s return nil, errors.Wrap(err, "FetchById") } // not exist + if weight == nil { + one := 1 + weight = &one + } } else { // exist if weight == nil { diff --git a/pkg/keystone/models/organizations.go b/pkg/keystone/models/organizations.go index ca80f5d748..c47dfacc30 100644 --- a/pkg/keystone/models/organizations.go +++ b/pkg/keystone/models/organizations.go @@ -661,3 +661,16 @@ func (org *SOrganization) getProjectOrganization(tags map[string]string) (*api.S } return &ret, nil } + +func (org *SOrganization) PerformClean( + ctx context.Context, + userCred mcclient.TokenCredential, + query jsonutils.JSONObject, + input api.OrganizationPerformCleanInput, +) (jsonutils.JSONObject, error) { + err := org.removeAll(ctx, userCred) + if err != nil { + return nil, errors.Wrap(err, "removeAll") + } + return nil, nil +}