github.com/coreos/mantle@v0.13.0/platform/machine/esx/flight.go (about) 1 // Copyright 2016 CoreOS, Inc. 2 // Copyright 2018 Red Hat 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 package esx 17 18 import ( 19 "github.com/coreos/pkg/capnslog" 20 21 "github.com/coreos/mantle/platform" 22 "github.com/coreos/mantle/platform/api/esx" 23 ) 24 25 const ( 26 Platform platform.Name = "esx" 27 ) 28 29 var ( 30 plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "platform/machine/esx") 31 ) 32 33 type flight struct { 34 *platform.BaseFlight 35 api *esx.API 36 } 37 38 // NewFlight creates an instance of a Flight suitable for spawning 39 // clusters on VMware ESXi vSphere platform. 40 func NewFlight(opts *esx.Options) (platform.Flight, error) { 41 api, err := esx.New(opts) 42 if err != nil { 43 return nil, err 44 } 45 46 bf, err := platform.NewBaseFlight(opts.Options, Platform, "") 47 if err != nil { 48 return nil, err 49 } 50 51 ef := &flight{ 52 BaseFlight: bf, 53 api: api, 54 } 55 56 return ef, nil 57 } 58 59 // NewCluster creates an instance of a Cluster suitable for spawning 60 // instances on VMware ESXi vSphere platform. 61 func (ef *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, error) { 62 bc, err := platform.NewBaseCluster(ef.BaseFlight, rconf) 63 if err != nil { 64 return nil, err 65 } 66 67 ec := &cluster{ 68 BaseCluster: bc, 69 flight: ef, 70 } 71 72 ef.AddCluster(ec) 73 74 return ec, nil 75 }