Skip to content

Commit

Permalink
Merge pull request #6 from chilianyi/fix
Browse files Browse the repository at this point in the history
Add key name as config
  • Loading branch information
chilianyi authored Mar 15, 2019
2 parents 9f4ee46 + 089ab68 commit a0f825b
Show file tree
Hide file tree
Showing 64 changed files with 9,796 additions and 3,094 deletions.
5 changes: 5 additions & 0 deletions pkg/service/runtime_provider/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ zone: .*
image_name: amzn2-ami-hvm-2.0.20180622.1-x86_64-gp2
image_url: https://openpitrix.pek3a.qingstor.com/image/amazon-linux.tar.gz
provider_type: vmbased
enable: true
advanced_options:
key_name: openpitrix
`
)

Expand All @@ -20,3 +23,5 @@ const (
DefaultDevice = "/dev/sdf"
DefaultZone = "us-east-2"
)

const AdvancedOptionsKeyName = "key_name"
2 changes: 1 addition & 1 deletion pkg/service/runtime_provider/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
runtimeclient "openpitrix.io/openpitrix/pkg/client/runtime"
"openpitrix.io/openpitrix/pkg/models"
"openpitrix.io/openpitrix/pkg/pb"
"openpitrix.io/openpitrix/pkg/pi"
"openpitrix.io/openpitrix/pkg/plugins/vmbased"
"openpitrix.io/openpitrix/pkg/util/pbutil"
"openpitrix.io/openpitrix/pkg/util/stringutil"
"openpitrix.io/openpitrix/pkg/pi"
)

func (p *Server) ParseClusterConf(ctx context.Context, req *pb.ParseClusterConfRequest) (*pb.ParseClusterConfResponse, error) {
Expand Down
7 changes: 7 additions & 0 deletions pkg/service/runtime_provider/provider_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"openpitrix.io/openpitrix/pkg/logger"
"openpitrix.io/openpitrix/pkg/models"
"openpitrix.io/openpitrix/pkg/pb"
"openpitrix.io/openpitrix/pkg/pi"
"openpitrix.io/openpitrix/pkg/plugins/vmbased"
"openpitrix.io/openpitrix/pkg/util/funcutil"
"openpitrix.io/openpitrix/pkg/util/jsonutil"
Expand Down Expand Up @@ -114,6 +115,12 @@ func (p *ProviderHandler) RunInstances(ctx context.Context, task *models.Task) (
MaxCount: aws.Int64(1),
MinCount: aws.Int64(1),
}

keyName, ok := pi.Global().GlobalConfig().Runtime[Provider].AdvancedOptions[AdvancedOptionsKeyName]
if ok && len(keyName.(string)) > 0 {
input.KeyName = aws.String(keyName.(string))
}

if instance.NeedUserData == 1 {
input.UserData = aws.String(instance.UserDataValue)
}
Expand Down
Loading

0 comments on commit a0f825b

Please sign in to comment.