Documentation ¶
Index ¶
- Constants
- func GetMyIp() (string, error)
- type AwsProvider
- func (a *AwsProvider) CreateWindowsVM() (windowsVM types.WindowsVM, err error)
- func (a *AwsProvider) CreateWindowsVMWithPrivateSubnet() (windowsVM types.WindowsVM, err error)
- func (a *AwsProvider) DeleteSG(sgID string) error
- func (a *AwsProvider) DestroyWindowsVM(instanceID string) error
- func (a *AwsProvider) DestroyWindowsVMs() error
- func (a *AwsProvider) GetClusterWorkerSGID(infraID string) (string, error)
- func (a *AwsProvider) GetIAMWorkerRole(infraID string) (*ec2.IamInstanceProfileSpecification, error)
- func (a *AwsProvider) GetInfraID() (string, error)
- func (a *AwsProvider) GetInstance(instanceID string) (*ec2.Instance, error)
- func (a *AwsProvider) GetPassword(instanceID string) (string, error)
- func (a *AwsProvider) GetPrivateIP(instanceID string) (string, error)
- func (a *AwsProvider) GetPublicIP(instanceID string) (string, error)
- func (a *AwsProvider) GetVPCByInfrastructure(infraID string) (*ec2.Vpc, error)
- func (a *AwsProvider) IsVMRunning(instanceID string) error
- func (a *AwsProvider) TerminateInstance(instanceID string) error
Constants ¶
const (
// Winrm port for https request
WINRM_PORT = 5986
)
Constant value
Variables ¶
This section is empty.
Functions ¶
func GetMyIp ¶
GetMyIp get the external IP of user's machine from https://checkip.amazonaws.com and returns an address or an error. The 'checkip' service is maintained by Amazon. This function is exposed for testing purpose.
Types ¶
type AwsProvider ¶
type AwsProvider struct { // A client for EC2. EC2 ec2iface.EC2API // A client for IAM. IAM *iam.IAM // contains filtered or unexported fields }
awsProvider is a provider specific struct which contains clients for EC2, IAM, and the existing OpenShift cluster that is running on EC2. This is an implementation of the Cloud interface. TODO: Move this into top level `pkg/types` so that we will have all the types needed across all cloud providers instead of relying on importing individual packages
func New ¶
func New(openShiftClient *client.OpenShift, imageID, instanceType, sshKey, credentialPath, credentialAccountID, resourceTrackerDir, privateKeyPath string) (*AwsProvider, error)
New returns the AWS implementations of the Cloud interface with AWS session in the same region as OpenShift Cluster. credentialPath is the file path the AWS credentials file. credentialAccountID is the account name the user uses to create VM instance. The credentialAccountID should exist in the AWS credentials file pointing at one specific credential. resourceTrackerDir is where created instance and security group information is stored. privateKeyPath is the path to private key which is used to decrypt the password for the Windows VM created
func (*AwsProvider) CreateWindowsVM ¶
func (a *AwsProvider) CreateWindowsVM() (windowsVM types.WindowsVM, err error)
CreateWindowsVM takes in imageId, instanceType, and sshKey name to create a Windows instance under the same VPC as the existing OpenShift cluster with the following: - attaches existing cloud-specific cluster worker security group and IAM to gain the same access as the linux workers, - uses public subnet, - attaches public ip to allow external access, - adds a security group that allows traffic from within the VPC range and RDP access from user's IP, - uses given image id, instance type, and sshKey name - creates a unique name tag for the instance using the same prefix as the OpenShift cluster name, and - logs id and security group information of the created instance in 'windows-node-installer.json' file at the resourceTrackerDir. On success, the function outputs RDP access information in the commandline interface. It also returns the the Windows VM Object to interact with using SSH, Winrm etc.
func (*AwsProvider) CreateWindowsVMWithPrivateSubnet ¶
func (a *AwsProvider) CreateWindowsVMWithPrivateSubnet() (windowsVM types.WindowsVM, err error)
CreateWindowsVMWithPrivateSubnet creates a WindowsVM within a private subnet of the OpenShift cluster. A public IP will not be associated with the WindowsVM created by this method.
func (*AwsProvider) DeleteSG ¶
func (a *AwsProvider) DeleteSG(sgID string) error
DeleteSG checks if security group is in use, deletes it if not in use based on sgID, and returns error if fails. This function is exposed for testing purpose.
func (*AwsProvider) DestroyWindowsVM ¶
func (a *AwsProvider) DestroyWindowsVM(instanceID string) error
DestroyWindowsVM destroys the given Windows VM
func (*AwsProvider) DestroyWindowsVMs ¶
func (a *AwsProvider) DestroyWindowsVMs() error
DestroyWindowsVMs destroys the created instances and security groups on AWS specified in the 'windows-node-installer.json' file. The security groups still in use by other instances will not be deleted.
func (*AwsProvider) GetClusterWorkerSGID ¶
func (a *AwsProvider) GetClusterWorkerSGID(infraID string) (string, error)
GetClusterWorkerSGID gets worker security group id from the existing cluster or returns an error. This function is exposed for testing purpose.
func (*AwsProvider) GetIAMWorkerRole ¶
func (a *AwsProvider) GetIAMWorkerRole(infraID string) (*ec2.IamInstanceProfileSpecification, error)
GetIAMWorkerRole gets worker IAM information from the existing cluster including IAM arn or an error. This function is exposed for testing purpose.
func (*AwsProvider) GetInfraID ¶
func (a *AwsProvider) GetInfraID() (string, error)
GetInfraID returns the infrastructure ID associated with the OpenShift cluster. This is public for testing purposes as of now.
func (*AwsProvider) GetInstance ¶
func (a *AwsProvider) GetInstance(instanceID string) (*ec2.Instance, error)
GetInstance gets instance ec2 instance object from the given instanceID. We're making this method public to use it in tests as of now.
func (*AwsProvider) GetPassword ¶
func (a *AwsProvider) GetPassword(instanceID string) (string, error)
GetPassword returns the password associated with the string. Exposing this to be used in tests later
func (*AwsProvider) GetPrivateIP ¶
func (a *AwsProvider) GetPrivateIP(instanceID string) (string, error)
GetPrivateIP returns the private IP address associated with the instance. Make to sure to call this function after the instance is in running state. Exposing this function to be used in testing later.
func (*AwsProvider) GetPublicIP ¶
func (a *AwsProvider) GetPublicIP(instanceID string) (string, error)
GetPublicIP returns the public IP address associated with the instance. Make to sure to call this function after the instance is in running state. Exposing this function to be used in testing later.
func (*AwsProvider) GetVPCByInfrastructure ¶
func (a *AwsProvider) GetVPCByInfrastructure(infraID string) (*ec2.Vpc, error)
GetVPCByInfrastructure finds the VPC of an infrastructure and returns the VPC struct or an error. This function is exposed for testing purpose.
func (*AwsProvider) IsVMRunning ¶
func (a *AwsProvider) IsVMRunning(instanceID string) error
IsVMRunning checks if the VM is in running state currently and then returns failure
func (*AwsProvider) TerminateInstance ¶
func (a *AwsProvider) TerminateInstance(instanceID string) error
TerminateInstance will delete an AWS instance based on instance id and returns error if deletion fails. This function is exposed for testing purpose.