mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-04 17:41:50 +08:00
Merge branch 'master' of https://github.com/yunionio/onecloud into bugfix/zxc-monitor
This commit is contained in:
@@ -60,6 +60,8 @@ func init() {
|
||||
|
||||
Sn string `help:"find host by sn"`
|
||||
|
||||
OrderByServerCount string `help:"Order by server count" choices:"desc|asc"`
|
||||
|
||||
options.BaseListOptions
|
||||
}
|
||||
R(&HostListOptions{}, "host-list", "List hosts", func(s *mcclient.ClientSession, opts *HostListOptions) error {
|
||||
|
||||
@@ -124,6 +124,10 @@ type HostListInput struct {
|
||||
ServerIdForNetwork string `json:"server_id_for_network"`
|
||||
// 宿主机 cpu 架构
|
||||
CpuArchitecture string `json:"cpu_architecture"`
|
||||
|
||||
// 按虚拟机数量排序
|
||||
// enum: asc,desc
|
||||
OrderByServerCount string `json:"order_by_server_count"`
|
||||
}
|
||||
|
||||
type HostDetails struct {
|
||||
|
||||
@@ -110,8 +110,8 @@ func (man *SProxyEndpointManager) PerformCreateFromServer(ctx context.Context, u
|
||||
IntranetIpAddr: nic.IpAddr,
|
||||
}
|
||||
proxyendpoint.Name = name
|
||||
proxyendpoint.DomainId = userCred.GetProjectDomainId()
|
||||
proxyendpoint.ProjectId = userCred.GetProjectId()
|
||||
proxyendpoint.DomainId = serverInfo.Server.DomainId
|
||||
proxyendpoint.ProjectId = serverInfo.Server.ProjectId
|
||||
if err := man.TableSpec().Insert(ctx, proxyendpoint); err != nil {
|
||||
return nil, httperrors.NewServerError("database insertion error: %v", err)
|
||||
}
|
||||
|
||||
@@ -490,6 +490,17 @@ func (manager *SHostManager) OrderByExtraFields(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SZoneResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
if db.NeedOrderQuery([]string{query.OrderByServerCount}) {
|
||||
guests := GuestManager.Query().SubQuery()
|
||||
guestCounts := guests.Query(
|
||||
guests.Field("host_id"),
|
||||
sqlchemy.COUNT("id").Label("guest_count"),
|
||||
).GroupBy("host_id").SubQuery()
|
||||
q = q.LeftJoin(guestCounts, sqlchemy.Equals(q.Field("id"), guestCounts.Field("host_id")))
|
||||
db.OrderByFields(q, []string{query.OrderByServerCount}, []sqlchemy.IQueryField{guestCounts.Field("guest_count")})
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func AddSshKeysHandler(prefix string, app *appsrv.Application) {
|
||||
func adminSshKeysHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
|
||||
publicOnly := false
|
||||
userCred := auth.FetchUserCredential(ctx, policy.FilterPolicyCredential)
|
||||
if !userCred.IsAllow(rbacutils.ScopeSystem, consts.GetServiceType(), "sshkeypairs", policy.PolicyActionGet) {
|
||||
if !userCred.IsAllow(rbacutils.ScopeDomain, consts.GetServiceType(), "sshkeypairs", policy.PolicyActionGet) {
|
||||
publicOnly = true
|
||||
}
|
||||
params := appctx.AppContextParams(ctx)
|
||||
|
||||
@@ -77,6 +77,7 @@ type EnabledStatusStandaloneResource struct {
|
||||
type VirtualResource struct {
|
||||
StatusStandaloneResource
|
||||
|
||||
DomainId string
|
||||
ProjectId string
|
||||
IsSystem bool
|
||||
PendingDeletedAt time.Time
|
||||
|
||||
Reference in New Issue
Block a user