-
Notifications
You must be signed in to change notification settings - Fork 44
/
ssh.go
54 lines (41 loc) · 1.28 KB
/
ssh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// gRPC Runtime of CB-Spider.
// The CB-Spider is a sub-Framework of the Cloud-Barista Multi-Cloud Project.
// The CB-Spider Mission is to connect all the clouds with a single interface.
//
// * Cloud-Barista: https://github.com/cloud-barista
//
// by CB-Spider Team, 2020.09.
package request
import (
"context"
"errors"
gc "github.com/cloud-barista/cb-spider/api-runtime/grpc-runtime/common"
pb "github.com/cloud-barista/cb-spider/api-runtime/grpc-runtime/stub/cbspider"
)
// ===== [ Constants and Variables ] =====
// ===== [ Types ] =====
// ===== [ Implementations ] =====
// SSHRun - SSH 실행
func (r *SSHRequest) SSHRun() (string, error) {
// 입력데이터 검사
if r.InData == "" {
return "", errors.New("input data required")
}
// 입력데이터 언마샬링
var item pb.SSHRunRequest
err := gc.ConvertToMessage(r.InType, r.InData, &item)
if err != nil {
return "", err
}
// 서버에 요청
ctx, cancel := context.WithTimeout(context.Background(), r.Timeout)
defer cancel()
resp, err2 := r.Client.SSHRun(ctx, &item)
if err2 != nil {
return "", err2
}
// 결과값 마샬링
return gc.ConvertToOutput(r.OutType, &resp)
}
// ===== [ Private Functions ] =====
// ===== [ Public Functions ] =====