mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
feat(cloudmon): upload meter currency of the cloudaccount
This commit is contained in:
@@ -357,6 +357,7 @@ func (self CloudaccountDetail) GetMetricTags() map[string]string {
|
||||
"brand": self.Brand,
|
||||
"domain_id": self.DomainId,
|
||||
"project_domain": self.ProjectDomain,
|
||||
"currency": self.Currency,
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -254,6 +254,9 @@ type SCloudaccount struct {
|
||||
// 账户余额
|
||||
// example: 124.2
|
||||
Balance float64 `json:"balance"`
|
||||
// 账户余额货币类型
|
||||
// enmu: CNY, USD
|
||||
Currency string `json:"currency"`
|
||||
// 上次账号探测时间
|
||||
ProbeAt time.Time `json:"probe_at"`
|
||||
// 账号健康状态
|
||||
@@ -264,6 +267,9 @@ type SCloudaccount struct {
|
||||
// 是否根据云上项目自动在本地创建对应项目
|
||||
// example: false
|
||||
AutoCreateProject bool `json:"auto_create_project"`
|
||||
// 是否根据云订阅自动在本地创建对应项目
|
||||
// example: false
|
||||
AutoCreateProjectForProvider bool `json:"auto_create_project_for_provider"`
|
||||
// 云API版本
|
||||
Version string `json:"version"`
|
||||
// 云系统信息
|
||||
@@ -288,6 +294,8 @@ type SCloudaccount struct {
|
||||
SubAccounts *cloudprovider.SubAccounts `json:"sub_accounts"`
|
||||
// 缺失的权限,云账号操作资源时自动更新
|
||||
LakeOfPermissions *SAccountPermissions `json:"lake_of_permissions"`
|
||||
// 跳过部分资源同步
|
||||
SkipSyncResources *SkipSyncResources `json:"skip_sync_resources"`
|
||||
}
|
||||
|
||||
// SCloudimage is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SCloudimage.
|
||||
@@ -802,9 +810,9 @@ type SElasticcache struct {
|
||||
NetworkId string `json:"network_id"`
|
||||
// 带宽
|
||||
Bandwidth int `json:"bandwidth"`
|
||||
// 内网DNS
|
||||
// 内网DNS
|
||||
PrivateDNS string `json:"private_dns"`
|
||||
// 内网IP地址
|
||||
// 内网IP地址
|
||||
PrivateIpAddr string `json:"private_ip_addr"`
|
||||
// 内网访问端口
|
||||
PrivateConnectPort int `json:"private_connect_port"`
|
||||
@@ -1706,9 +1714,12 @@ type SLoadbalancerAgentDeployment struct {
|
||||
|
||||
// SLoadbalancerAgentParams is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SLoadbalancerAgentParams.
|
||||
type SLoadbalancerAgentParams struct {
|
||||
KeepalivedConfTmpl string `json:"keepalived_conf_tmpl"`
|
||||
HaproxyConfTmpl string `json:"haproxy_conf_tmpl"`
|
||||
TelegrafConfTmpl string `json:"telegraf_conf_tmpl"`
|
||||
KeepalivedConfTmpl string `json:"keepalived_conf_tmpl"`
|
||||
HaproxyConfTmpl string `json:"haproxy_conf_tmpl"`
|
||||
TelegrafConfTmpl string `json:"telegraf_conf_tmpl"`
|
||||
Vrrp SLoadbalancerAgentParamsVrrp `json:"vrrp"`
|
||||
Haproxy SLoadbalancerAgentParamsHaproxy `json:"haproxy"`
|
||||
Telegraf SLoadbalancerAgentParamsTelegraf `json:"telegraf"`
|
||||
}
|
||||
|
||||
// SLoadbalancerAgentParamsHaproxy is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SLoadbalancerAgentParamsHaproxy.
|
||||
@@ -1853,9 +1864,9 @@ type SLoadbalancerHealthCheck struct {
|
||||
// 健康检查路径 /
|
||||
HealthCheckHttpCode string `json:"health_check_http_code"`
|
||||
HealthCheckRise int `json:"health_check_rise"`
|
||||
// 健康检查健康阈值 3秒
|
||||
// 健康检查健康阈值 3秒
|
||||
HealthCheckFall int `json:"health_check_fall"`
|
||||
// 健康检查不健康阈值 15秒
|
||||
// 健康检查不健康阈值 15秒
|
||||
HealthCheckTimeout int `json:"health_check_timeout"`
|
||||
// 健康检查超时时间 10秒
|
||||
HealthCheckInterval int `json:"health_check_interval"`
|
||||
@@ -2478,7 +2489,7 @@ type SSchedtag struct {
|
||||
apis.SStandaloneResourceBase
|
||||
apis.SScopedResourceBase
|
||||
DefaultStrategy string `json:"default_strategy"`
|
||||
// Column(VARCHAR(16, charset='ascii'), nullable=True, default='')
|
||||
// Column(VARCHAR(16, charset='ascii'), nullable=True, default=”)
|
||||
ResourceType string `json:"resource_type"`
|
||||
}
|
||||
|
||||
@@ -2568,9 +2579,10 @@ type SServerSku struct {
|
||||
NicMaxCount int `json:"nic_max_count"`
|
||||
GpuAttachable *bool `json:"gpu_attachable,omitempty"`
|
||||
GpuSpec string `json:"gpu_spec"`
|
||||
GpuCount int `json:"gpu_count"`
|
||||
GpuCount string `json:"gpu_count"`
|
||||
GpuMaxCount int `json:"gpu_max_count"`
|
||||
Provider string `json:"provider"`
|
||||
Md5 string `json:"md5"`
|
||||
}
|
||||
|
||||
// SServiceCatalog is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SServiceCatalog.
|
||||
@@ -2742,7 +2754,13 @@ type STimer struct {
|
||||
WeekDays byte `json:"week_days"`
|
||||
// 0-31 0 is unlimited
|
||||
MonthDays uint32 `json:"month_days"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
// StartTime represent the start time of this timer
|
||||
StartTime time.Time `json:"start_time"`
|
||||
// EndTime represent deadline of this timer
|
||||
EndTime time.Time `json:"end_time"`
|
||||
// NextTime represent the time timer should bell
|
||||
NextTime time.Time `json:"next_time"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
}
|
||||
|
||||
// SVpc is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SVpc.
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
jsonutils "yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
apis "yunion.io/x/onecloud/pkg/apis"
|
||||
tagutils "yunion.io/x/onecloud/pkg/util/tagutils"
|
||||
)
|
||||
|
||||
@@ -198,6 +198,38 @@ type SNonlocalUser struct {
|
||||
UserId string `json:"user_id"`
|
||||
}
|
||||
|
||||
// SOrganization is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SOrganization.
|
||||
type SOrganization struct {
|
||||
apis.SEnabledStatusInfrasResourceBase
|
||||
Type string `json:"type"`
|
||||
Keys string `json:"keys"`
|
||||
Level int `json:"level"`
|
||||
}
|
||||
|
||||
// SOrganizationDetails is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SOrganizationDetails.
|
||||
type SOrganizationDetails struct {
|
||||
apis.EnabledStatusInfrasResourceBaseDetails
|
||||
SOrganization
|
||||
}
|
||||
|
||||
// SOrganizationNode is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SOrganizationNode.
|
||||
type SOrganizationNode struct {
|
||||
apis.SStandaloneResourceBase
|
||||
OrgId string `json:"org_id"`
|
||||
FullLabel string `json:"full_label"`
|
||||
Level int `json:"level"`
|
||||
Weight *int `json:"weight"`
|
||||
}
|
||||
|
||||
// SOrganizationNodeDetails is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SOrganizationNodeDetails.
|
||||
type SOrganizationNodeDetails struct {
|
||||
apis.StandaloneResourceDetails
|
||||
SOrganizationNode
|
||||
Tags []tagutils.STag `json:"tags"`
|
||||
Organization string `json:"organization"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// SPassword is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SPassword.
|
||||
type SPassword struct {
|
||||
apis.SResourceBase
|
||||
|
||||
@@ -40,6 +40,7 @@ type SEmailQueue struct {
|
||||
DestBcc string `json:"dest_bcc"`
|
||||
SessionId string `json:"session_id"`
|
||||
Content jsonutils.JSONObject `json:"content"`
|
||||
MoreDetails jsonutils.JSONObject `json:"more_details"`
|
||||
ProjectId string `json:"project_id"`
|
||||
Project string `json:"project"`
|
||||
ProjectDomainId string `json:"project_domain_id"`
|
||||
@@ -127,9 +128,12 @@ type SReceiver struct {
|
||||
type SRobot struct {
|
||||
apis.SSharableVirtualResourceBase
|
||||
apis.SEnabledResourceBase
|
||||
Type string `json:"type"`
|
||||
Address string `json:"address"`
|
||||
Lang string `json:"lang"`
|
||||
Type string `json:"type"`
|
||||
Address string `json:"address"`
|
||||
Lang string `json:"lang"`
|
||||
Header jsonutils.JSONObject `json:"header"`
|
||||
Body jsonutils.JSONObject `json:"body"`
|
||||
MsgKey string `json:"msg_key"`
|
||||
}
|
||||
|
||||
// SSubscriber is an autogenerated struct via yunion.io/x/onecloud/pkg/notify/models.SSubscriber.
|
||||
@@ -180,7 +184,6 @@ type STopic struct {
|
||||
Resources uint64 `json:"resources"`
|
||||
Actions uint32 `json:"actions"`
|
||||
Results *bool `json:"results,omitempty"`
|
||||
AdvanceDays int `json:"advance_days"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
TitleEn string `json:"title_en"`
|
||||
ContentCn string `json:"content_cn"`
|
||||
|
||||
@@ -903,8 +903,11 @@ func (self *SResources) CollectMetrics(ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
urls, err := s.GetServiceURLs(apis.SERVICE_TYPE_INFLUXDB, options.Options.SessionEndpointType)
|
||||
if err != nil {
|
||||
log.Errorf("Get influxdb %s service url: %v", options.Options.SessionEndpointType, err)
|
||||
return
|
||||
}
|
||||
if err := influxdb.SendMetrics(urls, "meter_db", metrics, true); err != nil {
|
||||
log.Errorf("SendMetrics to meter_db: %v", err)
|
||||
return
|
||||
}
|
||||
influxdb.SendMetrics(urls, "meter_db", metrics, false)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ type SCloudaccount struct {
|
||||
|
||||
// 账户余额货币类型
|
||||
// enmu: CNY, USD
|
||||
Currency string `width:"5" charset:"utf8" nullable:"false" list:"domain" create:"domain_optional" update:"domain"`
|
||||
Currency string `width:"5" charset:"utf8" nullable:"false" list:"user" create:"domain_optional" update:"domain"`
|
||||
|
||||
// 上次账号探测时间
|
||||
ProbeAt time.Time `list:"domain"`
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
package cloudpods
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
|
||||
@@ -133,7 +131,7 @@ func (self *SServerSku) GetGpuSpec() string {
|
||||
}
|
||||
|
||||
func (self *SServerSku) GetGpuCount() string {
|
||||
return fmt.Sprintf("%d", self.GpuCount)
|
||||
return self.GpuCount
|
||||
}
|
||||
|
||||
func (self *SServerSku) GetGpuMaxCount() int {
|
||||
|
||||
@@ -26,7 +26,7 @@ var (
|
||||
func init() {
|
||||
Cloudaccounts = modules.NewComputeManager("cloudaccount", "cloudaccounts",
|
||||
[]string{"ID", "Name", "Enabled", "Status", "Access_url",
|
||||
"balance", "error_count", "health_status",
|
||||
"balance", "currency", "error_count", "health_status",
|
||||
"Sync_Status", "Last_sync",
|
||||
"guest_count", "project_domain", "domain_id",
|
||||
"Provider", "Brand",
|
||||
|
||||
Reference in New Issue
Block a user