mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-03 06:21:39 +08:00
Automatic merge from release/2.2.0 -> release/2.3.0
* commit '557d28244c144ac079fa3b5e12b2822c8988069a': support export filter
This commit is contained in:
@@ -342,6 +342,12 @@ func query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
jsonDict = getModelExtraDetails(item, ctx, jsonDict)
|
||||
}
|
||||
if query.Contains("export_keys") {
|
||||
exportDict := item.GetExportItems(ctx, userCred, query)
|
||||
if exportDict != nil {
|
||||
jsonDict.Update(exportDict)
|
||||
}
|
||||
}
|
||||
results = append(results, jsonDict)
|
||||
}
|
||||
return results, nil
|
||||
|
||||
@@ -78,6 +78,7 @@ type IModel interface {
|
||||
// get hooks
|
||||
AllowGetDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool
|
||||
GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict
|
||||
GetExportItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict
|
||||
|
||||
// create hooks
|
||||
CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data jsonutils.JSONObject) error
|
||||
|
||||
@@ -193,6 +193,10 @@ func (model *SModelBase) GetCustomizeColumns(ctx context.Context, userCred mccli
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
func (model *SModelBase) GetExportItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
|
||||
// get hooks
|
||||
func (model *SModelBase) AllowGetDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return false
|
||||
|
||||
@@ -1123,6 +1123,20 @@ func (self *SGuest) GetExtraDetails(ctx context.Context, userCred mcclient.Token
|
||||
return self.moreExtraInfo(extra)
|
||||
}
|
||||
|
||||
func (self *SGuest) GetExportItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
exportKeys, _ := query.GetString("export_keys")
|
||||
keys := strings.Split(exportKeys, ",")
|
||||
res := jsonutils.NewDict()
|
||||
if utils.IsInStringArray("os_distribution", keys) {
|
||||
osType := self.GetMetadata("os_distribution", userCred)
|
||||
if len(osType) == 0 {
|
||||
osType = self.OsType
|
||||
}
|
||||
res.Set("os_distribution", jsonutils.NewString(osType))
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (self *SGuest) getNetworksDetails() string {
|
||||
var buf bytes.Buffer
|
||||
for _, nic := range self.GetNetworks() {
|
||||
|
||||
Reference in New Issue
Block a user