Remove azure instances

This commit is contained in:
katexochen 2022-06-07 11:45:36 +02:00 committed by Paul Meyer
parent 3562345da4
commit 21127a4cdc
12 changed files with 95 additions and 228 deletions

View File

@ -15,7 +15,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure/auth"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
"github.com/edgelesssys/constellation/internal/state"
)
@ -42,8 +42,8 @@ type Client struct {
adReplicationLagCheckInterval time.Duration
adReplicationLagCheckMaxRetries int
nodes azure.Instances
coordinators azure.Instances
nodes cloudtypes.Instances
coordinators cloudtypes.Instances
name string
uid string
@ -103,8 +103,8 @@ func NewFromDefault(subscriptionID, tenantID string) (*Client, error) {
virtualMachinesAPI: &virtualMachinesClient{virtualMachinesAPI},
subscriptionID: subscriptionID,
tenantID: tenantID,
nodes: azure.Instances{},
coordinators: azure.Instances{},
nodes: cloudtypes.Instances{},
coordinators: cloudtypes.Instances{},
adReplicationLagCheckInterval: adReplicationLagCheckInterval,
adReplicationLagCheckMaxRetries: adReplicationLagCheckMaxRetries,
}, nil

View File

@ -3,7 +3,7 @@ package client
import (
"testing"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
"github.com/edgelesssys/constellation/internal/state"
"github.com/stretchr/testify/assert"
@ -18,13 +18,13 @@ func TestSetGetState(t *testing.T) {
"valid state": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -45,7 +45,7 @@ func TestSetGetState(t *testing.T) {
"missing nodes": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -67,7 +67,7 @@ func TestSetGetState(t *testing.T) {
"missing coordinator": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
@ -89,13 +89,13 @@ func TestSetGetState(t *testing.T) {
"missing name": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -116,13 +116,13 @@ func TestSetGetState(t *testing.T) {
"missing uid": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -143,13 +143,13 @@ func TestSetGetState(t *testing.T) {
"missing resource group": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -170,13 +170,13 @@ func TestSetGetState(t *testing.T) {
"missing location": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -197,13 +197,13 @@ func TestSetGetState(t *testing.T) {
"missing subscription": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -224,13 +224,13 @@ func TestSetGetState(t *testing.T) {
"missing tenant": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -251,13 +251,13 @@ func TestSetGetState(t *testing.T) {
"missing subnet": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -278,13 +278,13 @@ func TestSetGetState(t *testing.T) {
"missing network security group": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -305,13 +305,13 @@ func TestSetGetState(t *testing.T) {
"missing node scale set": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -332,13 +332,13 @@ func TestSetGetState(t *testing.T) {
"missing coordinator scale set": {
state: state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -422,13 +422,13 @@ func TestSetStateCloudProvider(t *testing.T) {
client := Client{}
stateMissingCloudProvider := state.ConstellationState{
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",
@ -447,13 +447,13 @@ func TestSetStateCloudProvider(t *testing.T) {
assert.Error(client.SetState(stateMissingCloudProvider))
stateIncorrectCloudProvider := state.ConstellationState{
CloudProvider: "incorrect",
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"0": {
PublicIP: "ip1",
PrivateIP: "ip2",
},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"0": {
PublicIP: "ip3",
PrivateIP: "ip4",

View File

@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
)
func (c *Client) CreateInstances(ctx context.Context, input CreateInstancesInput) error {
@ -127,45 +128,45 @@ func (c *Client) CreateInstancesVMs(ctx context.Context, input CreateInstancesIn
// createInstanceVM creates a single VM with a public IP address
// and a network interface.
// TODO: deprecate as soon as scale sets are available.
func (c *Client) createInstanceVM(ctx context.Context, input azure.VMInstance) (azure.Instance, error) {
func (c *Client) createInstanceVM(ctx context.Context, input azure.VMInstance) (cloudtypes.Instance, error) {
pubIPName := input.Name + "-pubIP"
pubIP, err := c.createPublicIPAddress(ctx, pubIPName)
if err != nil {
return azure.Instance{}, err
return cloudtypes.Instance{}, err
}
nicName := input.Name + "-NIC"
privIP, nicID, err := c.createNIC(ctx, nicName, *pubIP.ID)
if err != nil {
return azure.Instance{}, err
return cloudtypes.Instance{}, err
}
input.NIC = nicID
poller, err := c.virtualMachinesAPI.BeginCreateOrUpdate(ctx, c.resourceGroup, input.Name, input.Azure(), nil)
if err != nil {
return azure.Instance{}, err
return cloudtypes.Instance{}, err
}
vm, err := poller.PollUntilDone(ctx, 30*time.Second)
if err != nil {
return azure.Instance{}, err
return cloudtypes.Instance{}, err
}
if vm.Identity == nil || vm.Identity.PrincipalID == nil {
return azure.Instance{}, errors.New("virtual machine was created without system managed identity")
return cloudtypes.Instance{}, errors.New("virtual machine was created without system managed identity")
}
if err := c.assignResourceGroupRole(ctx, *vm.Identity.PrincipalID, virtualMachineContributorRoleDefinitionID); err != nil {
return azure.Instance{}, err
return cloudtypes.Instance{}, err
}
res, err := c.publicIPAddressesAPI.Get(ctx, c.resourceGroup, pubIPName, nil)
if err != nil {
return azure.Instance{}, err
return cloudtypes.Instance{}, err
}
return azure.Instance{PublicIP: *res.PublicIPAddressesClientGetResult.PublicIPAddress.Properties.IPAddress, PrivateIP: privIP}, nil
return cloudtypes.Instance{PublicIP: *res.PublicIPAddressesClientGetResult.PublicIPAddress.Properties.IPAddress, PrivateIP: privIP}, nil
}
func (c *Client) createScaleSet(ctx context.Context, input CreateScaleSetInput) error {
@ -212,8 +213,8 @@ func (c *Client) createScaleSet(ctx context.Context, input CreateScaleSetInput)
return nil
}
func (c *Client) getInstanceIPs(ctx context.Context, scaleSet string, count int) (azure.Instances, error) {
instances := azure.Instances{}
func (c *Client) getInstanceIPs(ctx context.Context, scaleSet string, count int) (cloudtypes.Instances, error) {
instances := cloudtypes.Instances{}
for i := 0; i < count; i++ {
// get public ip address
var publicIPAddress string
@ -245,7 +246,7 @@ func (c *Client) getInstanceIPs(ctx context.Context, scaleSet string, count int)
break
}
instance := azure.Instance{
instance := cloudtypes.Instance{
PrivateIP: privateIPAddress,
PublicIP: publicIPAddress,
}

View File

@ -8,7 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -38,8 +38,8 @@ func TestCreateResourceGroup(t *testing.T) {
name: "name",
uid: "uid",
resourceGroupAPI: tc.resourceGroupAPI,
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
}
if tc.wantErr {
@ -62,12 +62,12 @@ func TestTerminateResourceGroup(t *testing.T) {
subnetID: "subnet",
nodesScaleSet: "node-scale-set",
coordinatorsScaleSet: "coordinator-scale-set",
nodes: azure.Instances{
nodes: cloudtypes.Instances{
"0": {
PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1",
},
},
coordinators: azure.Instances{
coordinators: cloudtypes.Instances{
"0": {
PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1",
},
@ -214,8 +214,8 @@ func TestCreateInstances(t *testing.T) {
scaleSetsAPI: tc.scaleSetsAPI,
resourceGroupAPI: tc.resourceGroupAPI,
roleAssignmentsAPI: tc.roleAssignmentsAPI,
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
loadBalancerPubIP: "lbip",
}
@ -355,8 +355,8 @@ func TestCreateInstancesVMs(t *testing.T) {
virtualMachinesAPI: tc.virtualMachinesAPI,
resourceGroupAPI: tc.resourceGroupAPI,
roleAssignmentsAPI: tc.roleAssignmentsAPI,
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
}
if tc.wantErr {

View File

@ -5,7 +5,6 @@ import (
"errors"
"testing"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/stretchr/testify/assert"
)
@ -40,8 +39,8 @@ func TestCreateVirtualNetwork(t *testing.T) {
name: "name",
uid: "uid",
networksAPI: tc.networksAPI,
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
}
if tc.wantErr {
@ -103,8 +102,8 @@ func TestCreateSecurityGroup(t *testing.T) {
location: "location",
name: "name",
uid: "uid",
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
networkSecurityGroupsAPI: tc.networkSecurityGroupsAPI,
}
@ -153,8 +152,8 @@ func TestCreateNIC(t *testing.T) {
location: "location",
name: "name",
uid: "uid",
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
networkInterfacesAPI: tc.networkInterfacesAPI,
}
@ -202,8 +201,8 @@ func TestCreatePublicIPAddress(t *testing.T) {
location: "location",
name: "name",
uid: "uid",
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
publicIPAddressesAPI: tc.publicIPAddressesAPI,
}
@ -257,8 +256,8 @@ func TestCreateExternalLoadBalancer(t *testing.T) {
location: "location",
name: "name",
uid: "uid",
nodes: make(azure.Instances),
coordinators: make(azure.Instances),
nodes: make(cloudtypes.Instances),
coordinators: make(cloudtypes.Instances),
loadBalancersAPI: tc.loadBalancersAPI,
publicIPAddressesAPI: tc.publicIPAddressesAPI,
}

View File

@ -5,67 +5,10 @@ package azure
// TODO(katexochen): refactor into mulitcloud package.
import (
"errors"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
)
// Instance is a azure instance.
type Instance struct {
PublicIP string
PrivateIP string
}
// Instances is a map of azure Instances. The ID of an instance is used as key.
type Instances map[string]Instance
// IDs returns the IDs of all instances of the Constellation.
func (i Instances) IDs() []string {
var ids []string
for id := range i {
ids = append(ids, id)
}
return ids
}
// PublicIPs returns the public IPs of all the instances of the Constellation.
func (i Instances) PublicIPs() []string {
var ips []string
for _, instance := range i {
ips = append(ips, instance.PublicIP)
}
return ips
}
// PrivateIPs returns the private IPs of all the instances of the Constellation.
func (i Instances) PrivateIPs() []string {
var ips []string
for _, instance := range i {
ips = append(ips, instance.PrivateIP)
}
return ips
}
// GetOne return anyone instance out of the instances and its ID.
func (i Instances) GetOne() (string, Instance, error) {
for id, instance := range i {
return id, instance, nil
}
return "", Instance{}, errors.New("map is empty")
}
// GetOthers returns all instances but the one with the handed ID.
func (i Instances) GetOthers(id string) Instances {
others := make(Instances)
for key, instance := range i {
if key != id {
others[key] = instance
}
}
return others
}
// TODO: deprecate as soon as scale sets are available.
type VMInstance struct {
Name string

View File

@ -1,71 +0,0 @@
package azure
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIDs(t *testing.T) {
assert := assert.New(t)
testState := testInstances()
wantIDs := []string{"id-9", "id-10", "id-11", "id-12"}
assert.ElementsMatch(wantIDs, testState.IDs())
}
func TestPublicIPs(t *testing.T) {
assert := assert.New(t)
testState := testInstances()
wantIPs := []string{"192.0.2.1", "192.0.2.3", "192.0.2.5", "192.0.2.7"}
assert.ElementsMatch(wantIPs, testState.PublicIPs())
}
func TestPrivateIPs(t *testing.T) {
assert := assert.New(t)
testState := testInstances()
wantIPs := []string{"192.0.2.2", "192.0.2.4", "192.0.2.6", "192.0.2.8"}
assert.ElementsMatch(wantIPs, testState.PrivateIPs())
}
func TestGetOne(t *testing.T) {
assert := assert.New(t)
testState := testInstances()
id, instance, err := testState.GetOne()
assert.NoError(err)
assert.Contains(testState, id)
assert.Equal(testState[id], instance)
}
func TestGetOthers(t *testing.T) {
assert := assert.New(t)
testCases := testInstances().IDs()
for _, id := range testCases {
others := testInstances().GetOthers(id)
assert.NotContains(others, id)
wantInstances := testInstances()
delete(wantInstances, id)
assert.ElementsMatch(others.IDs(), wantInstances.IDs())
}
}
func testInstances() Instances {
return Instances{
"id-9": {
PublicIP: "192.0.2.1",
PrivateIP: "192.0.2.2",
},
"id-10": {
PublicIP: "192.0.2.3",
PrivateIP: "192.0.2.4",
},
"id-11": {
PublicIP: "192.0.2.5",
PrivateIP: "192.0.2.6",
},
"id-12": {
PublicIP: "192.0.2.7",
PrivateIP: "192.0.2.8",
},
}
}

View File

@ -5,7 +5,6 @@ import (
"errors"
"strconv"
"github.com/edgelesssys/constellation/cli/azure"
azurecl "github.com/edgelesssys/constellation/cli/azure/client"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
gcpcl "github.com/edgelesssys/constellation/cli/gcp/client"
@ -14,8 +13,8 @@ import (
)
type fakeAzureClient struct {
nodes azure.Instances
coordinators azure.Instances
nodes cloudtypes.Instances
coordinators cloudtypes.Instances
resourceGroup string
name string
@ -91,30 +90,30 @@ func (c *fakeAzureClient) CreateSecurityGroup(ctx context.Context, input azurecl
func (c *fakeAzureClient) CreateInstances(ctx context.Context, input azurecl.CreateInstancesInput) error {
c.coordinatorsScaleSet = "coordinators-scale-set"
c.nodesScaleSet = "nodes-scale-set"
c.nodes = make(azure.Instances)
c.nodes = make(cloudtypes.Instances)
for i := 0; i < input.CountNodes; i++ {
id := "id-" + strconv.Itoa(i)
c.nodes[id] = azure.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
c.nodes[id] = cloudtypes.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
}
c.coordinators = make(azure.Instances)
c.coordinators = make(cloudtypes.Instances)
for i := 0; i < input.CountCoordinators; i++ {
id := "id-" + strconv.Itoa(i)
c.coordinators[id] = azure.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
c.coordinators[id] = cloudtypes.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
}
return nil
}
// TODO: deprecate as soon as scale sets are available.
func (c *fakeAzureClient) CreateInstancesVMs(ctx context.Context, input azurecl.CreateInstancesInput) error {
c.nodes = make(azure.Instances)
c.nodes = make(cloudtypes.Instances)
for i := 0; i < input.CountNodes; i++ {
id := "id-" + strconv.Itoa(i)
c.nodes[id] = azure.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
c.nodes[id] = cloudtypes.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
}
c.coordinators = make(azure.Instances)
c.coordinators = make(cloudtypes.Instances)
for i := 0; i < input.CountCoordinators; i++ {
id := "id-" + strconv.Itoa(i)
c.coordinators[id] = azure.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
c.coordinators[id] = cloudtypes.Instance{PublicIP: "192.0.2.1", PrivateIP: "192.0.2.1"}
}
return nil
}

View File

@ -6,7 +6,6 @@ import (
"errors"
"testing"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
"github.com/edgelesssys/constellation/internal/config"
@ -42,11 +41,11 @@ func TestCreator(t *testing.T) {
wantAzureState := state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-2": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},

View File

@ -5,7 +5,6 @@ import (
"errors"
"testing"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/edgelesssys/constellation/internal/cloud/cloudprovider"
"github.com/edgelesssys/constellation/internal/state"
@ -36,11 +35,11 @@ func TestTerminator(t *testing.T) {
someAzureState := func() state.ConstellationState {
return state.ConstellationState{
CloudProvider: cloudprovider.Azure.String(),
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureResourceGroup: "group",

View File

@ -10,7 +10,6 @@ import (
"testing"
"time"
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/edgelesssys/constellation/cli/ec2"
"github.com/edgelesssys/constellation/internal/constants"
@ -46,11 +45,11 @@ func TestInitialize(t *testing.T) {
}
testAzureState := state.ConstellationState{
CloudProvider: "Azure",
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureResourceGroup: "test",
@ -524,11 +523,11 @@ func TestAutoscaleFlag(t *testing.T) {
}
testAzureState := state.ConstellationState{
CloudProvider: "azure",
AzureNodes: azure.Instances{
AzureNodes: cloudtypes.Instances{
"id-0": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
"id-1": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureCoordinators: azure.Instances{
AzureCoordinators: cloudtypes.Instances{
"id-c": {PrivateIP: "192.0.2.1", PublicIP: "192.0.2.1"},
},
AzureResourceGroup: "test",

View File

@ -1,7 +1,6 @@
package state
import (
"github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/cloud/cloudtypes"
"github.com/edgelesssys/constellation/cli/ec2"
)
@ -29,17 +28,17 @@ type ConstellationState struct {
GCPRegion string `json:"gcpregion,omitempty"`
GCPServiceAccount string `json:"gcpserviceaccount,omitempty"`
AzureNodes azure.Instances `json:"azurenodes,omitempty"`
AzureCoordinators azure.Instances `json:"azurecoordinators,omitempty"`
AzureResourceGroup string `json:"azureresourcegroup,omitempty"`
AzureLocation string `json:"azurelocation,omitempty"`
AzureSubscription string `json:"azuresubscription,omitempty"`
AzureTenant string `json:"azuretenant,omitempty"`
AzureSubnet string `json:"azuresubnet,omitempty"`
AzureNetworkSecurityGroup string `json:"azurenetworksecuritygroup,omitempty"`
AzureNodesScaleSet string `json:"azurenodesscaleset,omitempty"`
AzureCoordinatorsScaleSet string `json:"azurecoordinatorsscaleset,omitempty"`
AzureADAppObjectID string `json:"azureadappobjectid,omitempty"`
AzureNodes cloudtypes.Instances `json:"azurenodes,omitempty"`
AzureCoordinators cloudtypes.Instances `json:"azurecoordinators,omitempty"`
AzureResourceGroup string `json:"azureresourcegroup,omitempty"`
AzureLocation string `json:"azurelocation,omitempty"`
AzureSubscription string `json:"azuresubscription,omitempty"`
AzureTenant string `json:"azuretenant,omitempty"`
AzureSubnet string `json:"azuresubnet,omitempty"`
AzureNetworkSecurityGroup string `json:"azurenetworksecuritygroup,omitempty"`
AzureNodesScaleSet string `json:"azurenodesscaleset,omitempty"`
AzureCoordinatorsScaleSet string `json:"azurecoordinatorsscaleset,omitempty"`
AzureADAppObjectID string `json:"azureadappobjectid,omitempty"`
QEMUNodes cloudtypes.Instances `json:"qemunodes,omitempty"`
QEMUCoordinators cloudtypes.Instances `json:"qemucoordinators,omitempty"`