//
// SPDX-License-Identifier: AGPL-3.0
-package cloud
+package azure
import (
"context"
"sync"
"time"
+ "git.curoverse.com/arvados.git/lib/cloud"
"git.curoverse.com/arvados.git/sdk/go/arvados"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network"
logger logrus.FieldLogger
}
-func NewAzureInstanceSet(config map[string]interface{}, dispatcherID InstanceSetID, logger logrus.FieldLogger) (prv InstanceSet, err error) {
+func NewAzureInstanceSet(config map[string]interface{}, dispatcherID cloud.InstanceSetID, logger logrus.FieldLogger) (prv cloud.InstanceSet, err error) {
azcfg := AzureInstanceSetConfig{}
if err = mapstructure.Decode(config, &azcfg); err != nil {
return nil, err
func (az *AzureInstanceSet) Create(
instanceType arvados.InstanceType,
- imageId ImageID,
- newTags InstanceTags,
- publicKey ssh.PublicKey) (Instance, error) {
+ imageId cloud.ImageID,
+ newTags cloud.InstanceTags,
+ publicKey ssh.PublicKey) (cloud.Instance, error) {
az.stopWg.Add(1)
defer az.stopWg.Done()
}, nil
}
-func (az *AzureInstanceSet) Instances(InstanceTags) ([]Instance, error) {
+func (az *AzureInstanceSet) Instances(cloud.InstanceTags) ([]cloud.Instance, error) {
az.stopWg.Add(1)
defer az.stopWg.Done()
return nil, WrapAzureError(err)
}
- instances := make([]Instance, 0)
+ instances := make([]cloud.Instance, 0)
for ; result.NotDone(); err = result.Next() {
if err != nil {
vm compute.VirtualMachine
}
-func (ai *AzureInstance) ID() InstanceID {
- return InstanceID(*ai.vm.ID)
+func (ai *AzureInstance) ID() cloud.InstanceID {
+ return cloud.InstanceID(*ai.vm.ID)
}
func (ai *AzureInstance) String() string {
return string(ai.vm.VirtualMachineProperties.HardwareProfile.VMSize)
}
-func (ai *AzureInstance) SetTags(newTags InstanceTags) error {
+func (ai *AzureInstance) SetTags(newTags cloud.InstanceTags) error {
ai.provider.stopWg.Add(1)
defer ai.provider.stopWg.Done()
return nil
}
-func (ai *AzureInstance) Tags() InstanceTags {
+func (ai *AzureInstance) Tags() cloud.InstanceTags {
tags := make(map[string]string)
for k, v := range ai.vm.Tags {
// delete_dangling_resources_after: 20
// authorized_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLQS1ExT2+WjA0d/hntEAyAtgeN1W2ik2QX8c2zO6HjlPHWXL92r07W0WMuDib40Pcevpi1BXeBWXA9ZB5KKMJB+ukaAu22KklnQuUmNvk6ZXnPKSkGxuCYvPQb08WhHf3p1VxiKfP3iauedBDM4x9/bkJohlBBQiFXzNUcQ+a6rKiMzmJN2gbL8ncyUzc+XQ5q4JndTwTGtOlzDiGOc9O4z5Dd76wtAVJneOuuNpwfFRVHThpJM6VThpCZOnl8APaceWXKeuwOuCae3COZMz++xQfxOfZ9Z8aIwo+TlQhsRaNfZ4Vjrop6ej8dtfZtgUFKfbXEOYaHrGrWGotFDTD example@example"
-package cloud
+package azure
import (
"context"
"os"
"time"
+ "git.curoverse.com/arvados.git/lib/cloud"
"git.curoverse.com/arvados.git/sdk/go/arvados"
"git.curoverse.com/arvados.git/sdk/go/config"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute"
var live = flag.String("live-azure-cfg", "", "Test with real azure API, provide config file")
-func GetInstanceSet() (InstanceSet, ImageID, arvados.Cluster, error) {
+func GetInstanceSet() (cloud.InstanceSet, cloud.ImageID, arvados.Cluster, error) {
cluster := arvados.Cluster{
InstanceTypes: arvados.InstanceTypeMap(map[string]arvados.InstanceType{
"tiny": arvados.InstanceType{
cfg := make(map[string]interface{})
err := config.LoadFile(&cfg, *live)
if err != nil {
- return nil, ImageID(""), cluster, err
+ return nil, cloud.ImageID(""), cluster, err
}
ap, err := NewAzureInstanceSet(cfg, "test123", logrus.StandardLogger())
- return ap, ImageID(cfg["image"].(string)), cluster, err
+ return ap, cloud.ImageID(cfg["image"].(string)), cluster, err
} else {
ap := AzureInstanceSet{
azconfig: AzureInstanceSetConfig{
ap.ctx, ap.stopFunc = context.WithCancel(context.Background())
ap.vmClient = &VirtualMachinesClientStub{}
ap.netClient = &InterfacesClientStub{}
- return &ap, ImageID("blob"), cluster, nil
+ return &ap, cloud.ImageID("blob"), cluster, nil
}
}
},
}
wrapped := WrapAzureError(retryError)
- _, ok := wrapped.(RateLimitError)
+ _, ok := wrapped.(cloud.RateLimitError)
c.Check(ok, check.Equals, true)
quotaError := autorest.DetailedError{
},
}
wrapped = WrapAzureError(quotaError)
- _, ok = wrapped.(QuotaError)
+ _, ok = wrapped.(cloud.QuotaError)
c.Check(ok, check.Equals, true)
}
}
}
-func SetupSSHClient(c *check.C, inst Instance) (*ssh.Client, error) {
+func SetupSSHClient(c *check.C, inst cloud.Instance) (*ssh.Client, error) {
addr := inst.Address() + ":2222"
if addr == "" {
return nil, errors.New("instance has no address")