-
Notifications
You must be signed in to change notification settings - Fork 48
/
vmspec.go
109 lines (80 loc) · 3.2 KB
/
vmspec.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// 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 service
import (
"context"
gc "github.com/cloud-barista/cb-spider/api-runtime/grpc-runtime/common"
"github.com/cloud-barista/cb-spider/api-runtime/grpc-runtime/logger"
pb "github.com/cloud-barista/cb-spider/api-runtime/grpc-runtime/stub/cbspider"
cmrt "github.com/cloud-barista/cb-spider/api-runtime/common-runtime"
)
// ===== [ Constants and Variables ] =====
// ===== [ Types ] =====
// ===== [ Implementations ] =====
// ListVMSpec - VM Spec 목록
func (s *CCMService) ListVMSpec(ctx context.Context, req *pb.VMSpecAllQryRequest) (*pb.ListVMSpecInfoResponse, error) {
logger := logger.NewLogger()
logger.Debug("calling CCMService.ListVMSpec()")
// Call common-runtime API
result, err := cmrt.ListVMSpec(req.ConnectionName)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "CCMService.ListVMSpec()")
}
// CCM 객체에서 GRPC 메시지로 복사
var grpcObj []*pb.VMSpecInfo
err = gc.CopySrcToDest(&result, &grpcObj)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "CCMService.ListVMSpec()")
}
resp := &pb.ListVMSpecInfoResponse{Items: grpcObj}
return resp, nil
}
// GetVMSpec - VM Spec 조회
func (s *CCMService) GetVMSpec(ctx context.Context, req *pb.VMSpecQryRequest) (*pb.VMSpecInfoResponse, error) {
logger := logger.NewLogger()
logger.Debug("calling CCMService.GetVMSpec()")
// Call common-runtime API
result, err := cmrt.GetVMSpec(req.ConnectionName, req.Name)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "CCMService.GetVMSpec()")
}
// CCM 객체에서 GRPC 메시지로 복사
var grpcObj pb.VMSpecInfo
err = gc.CopySrcToDest(result, &grpcObj)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "CCMService.GetVMSpec()")
}
resp := &pb.VMSpecInfoResponse{Item: &grpcObj}
return resp, nil
}
// ListOrgVMSpec - 클라우드의 원래 VM Spec 목록
func (s *CCMService) ListOrgVMSpec(ctx context.Context, req *pb.VMSpecAllQryRequest) (*pb.StringResponse, error) {
logger := logger.NewLogger()
logger.Debug("calling CCMService.ListOrgVMSpec()")
// Call common-runtime API
result, err := cmrt.ListOrgVMSpec(req.ConnectionName)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "CCMService.ListOrgVMSpec()")
}
resp := &pb.StringResponse{Result: result}
return resp, nil
}
// GetOrgVMSpec - 클라우드의 원래 VM Spec 조회
func (s *CCMService) GetOrgVMSpec(ctx context.Context, req *pb.VMSpecQryRequest) (*pb.StringResponse, error) {
logger := logger.NewLogger()
logger.Debug("calling CCMService.GetOrgVMSpec()")
// Call common-runtime API
result, err := cmrt.GetOrgVMSpec(req.ConnectionName, req.Name)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "CCMService.GetOrgVMSpec()")
}
resp := &pb.StringResponse{Result: result}
return resp, nil
}
// ===== [ Private Functions ] =====
// ===== [ Public Functions ] =====