implement instancesV2

This commit is contained in:
gongguan 2020-06-20 17:23:05 +08:00
parent 531be1d28e
commit 22e083f132
7 changed files with 40 additions and 0 deletions

View File

@ -645,6 +645,10 @@ func (testcase *testcase) Instances() (cloudprovider.Instances, bool) {
return &instances{testcase.instanceID}, true
}
func (testcase *testcase) InstancesV2() (cloudprovider.InstancesV2, bool) {
return nil, false
}
func (testcase *testcase) DisksAreAttached(instanceID string, volumeIDs []string) (map[string]bool, error) {
expected := &testcase.disksAreAttached

View File

@ -59,6 +59,7 @@ type Cloud struct {
Exists bool
Err error
EnableInstancesV2 bool
ExistsByProviderID bool
ErrByProviderID error
NodeShutdown bool
@ -152,6 +153,16 @@ func (f *Cloud) Instances() (cloudprovider.Instances, bool) {
return f, true
}
// InstancesV2 returns a fake implementation of InstancesV2.
//
// Actually it just returns f itself.
func (f *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
if f.EnableInstancesV2 {
return f, true
}
return nil, false
}
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
func (f *Cloud) Zones() (cloudprovider.Zones, bool) {
return f, true

View File

@ -1394,6 +1394,11 @@ func (c *Cloud) Instances() (cloudprovider.Instances, bool) {
return c, true
}
// InstancesV2 returns an implementation of InstancesV2 for Amazon Web Services.
func (c *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
return nil, false
}
// Zones returns an implementation of Zones for Amazon Web Services.
func (c *Cloud) Zones() (cloudprovider.Zones, bool) {
return c, true

View File

@ -659,6 +659,11 @@ func (az *Cloud) Instances() (cloudprovider.Instances, bool) {
return az, true
}
// InstancesV2 returns an instancesV2 interface. Also returns true if the interface is supported, false otherwise.
func (az *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
return nil, false
}
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
func (az *Cloud) Zones() (cloudprovider.Zones, bool) {
return az, true

View File

@ -659,6 +659,11 @@ func (g *Cloud) Instances() (cloudprovider.Instances, bool) {
return g, true
}
// InstancesV2 returns an implementation of InstancesV2 for Google Compute Engine.
func (g *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
return nil, false
}
// Zones returns an implementation of Zones for Google Compute Engine.
func (g *Cloud) Zones() (cloudprovider.Zones, bool) {
return g, true

View File

@ -62,6 +62,11 @@ func (os *OpenStack) Instances() (cloudprovider.Instances, bool) {
}, true
}
// InstancesV2 returns an implementation of InstancesV2 for OpenStack.
func (os *OpenStack) InstancesV2() (cloudprovider.InstancesV2, bool) {
return nil, false
}
// CurrentNodeName implements Instances.CurrentNodeName
// Note this is *not* necessarily the same as hostname.
func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) {

View File

@ -560,6 +560,11 @@ func (vs *VSphere) Instances() (cloudprovider.Instances, bool) {
return vs, true
}
// InstancesV2 returns an implementation of InstancesV2 for vSphere.
func (vs *VSphere) InstancesV2() (cloudprovider.InstancesV2, bool) {
return nil, false
}
func getLocalIP() ([]v1.NodeAddress, error) {
// hashtable with VMware-allocated OUIs for MAC filtering
// List of official OUIs: http://standards-oui.ieee.org/oui.txt