mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #14100 from ioito/hotfix/qx-res-created-time
fix(region): sync resource created time
This commit is contained in:
@@ -32,6 +32,7 @@ type ICloudResource interface {
|
||||
GetId() string
|
||||
GetName() string
|
||||
GetGlobalId() string
|
||||
GetCreatedAt() time.Time
|
||||
|
||||
GetStatus() string
|
||||
|
||||
@@ -57,7 +58,6 @@ type IVirtualResource interface {
|
||||
|
||||
type IBillingResource interface {
|
||||
GetBillingType() string
|
||||
GetCreatedAt() time.Time
|
||||
GetExpiredAt() time.Time
|
||||
SetAutoRenew(bc billing.SBillingCycle) error
|
||||
Renew(bc billing.SBillingCycle) error
|
||||
@@ -223,7 +223,6 @@ type ICloudImage interface {
|
||||
GetMinOsDiskSizeGb() int
|
||||
GetMinRamSizeMb() int
|
||||
GetImageFormat() string
|
||||
GetCreatedAt() time.Time
|
||||
UEFI() bool
|
||||
GetPublicScope() rbacutils.TRbacScope
|
||||
GetSubImages() []SSubImage
|
||||
@@ -556,7 +555,6 @@ type ICloudGlobalVpc interface {
|
||||
type ICloudIPv6Gateway interface {
|
||||
IVirtualResource
|
||||
|
||||
GetCreatedAt() time.Time
|
||||
GetInstanceType() string
|
||||
}
|
||||
|
||||
|
||||
@@ -960,6 +960,10 @@ func (man *SLoadbalancerManager) newFromCloudLoadbalancer(ctx context.Context, u
|
||||
lbNetworkIds := getExtLbNetworkIds(extLb, lb.ManagerId)
|
||||
lb.NetworkId = strings.Join(lbNetworkIds, ",")
|
||||
|
||||
if createdAt := extLb.GetCreatedAt(); !createdAt.IsZero() {
|
||||
lb.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
// classic vpc
|
||||
if extLb.GetNetworkType() == api.LB_NETWORK_TYPE_CLASSIC {
|
||||
if vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(ctx, provider, region); err == nil && vpc != nil {
|
||||
@@ -1183,6 +1187,10 @@ func (lb *SLoadbalancer) SyncWithCloudLoadbalancer(ctx context.Context, userCred
|
||||
lb.CloudregionId = region.GetId()
|
||||
}
|
||||
|
||||
if createdAt := extLb.GetCreatedAt(); !createdAt.IsZero() {
|
||||
lb.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
// classic vpc
|
||||
if extLb.GetNetworkType() == api.LB_NETWORK_TYPE_CLASSIC {
|
||||
if vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(ctx, provider, region); err == nil && vpc != nil {
|
||||
|
||||
@@ -706,6 +706,10 @@ func (self *SNetwork) SyncWithCloudNetwork(ctx context.Context, userCred mcclien
|
||||
|
||||
self.AllocTimoutSeconds = extNet.GetAllocTimeoutSeconds()
|
||||
|
||||
if createdAt := extNet.GetCreatedAt(); !createdAt.IsZero() {
|
||||
self.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -758,6 +762,10 @@ func (manager *SNetworkManager) newFromCloudNetwork(ctx context.Context, userCre
|
||||
|
||||
net.AllocTimoutSeconds = extNet.GetAllocTimeoutSeconds()
|
||||
|
||||
if createdAt := extNet.GetCreatedAt(); !createdAt.IsZero() {
|
||||
net.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
var err = func() error {
|
||||
lockman.LockRawObject(ctx, manager.Keyword(), "name")
|
||||
defer lockman.ReleaseRawObject(ctx, manager.Keyword(), "name")
|
||||
|
||||
@@ -513,6 +513,11 @@ func (manager *SSecurityGroupCacheManager) SyncSecurityGroupCaches(ctx context.C
|
||||
cache.ExternalId = added[i].GetGlobalId()
|
||||
references, _ := added[i].GetReferences()
|
||||
cache.ReferenceCount = len(references)
|
||||
|
||||
if createdAt := added[i].GetCreatedAt(); !createdAt.IsZero() {
|
||||
cache.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -1101,6 +1101,10 @@ func (manager *SSecurityGroupManager) newFromCloudSecgroup(ctx context.Context,
|
||||
secgroup.ProjectId = provider.ProjectId
|
||||
secgroup.DomainId = provider.DomainId
|
||||
|
||||
if createdAt := extSec.GetCreatedAt(); !createdAt.IsZero() {
|
||||
secgroup.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
err = func() error {
|
||||
lockman.LockRawObject(ctx, manager.Keyword(), "name")
|
||||
defer lockman.ReleaseRawObject(ctx, manager.Keyword(), "name")
|
||||
|
||||
@@ -533,6 +533,10 @@ func (self *SVpc) SyncWithCloudVpc(ctx context.Context, userCred mcclient.TokenC
|
||||
self.IsEmulated = extVPC.IsEmulated()
|
||||
self.ExternalAccessMode = extVPC.GetExternalAccessMode()
|
||||
|
||||
if createdAt := extVPC.GetCreatedAt(); !createdAt.IsZero() {
|
||||
self.CreatedAt = createdAt
|
||||
}
|
||||
|
||||
if gId := extVPC.GetGlobalVpcId(); len(gId) > 0 {
|
||||
gVpc, err := db.FetchByExternalIdAndManagerId(GlobalVpcManager, gId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
return q.Equals("manager_id", self.ManagerId)
|
||||
@@ -572,6 +576,9 @@ func (manager *SVpcManager) newFromCloudVpc(ctx context.Context, userCred mcclie
|
||||
vpc.ExternalAccessMode = extVPC.GetExternalAccessMode()
|
||||
vpc.CloudregionId = region.Id
|
||||
vpc.ManagerId = provider.Id
|
||||
if createdAt := extVPC.GetCreatedAt(); !createdAt.IsZero() {
|
||||
vpc.CreatedAt = createdAt
|
||||
}
|
||||
if gId := extVPC.GetGlobalVpcId(); len(gId) > 0 {
|
||||
gVpc, err := db.FetchByExternalIdAndManagerId(GlobalVpcManager, gId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
return q.Equals("manager_id", provider.Id)
|
||||
|
||||
@@ -113,6 +113,10 @@ func (self *SSecurityGroup) GetDescription() string {
|
||||
return self.Description
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetCreatedAt() time.Time {
|
||||
return self.CreationTime
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetRules() ([]cloudprovider.SecurityRule, error) {
|
||||
rules := make([]cloudprovider.SecurityRule, 0)
|
||||
secgrp, err := self.vpc.region.GetSecurityGroupDetails(self.SecurityGroupId)
|
||||
|
||||
@@ -97,6 +97,10 @@ func (self *SVpc) GetStatus() string {
|
||||
return strings.ToLower(self.Status)
|
||||
}
|
||||
|
||||
func (self *SVpc) GetCreatedAt() time.Time {
|
||||
return self.CreationTime
|
||||
}
|
||||
|
||||
func (self *SVpc) Refresh() error {
|
||||
new, err := self.region.getVpc(self.VpcId)
|
||||
if err != nil {
|
||||
|
||||
@@ -79,8 +79,8 @@ func (self *SVSwitch) GetGlobalId() string {
|
||||
return self.VSwitchId
|
||||
}
|
||||
|
||||
func (self *SVSwitch) IsEmulated() bool {
|
||||
return false
|
||||
func (self *SVSwitch) GetCreatedAt() time.Time {
|
||||
return self.CreationTime
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetStatus() string {
|
||||
|
||||
@@ -27,9 +27,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancer struct {
|
||||
multicloud.SResourceBase
|
||||
region *SRegion
|
||||
eips []cloudprovider.ICloudEIP
|
||||
lbbgs []cloudprovider.ICloudLoadbalancerBackendGroup
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
// 应用型LB: HTTP 设置 + 后端池 = onecloud 后端服务器组
|
||||
// 4层LB: loadBalancingRules(backendPort)+ 后端池 = onecloud 后端服务器组
|
||||
type SLoadbalancerBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
lbbs []cloudprovider.ICloudLoadbalancerBackend
|
||||
|
||||
|
||||
@@ -29,9 +29,11 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SLoadbalancerCert struct {
|
||||
multicloud.SResourceBase
|
||||
lb *SLoadbalancer
|
||||
cert *x509.Certificate
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -29,10 +29,6 @@ func (self *SBillingBase) GetBillingType() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBillingBase) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SBillingBase) GetExpiredAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ func (self *SGlobalNetwork) Delete() error {
|
||||
return self.client.ecsDelete(self.SelfLink, nil)
|
||||
}
|
||||
|
||||
func (self *SGlobalNetwork) GetCreatedAt() time.Time {
|
||||
return self.CreationTimestamp
|
||||
}
|
||||
|
||||
func (self *SGlobalNetwork) Refresh() error {
|
||||
gvpc, err := self.client.GetGlobalNetwork(self.Id)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
@@ -91,6 +92,10 @@ func (self *SLoadbalancer) SetTags(tags map[string]string, replace bool) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SLoadbalancer) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SLoadbalancer) GetProjectId() string {
|
||||
return self.region.GetProjectId()
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
@@ -75,6 +76,10 @@ func (self *SLoadbalancerBackend) GetPort() int {
|
||||
return self.Port
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerBackend) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerBackend) GetBackendType() string {
|
||||
return api.LB_BACKEND_GUEST
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package google
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
@@ -63,6 +64,10 @@ func (self *SLoadBalancerBackendGroup) IsDefault() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SLoadBalancerBackendGroup) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SLoadBalancerBackendGroup) GetType() string {
|
||||
return api.LB_BACKENDGROUP_TYPE_NORMAL
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ func (self *SLoadbalancerCertificate) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerCertificate) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerCertificate) GetSysTags() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
@@ -52,6 +53,10 @@ func (self *SLoadbalancerListener) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerListener) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerListener) GetSysTags() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -46,6 +47,10 @@ func (self *SLoadbalancerListenerRule) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerListenerRule) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SLoadbalancerListenerRule) GetSysTags() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package google
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -56,6 +58,10 @@ func (network *SNetwork) GetStatus() string {
|
||||
return api.NETWORK_INTERFACE_STATUS_AVAILABLE
|
||||
}
|
||||
|
||||
func (network *SNetwork) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (network *SNetwork) Delete() error {
|
||||
return network.wire.vpc.Delete()
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ func (region *SRegion) GetGeographicInfo() cloudprovider.SGeographicInfo {
|
||||
return cloudprovider.SGeographicInfo{}
|
||||
}
|
||||
|
||||
func (self *SRegion) GetCreatedAt() time.Time {
|
||||
return self.CreationTimestamp
|
||||
}
|
||||
|
||||
func (region *SRegion) GetProvider() string {
|
||||
return CLOUD_PROVIDER_GOOGLE
|
||||
}
|
||||
|
||||
@@ -106,6 +106,10 @@ func (policy *SResourcePolicy) GetStatus() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (policy *SResourcePolicy) GetCreatedAt() time.Time {
|
||||
return policy.CreationTimestamp
|
||||
}
|
||||
|
||||
func (policy *SResourcePolicy) Refresh() error {
|
||||
_policy, err := policy.region.GetResourcePolicy(policy.Id)
|
||||
if err != nil {
|
||||
|
||||
@@ -78,6 +78,10 @@ func (snapshot *SSnapshot) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetCreatedAt() time.Time {
|
||||
return self.CreationTimestamp
|
||||
}
|
||||
|
||||
func (snapshot *SSnapshot) Refresh() error {
|
||||
_snapshot, err := snapshot.region.GetSnapshot(snapshot.Id)
|
||||
if err != nil {
|
||||
|
||||
@@ -65,6 +65,10 @@ func (storage *SStorage) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (storage *SStorage) Refresh() error {
|
||||
_storage, err := storage.zone.region.GetStorage(storage.SelfLink)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,6 +16,7 @@ package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
@@ -42,6 +43,10 @@ func (wire *SWire) GetName() string {
|
||||
return wire.vpc.GetName()
|
||||
}
|
||||
|
||||
func (wire *SWire) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (wire *SWire) CreateINetwork(opts *cloudprovider.SNetworkCreateOptions) (cloudprovider.ICloudNetwork, error) {
|
||||
return nil, cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
// https://support.huaweicloud.com/api-ecs/zh-cn_topic_0020212656.html
|
||||
type SInstanceType struct {
|
||||
multicloud.SResourceBase
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Vcpus string `json:"vcpus"`
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
package multicloud
|
||||
|
||||
import "time"
|
||||
|
||||
type SResourceBase struct {
|
||||
}
|
||||
|
||||
@@ -24,3 +26,7 @@ func (self *SResourceBase) IsEmulated() bool {
|
||||
func (self *SResourceBase) Refresh() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SResourceBase) GetCreatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user