2014-06-17 17:50:42 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cloudprovider
|
|
|
|
|
2014-06-18 04:58:41 +00:00
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
2014-07-10 11:46:56 +00:00
|
|
|
// Interface is an abstract, pluggable interface for cloud providers
|
2014-06-17 17:50:42 +00:00
|
|
|
type Interface interface {
|
2014-06-18 05:28:44 +00:00
|
|
|
// TCPLoadBalancer returns a balancer interface. Also returns true if the interface is supported, false otherwise.
|
|
|
|
TCPLoadBalancer() (TCPLoadBalancer, bool)
|
|
|
|
// Instances returns an instances interface. Also returns true if the interface is supported, false otherwise.
|
|
|
|
Instances() (Instances, bool)
|
2014-07-28 22:42:08 +00:00
|
|
|
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
|
|
|
|
Zones() (Zones, bool)
|
2014-06-17 17:50:42 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 11:46:56 +00:00
|
|
|
// TCPLoadBalancer is an abstract, pluggable interface for TCP load balancers.
|
2014-06-17 17:50:42 +00:00
|
|
|
type TCPLoadBalancer interface {
|
2014-07-10 11:46:56 +00:00
|
|
|
// TCPLoadBalancerExists returns whether the specified load balancer exists.
|
2014-06-17 17:50:42 +00:00
|
|
|
// TODO: Break this up into different interfaces (LB, etc) when we have more than one type of service
|
|
|
|
TCPLoadBalancerExists(name, region string) (bool, error)
|
2014-07-10 11:46:56 +00:00
|
|
|
// CreateTCPLoadBalancer creates a new tcp load balancer.
|
2014-06-17 17:50:42 +00:00
|
|
|
CreateTCPLoadBalancer(name, region string, port int, hosts []string) error
|
2014-07-10 11:46:56 +00:00
|
|
|
// UpdateTCPLoadBalancer updates hosts under the specified load balancer.
|
2014-06-17 17:50:42 +00:00
|
|
|
UpdateTCPLoadBalancer(name, region string, hosts []string) error
|
2014-07-10 11:46:56 +00:00
|
|
|
// DeleteTCPLoadBalancer deletes a specified load balancer.
|
2014-06-17 17:50:42 +00:00
|
|
|
DeleteTCPLoadBalancer(name, region string) error
|
|
|
|
}
|
2014-06-18 04:58:41 +00:00
|
|
|
|
2014-07-10 11:46:56 +00:00
|
|
|
// Instances is an abstract, pluggable interface for sets of instances.
|
2014-06-18 04:58:41 +00:00
|
|
|
type Instances interface {
|
2014-07-10 11:46:56 +00:00
|
|
|
// IPAddress returns an IP address of the specified instance.
|
2014-06-18 04:58:41 +00:00
|
|
|
IPAddress(name string) (net.IP, error)
|
2014-07-10 11:46:56 +00:00
|
|
|
// List lists instances that match 'filter' which is a regular expression which must match the entire instance name (fqdn)
|
2014-06-25 05:27:33 +00:00
|
|
|
List(filter string) ([]string, error)
|
2014-06-18 04:58:41 +00:00
|
|
|
}
|
2014-07-28 22:42:08 +00:00
|
|
|
|
2014-08-04 16:58:10 +00:00
|
|
|
// Zone represents the location of a particular machine
|
|
|
|
type Zone struct {
|
|
|
|
FailureDomain string
|
|
|
|
Region string
|
|
|
|
}
|
|
|
|
|
2014-07-28 22:42:08 +00:00
|
|
|
// Zones is an abstract, pluggable interface for zone enumeration.
|
|
|
|
type Zones interface {
|
2014-08-04 16:58:10 +00:00
|
|
|
// GetZone returns the Zone containing the current failure zone and locality region that the program is running in
|
|
|
|
GetZone() (Zone, error)
|
2014-07-28 22:42:08 +00:00
|
|
|
}
|