Commit cc951ab1 authored by yaocw2020's avatar yaocw2020
Browse files

Support harvester cloud provider

parent b66c7ff1
Showing with 59 additions and 0 deletions
+59 -0
......@@ -4,6 +4,7 @@ import (
"github.com/rancher/rke/cloudprovider/aws"
"github.com/rancher/rke/cloudprovider/azure"
"github.com/rancher/rke/cloudprovider/custom"
"github.com/rancher/rke/cloudprovider/harvester"
"github.com/rancher/rke/cloudprovider/openstack"
"github.com/rancher/rke/cloudprovider/vsphere"
v3 "github.com/rancher/rke/types"
......@@ -29,6 +30,9 @@ func InitCloudProvider(cloudProviderConfig v3.CloudProvider) (CloudProvider, err
if cloudProviderConfig.VsphereCloudProvider != nil || cloudProviderConfig.Name == vsphere.VsphereCloudProviderName {
p = vsphere.GetInstance()
}
if cloudProviderConfig.HarvesterCloudProvider != nil || cloudProviderConfig.Name == harvester.HarvesterCloudProviderName {
p = harvester.GetInstance()
}
if cloudProviderConfig.CustomCloudProvider != "" {
p = custom.GetInstance()
}
......
package harvester
import v3 "github.com/rancher/rke/types"
const HarvesterCloudProviderName = "harvester"
type CloudProvider struct {
Name string
Config string
}
func GetInstance() *CloudProvider {
return &CloudProvider{}
}
func (p *CloudProvider) Init(cloudProviderConfig v3.CloudProvider) error {
// Harvester cloud provider is an external cloud provider
p.Name = "external"
p.Config = cloudProviderConfig.HarvesterCloudProvider.CloudConfig
return nil
}
func (p *CloudProvider) GetName() string {
return p.Name
}
func (p *CloudProvider) GenerateCloudConfigFile() (string, error) {
return p.Config, nil
}
......@@ -556,6 +556,8 @@ type CloudProvider struct {
OpenstackCloudProvider *OpenstackCloudProvider `yaml:"openstackCloudProvider,omitempty" json:"openstackCloudProvider,omitempty"`
// VsphereCloudProvider
VsphereCloudProvider *VsphereCloudProvider `yaml:"vsphereCloudProvider,omitempty" json:"vsphereCloudProvider,omitempty"`
// HarvesterCloudProvider
HarvesterCloudProvider *HarvesterCloudProvider `yaml:"harvesterCloudProvider,omitempty" json:"harvesterCloudProvider,omitempty"`
// CustomCloudProvider is a multiline string that represent a custom cloud config file
CustomCloudProvider string `yaml:"customCloudProvider,omitempty" json:"customCloudProvider,omitempty"`
}
......@@ -848,6 +850,9 @@ type AWSCloudProvider struct {
ServiceOverride map[string]ServiceOverride `json:"serviceOverride,omitempty" yaml:"service_override,omitempty" ini:"ServiceOverride,omitempty"`
}
type HarvesterCloudProvider struct {
CloudConfig string `json:"cloudConfig" yaml:"cloud_config"`
}
type ServiceOverride struct {
Service string `json:"service" yaml:"service" ini:"Service,omitempty"`
Region string `json:"region" yaml:"region" ini:"Region,omitempty"`
......
......@@ -376,6 +376,11 @@ func (in *CloudProvider) DeepCopyInto(out *CloudProvider) {
*out = new(VsphereCloudProvider)
(*in).DeepCopyInto(*out)
}
if in.HarvesterCloudProvider != nil {
in, out := &in.HarvesterCloudProvider, &out.HarvesterCloudProvider
*out = new(HarvesterCloudProvider)
**out = **in
}
return
}
......@@ -808,6 +813,22 @@ func (in *GlobalVsphereOpts) DeepCopy() *GlobalVsphereOpts {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HarvesterCloudProvider) DeepCopyInto(out *HarvesterCloudProvider) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HarvesterCloudProvider.
func (in *HarvesterCloudProvider) DeepCopy() *HarvesterCloudProvider {
if in == nil {
return nil
}
out := new(HarvesterCloudProvider)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HealthCheck) DeepCopyInto(out *HealthCheck) {
*out = *in
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment