mirror of https://github.com/kubernetes/kops.git
Sample vsphere tasks added
This commit is contained in:
parent
82f9f0668d
commit
333e1aee40
|
|
@ -0,0 +1,44 @@
|
|||
package vspheremodel
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/pkg/model"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/vspheretasks"
|
||||
)
|
||||
|
||||
// AutoscalingGroupModelBuilder configures AutoscalingGroup objects
|
||||
type AutoscalingGroupModelBuilder struct {
|
||||
*VSphereModelContext
|
||||
|
||||
BootstrapScript *model.BootstrapScript
|
||||
}
|
||||
|
||||
var _ fi.ModelBuilder = &AutoscalingGroupModelBuilder{}
|
||||
|
||||
func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||
glog.Warning("AutoscalingGroupModelBuilder.Build not implemented for vsphere")
|
||||
for _, ig := range b.InstanceGroups {
|
||||
name := b.AutoscalingGroupName(ig)
|
||||
createVmTask := &vspheretasks.VirtualMachine{
|
||||
Name: &name,
|
||||
VMTemplateName: fi.String("dummyVmTemplate"),
|
||||
}
|
||||
c.AddTask(createVmTask)
|
||||
|
||||
attachISOTaskName := "AttachISO-" + name
|
||||
attachISOTask := &vspheretasks.AttachISO{
|
||||
Name: &attachISOTaskName,
|
||||
VM: createVmTask,
|
||||
}
|
||||
c.AddTask(attachISOTask)
|
||||
|
||||
powerOnTaskName := "PowerON-" + name
|
||||
powerOnTask := &vspheretasks.VMPowerOn{
|
||||
Name: &powerOnTaskName,
|
||||
AttachISO: attachISOTask,
|
||||
}
|
||||
c.AddTask(powerOnTask)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package vspheremodel
|
||||
|
||||
import "k8s.io/kops/pkg/model"
|
||||
|
||||
type VSphereModelContext struct {
|
||||
*model.KopsModelContext
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package vspheremodel
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Do we need this model builder?
|
||||
|
||||
// AutoscalingGroupModelBuilder configures AutoscalingGroup objects
|
||||
type VirtualMachineModelBuilder struct {
|
||||
*VSphereModelContext
|
||||
}
|
||||
|
||||
func (b *VirtualMachineModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||
fmt.Print("In VirtualMachineModelBuilder.Build function!!")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
KubeAPIServer:
|
||||
CloudProvider: vsphere
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package vsphere
|
||||
|
||||
import "k8s.io/kops/upup/pkg/fi"
|
||||
|
||||
type VSphereAPITarget struct {
|
||||
Cloud *VSphereCloud
|
||||
}
|
||||
|
||||
var _ fi.Target = &VSphereAPITarget{}
|
||||
|
||||
func NewVSphereAPITarget(cloud *VSphereCloud) *VSphereAPITarget {
|
||||
return &VSphereAPITarget{
|
||||
Cloud: cloud,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *VSphereAPITarget) Finish(taskMap map[string]fi.Task) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *VSphereAPITarget) ProcessDeletions() bool {
|
||||
return true
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package vsphere
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kubernetes/federation/pkg/dnsprovider"
|
||||
"github.com/golang/glog"
|
||||
k8sroute53 "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/aws/route53"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type VSphereCloud struct {
|
||||
// dummy field
|
||||
name string
|
||||
Region string
|
||||
}
|
||||
|
||||
var _ fi.Cloud = &VSphereCloud{}
|
||||
|
||||
func (c *VSphereCloud) ProviderID() fi.CloudProviderID {
|
||||
return fi.CloudProviderVSphere
|
||||
}
|
||||
|
||||
func (c *VSphereCloud) DNS() (dnsprovider.Interface, error) {
|
||||
glog.Warning("DNS() not implemented on VSphere")
|
||||
provider, err := dnsprovider.GetDnsProvider(k8sroute53.ProviderName, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error building (k8s) DNS provider: %v", err)
|
||||
}
|
||||
return provider, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *VSphereCloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
|
||||
glog.Warningf("FindVPCInfo not (yet) implemented on VSphere")
|
||||
return nil, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package vspheretasks
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/vsphere"
|
||||
)
|
||||
|
||||
// AttachISO represents the cloud-init ISO file attached to a VMware VM
|
||||
//go:generate fitask -type=AttachISO
|
||||
type AttachISO struct {
|
||||
Name *string
|
||||
VM *VirtualMachine
|
||||
}
|
||||
|
||||
var _ fi.HasName = &AttachISO{}
|
||||
|
||||
// GetName returns the Name of the object, implementing fi.HasName
|
||||
func (o *AttachISO) GetName() *string {
|
||||
return o.Name
|
||||
}
|
||||
|
||||
// SetName sets the Name of the object, implementing fi.SetName
|
||||
func (o *AttachISO) SetName(name string) {
|
||||
o.Name = &name
|
||||
}
|
||||
|
||||
func (e *AttachISO) Run(c *fi.Context) error {
|
||||
glog.Info("AttachISO.Run invoked!")
|
||||
return fi.DefaultDeltaRunMethod(e, c)
|
||||
}
|
||||
|
||||
func (e *AttachISO) Find(c *fi.Context) (*AttachISO, error) {
|
||||
glog.Info("AttachISO.Find invoked!")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (_ *AttachISO) CheckChanges(a, e, changes *AttachISO) error {
|
||||
glog.Info("AttachISO.CheckChanges invoked!")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ *AttachISO) RenderVC(t *vsphere.VSphereAPITarget, a, e, changes *AttachISO) error {
|
||||
glog.Info("AttachISO.RenderVC invoked!")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package vspheretasks
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/vsphere"
|
||||
)
|
||||
|
||||
// VirtualMachine represents a VMware VM
|
||||
//go:generate fitask -type=VirtualMachine
|
||||
type VirtualMachine struct {
|
||||
Name *string
|
||||
VMTemplateName *string
|
||||
}
|
||||
|
||||
var _ fi.CompareWithID = &VirtualMachine{}
|
||||
var _ fi.HasName = &VirtualMachine{}
|
||||
|
||||
// GetName returns the Name of the object, implementing fi.HasName
|
||||
func (o *VirtualMachine) GetName() *string {
|
||||
return o.Name
|
||||
}
|
||||
|
||||
// SetName sets the Name of the object, implementing fi.SetName
|
||||
func (o *VirtualMachine) SetName(name string) {
|
||||
o.Name = &name
|
||||
}
|
||||
|
||||
// String is the stringer function for the task, producing readable output using fi.TaskAsString
|
||||
func (o *VirtualMachine) String() string {
|
||||
return fi.TaskAsString(o)
|
||||
}
|
||||
|
||||
func (e *VirtualMachine) CompareWithID() *string {
|
||||
glog.Info("VirtualMachine.CompareWithID invoked!")
|
||||
return e.Name
|
||||
}
|
||||
|
||||
func (e *VirtualMachine) Find(c *fi.Context) (*VirtualMachine, error) {
|
||||
glog.Info("VirtualMachine.Find invoked!")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (e *VirtualMachine) Run(c *fi.Context) error {
|
||||
glog.Info("VirtualMachine.Run invoked!")
|
||||
return fi.DefaultDeltaRunMethod(e, c)
|
||||
}
|
||||
|
||||
func (_ *VirtualMachine) CheckChanges(a, e, changes *VirtualMachine) error {
|
||||
glog.Info("VirtualMachine.CheckChanges invoked!")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ *VirtualMachine) RenderVSphere(t *vsphere.VSphereAPITarget, a, e, changes *VirtualMachine) error {
|
||||
glog.Info("VirtualMachine.RenderVSphere invoked!")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package vspheretasks
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/vsphere"
|
||||
)
|
||||
|
||||
// VMPowerOn powers on a VMware VM
|
||||
//go:generate fitask -type=VMPowerOn
|
||||
type VMPowerOn struct {
|
||||
Name *string
|
||||
AttachISO *AttachISO
|
||||
}
|
||||
|
||||
var _ fi.HasName = &VMPowerOn{}
|
||||
|
||||
// GetName returns the Name of the object, implementing fi.HasName
|
||||
func (o *VMPowerOn) GetName() *string {
|
||||
return o.Name
|
||||
}
|
||||
|
||||
// SetName sets the Name of the object, implementing fi.SetName
|
||||
func (o *VMPowerOn) SetName(name string) {
|
||||
o.Name = &name
|
||||
}
|
||||
|
||||
func (e *VMPowerOn) Run(c *fi.Context) error {
|
||||
glog.Info("VMPowerOn.Run invoked!")
|
||||
return fi.DefaultDeltaRunMethod(e, c)
|
||||
}
|
||||
|
||||
func (e *VMPowerOn) Find(c *fi.Context) (*VMPowerOn, error) {
|
||||
glog.Info("VMPowerOn.Find invoked!")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (_ *VMPowerOn) CheckChanges(a, e, changes *VMPowerOn) error {
|
||||
glog.Info("VMPowerOn.CheckChanges invoked!")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ *VMPowerOn) RenderVC(t *vsphere.VSphereAPITarget, a, e, changes *VMPowerOn) error {
|
||||
glog.Info("VMPowerOn.RenderVC invoked!")
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue