-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tinkerbell ci test harness to e2e test framework
- Loading branch information
1 parent
6a20e4b
commit 1e8dcbc
Showing
12 changed files
with
437 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
|
||
ec2: | ||
amiId: ami-00c71c2441b729da0 | ||
subnetId: subnet-0fd4b6ba7c9e17b5f | ||
|
||
vSphere: | ||
url: https://10.61.250.74 | ||
insecure: True | ||
library: eks-a-templates | ||
template: eks-a-admin-v0.0.0-e920823-20220509234801 | ||
datacenter: Datacenter | ||
datastore: datastore2 | ||
resourcePool: TestResourcePool | ||
network: VM Network | ||
folder: gwesterf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ssm | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/ssm" | ||
) | ||
|
||
type ActivationInfo struct { | ||
ActivationCode string | ||
ActivationID string | ||
} | ||
|
||
func CreateActivation(session *session.Session, instanceName, role string) (*ActivationInfo, error) { | ||
s := ssm.New(session) | ||
|
||
request := ssm.CreateActivationInput{ | ||
DefaultInstanceName: &instanceName, | ||
Description: &instanceName, | ||
IamRole: &role, | ||
} | ||
|
||
result, err := s.CreateActivation(&request) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to activate ssm instance %s: %v", instanceName, err) | ||
} | ||
|
||
return &ActivationInfo{ActivationCode: *result.ActivationCode, ActivationID: *result.ActivationId}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ssm | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/ssm" | ||
) | ||
|
||
func GetInstanceByActivationId(session *session.Session, id string) (*ssm.InstanceInformation, error) { | ||
s := ssm.New(session) | ||
instanceActivationIdKey := "ActivationIds" | ||
input := ssm.DescribeInstanceInformationInput{ | ||
Filters: []*ssm.InstanceInformationStringFilter{ | ||
{Key: &instanceActivationIdKey, Values: []*string{&id}}, | ||
}, | ||
} | ||
|
||
output, err := s.DescribeInstanceInformation(&input) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to describe ssm instance %s: %v", id, err) | ||
} | ||
|
||
infoList := output.InstanceInformationList | ||
|
||
if len(infoList) == 0 { | ||
return nil, fmt.Errorf("no ssm instance with name %s: %v", id, err) | ||
} | ||
|
||
return infoList[0], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package vsphere | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/aws/eks-anywhere/pkg/executables" | ||
"github.com/aws/eks-anywhere/pkg/filewriter" | ||
) | ||
|
||
type OVFDeployOptions struct { | ||
Name string `json:"Name"` | ||
PowerOn bool `json:"PowerOn"` | ||
DiskProvisioning string `json:"DiskProvisioning"` | ||
WaitForIP bool `json:"WaitForIP"` | ||
NetworkMappings []NetworkMapping `json:"NetworkMapping"` | ||
Annotation string `json:"Annotation"` | ||
PropertyMapping []OVFProperty `json:"PropertyMapping"` | ||
InjectOvfEnv bool `json:"InjectOvfEnv"` | ||
} | ||
|
||
type OVFProperty struct { | ||
Key string `json:"Key"` | ||
Value string `json:"Value"` | ||
} | ||
|
||
type NetworkMapping struct { | ||
Name string `json:"Name"` | ||
Network string `json:"Network"` | ||
} | ||
|
||
func DeployTemplate(library, templateName, vmName, deployFolder, datacenter, datastore, resourcePool string, opts OVFDeployOptions) error { | ||
context := context.Background() | ||
executableBuilder, close, err := executables.NewExecutableBuilder(context, executables.DefaultEksaImage()) | ||
if err != nil { | ||
return fmt.Errorf("unable to initialize executables: %v", err) | ||
} | ||
|
||
defer close.CheckErr(context) | ||
tmpWriter, _ := filewriter.NewWriter(vmName) | ||
govc := executableBuilder.BuildGovcExecutable(tmpWriter) | ||
defer govc.Close(context) | ||
|
||
deployOptions, err := json.Marshal(opts) | ||
if err != nil { | ||
return fmt.Errorf("failed to marshall vm deployment options: %v", err) | ||
} | ||
|
||
// deploy template | ||
if err := govc.DeployTemplate(context, library, templateName, vmName, deployFolder, datacenter, datastore, resourcePool, deployOptions); err != nil { | ||
return fmt.Errorf("failed to deploy vm from library template: %v", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.