添加interface接口

This commit is contained in:
屈轩
2018-08-27 18:07:53 +08:00
parent 08e834b470
commit 23ebca6cfe
23 changed files with 221 additions and 31 deletions
+10
View File
@@ -54,6 +54,16 @@ type SDisk struct {
ZoneId string
}
func (self *SDisk) GetMetadata() *jsonutils.JSONDict {
data := jsonutils.NewDict()
// The pricingInfo key structure is 'RegionId::DiskCategory::DiskType
priceKey := fmt.Sprintf("%s::%s::%s", self.RegionId, self.Category, self.Type)
data.Add(jsonutils.NewString(priceKey), "price_key")
return data
}
func (self *SRegion) GetDisks(instanceId string, zoneId string, category string, diskIds []string, offset int, limit int) ([]SDisk, int, error) {
if limit > 50 || limit <= 0 {
limit = 50
+4
View File
@@ -19,6 +19,10 @@ type SHost struct {
zone *SZone
}
func (self *SHost) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SHost) GetIWires() ([]cloudprovider.ICloudWire, error) {
return self.zone.GetIWires()
}
+4
View File
@@ -55,6 +55,10 @@ type SImage struct {
Usage string
}
func (self *SImage) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SImage) GetId() string {
return self.ImageId
}
+15
View File
@@ -3,6 +3,7 @@ package aliyun
import (
"fmt"
"time"
"yunion.io/x/onecloud/pkg/util/seclib2"
"yunion.io/x/jsonutils"
@@ -164,6 +165,20 @@ func (self *SRegion) GetInstances(zoneId string, ids []string, offset int, limit
return instances, int(total), nil
}
func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
data := jsonutils.NewDict()
// The pricingInfo key structure is 'RegionId::InstanceType::NetworkType::OSType::IoOptimized'
optimized := "optimized"
if !self.IoOptimized {
optimized = "none"
}
priceKey := fmt.Sprintf("%s::%s::%s::%s::%s", self.RegionId, self.InstanceType, self.InstanceNetworkType, self.OSType, optimized)
data.Add(jsonutils.NewString(priceKey), "price_key")
return data
}
func (self *SInstance) GetCreateTime() time.Time {
return self.CreationTime
}
+4
View File
@@ -36,6 +36,10 @@ func (self *SRegion) GetClient() *SAliyunClient {
return self.client
}
func (self *SRegion) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SRegion) getEcsClient() (*sdk.Client, error) {
if self.ecsClient == nil {
cli, err := sdk.NewClientWithAccessKey(self.RegionId, self.client.accessKey, self.client.secret)
+4
View File
@@ -77,6 +77,10 @@ func (v PermissionSet) Less(i, j int) bool {
return false
}
func (self *SSecurityGroup) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SSecurityGroup) GetId() string {
return self.SecurityGroupId
}
+4
View File
@@ -15,6 +15,10 @@ type SStorage struct {
storageType string
}
func (self *SStorage) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SStorage) GetId() string {
return fmt.Sprintf("%s-%s-%s", self.zone.region.client.providerId, self.zone.GetId(), self.storageType)
}
+5
View File
@@ -5,6 +5,7 @@ import (
"strings"
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/options"
@@ -19,6 +20,10 @@ type SStoragecache struct {
iimages []cloudprovider.ICloudImage
}
func (self *SStoragecache) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SStoragecache) GetId() string {
return fmt.Sprintf("%s-%s", self.region.client.providerId, self.region.GetId())
}
+4
View File
@@ -45,6 +45,10 @@ type SVpc struct {
VpcName string
}
func (self *SVpc) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SVpc) GetId() string {
return self.VpcId
}
+4
View File
@@ -34,6 +34,10 @@ type SVSwitch struct {
ZoneId string
}
func (self *SVSwitch) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SVSwitch) GetId() string {
return self.VSwitchId
}
+5
View File
@@ -3,6 +3,7 @@ package aliyun
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/cloudprovider"
)
@@ -14,6 +15,10 @@ type SWire struct {
inetworks []cloudprovider.ICloudNetwork
}
func (self *SWire) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SWire) GetId() string {
return fmt.Sprintf("%s-%s", self.vpc.GetId(), self.zone.GetId())
}
+5
View File
@@ -3,6 +3,7 @@ package aliyun
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
@@ -111,6 +112,10 @@ type SZone struct {
AvailableDedicatedHostTypes SDedicatedHostTypes
}
func (self *SZone) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SZone) GetId() string {
return self.ZoneId
}
+4
View File
@@ -68,6 +68,10 @@ func NewHost(manager *SESXiClient, host *mo.HostSystem, dc *SDatacenter) *SHost
return &SHost{SManagedObject: newManagedObject(manager, host, dc)}
}
func (self *SHost) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SHost) getHostSystem() *mo.HostSystem {
return self.object.(*mo.HostSystem)
}
+5 -1
View File
@@ -18,6 +18,10 @@ func NewDatastore(manager *SESXiClient, ds *mo.Datastore, dc *SDatacenter) *SDat
return &SDatastore{SManagedObject: newManagedObject(manager, ds, dc)}
}
func (self *SDatastore) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SDatastore) getDatastore() *mo.Datastore {
return self.object.(*mo.Datastore)
}
@@ -89,4 +93,4 @@ func (self *SDatastore) GetManagerId() string {
func (self *SDatastore) CreateIDisk(name string, sizeGb int, desc string) (cloudprovider.ICloudDisk, error) {
return nil, cloudprovider.ErrNotImplemented
}
}
+6 -2
View File
@@ -27,6 +27,10 @@ func NewVirtualMachine(manager *SESXiClient, vm *mo.VirtualMachine, dc *SDatacen
return &SVirtualMachine{SManagedObject: newManagedObject(manager, vm, dc), host: host}
}
func (self *SVirtualMachine) GetMetadata() *jsonutils.JSONDict {
return nil
}
func (self *SVirtualMachine) getVirtualMachine() *mo.VirtualMachine {
return self.object.(*mo.VirtualMachine)
}
@@ -226,6 +230,6 @@ func (self *SVirtualMachine) acquireVmrcUrl() (jsonutils.JSONObject, error) {
return ret, nil
}
func (dc *SVirtualMachine) ChangeConfig(instanceId string,ncpu int, vmem int) error {
func (dc *SVirtualMachine) ChangeConfig(instanceId string, ncpu int, vmem int) error {
return cloudprovider.ErrNotImplemented
}
}