Skip to content

Commit

Permalink
fix: cleanup compute options 20240615 (#20547)
Browse files Browse the repository at this point in the history
Co-authored-by: Qiu Jian <[email protected]>
  • Loading branch information
swordqiu and Qiu Jian authored Jun 16, 2024
1 parent 4a59da5 commit 410b5b7
Show file tree
Hide file tree
Showing 30 changed files with 134 additions and 92 deletions.
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/cloudaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
5 changes: 3 additions & 2 deletions cmd/climc/shell/compute/dbinstance_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
cmd := shell.NewResourceCmd(&modules.DBInstanceAccounts).WithKeyword("dbinstance-account")
cmd.List(&options.DBInstanceAccountListOptions{})
cmd.Update(&options.BaseUpdateOptions{})
cmd.Update(&baseoptions.BaseUpdateOptions{})
cmd.Show(&options.DBInstanceAccountIdOptions{})
cmd.Delete(&options.DBInstanceAccountIdOptions{})
}
5 changes: 3 additions & 2 deletions cmd/climc/shell/compute/dbinstance_databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
cmd := shell.NewResourceCmd(&modules.DBInstanceDatabases).WithKeyword("dbinstance-database")
cmd.List(&options.DBInstanceDatabaseListOptions{})
cmd.Update(&options.BaseUpdateOptions{})
cmd.Update(&baseoptions.BaseUpdateOptions{})
cmd.Delete(&options.DBInstanceDatabaseIdOptions{})
cmd.Show(&options.DBInstanceDatabaseIdOptions{})
cmd.Create(&options.DBInstanceDatabaseCreateOptions{})
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/dbinstance_skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
26 changes: 13 additions & 13 deletions cmd/climc/shell/compute/elasticcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
cmd.PerformWithKeyword("disable-auth", "update-auth-mode", &compute.ElasticCacheDisableAuthOptions{})

type ElasticCacheAccountResetPasswordOptions struct {
options.ElasticCacheIdOptions
compute.ElasticCacheIdOptions
PASSWORD string `help:"elastic cache account password."`
}

Expand Down Expand Up @@ -77,7 +77,7 @@ func init() {
return nil
})

