Skip to content

Commit

Permalink
Implement of getting software migration list
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Nov 13, 2024
1 parent 4a948c2 commit 8124693
Show file tree
Hide file tree
Showing 11 changed files with 631 additions and 462 deletions.
64 changes: 64 additions & 0 deletions common/connectionInfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package common

import (
"encoding/base64"
"errors"
"github.com/cloud-barista/cm-grasshopper/lib/rsautil"
honeybee "github.com/cloud-barista/cm-honeybee/server/pkg/api/rest/model"
"github.com/jollaman999/utils/logger"
)

func ConnectionInfoDecryptSecrets(connectionInfo *honeybee.ConnectionInfo) (*honeybee.ConnectionInfo, error) {
encryptedUser, err := base64.StdEncoding.DecodeString(connectionInfo.User)
if err != nil {
errMsg := "error occurred while decrypting the base64 encoded encrypted user (" + err.Error() + ")"
logger.Println(logger.ERROR, true, errMsg)

return nil, errors.New(errMsg)
}

decryptedUserBytes, err := rsautil.DecryptWithPrivateKey(encryptedUser, HoneybeePrivateKey)
if err != nil {
errMsg := "error occurred while decrypting user (" + err.Error() + ")"
logger.Println(logger.ERROR, true, errMsg)

return nil, errors.New(errMsg)
}
connectionInfo.User = string(decryptedUserBytes)

encryptedPassword, err := base64.StdEncoding.DecodeString(connectionInfo.Password)
if err != nil {
errMsg := "error occurred while decrypting the base64 encoded encrypted password (" + err.Error() + ")"
logger.Println(logger.ERROR, true, errMsg)

return nil, errors.New(errMsg)
}

decryptedPasswordBytes, err := rsautil.DecryptWithPrivateKey(encryptedPassword, HoneybeePrivateKey)
if err != nil {
errMsg := "error occurred while decrypting password (" + err.Error() + ")"
logger.Println(logger.ERROR, true, errMsg)

return nil, errors.New(errMsg)
}
connectionInfo.Password = string(decryptedPasswordBytes)

encryptedPrivateKey, err := base64.StdEncoding.DecodeString(connectionInfo.PrivateKey)
if err != nil {
errMsg := "error occurred while decrypting the base64 encoded encrypted private key (" + err.Error() + ")"
logger.Println(logger.ERROR, true, errMsg)

return nil, errors.New(errMsg)
}

decryptedPrivateKeyBytes, err := rsautil.DecryptWithPrivateKey(encryptedPrivateKey, HoneybeePrivateKey)
if err != nil {
errMsg := "error occurred while decrypting private key (" + err.Error() + ")"
logger.Println(logger.ERROR, true, errMsg)

return nil, errors.New(errMsg)
}
connectionInfo.PrivateKey = string(decryptedPrivateKeyBytes)

return connectionInfo, nil
}
116 changes: 0 additions & 116 deletions lib/software/executionList.go

This file was deleted.

4 changes: 2 additions & 2 deletions lib/software/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
)

func MigrateSoftware(executionID string, executionList *[]model.Execution,
func MigrateSoftware(executionID string, executionList *[]model.MigrationSoftwareInfo,
sourceConnectionInfoID string, target *model.Target) error {
var executionStatusList []model.ExecutionStatus

Expand Down Expand Up @@ -50,7 +50,7 @@ func MigrateSoftware(executionID string, executionList *[]model.Execution,
return err
}

go func(id string, exList []model.Execution, exStatusList []model.ExecutionStatus,
go func(id string, exList []model.MigrationSoftwareInfo, exStatusList []model.ExecutionStatus,
s *ssh.Client, t *ssh.Client) {
defer func() {
_ = s.Close()
Expand Down
Loading

0 comments on commit 8124693

Please sign in to comment.