Skip to content

[WIP] fix: splitable get item #17143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/climc/shell/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
package events

import (
"fmt"

"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"

"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
Expand Down Expand Up @@ -147,6 +150,23 @@ func DoEventList(man modulebase.ResourceManager, s *mcclient.ClientSession, args
func init() {
R(&EventListOptions{}, "event-show", "Show operation event logs", doComputeEventList)

type EventDetailOptions struct {
ID string `help:"event id"`

Service string `help:"service type"`
}
R(&EventDetailOptions{}, "event-detail", "show details of event log", func(s *mcclient.ClientSession, args *EventDetailOptions) error {
if args.Service == "" {
args.Service = "compute_v2"
}
resp, err := modulebase.ServiceJsonRequest(s, args.Service, "GET", fmt.Sprintf("/events/%s", args.ID), nil, nil)
if err != nil {
return errors.Wrap(err, "ServiceJsonRequest")
}
printObject(resp)
return nil
})

R(&TypeEventListOptions{}, "server-event", "Show operation event logs of server", func(s *mcclient.ClientSession, args *TypeEventListOptions) error {
nargs := EventListOptions{BaseEventListOptions: args.BaseEventListOptions, Id: args.ID, Type: []string{"server"}}
return doComputeEventList(s, &nargs)
Expand Down
13 changes: 7 additions & 6 deletions pkg/cloudcommon/db/baselog.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,23 @@ func (opslog *SLogBase) GetId() string {
return fmt.Sprintf("%d", opslog.Id)
}

func (self *SLogBase) ValidateDeleteCondition(ctx context.Context, info jsonutils.JSONObject) error {
func (logbase *SLogBase) ValidateDeleteCondition(ctx context.Context, info jsonutils.JSONObject) error {
return httperrors.NewForbiddenError("not allow to delete log")
}

func (self *SLogBaseManager) FilterById(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery {
id, _ := strconv.Atoi(idStr)
func (logbase *SLogBaseManager) FilterById(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery {
id, _ := strconv.ParseInt(idStr, 10, 64)
return q.Equals("id", id)
}

func (self *SLogBaseManager) FilterByNotId(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery {
func (logbase *SLogBaseManager) FilterByNotId(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery {
id, _ := strconv.Atoi(idStr)
return q.NotEquals("id", id)
}

func (self *SLogBaseManager) FilterByName(q *sqlchemy.SQuery, name string) *sqlchemy.SQuery {
return q
func (logbase *SLogBaseManager) FilterByName(q *sqlchemy.SQuery, name string) *sqlchemy.SQuery {
id, _ := strconv.ParseInt(name, 10, 64)
return q.Equals("id", id)
}

func (manager *SLogBaseManager) GetPagingConfig() *SPagingConfig {
Expand Down
12 changes: 12 additions & 0 deletions pkg/mcclient/modulebase/appoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
package modulebase

import (
"net/http"

"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/httputils"

"yunion.io/x/onecloud/pkg/mcclient"
)
Expand All @@ -29,3 +32,12 @@ func GetAppOptions(s *mcclient.ClientSession, serviceType string) (jsonutils.JSO
}
return resp, nil
}

func ServiceJsonRequest(s *mcclient.ClientSession, serviceType string, method httputils.THttpMethod, url string, header http.Header, body jsonutils.JSONObject) (jsonutils.JSONObject, error) {
man := NewBaseManager(serviceType, "", "", nil, nil)
_, resp, err := man.jsonRequest(s, method, url, header, body)
if err != nil {
return nil, errors.Wrap(err, "man.jsonRequest")
}
return resp, nil
}