Skip to content

Commit c5f16a6

Browse files
zhengyaSongZhen0704
authored andcommitted
[CLI] support gateway host
1 parent d958ba9 commit c5f16a6

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

cli/ctl/example/domain_additional_resource.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ hosts:
3131
domain_uuid: xxxx # required
3232
vinterfaces: # optional. network interfaces
3333
- mac: xx:xx:xx:xx:xx:xx # required
34-
subnet_uuid: xxxx # required
34+
subnet_uuid: xxxx # optional
3535
ips: ["x.x.x.x"] # optional
3636

3737
# chost, cloud/legacy host, including vm (virtual mechine) and bm (bare metal)
@@ -74,4 +74,4 @@ lbs:
7474
port: xx # required
7575
lb_target_servers: # optional, lb target servers
7676
- ip: x.x.x.x # required
77-
port: xx # required
77+
port: xx # required

server/controller/cloud/model/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type VInterface struct {
144144
TapMac string `json:"tap_mac"`
145145
DeviceLcuuid string `json:"device_lcuuid" binding:"required"`
146146
DeviceType int `json:"device_type" binding:"required"`
147-
NetworkLcuuid string `json:"network_lcuuid" binding:"required"`
147+
NetworkLcuuid string `json:"network_lcuuid"`
148148
VPCLcuuid string `json:"vpc_lcuuid"` // TODO not used
149149
RegionLcuuid string `json:"region_lcuuid" binding:"required"`
150150
SubDomainLcuuid string `json:"sub_domain_lcuuid"`

server/controller/http/service/resource/domain_additional_resource.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ func generateToolDataSet(additionalRsc model.AdditionalResource) (map[string]*ad
253253
toolDS.hostIPToUUID[host.IP] = host.UUID
254254
toolDS.additionalHosts = append(toolDS.additionalHosts, host)
255255
for _, vif := range host.VInterfaces {
256+
if vif.SubnetUUID == "" {
257+
if len(vif.IPs) != 0 {
258+
return nil, servicecommon.NewError(
259+
common.RESOURCE_NOT_FOUND,
260+
fmt.Sprintf("host (name: %s) vinterface (mac: %s) subnet (uuid: %s) not found", host.Name, vif.Mac, vif.SubnetUUID),
261+
)
262+
}
263+
continue
264+
}
256265
if _, ok := toolDS.subnetUUIDToType[vif.SubnetUUID]; !ok {
257266
return nil, servicecommon.NewError(
258267
common.RESOURCE_NOT_FOUND,

server/controller/recorder/updater/vinterface.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,21 @@ func (i *VInterface) getDiffBaseByCloudItem(cloudItem *cloudmodel.VInterface) (d
5151
}
5252

5353
func (i *VInterface) generateDBItemToAdd(cloudItem *cloudmodel.VInterface) (*mysql.VInterface, bool) {
54-
networkID, exists := i.cache.ToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid)
55-
if !exists {
56-
if i.domainToolDataSet != nil {
57-
networkID, exists = i.domainToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid)
58-
}
54+
var networkID int
55+
if cloudItem.NetworkLcuuid != "" {
56+
var exists bool
57+
networkID, exists = i.cache.ToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid)
5958
if !exists {
60-
log.Errorf(resourceAForResourceBNotFound(
61-
common.RESOURCE_TYPE_NETWORK_EN, cloudItem.NetworkLcuuid,
62-
common.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid,
63-
))
64-
return nil, false
59+
if i.domainToolDataSet != nil {
60+
networkID, exists = i.domainToolDataSet.GetNetworkIDByLcuuid(cloudItem.NetworkLcuuid)
61+
}
62+
if !exists {
63+
log.Errorf(resourceAForResourceBNotFound(
64+
common.RESOURCE_TYPE_NETWORK_EN, cloudItem.NetworkLcuuid,
65+
common.RESOURCE_TYPE_VINTERFACE_EN, cloudItem.Lcuuid,
66+
))
67+
return nil, false
68+
}
6569
}
6670
}
6771
deviceID, exists := i.cache.ToolDataSet.GetDeviceIDByDeviceLcuuid(cloudItem.DeviceType, cloudItem.DeviceLcuuid)

0 commit comments

Comments
 (0)