mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): vendor update (#18707)
This commit is contained in:
@@ -86,7 +86,7 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231115130252-a322ce3ced5f
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231116081347-9207615214fe
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
|
||||
@@ -1192,8 +1192,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231115130252-a322ce3ced5f h1:VWGqYO7ZdI8SYb9zPnGjua+hLZ/OsN6YHPkYkxfjCyw=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231115130252-a322ce3ced5f/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231116081347-9207615214fe h1:xFiw/QyM1Mui9uzuPDCV5vCondoTtdh2+ityoN4jKYQ=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231116081347-9207615214fe/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
@@ -138,7 +138,7 @@ type SCloudaccount struct {
|
||||
AutoCreateProjectForProvider bool `list:"domain" create:"domain_optional"`
|
||||
|
||||
// 云API版本
|
||||
Version string `width:"32" charset:"ascii" nullable:"true" list:"domain"`
|
||||
Version string `width:"64" charset:"ascii" nullable:"true" list:"domain"`
|
||||
|
||||
// 云系统信息
|
||||
Sysinfo jsonutils.JSONObject `get:"domain"`
|
||||
|
||||
+11
-12
@@ -443,24 +443,23 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl
|
||||
wire.Description = extWire.GetDescription()
|
||||
wire.VpcId = vpc.Id
|
||||
wire.ManagerId = provider.Id
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion for vpc %s(%s)", vpc.Name, vpc.Id)
|
||||
}
|
||||
if zone != nil {
|
||||
wire.ZoneId = zone.Id
|
||||
} else if !utils.IsInStringArray(region.Provider, api.REGIONAL_NETWORK_PROVIDERS) {
|
||||
var err error
|
||||
wire.ZoneId, err = func() (string, error) {
|
||||
if zone != nil {
|
||||
return zone.Id, nil
|
||||
}
|
||||
izone := extWire.GetIZone()
|
||||
if gotypes.IsNil(izone) {
|
||||
return nil, fmt.Errorf("missing zone for wire %s(%s)", wire.Name, wire.ExternalId)
|
||||
return "", nil
|
||||
}
|
||||
zone, err := vpc.getZoneByExternalId(izone.GetGlobalId())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "newFromCloudWire.getZoneByExternalId")
|
||||
return "", errors.Wrapf(err, "getZoneByExternalId")
|
||||
}
|
||||
wire.ZoneId = zone.Id
|
||||
} else {
|
||||
// regional network, wire belongs to region
|
||||
return zone.Id, nil
|
||||
}()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "get zone id")
|
||||
}
|
||||
|
||||
wire.IsEmulated = extWire.IsEmulated()
|
||||
|
||||
Vendored
+1
-1
@@ -1458,7 +1458,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231115130252-a322ce3ced5f
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231116081347-9207615214fe
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+3
@@ -110,6 +110,9 @@ const (
|
||||
STORAGE_VOLCENGINE_FlexPL = "ESSD_FlexPL" // 极速型SSD(单盘最大IOPS 5万)
|
||||
STORAGE_VOLCENGINE_PL0 = "ESSD_PL0" // 极速型SSD(单盘最大IOPS 1万)
|
||||
STORAGE_VOLCENGINE_PTSSD = "PTSSD" // 性能型SSD(上一代产品)
|
||||
|
||||
STORAGE_FULL = "full"
|
||||
STORAGE_SYSTEM_FULL = "system_full"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type Placement struct {
|
||||
ProjectId int
|
||||
Zone string
|
||||
}
|
||||
|
||||
type SBootDisk struct {
|
||||
storage *SStorage
|
||||
multicloud.SDisk
|
||||
SOracleTag
|
||||
|
||||
AvailabilityDomain string
|
||||
DisplayName string
|
||||
Id string
|
||||
IsHydrated bool
|
||||
LifecycleState string
|
||||
VpusPerGB int
|
||||
SizeInGBs int
|
||||
SizeInMBs int
|
||||
TimeCreated time.Time
|
||||
VolumeType string
|
||||
ImageId string
|
||||
}
|
||||
|
||||
func (self *SRegion) GetBootDisk(id string) (*SBootDisk, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "bootVolumes", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SBootDisk{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SBootDisk) Delete(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SBootDisk) Resize(ctx context.Context, sizeMb int64) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetIStorage() (cloudprovider.ICloudStorage, error) {
|
||||
return self.storage, nil
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetStatus() string {
|
||||
// AVAILABLE, FAULTY, PROVISIONING, RESTORING, TERMINATED, TERMINATING
|
||||
switch self.LifecycleState {
|
||||
case "ATTACHING", "DETACHING", "EXPANDING", "ROLLBACKING":
|
||||
return api.DISK_ALLOCATING
|
||||
default:
|
||||
return api.DISK_READY
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SBootDisk) Refresh() error {
|
||||
disk, err := self.storage.zone.region.GetBootDisk(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, disk)
|
||||
}
|
||||
|
||||
func (self *SBootDisk) CreateISnapshot(ctx context.Context, name, desc string) (cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetDiskType() string {
|
||||
return api.DISK_TYPE_SYS
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetFsFormat() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetIsNonPersistent() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetDriver() string {
|
||||
return "scsi"
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetCacheMode() string {
|
||||
return "none"
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetMountpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetBillingType() string {
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetDiskFormat() string {
|
||||
return "vhd"
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetDiskSizeMB() int {
|
||||
return self.SizeInMBs
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetIsAutoDelete() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetCreatedAt() time.Time {
|
||||
return self.TimeCreated
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetExpiredAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetISnapshot(snapshotId string) (cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetExtSnapshotPolicyIds() ([]string, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetTemplateId() string {
|
||||
return self.ImageId
|
||||
}
|
||||
|
||||
func (disk *SBootDisk) GetAccessPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBootDisk) Rebuild(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SBootDisk) Reset(ctx context.Context, snapshotId string) (string, error) {
|
||||
return "", cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SBootDisk) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SRegion) GetBootDisks(zoneId string) ([]SBootDisk, error) {
|
||||
params := map[string]interface{}{}
|
||||
if len(zoneId) > 0 {
|
||||
params["availabilityDomain"] = zoneId
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "bootVolumes", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SBootDisk{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SDisk struct {
|
||||
storage *SStorage
|
||||
multicloud.SDisk
|
||||
SOracleTag
|
||||
|
||||
AvailabilityDomain string
|
||||
DisplayName string
|
||||
Id string
|
||||
IsHydrated bool
|
||||
LifecycleState string
|
||||
VpusPerGB int
|
||||
SizeInGBs int
|
||||
SizeInMBs int
|
||||
TimeCreated time.Time
|
||||
VolumeType string
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDisk(id string) (*SDisk, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "volumes", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SDisk{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteDisk(diskId string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) Delete(ctx context.Context) error {
|
||||
return self.storage.zone.region.DeleteDisk(self.Id)
|
||||
}
|
||||
|
||||
func (self *SRegion) ResizeDisk(ctx context.Context, diskId string, sizeGb int64) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) Resize(ctx context.Context, sizeMb int64) error {
|
||||
return self.storage.zone.region.ResizeDisk(ctx, self.Id, sizeMb/1024)
|
||||
}
|
||||
|
||||
func (self *SDisk) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SDisk) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SDisk) GetIStorage() (cloudprovider.ICloudStorage, error) {
|
||||
return self.storage, nil
|
||||
}
|
||||
|
||||
func (self *SDisk) GetStatus() string {
|
||||
// AVAILABLE, FAULTY, PROVISIONING, RESTORING, TERMINATED, TERMINATING
|
||||
switch self.LifecycleState {
|
||||
case "ATTACHING", "DETACHING", "EXPANDING", "ROLLBACKING":
|
||||
return api.DISK_ALLOCATING
|
||||
default:
|
||||
return api.DISK_READY
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SDisk) Refresh() error {
|
||||
disk, err := self.storage.zone.region.GetDisk(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, disk)
|
||||
}
|
||||
|
||||
func (self *SDisk) CreateISnapshot(ctx context.Context, name, desc string) (cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) GetDiskType() string {
|
||||
return api.DISK_TYPE_DATA
|
||||
}
|
||||
|
||||
func (self *SDisk) GetFsFormat() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SDisk) GetIsNonPersistent() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SDisk) GetDriver() string {
|
||||
return "scsi"
|
||||
}
|
||||
|
||||
func (self *SDisk) GetCacheMode() string {
|
||||
return "none"
|
||||
}
|
||||
|
||||
func (self *SDisk) GetMountpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SDisk) GetBillingType() string {
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
}
|
||||
|
||||
func (self *SDisk) GetDiskFormat() string {
|
||||
return "vhd"
|
||||
}
|
||||
|
||||
func (self *SDisk) GetDiskSizeMB() int {
|
||||
return self.SizeInMBs
|
||||
}
|
||||
|
||||
func (self *SDisk) GetIsAutoDelete() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SDisk) GetCreatedAt() time.Time {
|
||||
return self.TimeCreated
|
||||
}
|
||||
|
||||
func (self *SDisk) GetExpiredAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SDisk) GetISnapshot(snapshotId string) (cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) GetExtSnapshotPolicyIds() ([]string, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SDisk) GetTemplateId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (disk *SDisk) GetAccessPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SDisk) Rebuild(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SDisk) Reset(ctx context.Context, snapshotId string) (string, error) {
|
||||
return "", cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SDisk) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDisks(zoneId string) ([]SDisk, error) {
|
||||
params := map[string]interface{}{}
|
||||
if len(zoneId) > 0 {
|
||||
params["availabilityDomain"] = zoneId
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "volumes", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SDisk{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SEipAddress struct {
|
||||
region *SRegion
|
||||
multicloud.SEipBase
|
||||
SOracleTag
|
||||
|
||||
Id string
|
||||
AssignedEntityType string
|
||||
AvailabilityDomain string
|
||||
DisplayName string
|
||||
IpAddress string
|
||||
LifecycleState string
|
||||
Lifetime string
|
||||
Scope string
|
||||
TimeCreated time.Time
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetStatus() string {
|
||||
// ASSIGNED, ASSIGNING, AVAILABLE, PROVISIONING, TERMINATED, TERMINATING, UNASSIGNED, UNASSIGNING
|
||||
switch self.LifecycleState {
|
||||
case "ASSIGNED", "AVAILABLE", "UNASSIGNED":
|
||||
return api.EIP_STATUS_READY
|
||||
case "ASSIGNING":
|
||||
return api.EIP_STATUS_ASSOCIATE
|
||||
case "PROVISIONING":
|
||||
return api.EIP_STATUS_ALLOCATE
|
||||
case "TERMINATED", "TERMINATING":
|
||||
return api.EIP_STATUS_DEALLOCATE
|
||||
case "UNASSIGNING":
|
||||
return api.EIP_STATUS_DISSOCIATE
|
||||
}
|
||||
return api.EIP_STATUS_READY
|
||||
}
|
||||
|
||||
func (self *SEipAddress) Refresh() error {
|
||||
eip, err := self.region.GetEip(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, eip)
|
||||
}
|
||||
|
||||
func (self *SEipAddress) IsEmulated() bool {
|
||||
return self.Lifetime == "EPHEMERAL"
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetIpAddr() string {
|
||||
return self.IpAddress
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetMode() string {
|
||||
if self.Lifetime == "EPHEMERAL" {
|
||||
return api.EIP_MODE_INSTANCE_PUBLICIP
|
||||
}
|
||||
return api.EIP_MODE_STANDALONE_EIP
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetAssociationType() string {
|
||||
return api.EIP_ASSOCIATE_TYPE_SERVER
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetAssociationExternalId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SEipAddress) Delete() error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetBandwidth() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetINetworkId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetBillingType() string {
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetCreatedAt() time.Time {
|
||||
return self.TimeCreated
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetExpiredAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetInternetChargeType() string {
|
||||
return api.EIP_CHARGE_TYPE_BY_TRAFFIC
|
||||
}
|
||||
|
||||
func (self *SEipAddress) Associate(conf *cloudprovider.AssociateConfig) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SEipAddress) Dissociate() error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SEipAddress) ChangeBandwidth(bw int) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SRegion) GetEip(id string) (*SEipAddress, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "publicIps", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SEipAddress{region: self}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetEips(lifetime string) ([]SEipAddress, error) {
|
||||
zones, err := self.GetZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params := map[string]interface{}{
|
||||
"scope": "AVAILABILITY_DOMAIN",
|
||||
}
|
||||
if len(lifetime) > 0 {
|
||||
params["lifetime"] = lifetime
|
||||
}
|
||||
ret := []SEipAddress{}
|
||||
for _, zone := range zones {
|
||||
params["availabilityDomain"] = zone.Name
|
||||
resp, err := self.list(SERVICE_IAAS, "publicIps", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
part := []SEipAddress{}
|
||||
err = resp.Unmarshal(&part)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret = append(ret, part...)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SHost struct {
|
||||
multicloud.SHostBase
|
||||
|
||||
zone *SZone
|
||||
}
|
||||
|
||||
func (self *SHost) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.zone.region.client.cpcfg.Id, self.zone.GetId())
|
||||
}
|
||||
|
||||
func (self *SHost) GetName() string {
|
||||
return fmt.Sprintf("%s-%s", self.zone.region.client.cpcfg.Name, self.zone.GetId())
|
||||
}
|
||||
|
||||
func (self *SHost) GetGlobalId() string {
|
||||
return self.GetId()
|
||||
}
|
||||
|
||||
func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudprovider.ICloudVM, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SHost) GetAccessIp() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SHost) GetAccessMac() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SHost) GetSN() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SHost) GetCpuCount() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SHost) GetNodeCount() int8 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SHost) GetCpuDesc() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SHost) GetCpuMhz() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SHost) GetMemSizeMB() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SHost) GetStorageSizeMB() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SHost) GetEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SHost) GetStatus() string {
|
||||
return api.HOST_STATUS_RUNNING
|
||||
}
|
||||
|
||||
func (self *SHost) GetHostStatus() string {
|
||||
return api.HOST_ONLINE
|
||||
}
|
||||
|
||||
func (self *SHost) GetHostType() string {
|
||||
return api.HOST_TYPE_ORACLE
|
||||
}
|
||||
|
||||
func (self *SHost) GetStorageType() string {
|
||||
return api.DISK_TYPE_HYBRID
|
||||
}
|
||||
|
||||
func (self *SHost) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
|
||||
return self.zone.GetIStorageById(id)
|
||||
}
|
||||
|
||||
func (self *SHost) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
|
||||
return self.zone.GetIStorages()
|
||||
}
|
||||
|
||||
func (self *SHost) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
|
||||
vm, err := self.zone.region.GetInstance(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vm.host = self
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
func (self *SHost) GetIVMs() ([]cloudprovider.ICloudVM, error) {
|
||||
vms, err := self.zone.region.GetInstances(self.zone.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudVM{}
|
||||
for i := range vms {
|
||||
vms[i].host = self
|
||||
ret = append(ret, &vms[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SHost) GetSysInfo() jsonutils.JSONObject {
|
||||
info := jsonutils.NewDict()
|
||||
info.Add(jsonutils.NewString(api.CLOUD_PROVIDER_ORACLE), "manufacture")
|
||||
return info
|
||||
}
|
||||
|
||||
func (self *SHost) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (host *SHost) GetIHostNics() ([]cloudprovider.ICloudHostNetInterface, error) {
|
||||
vpcs, err := host.zone.region.GetVpcs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
wires := []cloudprovider.ICloudWire{}
|
||||
for i := range vpcs {
|
||||
vpcs[i].region = host.zone.region
|
||||
wires = append(wires, &SWire{vpc: &vpcs[i], zone: host.zone})
|
||||
wires = append(wires, vpcs[i].getRegionWire())
|
||||
}
|
||||
return cloudprovider.GetHostNetifs(host, wires), nil
|
||||
}
|
||||
|
||||
func (host *SHost) GetIsMaintenance() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (host *SHost) GetVersion() string {
|
||||
return DEFAULT_API_VERSION
|
||||
}
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/imagetools"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SImage struct {
|
||||
multicloud.SImageBase
|
||||
SOracleTag
|
||||
storageCache *SStoragecache
|
||||
|
||||
// normalized image info
|
||||
imgInfo *imagetools.ImageInfo
|
||||
|
||||
DisplayName string
|
||||
Id string
|
||||
LaunchMode string
|
||||
LaunchOptions struct {
|
||||
BootVolumeType string
|
||||
Firmware string
|
||||
NetworkType string
|
||||
RemoteDataVolumeType string
|
||||
IsPvEncryptionInTransitEnabled bool
|
||||
IsConsistentVolumeNamingEnabled string
|
||||
}
|
||||
LifecycleState string
|
||||
OperatingSystem string
|
||||
OperatingSystemVersion string
|
||||
SizeInMBs int
|
||||
BillableSizeInGBs int
|
||||
TimeCreated time.Time
|
||||
}
|
||||
|
||||
func (self *SImage) GetMinRamSizeMb() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SImage) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SImage) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SImage) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SImage) Delete(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SImage) GetStatus() string {
|
||||
// AVAILABLE, DELETED, DISABLED, EXPORTING, IMPORTING, PROVISIONING
|
||||
switch self.LifecycleState {
|
||||
case "PROVISIONING", "IMPORTING":
|
||||
return api.CACHED_IMAGE_STATUS_CACHING
|
||||
case "AVAILABLE", "EXPORTING":
|
||||
return api.CACHED_IMAGE_STATUS_ACTIVE
|
||||
default:
|
||||
return api.CACHED_IMAGE_STATUS_CACHE_FAILED
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SImage) GetImageStatus() string {
|
||||
switch self.LifecycleState {
|
||||
case "PROVISIONING", "IMPORTING":
|
||||
return cloudprovider.IMAGE_STATUS_SAVING
|
||||
case "AVAILABLE", "EXPORTING":
|
||||
return cloudprovider.IMAGE_STATUS_ACTIVE
|
||||
case "DELETED", "DISABLED":
|
||||
return cloudprovider.IMAGE_STATUS_DELETED
|
||||
default:
|
||||
return cloudprovider.IMAGE_STATUS_DELETED
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SImage) Refresh() error {
|
||||
image, err := self.storageCache.region.GetImage(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, image)
|
||||
}
|
||||
|
||||
func (self *SImage) GetImageType() cloudprovider.TImageType {
|
||||
return cloudprovider.ImageTypeSystem
|
||||
}
|
||||
|
||||
func (self *SImage) GetSizeByte() int64 {
|
||||
return int64(self.SizeInMBs) * 1024 * 1024
|
||||
}
|
||||
|
||||
func (self *SImage) getNormalizedImageInfo() *imagetools.ImageInfo {
|
||||
if self.imgInfo == nil {
|
||||
imgInfo := imagetools.NormalizeImageInfo(self.DisplayName, "", self.OperatingSystem, "", self.OperatingSystemVersion)
|
||||
self.imgInfo = &imgInfo
|
||||
}
|
||||
return self.imgInfo
|
||||
}
|
||||
|
||||
func (self *SImage) GetOsType() cloudprovider.TOsType {
|
||||
return cloudprovider.TOsType(self.getNormalizedImageInfo().OsType)
|
||||
}
|
||||
|
||||
func (self *SImage) GetOsDist() string {
|
||||
return self.getNormalizedImageInfo().OsDistro
|
||||
}
|
||||
|
||||
func (self *SImage) GetOsVersion() string {
|
||||
return self.getNormalizedImageInfo().OsVersion
|
||||
}
|
||||
|
||||
func (self *SImage) GetOsArch() string {
|
||||
return self.getNormalizedImageInfo().OsArch
|
||||
}
|
||||
|
||||
func (img *SImage) GetBios() cloudprovider.TBiosType {
|
||||
return cloudprovider.ToBiosType(img.getNormalizedImageInfo().OsBios)
|
||||
}
|
||||
|
||||
func (img *SImage) GetFullOsName() string {
|
||||
return fmt.Sprintf("%s %s", img.OperatingSystem, img.OperatingSystemVersion)
|
||||
}
|
||||
|
||||
func (img *SImage) GetOsLang() string {
|
||||
return img.getNormalizedImageInfo().OsLang
|
||||
}
|
||||
|
||||
func (self *SImage) GetMinOsDiskSizeGb() int {
|
||||
return self.SizeInMBs / 1024
|
||||
}
|
||||
|
||||
func (self *SImage) GetImageFormat() string {
|
||||
return "qcow2"
|
||||
}
|
||||
|
||||
func (self *SImage) GetCreatedAt() time.Time {
|
||||
return self.TimeCreated
|
||||
}
|
||||
|
||||
func (self *SRegion) GetImage(id string) (*SImage, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "images", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SImage{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SImage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return self.storageCache
|
||||
}
|
||||
|
||||
func (self *SRegion) GetImages() ([]SImage, error) {
|
||||
resp, err := self.list(SERVICE_IAAS, "images", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SImage{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+348
-2
@@ -15,12 +15,26 @@
|
||||
package oracle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/billing"
|
||||
"yunion.io/x/pkg/util/imagetools"
|
||||
)
|
||||
|
||||
type SInstance struct {
|
||||
multicloud.SInstanceBase
|
||||
SOracleTag
|
||||
host *SHost
|
||||
|
||||
osInfo *imagetools.ImageInfo
|
||||
|
||||
AvailabilityDomain string
|
||||
CompartmentId string
|
||||
DefinedTags struct {
|
||||
@@ -53,6 +67,7 @@ type SInstance struct {
|
||||
IsLiveMigrationPreferred bool
|
||||
RecoveryAction string
|
||||
}
|
||||
// CREATING_IMAGE, MOVING, PROVISIONING, RUNNING, STARTING, STOPPED, STOPPING, TERMINATED, TERMINATING
|
||||
LifecycleState string
|
||||
Metadata struct {
|
||||
}
|
||||
@@ -87,8 +102,12 @@ type SInstance struct {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SRegion) GetInstances() ([]SInstance, error) {
|
||||
resp, err := self.list(SERVICE_IAAS, "instances", nil)
|
||||
func (self *SRegion) GetInstances(zoneId string) ([]SInstance, error) {
|
||||
params := map[string]interface{}{}
|
||||
if len(zoneId) > 0 {
|
||||
params["availabilityDomain"] = zoneId
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "instances", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -99,3 +118,330 @@ func (self *SRegion) GetInstances() ([]SInstance, error) {
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetInstance(id string) (*SInstance, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "instances", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SInstance{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) GetIHost() cloudprovider.ICloudHost {
|
||||
return self.host
|
||||
}
|
||||
|
||||
func (self *SInstance) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SInstance) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SInstance) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SInstance) GetInstanceType() string {
|
||||
return self.Shape
|
||||
}
|
||||
|
||||
func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
ret := []cloudprovider.ICloudDisk{}
|
||||
root, err := self.host.zone.region.GetBootVolumeAttachments(self.AvailabilityDomain, self.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, r := range root {
|
||||
disk, err := self.host.zone.region.GetBootDisk(r.BootVolumeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
disk.storage = &SStorage{zone: self.host.zone, boot: true}
|
||||
ret = append(ret, disk)
|
||||
}
|
||||
data, err := self.host.zone.region.GetAttachedDisks(self.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, d := range data {
|
||||
disk, err := self.host.zone.region.GetDisk(d.VolumeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
disk.storage = &SStorage{zone: self.host.zone}
|
||||
ret = append(ret, disk)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetINics() ([]cloudprovider.ICloudNic, error) {
|
||||
nics, err := self.host.zone.region.GetVnicAttachments(self.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudNic{}
|
||||
for _, n := range nics {
|
||||
nic, err := self.host.zone.region.GetInstanceNic(n.VnicId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret = append(ret, nic)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetVcpuCount() int {
|
||||
return int(self.ShapeConfig.Ocpus)
|
||||
}
|
||||
|
||||
func (self *SInstance) GetVmemSizeMB() int {
|
||||
return int(self.ShapeConfig.MemoryInGBs) * 1024
|
||||
}
|
||||
|
||||
func (self *SInstance) GetBootOrder() string {
|
||||
return "dcn"
|
||||
}
|
||||
|
||||
func (self *SInstance) GetVga() string {
|
||||
return "std"
|
||||
}
|
||||
|
||||
func (self *SInstance) GetVdi() string {
|
||||
return "vnc"
|
||||
}
|
||||
|
||||
func (self *SInstance) getNormalizedOsInfo() *imagetools.ImageInfo {
|
||||
if self.osInfo != nil {
|
||||
return self.osInfo
|
||||
}
|
||||
image, err := self.host.zone.region.GetImage(self.ImageId)
|
||||
if err != nil {
|
||||
return &imagetools.ImageInfo{}
|
||||
}
|
||||
osInfo := imagetools.NormalizeImageInfo(image.DisplayName, "", image.OperatingSystem, "", image.OperatingSystemVersion)
|
||||
self.osInfo = &osInfo
|
||||
return self.osInfo
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetOsType() cloudprovider.TOsType {
|
||||
return cloudprovider.TOsType(ins.getNormalizedOsInfo().OsType)
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetBios() cloudprovider.TBiosType {
|
||||
return cloudprovider.ToBiosType(ins.getNormalizedOsInfo().OsBios)
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetFullOsName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetOsLang() string {
|
||||
return ins.getNormalizedOsInfo().OsLang
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetOsArch() string {
|
||||
return ins.getNormalizedOsInfo().OsArch
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetOsDist() string {
|
||||
return ins.getNormalizedOsInfo().OsDistro
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetOsVersion() string {
|
||||
return ins.getNormalizedOsInfo().OsVersion
|
||||
}
|
||||
|
||||
func (self *SInstance) GetMachine() string {
|
||||
return "pc"
|
||||
}
|
||||
|
||||
func (self *SInstance) GetStatus() string {
|
||||
// CREATING_IMAGE, MOVING, PROVISIONING, RUNNING, STARTING, STOPPED, STOPPING, TERMINATED, TERMINATING
|
||||
switch self.LifecycleState {
|
||||
case "CREATING_IMAGE", "RUNNING":
|
||||
return api.VM_RUNNING
|
||||
case "MOVING":
|
||||
return api.VM_MIGRATING
|
||||
case "PROVISIONING":
|
||||
return api.VM_DEPLOYING
|
||||
case "STARTING":
|
||||
return api.VM_STARTING
|
||||
case "STOPPED":
|
||||
return api.VM_READY
|
||||
case "STOPPING":
|
||||
return api.VM_STOPPING
|
||||
case "TERMINATED", "TERMINATING":
|
||||
return api.VM_DELETING
|
||||
default:
|
||||
return api.VM_UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) Refresh() error {
|
||||
vm, err := self.host.zone.region.GetInstance(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, vm)
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHypervisor() string {
|
||||
return api.HYPERVISOR_ORACLE
|
||||
}
|
||||
|
||||
func (self *SInstance) StartVM(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) StopVM(ctx context.Context, opts *cloudprovider.ServerStopOptions) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudprovider.ServerVncOutput, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
return "", cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.SManagedVMChangeConfig) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) AttachDisk(ctx context.Context, diskId string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) DetachDisk(ctx context.Context, diskId string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) SetSecurityGroups(secgroupIds []string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) GetIEIP() (cloudprovider.ICloudEIP, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) GetBillingType() string {
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
}
|
||||
|
||||
func (self *SInstance) GetCreatedAt() time.Time {
|
||||
return self.TimeCreated
|
||||
}
|
||||
|
||||
func (self *SInstance) GetExpiredAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateUserData(userData string) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SInstance) Renew(bc billing.SBillingCycle) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SInstance) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetError() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) SaveImage(opts *cloudprovider.SaveImageOptions) (cloudprovider.ICloudImage, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
type SVolumeAttachment struct {
|
||||
VolumeId string `json:"volume-id"`
|
||||
}
|
||||
|
||||
func (self *SRegion) GetAttachedDisks(instanceId string) ([]SVolumeAttachment, error) {
|
||||
params := map[string]interface{}{
|
||||
"instanceId": instanceId,
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "volumeAttachments", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SVolumeAttachment{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
type SBootVolumeAttachment struct {
|
||||
BootVolumeId string `json:"boot-volume-id"`
|
||||
}
|
||||
|
||||
func (self *SRegion) GetBootVolumeAttachments(zoneId, instanceId string) ([]SBootVolumeAttachment, error) {
|
||||
params := map[string]interface{}{
|
||||
"instanceId": instanceId,
|
||||
"availabilityDomain": zoneId,
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "bootVolumeAttachments", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SBootVolumeAttachment{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
type SVnicAttachment struct {
|
||||
VnicId string `json:"vnic-id"`
|
||||
}
|
||||
|
||||
func (self *SRegion) GetVnicAttachments(instanceId string) ([]SVnicAttachment, error) {
|
||||
params := map[string]interface{}{}
|
||||
if len(instanceId) > 0 {
|
||||
params["instanceId"] = instanceId
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "vnicAttachments", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SVnicAttachment{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SInstanceNic struct {
|
||||
instance *SInstance
|
||||
|
||||
Id string
|
||||
SubnetId string `json:"subnet-id"`
|
||||
MacAddress string `json:"mac-address"`
|
||||
PrivateIp string `json:"private-ip"`
|
||||
PublicIp string `json:"public-ip"`
|
||||
|
||||
cloudprovider.DummyICloudNic
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetIP() string {
|
||||
return self.PrivateIp
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetMAC() string {
|
||||
return self.MacAddress
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetDriver() string {
|
||||
return "virtio"
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) InClassicNetwork() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SInstanceNic) GetINetworkId() string {
|
||||
return self.SubnetId
|
||||
}
|
||||
|
||||
func (self *SRegion) GetInstanceNic(id string) (*SInstanceNic, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "vnics", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SInstanceNic{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/apis"
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SNetwork struct {
|
||||
multicloud.SResourceBase
|
||||
SOracleTag
|
||||
wire *SWire
|
||||
|
||||
AvailabilityDomain string
|
||||
Id string
|
||||
CidrBlock string
|
||||
DisplayName string
|
||||
DnsLabel string
|
||||
LifecycleState string
|
||||
SecurityListIds []string
|
||||
SubnetDomainName string
|
||||
TimeCreated time.Time
|
||||
VcnId string
|
||||
VirtualRouterIp string
|
||||
VirtualRouterMac string
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetStatus() string {
|
||||
// AVAILABLE, PROVISIONING, TERMINATED, TERMINATING, UPDATING
|
||||
switch self.LifecycleState {
|
||||
case "AVAILABLE", "UPDATING":
|
||||
return api.NETWORK_STATUS_AVAILABLE
|
||||
case "PROVISIONING":
|
||||
return apis.STATUS_CREATING
|
||||
case "TERMINATED", "TERMINATING":
|
||||
return apis.STATUS_DELETING
|
||||
default:
|
||||
return api.NETWORK_STATUS_UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SNetwork) Delete() error {
|
||||
return self.wire.vpc.region.DeleteNetwork(self.Id)
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteNetwork(networkId string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetIWire() cloudprovider.ICloudWire {
|
||||
return self.wire
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetAllocTimeoutSeconds() int {
|
||||
return 120 // 2 minutes
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetGateway() string {
|
||||
pref, _ := netutils.NewIPV4Prefix(self.CidrBlock)
|
||||
endIp := pref.Address.BroadcastAddr(pref.MaskLen) // 255
|
||||
endIp = endIp.StepDown() // 254
|
||||
return endIp.String()
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetIpStart() string {
|
||||
pref, _ := netutils.NewIPV4Prefix(self.CidrBlock)
|
||||
startIp := pref.Address.NetAddr(pref.MaskLen) // 0
|
||||
startIp = startIp.StepUp() // 1
|
||||
startIp = startIp.StepUp() // 2
|
||||
return startIp.String()
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetIpEnd() string {
|
||||
pref, _ := netutils.NewIPV4Prefix(self.CidrBlock)
|
||||
endIp := pref.Address.BroadcastAddr(pref.MaskLen) // 255
|
||||
endIp = endIp.StepDown() // 254
|
||||
return endIp.String()
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetIpMask() int8 {
|
||||
pref, _ := netutils.NewIPV4Prefix(self.CidrBlock)
|
||||
return pref.MaskLen
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope {
|
||||
return rbacscope.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetServerType() string {
|
||||
return api.NETWORK_TYPE_GUEST
|
||||
}
|
||||
|
||||
func (self *SNetwork) Refresh() error {
|
||||
subnet, err := self.wire.vpc.region.GetNetwork(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, subnet)
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SRegion) GetNetworks(vpcId string) ([]SNetwork, error) {
|
||||
params := map[string]interface{}{}
|
||||
if len(vpcId) > 0 {
|
||||
params["vcnId"] = vpcId
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "subnets", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SNetwork{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetNetwork(id string) (*SNetwork, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "subnets", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SNetwork{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+44
-29
@@ -44,7 +44,8 @@ const (
|
||||
CLOUD_PROVIDER_ORACLE_CN = "甲骨文"
|
||||
ORACLE_DEFAULT_REGION = "ap-singapore-1"
|
||||
DEFAULT_API_VERSION = "20160918"
|
||||
ISO8601 = "2006-01-02T15:04:05Z"
|
||||
|
||||
NEXT_TOKEN = "opc-next-page"
|
||||
|
||||
SERVICE_IAAS = "iaas"
|
||||
SERVICE_IDENTITY = "identity"
|
||||
@@ -156,7 +157,8 @@ func (self *SOracleClient) GetRegions() ([]SRegion, error) {
|
||||
if len(self.regions) > 0 {
|
||||
return self.regions, nil
|
||||
}
|
||||
resp, err := self.list(SERVICE_IDENTITY, ORACLE_DEFAULT_REGION, "regions", nil)
|
||||
resource := fmt.Sprintf("tenancies/%s/regionSubscriptions", self.tenancyOCID)
|
||||
resp, err := self.list(SERVICE_IDENTITY, ORACLE_DEFAULT_REGION, resource, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -174,8 +176,8 @@ func (self *SOracleClient) GetRegion(id string) (*SRegion, error) {
|
||||
return nil, err
|
||||
}
|
||||
for i := range regions {
|
||||
if regions[i].Name == id {
|
||||
regions[i].client = self
|
||||
regions[i].client = self
|
||||
if regions[i].RegionName == id || regions[i].GetGlobalId() == id {
|
||||
return ®ions[i], nil
|
||||
}
|
||||
}
|
||||
@@ -264,7 +266,6 @@ func (self *SOracleClient) Do(req *http.Request) (*http.Response, error) {
|
||||
|
||||
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
||||
signer := common.DefaultRequestSigner(self)
|
||||
|
||||
signer.Sign(req)
|
||||
|
||||
return client.Do(req)
|
||||
@@ -274,20 +275,45 @@ func (self *SOracleClient) list(service, regionId, resource string, params map[s
|
||||
if params == nil {
|
||||
params = map[string]interface{}{}
|
||||
}
|
||||
if service == SERVICE_IAAS && len(self.compartment) > 0 {
|
||||
if len(self.compartment) > 0 {
|
||||
params["compartmentId"] = self.compartment
|
||||
}
|
||||
return self.request(httputils.GET, service, regionId, resource, params)
|
||||
ret := jsonutils.NewArray()
|
||||
for {
|
||||
resp, token, err := self.request(httputils.GET, service, regionId, resource, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items, _ := resp.GetArray()
|
||||
ret.Add(items...)
|
||||
if len(token) == 0 {
|
||||
break
|
||||
}
|
||||
params["page"] = token
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SOracleClient) get(service, regionId, resource, id string, params map[string]interface{}) (jsonutils.JSONObject, error) {
|
||||
if len(id) == 0 {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "empty id")
|
||||
}
|
||||
if params == nil {
|
||||
params = map[string]interface{}{}
|
||||
}
|
||||
resp, _, err := self.request(httputils.GET, service, regionId, resource+"/"+id, params)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (self *SOracleClient) post(service, regionId, resource string, params map[string]interface{}) (jsonutils.JSONObject, error) {
|
||||
return self.request(httputils.POST, service, regionId, resource, params)
|
||||
resp, _, err := self.request(httputils.POST, service, regionId, resource, params)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (self *SOracleClient) request(method httputils.THttpMethod, service, regionId, resource string, params map[string]interface{}) (jsonutils.JSONObject, error) {
|
||||
func (self *SOracleClient) request(method httputils.THttpMethod, service, regionId, resource string, params map[string]interface{}) (jsonutils.JSONObject, string, error) {
|
||||
uri, err := self.getUrl(service, regionId, resource)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, "", err
|
||||
}
|
||||
if params == nil {
|
||||
params = map[string]interface{}{}
|
||||
@@ -306,8 +332,11 @@ func (self *SOracleClient) request(method httputils.THttpMethod, service, region
|
||||
req := httputils.NewJsonRequest(method, uri, params)
|
||||
bErr := &sOracleError{}
|
||||
client := httputils.NewJsonClient(self)
|
||||
_, resp, err := client.Send(self.ctx, req, bErr, self.debug)
|
||||
return resp, err
|
||||
header, resp, err := client.Send(self.ctx, req, bErr, self.debug)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return resp, header.Get("Opc-Next-Page"), nil
|
||||
}
|
||||
|
||||
func (self *SOracleClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error) {
|
||||
@@ -356,26 +385,12 @@ func (self *SOracleClient) GetAccountId() string {
|
||||
return self.tenancyOCID
|
||||
}
|
||||
|
||||
type CashBalance struct {
|
||||
CashBalance float64
|
||||
}
|
||||
|
||||
func (self *SOracleClient) QueryBalance() (*CashBalance, error) {
|
||||
resp, err := self.post("billing", "", "/v1/finance/cash/balance", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &CashBalance{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "resp.Unmarshal")
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SOracleClient) GetCapabilities() []string {
|
||||
caps := []string{
|
||||
cloudprovider.CLOUD_CAPABILITY_COMPUTE + cloudprovider.READ_ONLY_SUFFIX,
|
||||
cloudprovider.CLOUD_CAPABILITY_NETWORK + cloudprovider.READ_ONLY_SUFFIX,
|
||||
cloudprovider.CLOUD_CAPABILITY_SECURITY_GROUP + cloudprovider.READ_ONLY_SUFFIX,
|
||||
cloudprovider.CLOUD_CAPABILITY_EIP + cloudprovider.READ_ONLY_SUFFIX,
|
||||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
+154
-15
@@ -21,6 +21,7 @@ import (
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
)
|
||||
|
||||
type SRegion struct {
|
||||
@@ -29,16 +30,18 @@ type SRegion struct {
|
||||
multicloud.SNoLbRegion
|
||||
client *SOracleClient
|
||||
|
||||
Key string
|
||||
Name string
|
||||
IsHomeRegion bool `json:"is-home-region"`
|
||||
RegionKey string `json:"region-key"`
|
||||
RegionName string `json:"region-name"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func (self *SRegion) GetId() string {
|
||||
return self.Name
|
||||
return self.RegionName
|
||||
}
|
||||
|
||||
func (self *SRegion) GetGlobalId() string {
|
||||
return fmt.Sprintf("%s/%s", api.CLOUD_PROVIDER_ORACLE, self.Name)
|
||||
return fmt.Sprintf("%s/%s", api.CLOUD_PROVIDER_ORACLE, self.RegionName)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetProvider() string {
|
||||
@@ -50,7 +53,9 @@ func (self *SRegion) GetCloudEnv() string {
|
||||
}
|
||||
|
||||
func (self *SRegion) GetGeographicInfo() cloudprovider.SGeographicInfo {
|
||||
geo, ok := map[string]cloudprovider.SGeographicInfo{}[self.Name]
|
||||
geo, ok := map[string]cloudprovider.SGeographicInfo{
|
||||
"ap-singapore-1": api.RegionSingapore,
|
||||
}[self.RegionName]
|
||||
if ok {
|
||||
return geo
|
||||
}
|
||||
@@ -58,16 +63,19 @@ func (self *SRegion) GetGeographicInfo() cloudprovider.SGeographicInfo {
|
||||
}
|
||||
|
||||
func (self *SRegion) GetName() string {
|
||||
return self.Name
|
||||
return self.RegionName
|
||||
}
|
||||
|
||||
func (self *SRegion) GetI18n() cloudprovider.SModelI18nTable {
|
||||
table := cloudprovider.SModelI18nTable{}
|
||||
table["name"] = cloudprovider.NewSModelI18nEntry(self.GetName()).CN(self.GetName()).EN(self.Name)
|
||||
table["name"] = cloudprovider.NewSModelI18nEntry(self.GetName()).CN(self.GetName()).EN(self.RegionName)
|
||||
return table
|
||||
}
|
||||
|
||||
func (self *SRegion) GetStatus() string {
|
||||
if self.Status != "READY" {
|
||||
return api.CLOUD_REGION_STATUS_OUTOFSERVICE
|
||||
}
|
||||
return api.CLOUD_REGION_STATUS_INSERVER
|
||||
}
|
||||
|
||||
@@ -92,33 +100,164 @@ func (self *SRegion) CreateIVpc(opts *cloudprovider.VpcCreateOptions) (cloudprov
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
vpcs, err := self.GetVpcs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudVpc{}
|
||||
for i := range vpcs {
|
||||
vpcs[i].region = self
|
||||
ret = append(ret, &vpcs[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
vpc, err := self.GetVpc(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return vpc, nil
|
||||
}
|
||||
|
||||
func (region *SRegion) GetCapabilities() []string {
|
||||
return region.client.GetCapabilities()
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIEipById(eipId string) (cloudprovider.ICloudEIP, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
func (self *SRegion) GetIEipById(id string) (cloudprovider.ICloudEIP, error) {
|
||||
eip, err := self.GetEip(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return eip, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIEips() ([]cloudprovider.ICloudEIP, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
eips, err := self.GetEips("RESERVED")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudEIP{}
|
||||
for i := range eips {
|
||||
eips[i].region = self
|
||||
ret = append(ret, &eips[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
zones, err := self.GetZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudZone{}
|
||||
for i := range zones {
|
||||
zones[i].region = self
|
||||
ret = append(ret, &zones[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
zones, err := self.GetIZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range zones {
|
||||
if zones[i].GetGlobalId() == id {
|
||||
return zones[i], nil
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SRegion) list(service, resource string, params map[string]interface{}) (jsonutils.JSONObject, error) {
|
||||
return self.client.list(service, self.Name, resource, params)
|
||||
return self.client.list(service, self.RegionName, resource, params)
|
||||
}
|
||||
|
||||
func (self *SRegion) get(service, resource, id string, params map[string]interface{}) (jsonutils.JSONObject, error) {
|
||||
return self.client.get(service, self.RegionName, resource, id, params)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
|
||||
caches, err := self.GetIStoragecaches()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range caches {
|
||||
if caches[i].GetGlobalId() == id {
|
||||
return caches[i], nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStoragecaches() ([]cloudprovider.ICloudStoragecache, error) {
|
||||
return []cloudprovider.ICloudStoragecache{self.GetStoragecache()}, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
|
||||
izones, err := self.GetIZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := 0; i < len(izones); i += 1 {
|
||||
ihost, err := izones[i].GetIHostById(id)
|
||||
if err == nil {
|
||||
return ihost, nil
|
||||
} else if errors.Cause(err) != cloudprovider.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIHosts() ([]cloudprovider.ICloudHost, error) {
|
||||
iHosts := make([]cloudprovider.ICloudHost, 0)
|
||||
|
||||
izones, err := self.GetIZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := 0; i < len(izones); i += 1 {
|
||||
iZoneHost, err := izones[i].GetIHosts()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
iHosts = append(iHosts, iZoneHost...)
|
||||
}
|
||||
return iHosts, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
|
||||
iStores := make([]cloudprovider.ICloudStorage, 0)
|
||||
|
||||
izones, err := self.GetIZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := 0; i < len(izones); i += 1 {
|
||||
iZoneStores, err := izones[i].GetIStorages()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
iStores = append(iStores, iZoneStores...)
|
||||
}
|
||||
return iStores, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
|
||||
izones, err := self.GetIZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := 0; i < len(izones); i += 1 {
|
||||
istore, err := izones[i].GetIStorageById(id)
|
||||
if err == nil {
|
||||
return istore, nil
|
||||
} else if errors.Cause(err) != cloudprovider.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// 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 oracle
|
||||
|
||||
type SSecurityGroupRule struct {
|
||||
Description string
|
||||
Destination string
|
||||
DestinationType string `json:"destination-type"`
|
||||
Protocol string
|
||||
TcpOptions string `json:"tcp-options"`
|
||||
UdpOptions string `json:"udp-options"`
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
"yunion.io/x/jsonutils"
|
||||
)
|
||||
|
||||
type SSecurityGroup struct {
|
||||
multicloud.SSecurityGroup
|
||||
SOracleTag
|
||||
|
||||
region *SRegion
|
||||
|
||||
Id string
|
||||
IngressSecurityRules []SSecurityGroupRule `json:"ingress-security-rules"`
|
||||
EgressSecurityRules []SSecurityGroupRule `json:"egress-security-rules"`
|
||||
LifecycleState string `json:"lifecycle-state"`
|
||||
VcnId string `json:"vcn-id"`
|
||||
DisplayName string `json:"display-name"`
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetVpcId() string {
|
||||
return self.VcnId
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetDescription() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetRules() ([]cloudprovider.ISecurityGroupRule, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetStatus() string {
|
||||
return api.SECGROUP_STATUS_READY
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) Refresh() error {
|
||||
group, err := self.region.GetSecurityGroup(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, group)
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetReferences() ([]cloudprovider.SecurityGroupReference, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) Delete() error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) CreateRule(opts *cloudprovider.SecurityGroupRuleCreateOptions) (cloudprovider.ISecurityGroupRule, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SRegion) GetSecurityGroups(vpcId string) ([]SSecurityGroup, error) {
|
||||
params := map[string]interface{}{}
|
||||
if len(vpcId) > 0 {
|
||||
params["vcnId"] = vpcId
|
||||
}
|
||||
resp, err := self.list(SERVICE_IAAS, "securityLists", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SSecurityGroup{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetSecurityGroup(id string) (*SSecurityGroup, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "securityLists", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SSecurityGroup{}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+142
@@ -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 oracle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
"yunion.io/x/jsonutils"
|
||||
)
|
||||
|
||||
type SStorage struct {
|
||||
multicloud.SStorageBase
|
||||
boot bool
|
||||
|
||||
zone *SZone
|
||||
}
|
||||
|
||||
func (self *SStorage) GetId() string {
|
||||
if self.boot {
|
||||
return fmt.Sprintf("%s/%s-system", self.zone.GetGlobalId(), self.zone.region.client.cpcfg.Id)
|
||||
}
|
||||
return fmt.Sprintf("%s/%s", self.zone.GetGlobalId(), self.zone.region.client.cpcfg.Id)
|
||||
}
|
||||
|
||||
func (self *SStorage) GetGlobalId() string {
|
||||
return self.GetId()
|
||||
}
|
||||
|
||||
func (self *SStorage) GetName() string {
|
||||
res := fmt.Sprintf("%s-%s-%s-%s", self.zone.region.client.cpcfg.Name, self.zone.region.RegionName, self.zone.Name, api.STORAGE_FULL)
|
||||
if self.boot {
|
||||
res += "-system"
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (self *SStorage) GetStatus() string {
|
||||
return api.STORAGE_ONLINE
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SStorage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return self.zone.region.GetStoragecache()
|
||||
}
|
||||
|
||||
func (self *SStorage) GetIZone() cloudprovider.ICloudZone {
|
||||
return self.zone
|
||||
}
|
||||
|
||||
func (self *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
ret := []cloudprovider.ICloudDisk{}
|
||||
if self.boot {
|
||||
disks, err := self.zone.region.GetBootDisks(self.zone.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range disks {
|
||||
disks[i].storage = self
|
||||
ret = append(ret, &disks[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
disks, err := self.zone.region.GetDisks(self.zone.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range disks {
|
||||
disks[i].storage = self
|
||||
ret = append(ret, &disks[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SStorage) GetIDiskById(id string) (cloudprovider.ICloudDisk, error) {
|
||||
if self.boot {
|
||||
disk, err := self.zone.region.GetBootDisk(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
disk.storage = self
|
||||
return disk, nil
|
||||
}
|
||||
disk, err := self.zone.region.GetDisk(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
disk.storage = self
|
||||
return disk, nil
|
||||
}
|
||||
|
||||
func (self *SStorage) GetStorageType() string {
|
||||
if self.boot {
|
||||
return api.STORAGE_SYSTEM_FULL
|
||||
}
|
||||
return api.STORAGE_FULL
|
||||
}
|
||||
|
||||
func (self *SStorage) GetMediumType() string {
|
||||
return api.DISK_TYPE_SSD
|
||||
}
|
||||
|
||||
func (self *SStorage) GetEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
return self.boot
|
||||
}
|
||||
|
||||
func (self *SStorage) GetCapacityMB() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SStorage) GetCapacityUsedMB() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SStorage) GetMountPoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStorage) GetStorageConf() jsonutils.JSONObject {
|
||||
return jsonutils.NewDict()
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/apis"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SStoragecache struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.STagBase
|
||||
|
||||
region *SRegion
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.region.client.cpcfg.Id, self.region.GetId())
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetName() string {
|
||||
return fmt.Sprintf("%s-%s", self.region.client.cpcfg.Name, self.region.GetId())
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetGlobalId() string {
|
||||
return fmt.Sprintf("%s-%s", self.region.client.cpcfg.Id, self.region.GetGlobalId())
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetStatus() string {
|
||||
return apis.STATUS_AVAILABLE
|
||||
}
|
||||
|
||||
func (self *SStoragecache) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetICloudImages() ([]cloudprovider.ICloudImage, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetICustomizedCloudImages() ([]cloudprovider.ICloudImage, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetIImageById(extId string) (cloudprovider.ICloudImage, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SStoragecache) UploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) {
|
||||
return "", cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SRegion) GetStoragecache() *SStoragecache {
|
||||
return &SStoragecache{region: self}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SOracleTag struct {
|
||||
}
|
||||
|
||||
func (self SOracleTag) GetSysTags() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self SOracleTag) GetTags() (map[string]string, error) {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotImplemented, "GetTags")
|
||||
}
|
||||
|
||||
func (self SOracleTag) SetTags(tags map[string]string, replace bool) error {
|
||||
return errors.Wrap(cloudprovider.ErrNotImplemented, "SetTags")
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
)
|
||||
|
||||
type SVpc struct {
|
||||
multicloud.SVpc
|
||||
SOracleTag
|
||||
|
||||
region *SRegion
|
||||
|
||||
Id string
|
||||
CidrBlock string `json:"cidr-block"`
|
||||
TimeCreated time.Time `json:"time-created"`
|
||||
DisplayName string `json:"display-name"`
|
||||
DnsLabel string `json:"dns-label"`
|
||||
LifecycleState string `json:"lifecycle-state"`
|
||||
}
|
||||
|
||||
func (self *SVpc) GetId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SVpc) GetName() string {
|
||||
return self.DisplayName
|
||||
}
|
||||
|
||||
func (self *SVpc) GetGlobalId() string {
|
||||
return self.Id
|
||||
}
|
||||
|
||||
func (self *SVpc) GetIsDefault() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SVpc) GetCidrBlock() string {
|
||||
return self.CidrBlock
|
||||
}
|
||||
|
||||
func (self *SVpc) GetStatus() string {
|
||||
if self.LifecycleState != "AVAILABLE" {
|
||||
return api.VPC_STATUS_UNKNOWN
|
||||
}
|
||||
return api.VPC_STATUS_AVAILABLE
|
||||
}
|
||||
|
||||
func (self *SVpc) Delete() error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SVpc) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
|
||||
groups, err := self.region.GetSecurityGroups(self.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudSecurityGroup{}
|
||||
for i := range groups {
|
||||
groups[i].region = self.region
|
||||
ret = append(ret, &groups[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SVpc) GetIRouteTables() ([]cloudprovider.ICloudRouteTable, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SVpc) GetIRouteTableById(routeTableId string) (cloudprovider.ICloudRouteTable, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SVpc) GetINatGateways() ([]cloudprovider.ICloudNatGateway, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SVpc) GetIWireById(id string) (cloudprovider.ICloudWire, error) {
|
||||
wires, err := self.GetIWires()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range wires {
|
||||
if wires[i].GetGlobalId() == id {
|
||||
return wires[i], nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
|
||||
}
|
||||
|
||||
func (self *SVpc) getRegionWire() *SWire {
|
||||
return &SWire{vpc: self}
|
||||
}
|
||||
|
||||
func (self *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) {
|
||||
ret := []cloudprovider.ICloudWire{self.getRegionWire()}
|
||||
zones, err := self.region.GetZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range zones {
|
||||
zones[i].region = self.region
|
||||
ret = append(ret, &SWire{vpc: self, zone: &zones[i]})
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
|
||||
return self.region
|
||||
}
|
||||
|
||||
func (self *SVpc) Refresh() error {
|
||||
vpc, err := self.region.GetVpc(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, vpc)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetVpcs() ([]SVpc, error) {
|
||||
resp, err := self.list(SERVICE_IAAS, "vcns", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []SVpc{}
|
||||
err = resp.Unmarshal(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetVpc(id string) (*SVpc, error) {
|
||||
resp, err := self.get(SERVICE_IAAS, "vcns", id, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &SVpc{region: self}
|
||||
err = resp.Unmarshal(ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SWire struct {
|
||||
multicloud.SResourceBase
|
||||
SOracleTag
|
||||
|
||||
vpc *SVpc
|
||||
zone *SZone
|
||||
}
|
||||
|
||||
func (self *SWire) GetId() string {
|
||||
if self.zone != nil {
|
||||
return fmt.Sprintf("%s-%s", self.vpc.GetId(), self.zone.Name)
|
||||
}
|
||||
return self.vpc.GetId()
|
||||
}
|
||||
|
||||
func (self *SWire) GetName() string {
|
||||
return self.GetId()
|
||||
}
|
||||
|
||||
func (self *SWire) IsEmulated() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SWire) GetStatus() string {
|
||||
return api.WIRE_STATUS_AVAILABLE
|
||||
}
|
||||
|
||||
func (self *SWire) Refresh() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SWire) GetGlobalId() string {
|
||||
return self.GetId()
|
||||
}
|
||||
|
||||
func (self *SWire) GetIVpc() cloudprovider.ICloudVpc {
|
||||
return self.vpc
|
||||
}
|
||||
|
||||
func (self *SWire) GetIZone() cloudprovider.ICloudZone {
|
||||
if self.zone == nil {
|
||||
return nil
|
||||
}
|
||||
return self.zone
|
||||
}
|
||||
|
||||
func (self *SWire) GetBandwidth() int {
|
||||
return 10000
|
||||
}
|
||||
|
||||
func (self *SWire) CreateINetwork(opts *cloudprovider.SNetworkCreateOptions) (cloudprovider.ICloudNetwork, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SWire) GetINetworkById(id string) (cloudprovider.ICloudNetwork, error) {
|
||||
network, err := self.vpc.region.GetNetwork(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
network.wire = self
|
||||
return network, nil
|
||||
}
|
||||
|
||||
func (self *SWire) GetINetworks() ([]cloudprovider.ICloudNetwork, error) {
|
||||
networks, err := self.vpc.region.GetNetworks(self.vpc.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := []cloudprovider.ICloudNetwork{}
|
||||
for i := range networks {
|
||||
if self.zone == nil && len(networks[i].AvailabilityDomain) > 0 || (self.zone != nil && networks[i].AvailabilityDomain != self.zone.Name) {
|
||||
continue
|
||||
}
|
||||
networks[i].wire = self
|
||||
ret = append(ret, &networks[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
// 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 oracle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SZone struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.STagBase
|
||||
|
||||
region *SRegion
|
||||
|
||||
Id string
|
||||
Name string
|
||||
}
|
||||
|
||||
func (self *SZone) GetName() string {
|
||||
return self.Name
|
||||
}
|
||||
|
||||
func (self *SZone) GetId() string {
|
||||
return self.Name
|
||||
}
|
||||
|
||||
func (self *SZone) GetGlobalId() string {
|
||||
return fmt.Sprintf("%s/%s/%s", api.CLOUD_PROVIDER_ORACLE, self.region.RegionName, self.Name)
|
||||
}
|
||||
|
||||
func (self *SZone) GetStatus() string {
|
||||
return api.ZONE_ENABLE
|
||||
}
|
||||
|
||||
func (self *SZone) GetIRegion() cloudprovider.ICloudRegion {
|
||||
return self.region
|
||||
}
|
||||
|
||||
func (self *SZone) GetI18n() cloudprovider.SModelI18nTable {
|
||||
table := cloudprovider.SModelI18nTable{}
|
||||
return table
|
||||
}
|
||||
|
||||
func (self *SZone) getHost() *SHost {
|
||||
return &SHost{zone: self}
|
||||
}
|
||||
|
||||
func (self *SZone) GetIHosts() ([]cloudprovider.ICloudHost, error) {
|
||||
return []cloudprovider.ICloudHost{self.getHost()}, nil
|
||||
}
|
||||
|
||||
func (self *SZone) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
|
||||
hosts, err := self.GetIHosts()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range hosts {
|
||||
if hosts[i].GetGlobalId() == id {
|
||||
return hosts[i], nil
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SZone) getStorage() *SStorage {
|
||||
return &SStorage{zone: self}
|
||||
}
|
||||
|
||||
func (self *SZone) getBootStorage() *SStorage {
|
||||
return &SStorage{zone: self, boot: true}
|
||||
}
|
||||
|
||||
func (self *SZone) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
|
||||
return []cloudprovider.ICloudStorage{self.getStorage(), self.getBootStorage()}, nil
|
||||
}
|
||||
|
||||
func (self *SZone) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
|
||||
storages, err := self.GetIStorages()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range storages {
|
||||
if storages[i].GetGlobalId() == id {
|
||||
return storages[i], nil
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SRegion) GetZones() ([]SZone, error) {
|
||||
resp, err := self.list(SERVICE_IDENTITY, "availabilityDomains", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
zones := []SZone{}
|
||||
err = resp.Unmarshal(&zones)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return zones, nil
|
||||
}
|
||||
Reference in New Issue
Block a user