mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
server delete etc fix
This commit is contained in:
@@ -20,3 +20,35 @@ const (
|
||||
RESOURCE_TYPE_IP = "hws.resource.type.ip" // VPC公网IP
|
||||
RESOURCE_TYPE_IMAGE = "hws.resource.type.marketplace" // 市场镜像
|
||||
)
|
||||
|
||||
// Not Found Error code
|
||||
// 网络等资源直接通过http code 404即可判断资源不存在。另外有些资源可能不是返回404这里单独列出来
|
||||
const (
|
||||
VM_NOT_FOUND = "Ecs.0114" // 云服务器不存在
|
||||
ECS_NOT_FOUND = "Ecs.0614" // 弹性云服务器不存在
|
||||
IMG_ID_NOT_FOUND = "IMG.0027" // 请求的镜像ID不存在
|
||||
IMG_NOT_FOUND = "IMG.0027" // 镜像不存在
|
||||
IMG_ERR_NOT_FOUND = "IMG.0057" // 镜像文件不存在或者为空或者不是允许格式的文件
|
||||
IMG_BACKUP_NOT_FOUND = "IMG.0020" // 备份不存在
|
||||
IMG_VM_BACKUP_NOT_FOUND = "IMG.0127" // 云服务器备份不存在
|
||||
IMG_VM_NOT_FOUND = "IMG.0005" // 云主机不存在
|
||||
JOB_NOT_FOUND = "Common.0011" // jobId为空
|
||||
EVS_NOT_FOUND = "EVS.5404" // 磁盘、快照和备份等资源未找到。
|
||||
FIP_NOT_FOUND = "VPC.0504" // 未找到弹性公网IP。
|
||||
VPC_NOT_FOUND = "VPC.0012" // 未找到弹性公网VPC。
|
||||
)
|
||||
|
||||
var NOT_FOUND_CODES = []string{
|
||||
VM_NOT_FOUND,
|
||||
ECS_NOT_FOUND,
|
||||
IMG_ID_NOT_FOUND,
|
||||
IMG_NOT_FOUND,
|
||||
IMG_ERR_NOT_FOUND,
|
||||
IMG_BACKUP_NOT_FOUND,
|
||||
IMG_VM_BACKUP_NOT_FOUND,
|
||||
IMG_VM_NOT_FOUND,
|
||||
JOB_NOT_FOUND,
|
||||
EVS_NOT_FOUND,
|
||||
FIP_NOT_FOUND,
|
||||
VPC_NOT_FOUND,
|
||||
}
|
||||
|
||||
@@ -640,6 +640,7 @@ func (self *SRegion) addSecurityGroupRules(secGrpId string, rule *secrules.Secur
|
||||
return nil
|
||||
}
|
||||
|
||||
// todo: icmp协议目前存在差异,华为云能指定icmp code,onecloud不支持
|
||||
func (self *SRegion) addSecurityGroupRule(secGrpId, direction, portStart, portEnd, protocol, ipNet string) error {
|
||||
params := jsonutils.NewDict()
|
||||
secgroupObj := jsonutils.NewDict()
|
||||
@@ -647,10 +648,11 @@ func (self *SRegion) addSecurityGroupRule(secGrpId, direction, portStart, portEn
|
||||
secgroupObj.Add(jsonutils.NewString(direction), "direction")
|
||||
secgroupObj.Add(jsonutils.NewString(ipNet), "remote_ip_prefix")
|
||||
secgroupObj.Add(jsonutils.NewString("IPV4"), "ethertype")
|
||||
if len(portStart) > 0 && portStart != "0" {
|
||||
// 端口为空或者1-65535
|
||||
if len(portStart) > 0 && portStart != "0" && portStart != "-1" {
|
||||
secgroupObj.Add(jsonutils.NewString(portStart), "port_range_min")
|
||||
}
|
||||
if len(portEnd) > 0 && portEnd != "0" {
|
||||
if len(portEnd) > 0 && portEnd != "0" && portEnd != "-1" {
|
||||
secgroupObj.Add(jsonutils.NewString(portEnd), "port_range_max")
|
||||
}
|
||||
if len(protocol) > 0 {
|
||||
|
||||
@@ -194,7 +194,7 @@ func (self *SSecurityGroup) GetSecurityRule(ruleId string, withRuleId bool) (sec
|
||||
} else {
|
||||
desc = remoteRule.Description
|
||||
}
|
||||
// todo: icmp 可能不兼容
|
||||
// todo: icmp 可能不兼容。华为云能指定icmp code,onecloud不支持
|
||||
rule := secrules.SecurityRule{
|
||||
Priority: 1,
|
||||
Action: secrules.SecurityRuleAllow,
|
||||
|
||||
@@ -22,11 +22,21 @@ type deleteFunc2 func(ctx manager.IManagerContext, id string, spec string, param
|
||||
type listInCtxFunc func(ctx manager.IManagerContext, querys map[string]string) (*responses.ListResult, error)
|
||||
type listInCtxWithSpecFunc func(ctx manager.IManagerContext, spec string, querys map[string]string, responseKey string) (*responses.ListResult, error)
|
||||
|
||||
func notFound(code string) bool {
|
||||
for _, c := range NOT_FOUND_CODES {
|
||||
if code == c {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func unmarshalResult(resp jsonutils.JSONObject, respErr error, result interface{}) error {
|
||||
if respErr != nil {
|
||||
switch e := respErr.(type) {
|
||||
case *httputils.JSONClientError:
|
||||
if e.Code == 404 {
|
||||
if e.Code == 404 || notFound(e.Class) {
|
||||
return cloudprovider.ErrNotFound
|
||||
}
|
||||
return e
|
||||
|
||||
Reference in New Issue
Block a user