mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): log export
This commit is contained in:
@@ -395,3 +395,7 @@ type SyncstatusInput struct {
|
||||
type PurgeSplitTableInput struct {
|
||||
Tables []string `json:"tables"`
|
||||
}
|
||||
|
||||
type SplitTableExportInput struct {
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
@@ -959,7 +959,7 @@ func (dispatcher *DBModelDispatcher) Get(ctx context.Context, idStr string, quer
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, httperrors.NewResourceNotFoundError2(dispatcher.modelManager.Keyword(), idStr)
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "fetchItem")
|
||||
}
|
||||
|
||||
err = isObjectRbacAllowed(ctx, model, userCred, policy.PolicyActionGet)
|
||||
|
||||
@@ -272,6 +272,10 @@ func (manager *SModelBaseManager) GetExportExtraKeys(ctx context.Context, keys s
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) CustomizeHandlerInfo(info *appsrv.SHandlerInfo) {
|
||||
switch info.GetName(nil) {
|
||||
case "get_splitable_export":
|
||||
info.SetProcessTimeout(time.Minute * 120)
|
||||
}
|
||||
info.SetProcessTimeoutCallback(manager.GetIModelManager().SetHandlerProcessTimeout)
|
||||
}
|
||||
|
||||
@@ -451,6 +455,32 @@ func (manager *SModelBaseManager) GetPropertySplitable(ctx context.Context, user
|
||||
return jsonutils.Marshal(metas), nil
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) GetPropertySplitableExport(ctx context.Context, userCred mcclient.TokenCredential, input apis.SplitTableExportInput) (jsonutils.JSONObject, error) {
|
||||
splitable := manager.GetSplitTable()
|
||||
if splitable == nil {
|
||||
return nil, errors.Wrap(httperrors.ErrNotSupported, "not splitable")
|
||||
}
|
||||
if len(input.Table) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("table")
|
||||
}
|
||||
|
||||
metas, err := splitable.GetTableMetas()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetTableMetas")
|
||||
}
|
||||
for i := 0; i < len(metas); i += 1 {
|
||||
if metas[i].Table == input.Table {
|
||||
q := splitable.GetTableSpec(metas[i]).Query()
|
||||
resp, err := q.AllStringMap()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "q.AllStringMap")
|
||||
}
|
||||
return jsonutils.Marshal(resp), nil
|
||||
}
|
||||
}
|
||||
return nil, httperrors.NewResourceNotFoundError("table %s not found", input.Table)
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) AllowPerformPurgeSplitable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ package options
|
||||
import "yunion.io/x/jsonutils"
|
||||
|
||||
type EventSplitableOptions struct {
|
||||
ID string `choices:"splitable"`
|
||||
ID string `choices:"splitable|splitable-export"`
|
||||
Service string `help:"service" choices:"compute|identity|image|log|cloudevent" default:"compute"`
|
||||
Table string `help:"when id is splitable-export table must be input"`
|
||||
}
|
||||
|
||||
func (self *EventSplitableOptions) GetId() string {
|
||||
|
||||
Reference in New Issue
Block a user