37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
machinedriver_data.go 3.03 KB
一键复制 编辑 原始数据 按行查看 历史
Yuxing 提交于 2018-05-10 19:11 . Add aliyunecs machine driver
package app
import (
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
func addMachineDrivers(management *config.ManagementContext) error {
if err := addMachineDriver("amazonec2", "local://", "", []string{"*.amazonaws.com", "*.amazonaws.com.cn"}, true, true, management); err != nil {
return err
}
if err := addMachineDriver("azure", "local://", "", nil, true, true, management); err != nil {
return err
}
if err := addMachineDriver("digitalocean", "local://", "", []string{"api.digitalocean.com"}, true, true, management); err != nil {
return err
}
if err := addMachineDriver("exoscale", "local://", "", []string{"api.exoscale.ch"}, false, true, management); err != nil {
return err
}
if err := addMachineDriver("openstack", "local://", "", nil, false, true, management); err != nil {
return err
}
if err := addMachineDriver("otc", "https://obs.otc.t-systems.com/dockermachinedriver/docker-machine-driver-otc",
"e98f246f625ca46f5e037dc29bdf00fe", []string{"*.otc.t-systems.com"}, false, false, management); err != nil {
return err
}
if err := addMachineDriver("packet", "https://github.com/packethost/docker-machine-driver-packet/releases/download/v0.1.4/docker-machine-driver-packet_linux-amd64.zip",
"2cd0b9614ab448b61b1bf73ef4738ab5", []string{"api.packet.net"}, false, false, management); err != nil {
return err
}
if err := addMachineDriver("rackspace", "local://", "", nil, false, true, management); err != nil {
return err
}
if err := addMachineDriver("softlayer", "local://", "", nil, false, true, management); err != nil {
return err
}
if err := addMachineDriver("aliyunecs", "http://machine-driver.oss-cn-shanghai.aliyuncs.com/aliyun/1.0.1/linux/amd64/docker-machine-driver-aliyunecs.tgz",
"f13d3366c5f84fcb5b5840087bddedf0", []string{"ecs.aliyuncs.com"}, false, false, management); err != nil {
return err
}
return addMachineDriver("vmwarevsphere", "local://", "", nil, true, true, management)
}
func addMachineDriver(name, url, checksum string, whitelist []string, active, builtin bool, management *config.ManagementContext) error {
lister := management.Management.NodeDrivers("").Controller().Lister()
cli := management.Management.NodeDrivers("")
m, _ := lister.Get("", name)
if m != nil {
if m.Spec.Builtin != builtin || m.Spec.URL != url || m.Spec.Checksum != checksum || m.Spec.DisplayName != name {
logrus.Infof("Updating node driver %v", name)
m.Spec.Builtin = builtin
m.Spec.URL = url
m.Spec.Checksum = checksum
m.Spec.DisplayName = name
m.Spec.WhitelistDomains = whitelist
_, err := cli.Update(m)
return err
}
return nil
}
logrus.Infof("Creating node driver %v", name)
_, err := cli.Create(&v3.NodeDriver{
ObjectMeta: v1.ObjectMeta{
Name: name,
},
Spec: v3.NodeDriverSpec{
Active: active,
Builtin: builtin,
URL: url,
DisplayName: name,
Checksum: checksum,
WhitelistDomains: whitelist,
},
})
return err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.1-rc3

搜索帮助