37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
machinedriver_data.go 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-02-26 16:34 . Disable packet
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://", "", true, true, management); err != nil {
return err
}
if err := addMachineDriver("digitalocean", "local://", "", true, true, management); err != nil {
return err
}
if err := addMachineDriver("exoscale", "local://", "", false, true, management); err != nil {
return err
}
if err := addMachineDriver("openstack", "local://", "", false, true, management); err != nil {
return err
}
if err := addMachineDriver("otc", "https://obs.otc.t-systems.com/dockermachinedriver/docker-machine-driver-otc",
"e98f246f625ca46f5e037dc29bdf00fe", false, false, management); err != nil {
return err
}
if err := addMachineDriver("packet", "https://github.com/packethost/docker-machine-driver-packet/releases/download/v0.1.5/docker-machine-driver-packet_linux-amd64.zip",
"8231136e899311d54eca0b560b1feb96", false, false, management); err != nil {
return err
}
if err := addMachineDriver("rackspace", "local://", "", false, true, management); err != nil {
return err
}
if err := addMachineDriver("softlayer", "local://", "", false, true, management); err != nil {
return err
}
return addMachineDriver("vmwarevsphere", "local://", "", true, true, management)
}
func addMachineDriver(name, url, checksum 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
_, 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,
},
})
return err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.0-alpha18

搜索帮助

0d507c66 1850385 C8b1a773 1850385