security group list update

This commit is contained in:
TangBin
2018-10-25 18:26:25 +08:00
parent a2baa3bfb8
commit 94d93bee07
2 changed files with 22 additions and 13 deletions
+17 -13
View File
@@ -426,40 +426,44 @@ func (self *SRegion) GetInstances(zoneId string, ids []string, offset int, limit
networkInterfaces.NetworkInterface = append(networkInterfaces.NetworkInterface, i)
}
var vpcattr SVpcAttributes
vpcattr.VpcId = *instance.VpcId
vpcattr.PrivateIpAddress = SIpAddress{[]string{*instance.PrivateIpAddress}}
vpcattr.NetworkId = *instance.SubnetId
var productCodes []string
for _, p := range instance.ProductCodes {
productCodes = append(productCodes, *p.ProductCodeId)
}
sinstance := SInstance{
RegionId: self.RegionId,
ZoneId: *instance.Placement.AvailabilityZone,
InstanceId: *instance.InstanceId,
ImageId: *instance.ImageId,
InstanceName: tagspec.GetNameTag(),
InstanceType: *instance.InstanceType,
Cpu: int8(*instance.CpuOptions.CoreCount),
Memory: instanceType.memoryMB(),
IoOptimized: *instance.EbsOptimized,
KeyPairName: *instance.KeyName,
CreationTime: *instance.LaunchTime,
// ExpiredTime:
// ProductCodes: *instance.ProductCodes
PublicDNSName: *instance.PublicDnsName,
RootDeviceName: *instance.RootDeviceName,
Status: *instance.State.Name,
InnerIpAddress: SIpAddress{[]string{*instance.PrivateIpAddress}},
PublicIpAddress: SIpAddress{[]string{*instance.PublicIpAddress}},
InstanceName: tagspec.GetNameTag(),
Description: tagspec.GetDescTag(),
Disks: disks,
SecurityGroupIds: secgroups,
NetworkInterfaces: networkInterfaces,
VpcAttributes: vpcattr,
ProductCodes: productCodes,
// ExpiredTime:
// EipAddress:
// VlanId:
// VpcAttributes:
// OSName:
// OSType:
Description: tagspec.GetDescTag(),
}
if instance.PrivateIpAddress != nil {
sinstance.InnerIpAddress = SIpAddress{[]string{*instance.PrivateIpAddress}}
}
if instance.PublicIpAddress != nil {
sinstance.PublicIpAddress = SIpAddress{[]string{*instance.PublicIpAddress}}
}
instances = append(instances, sinstance)
+5
View File
@@ -218,6 +218,11 @@ func (self *SRegion) GetSecurityGroups(vpcId string, offset int, limit int) ([]S
return nil, 0, err
}
if len(*item.VpcId) == 0 {
log.Debugf("ingored: security group with no vpc binded")
continue
}
vpc, err := self.getVpc(*item.VpcId)
if err != nil {
log.Errorf("vpc %s not found", *item.VpcId)