Skip to content

Commit da3e11a

Browse files
authored
Merge pull request #198 from dev4unet/master
보안그룹 룰 변경 및 확인
2 parents 792781c + 40232af commit da3e11a

File tree

6 files changed

+1366
-37
lines changed

6 files changed

+1366
-37
lines changed

cloud-control-manager/cloud-driver/drivers/alibaba/main/Test_Resources.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ func handleSecurity() {
339339
//config := readConfigFile()
340340
//VmID := config.Aws.VmID
341341

342-
securityName := "CB-SecurityTest1"
343-
securityId := "sg-6weeb9xaodr65g7bq10c"
342+
securityName := "CB-SecurityTestIcmp"
343+
securityId := "sg-6wedru4yb4m6qqfvd3sj"
344344
vpcId := "vpc-6wei16ufuimfcct41o0xh"
345345

346346
for {
@@ -400,6 +400,13 @@ func handleSecurity() {
400400
IPProtocol: "tcp",
401401
Direction: "inbound",
402402
},
403+
{
404+
FromPort: "-1",
405+
ToPort: "-1",
406+
IPProtocol: "icmp",
407+
Direction: "inbound",
408+
},
409+
403410
{
404411
FromPort: "443",
405412
ToPort: "443",
@@ -908,8 +915,8 @@ func main() {
908915
//handleVMSpec()
909916
//handleImage() //AMI
910917
//handleKeyPair()
911-
//handleSecurity()
912-
handleVM()
918+
handleSecurity()
919+
//handleVM()
913920

914921
//handlePublicIP() // PublicIP 생성 후 conf
915922

cloud-control-manager/cloud-driver/drivers/aws/main/Test_Resources.go

+138-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,142 @@ func init() {
3636
cblog.SetLevel("debug")
3737
}
3838

39-
// Test SecurityHandler
4039
func handleSecurity() {
40+
cblogger.Debug("Start Security Resource Test")
41+
42+
ResourceHandler, err := getResourceHandler("Security")
43+
if err != nil {
44+
panic(err)
45+
}
46+
handler := ResourceHandler.(irs.SecurityHandler)
47+
48+
//config := readConfigFile()
49+
//VmID := config.Aws.VmID
50+
51+
securityName := "CB-SecurityTest1"
52+
securityId := "sg-0d6a2bb960481ce68"
53+
vpcId := "vpc-c0479cab"
54+
55+
for {
56+
fmt.Println("Security Management")
57+
fmt.Println("0. Quit")
58+
fmt.Println("1. Security List")
59+
fmt.Println("2. Security Create")
60+
fmt.Println("3. Security Get")
61+
fmt.Println("4. Security Delete")
62+
63+
var commandNum int
64+
inputCnt, err := fmt.Scan(&commandNum)
65+
if err != nil {
66+
panic(err)
67+
}
68+
69+
if inputCnt == 1 {
70+
switch commandNum {
71+
case 0:
72+
return
73+
74+
case 1:
75+
result, err := handler.ListSecurity()
76+
if err != nil {
77+
cblogger.Infof(" Security 목록 조회 실패 : ", err)
78+
} else {
79+
cblogger.Info("Security 목록 조회 결과")
80+
//cblogger.Info(result)
81+
spew.Dump(result)
82+
if result != nil {
83+
securityId = result[0].IId.SystemId // 조회 및 삭제를 위해 생성된 ID로 변경
84+
}
85+
}
86+
87+
case 2:
88+
cblogger.Infof("[%s] Security 생성 테스트", securityName)
89+
90+
securityReqInfo := irs.SecurityReqInfo{
91+
IId: irs.IID{NameId: securityName},
92+
VpcIID: irs.IID{SystemId: vpcId},
93+
SecurityRules: &[]irs.SecurityRuleInfo{ //보안 정책 설정
94+
{
95+
FromPort: "20",
96+
ToPort: "22",
97+
IPProtocol: "tcp",
98+
Direction: "inbound",
99+
},
100+
101+
{
102+
FromPort: "80",
103+
ToPort: "80",
104+
IPProtocol: "tcp",
105+
Direction: "inbound",
106+
},
107+
{
108+
FromPort: "8080",
109+
ToPort: "8080",
110+
IPProtocol: "tcp",
111+
Direction: "inbound",
112+
},
113+
{
114+
FromPort: "-1",
115+
ToPort: "-1",
116+
IPProtocol: "icmp",
117+
Direction: "inbound",
118+
},
119+
{
120+
FromPort: "443",
121+
ToPort: "443",
122+
IPProtocol: "tcp",
123+
Direction: "outbound",
124+
},
125+
{
126+
FromPort: "8443",
127+
ToPort: "9999",
128+
IPProtocol: "tcp",
129+
Direction: "outbound",
130+
},
131+
/*
132+
{
133+
//FromPort: "8443",
134+
//ToPort: "9999",
135+
IPProtocol: "-1", // 모두 허용 (포트 정보 없음)
136+
Direction: "inbound",
137+
},
138+
*/
139+
},
140+
}
141+
142+
result, err := handler.CreateSecurity(securityReqInfo)
143+
if err != nil {
144+
cblogger.Infof(securityName, " Security 생성 실패 : ", err)
145+
} else {
146+
cblogger.Infof("[%s] Security 생성 결과 : [%v]", securityName, result)
147+
spew.Dump(result)
148+
}
149+
150+
case 3:
151+
cblogger.Infof("[%s] Security 조회 테스트", securityId)
152+
result, err := handler.GetSecurity(irs.IID{SystemId: securityId})
153+
if err != nil {
154+
cblogger.Infof(securityId, " Security 조회 실패 : ", err)
155+
} else {
156+
cblogger.Infof("[%s] Security 조회 결과 : [%v]", securityId, result)
157+
spew.Dump(result)
158+
}
159+
160+
case 4:
161+
cblogger.Infof("[%s] Security 삭제 테스트", securityId)
162+
result, err := handler.DeleteSecurity(irs.IID{SystemId: securityId})
163+
if err != nil {
164+
cblogger.Infof(securityId, " Security 삭제 실패 : ", err)
165+
} else {
166+
cblogger.Infof("[%s] Security 삭제 결과 : [%s]", securityId, result)
167+
}
168+
}
169+
}
170+
}
171+
}
172+
173+
// Test SecurityHandler
174+
func handleSecurityOld() {
41175
cblogger.Debug("Start handler")
42176

43177
ResourceHandler, err := getResourceHandler("Security")
@@ -937,16 +1071,15 @@ func main() {
9371071
}
9381072
*/
9391073

940-
//handleVNetwork() //VPC
1074+
//handleVPC()
9411075
//handleKeyPair()
9421076
//handlePublicIP() // PublicIP 생성 후 conf
943-
//handleSecurity()
944-
handleVM()
1077+
handleSecurity()
1078+
//handleVM()
9451079

9461080
//handleImage() //AMI
9471081
//handleVNic() //Lancard
9481082
//handleVMSpec()
949-
//handleVPC()
9501083

9511084
/*
9521085
KeyPairHandler, err := setKeyPairHandler()

0 commit comments

Comments
 (0)