diff --git a/cmd/climc/shell/licenses.go b/cmd/climc/shell/licenses.go new file mode 100644 index 0000000000..20d963d6c6 --- /dev/null +++ b/cmd/climc/shell/licenses.go @@ -0,0 +1,57 @@ +package shell + +import ( + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" +) + +func init() { + type LicenseListOptions struct { + options.BaseListOptions + } + + R(&LicenseListOptions{}, "licenses-list", "show licenses", func(s *mcclient.ClientSession, args *LicenseListOptions) error { + params, err := options.ListStructToParams(args) + if err != nil { + return err + } + + lics, err := modules.License.List(s, params) + if err != nil { + return err + } + + printList(lics, modules.License.GetColumns(s)) + return nil + }) + + type LicenseShowOptions struct { + SERVICE string `help:"service name" choices:"compute|service_tree"` + } + + R(&LicenseShowOptions{}, "licenses-show", "show actived license", func(s *mcclient.ClientSession, args *LicenseShowOptions) error { + lic, e := modules.License.Get(s, args.SERVICE, nil) + if e != nil { + return e + } + + printObject(lic) + return nil + }) + + type LicenseStatusOptions struct { + SERVICE string `help:"service name" choices:"compute|service_tree"` + } + + R(&LicenseStatusOptions{}, "licenses-usage", "show license usages status", func(s *mcclient.ClientSession, args *LicenseStatusOptions) error { + status, err := modules.License.GetSpecific(s, args.SERVICE, "status", nil) + if err != nil { + return err + } + + printObject(status) + return nil + }) + +} diff --git a/pkg/cloudcommon/db/resourcebase.go b/pkg/cloudcommon/db/resourcebase.go index 2ed2045b0c..7221c0e67b 100644 --- a/pkg/cloudcommon/db/resourcebase.go +++ b/pkg/cloudcommon/db/resourcebase.go @@ -12,7 +12,7 @@ import ( type SResourceBase struct { SModelBase - CreatedAt time.Time `nullable:"false" created_at:"true" get:"user"` + CreatedAt time.Time `nullable:"false" created_at:"true" get:"user" list:"user"` UpdatedAt time.Time `nullable:"false" updated_at:"true" list:"user"` UpdateVersion int `default:"0" nullable:"false" auto_version:"true" list:"user"` DeletedAt time.Time `` diff --git a/pkg/yunionconf/models/parameters.go b/pkg/yunionconf/models/parameters.go index 02f3fa3ca2..ff87dd075c 100644 --- a/pkg/yunionconf/models/parameters.go +++ b/pkg/yunionconf/models/parameters.go @@ -26,7 +26,6 @@ type SParameter struct { db.SResourceBase Id int64 `primary:"true" auto_increment:"true" list:"user"` // = Column(BigInteger, primary_key=True) - CreatedBy string `width:"128" charset:"ascii" nullable:"false" create:"required" list:"user"` // Column(VARCHAR(length=128, charset='ascii'), nullable=False) UpdatedBy string `width:"128" charset:"ascii" nullable:"false" create:"required" update:"user" list:"user"` // Column(VARCHAR(length=128, charset='ascii'), nullable=False) "user"/ serviceName/ "admin" Namespace string `width:"64" charset:"ascii" default:"user" nullable:"false" create:"required" list:"admin"` // Column(VARCHAR(length=128, charset='ascii'), nullable=False) user_id / serviceid NamespaceId string `width:"128" charset:"ascii" nullable:"false" index:"true" create:"required" list:"admin"` // Column(VARCHAR(length=128, charset='ascii'), nullable=False)