Skip to content

Commit

Permalink
feat(external_cloud): support external_cloud instance list
Browse files Browse the repository at this point in the history
  • Loading branch information
马鸿飞 committed Sep 28, 2023
1 parent ebff763 commit 2c6e964
Show file tree
Hide file tree
Showing 22 changed files with 2,001 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/multicloud/baidu/baidu.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/util/httputils"
Expand Down Expand Up @@ -115,6 +116,8 @@ func (self *SBaiduClient) getUrl(service, regionId, resource string) (string, er
switch service {
case "bbc":
return fmt.Sprintf("https://bbc.%s.baidubce.com/%s", regionId, strings.TrimPrefix(resource, "/")), nil
case "bcc":
return fmt.Sprintf("https://bcc.%s.baidubce.com/%s", regionId, strings.TrimPrefix(resource, "/")), nil
case "bos":
return fmt.Sprintf("https://%s.bcebos.com", regionId), nil
case "billing":
Expand Down Expand Up @@ -194,6 +197,7 @@ func (self *SBaiduClient) request(method httputils.THttpMethod, service, regionI
if err != nil {
return nil, err
}
log.Infoln("this is uri:", uri)
if params == nil {
params = map[string]interface{}{}
}
Expand Down
142 changes: 142 additions & 0 deletions pkg/multicloud/baidu/host.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package baidu

import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
)

type SHost struct {
multicloud.SHostBase
zone *SZone

projectId string
}

func (host *SHost) GetIVMs() ([]cloudprovider.ICloudVM, error) {
vms, err := host.zone.region.GetInstances()
if err != nil {
return nil, err
}

filtedVms := make([]SInstance, 0)
for i := range vms {
filtedVms = append(filtedVms, vms[i])
}

ivms := make([]cloudprovider.ICloudVM, len(filtedVms))
for i := 0; i < len(filtedVms); i += 1 {
filtedVms[i].host = host
ivms[i] = &filtedVms[i]
}
return ivms, nil
}

func (host *SHost) CreateVM(desc *cloudprovider.SManagedVMCreateConfig) (cloudprovider.ICloudVM, error) {
return nil, nil
}

func (host *SHost) GetAccessIp() string {
return ""
}

func (host *SHost) GetAccessMac() string {
return ""
}

func (host *SHost) GetName() string {
return ""
}

func (host *SHost) GetNodeCount() int8 {
return 0
}

func (host *SHost) GetSN() string {
return ""
}

func (host *SHost) GetStatus() string {
return ""
}

func (host *SHost) GetCpuCount() int {
return 0
}

func (host *SHost) GetCpuDesc() string {
return ""
}

func (host *SHost) GetCpuMhz() int {
return 0
}

func (host *SHost) GetMemSizeMB() int {
return 0
}

func (host *SHost) GetStorageSizeMB() int {
return 0
}

func (host *SHost) GetStorageClass() string {
return ""
}

func (host *SHost) GetStorageType() string {
return ""
}

func (host *SHost) GetEnabled() bool {
return false
}

func (host *SHost) GetIsMaintenance() bool {
return false
}

func (host *SHost) GetGlobalId() string {
return ""
}

func (host *SHost) GetId() string {
return ""
}

func (host *SHost) GetHostStatus() string {
return ""
}

func (host *SHost) GetHostType() string {
return ""
}

func (host *SHost) GetIHostNics() ([]cloudprovider.ICloudHostNetInterface, error) {
return nil, nil
}

func (host *SHost) GetIStorageById(storageId string) (cloudprovider.ICloudStorage, error) {
return nil, nil
}

func (host *SHost) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
return nil, nil
}

func (host *SHost) GetIVMById(vmId string) (cloudprovider.ICloudVM, error) {
return nil, nil
}
Loading

0 comments on commit 2c6e964

Please sign in to comment.