R(&options.ElasticCacheAccountCreateOptions{}, "elastic-cache-account-create", "Create elastisc cache account", func(s *mcclient.ClientSession, opts *options.ElasticCacheAccountCreateOptions) error {
R(&compute.ElasticCacheAccountCreateOptions{}, "elastic-cache-account-create", "Create elastisc cache account", func(s *mcclient.ClientSession, opts *compute.ElasticCacheAccountCreateOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
Expand All @@ -92,7 +92,7 @@ func init() {
return nil
})

R(&options.ElasticCacheIdOptions{}, "elastic-cache-account-delete", "Delete elastisc cache account", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
R(&compute.ElasticCacheIdOptions{}, "elastic-cache-account-delete", "Delete elastisc cache account", func(s *mcclient.ClientSession, opts *compute.ElasticCacheIdOptions) error {
result, err := modules.ElasticCacheAccount.Delete(s, opts.ID, nil)
if err != nil {
return err
Expand All @@ -102,7 +102,7 @@ func init() {
return nil
})

R(&options.ElasticCacheBackupCreateOptions{}, "elastic-cache-backup-create", "Create elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheBackupCreateOptions) error {
R(&compute.ElasticCacheBackupCreateOptions{}, "elastic-cache-backup-create", "Create elastisc cache backup", func(s *mcclient.ClientSession, opts *compute.ElasticCacheBackupCreateOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
Expand Down Expand Up @@ -132,7 +132,7 @@ func init() {
return nil
})

R(&options.ElasticCacheIdOptions{}, "elastic-cache-backup-delete", "Delete elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
R(&compute.ElasticCacheIdOptions{}, "elastic-cache-backup-delete", "Delete elastisc cache backup", func(s *mcclient.ClientSession, opts *compute.ElasticCacheIdOptions) error {
result, err := modules.ElasticCacheBackup.Delete(s, opts.ID, nil)
if err != nil {
return err
Expand All @@ -142,7 +142,7 @@ func init() {
return nil
})

R(&options.ElasticCacheIdOptions{}, "elastic-cache-backup-restore", "Restore elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
R(&compute.ElasticCacheIdOptions{}, "elastic-cache-backup-restore", "Restore elastisc cache backup", func(s *mcclient.ClientSession, opts *compute.ElasticCacheIdOptions) error {
result, err := modules.ElasticCacheBackup.PerformAction(s, opts.ID, "restore-instance", nil)
if err != nil {
return err
Expand All @@ -152,7 +152,7 @@ func init() {
return nil
})

R(&options.ElasticCacheAclCreateOptions{}, "elastic-cache-acl-create", "Create elastisc cache acl", func(s *mcclient.ClientSession, opts *options.ElasticCacheAclCreateOptions) error {
R(&compute.ElasticCacheAclCreateOptions{}, "elastic-cache-acl-create", "Create elastisc cache acl", func(s *mcclient.ClientSession, opts *compute.ElasticCacheAclCreateOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
Expand All @@ -167,7 +167,7 @@ func init() {
return nil
})

R(&options.ElasticCacheIdOptions{}, "elastic-cache-acl-delete", "Delete elastisc cache acl", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
R(&compute.ElasticCacheIdOptions{}, "elastic-cache-acl-delete", "Delete elastisc cache acl", func(s *mcclient.ClientSession, opts *compute.ElasticCacheIdOptions) error {
result, err := modules.ElasticCacheAcl.Delete(s, opts.ID, nil)
if err != nil {
return err
Expand All @@ -192,7 +192,7 @@ func init() {
return nil
})

R(&options.ElasticCacheAclUpdateOptions{}, "elastic-cache-acl-update", "Update elastisc cache acl", func(s *mcclient.ClientSession, opts *options.ElasticCacheAclUpdateOptions) error {
R(&compute.ElasticCacheAclUpdateOptions{}, "elastic-cache-acl-update", "Update elastisc cache acl", func(s *mcclient.ClientSession, opts *compute.ElasticCacheAclUpdateOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
Expand Down Expand Up @@ -223,7 +223,7 @@ func init() {
return nil
})

R(&options.ElasticCacheParameterUpdateOptions{}, "elastic-cache-parameter-update", "Update elastisc cache parameter", func(s *mcclient.ClientSession, opts *options.ElasticCacheParameterUpdateOptions) error {
R(&compute.ElasticCacheParameterUpdateOptions{}, "elastic-cache-parameter-update", "Update elastisc cache parameter", func(s *mcclient.ClientSession, opts *compute.ElasticCacheParameterUpdateOptions) error {
params, err := options.ListStructToParams(opts)
if err != nil {
return err
Expand Down Expand Up @@ -293,7 +293,7 @@ func init() {
return nil
})

R(&options.ElasticCacheRemoteUpdateOptions{}, "elastic-cache-remote-update", "Restore elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheRemoteUpdateOptions) error {
R(&compute.ElasticCacheRemoteUpdateOptions{}, "elastic-cache-remote-update", "Restore elastisc cache backup", func(s *mcclient.ClientSession, opts *compute.ElasticCacheRemoteUpdateOptions) error {
params, err := options.StructToParams(opts)
if err != nil {
return err
Expand All @@ -307,7 +307,7 @@ func init() {
return nil
})

R(&options.ElasticCacheAutoRenewOptions{}, "elastic-cache-auto-renew", "Set elastisc cache auto renew", func(s *mcclient.ClientSession, opts *options.ElasticCacheAutoRenewOptions) error {
R(&compute.ElasticCacheAutoRenewOptions{}, "elastic-cache-auto-renew", "Set elastisc cache auto renew", func(s *mcclient.ClientSession, opts *compute.ElasticCacheAutoRenewOptions) error {
params, err := options.StructToParams(opts)
if err != nil {
return err
Expand All @@ -321,7 +321,7 @@ func init() {
return nil
})

R(&options.ElasticCacheRenewOptions{}, "elastic-cache-renew", "Renew elastisc cache", func(s *mcclient.ClientSession, opts *options.ElasticCacheRenewOptions) error {
R(&compute.ElasticCacheRenewOptions{}, "elastic-cache-renew", "Renew elastisc cache", func(s *mcclient.ClientSession, opts *compute.ElasticCacheRenewOptions) error {
params, err := options.StructToParams(opts)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/networkaddresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/routetable_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/routetable_routeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/routetables.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/schedtagresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

type schedtagModelHelper struct {
Expand Down
5 changes: 3 additions & 2 deletions cmd/climc/shell/compute/schedtags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand All @@ -29,6 +30,6 @@ func init() {
cmd.Create(new(options.SchedtagCreateOptions))
cmd.Update(new(options.SchedtagUpdateOptions))
cmd.BatchPerform("set-scope", new(options.SchedtagSetScopeOptions))
cmd.PerformWithKeyword("set-user-metadata", "user-metadata", new(options.ResourceMetadataOptions))
cmd.PerformWithKeyword("set-user-metadata", "user-metadata", new(baseoptions.ResourceMetadataOptions))
cmd.Perform("set-resource", new(options.SchedtagSetResource))
}
5 changes: 3 additions & 2 deletions cmd/climc/shell/compute/secgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
cmd := shell.NewResourceCmd(&modules.SecGroups)
cmd.List(&options.SecgroupListOptions{})
cmd.Create(&options.SecgroupCreateOptions{})
cmd.Show(&options.SecgroupIdOptions{})
cmd.Update(&options.BaseUpdateOptions{})
cmd.Update(&baseoptions.BaseUpdateOptions{})
cmd.Delete(&options.SecgroupIdOptions{})
cmd.Perform("public", &options.SecgroupIdOptions{})
cmd.Perform("syncstatus", &options.SecgroupIdOptions{})
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/climc/shell/compute/vpc_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package compute
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand Down
7 changes: 4 additions & 3 deletions cmd/climc/shell/compute/vpcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/mcclient"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
"yunion.io/x/onecloud/pkg/mcclient/options"
baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
)

func init() {
Expand All @@ -33,12 +34,12 @@ func init() {
cmd.Perform("sync", &options.VpcIdOptions{})
cmd.Perform("syncstatus", &options.VpcIdOptions{})
cmd.Perform("private", &options.VpcIdOptions{})
cmd.Perform("public", &options.BasePublicOptions{})
cmd.Perform("public", &baseoptions.BasePublicOptions{})
cmd.Perform("change-owner", &options.VpcChangeOwnerOptions{})
cmd.Get("vpc-change-owner-candidate-domains", &options.VpcIdOptions{})
cmd.Get("topology", &options.VpcIdOptions{})

R(&options.ResourceMetadataOptions{}, "vpc-set-user-metadata", "Set metadata of a vpc", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
R(&baseoptions.ResourceMetadataOptions{}, "vpc-set-user-metadata", "Set metadata of a vpc", func(s *mcclient.ClientSession, opts *baseoptions.ResourceMetadataOptions) error {
params, err := opts.Params()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/compute/zz_generated.model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package options
package compute

import (
"fmt"
Expand All @@ -22,10 +22,11 @@ import (
"yunion.io/x/jsonutils"

api "yunion.io/x/onecloud/pkg/apis/compute"
baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
)

type CloudaccountListOptions struct {
BaseListOptions
baseoptions.BaseListOptions
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event|tablestore"`

ReadOnly *bool `help:"filter read only account" negative:"no-read-only"`
Expand All @@ -38,7 +39,7 @@ type CloudaccountListOptions struct {
}

func (opts *CloudaccountListOptions) Params() (jsonutils.JSONObject, error) {
return ListStructToParams(opts)
return baseoptions.ListStructToParams(opts)
}

type SUserPasswordCredential struct {
Expand Down Expand Up @@ -1162,7 +1163,7 @@ type CloudaccountEnableAutoSyncOptions struct {
}

func (opts *CloudaccountEnableAutoSyncOptions) Params() (jsonutils.JSONObject, error) {
return StructToParams(opts)
return baseoptions.StructToParams(opts)
}

type CloudaccountPublicOptions struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package options
package compute

import "yunion.io/x/jsonutils"
import (
"yunion.io/x/jsonutils"

baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
)

type DBInstanceAccountListOptions struct {
BaseListOptions
baseoptions.BaseListOptions
DBInstance string `help:"ID or Name of DBInstance" json:"dbinstance"`
}

func (opts *DBInstanceAccountListOptions) Params() (jsonutils.JSONObject, error) {
return ListStructToParams(opts)
return baseoptions.ListStructToParams(opts)
}

type DBInstanceAccountIdOptions struct {
Expand Down
Loading

0 comments on commit 410b5b7

Please sign in to comment.