Skip to content

Commit

Permalink
<fix>[conf]: add virtualswitch module
Browse files Browse the repository at this point in the history
DBImpact

Resolves: ZSTAC-58532

Change-Id: I6876757566726679776f647a7870757163687275
  • Loading branch information
ruansteve authored and AlanJager committed Nov 9, 2023
1 parent 0dcab1a commit 8cd8b73
Show file tree
Hide file tree
Showing 43 changed files with 1,386 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ test-premium/zstack-integration-test-result/
envDSLTree
test/zstack-integration-test-result/
premium/test-premium/zstack-api.log
**/bin/
5 changes: 5 additions & 0 deletions build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@
<artifactId>zsv</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.zstack</groupId>
<artifactId>virtualSwitchNetwork</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
Expand Down
30 changes: 30 additions & 0 deletions conf/db/upgrade/V4.7.0.4__schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE IF NOT EXISTS `zstack`.`L2VirtualSwitchNetworkVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`isDistributed` boolean NOT NULL DEFAULT TRUE,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `zstack`.`L2PortGroupNetworkVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`vSwitchUuid` varchar(32) NOT NULL,
`vlanMode` varchar(32) NOT NULL default 'ACCESS',
`vlanId` int unsigned NOT NULL,
`vlanRanges` varchar(256) default NULL,
PRIMARY KEY (`uuid`),
CONSTRAINT `fkL2PortGroupNetworkVOL2VirtualSwitchNetworkVO` FOREIGN KEY (`vSwitchUuid`) REFERENCES L2VirtualSwitchNetworkVO (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `zstack`.`L2NetworkHostRefVO` (
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
`l2NetworkUuid` varchar(32) NOT NULL,
`hostUuid` varchar(32) NOT NULL,
`l2ProviderType` varchar(32) default NULL,
`attachStatus` varchar(32) default NULL,
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp,
PRIMARY KEY (`id`),
CONSTRAINT `fkL2NetworkHostRefVOHostEO` FOREIGN KEY (`hostUuid`) REFERENCES HostEO (`uuid`) ON DELETE CASCADE,
CONSTRAINT `fkL2NetworkHostRefVOL2NetworkEO` FOREIGN KEY (`l2NetworkUuid`) REFERENCES L2NetworkEO (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `zstack`.`L2NetworkClusterRefVO` ADD COLUMN `l2ProviderType` varchar(32) default NULL;
43 changes: 43 additions & 0 deletions conf/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -17842,6 +17842,49 @@
"line": 608,
"fileName": "src/main/java/org/zstack/network/l2/L2NoVlanNetwork.java"
},
{
"raw": "could not create L2PortGroupNetwork, because L2VirtualSwitchNetwork[uuid:%s] already has L2PortGroupNetworks with the same vlanId[%s]",
"en_US": "could not create L2PortGroupNetwork, because L2VirtualSwitchNetwork[uuid:{0}] already has L2PortGroupNetworks with the same vlanId[{1}]",
"zh_CN": "创建端口组失败,因为虚拟交换机[uuid:{0}]已经存在vlanId[{1}]的端口组",
"arguments": [
"msg.getvSwitchUuid()",
"msg.getVlan()"
],
"line": 84,
"fileName": "src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java"
},
{
"raw": "could not attach L2VirtualSwitchNetwork, because interface[%s] in cluster[uuid:%s] is already used for another L2VirtualSwitchNetwork",
"en_US": "could not attach L2VirtualSwitchNetwork, because interface[{0}] in cluster[uuid:{1}] is already used for another L2VirtualSwitchNetwork",
"zh_CN": "挂载虚拟交换机失败,因为集群[uuid:{1}]中的网卡[{0}]已被其他虚拟交换机使用",
"arguments": [
"vswitchVO.getPhysicalInterface()",
"msg.getClusterUuid()"
],
"line": 106,
"fileName": "src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java"
},
{
"raw": "could not attach L2VirtualSwitchNetwork, because there are no hosts in cluster[uuid:%s]",
"en_US": "could not attach L2VirtualSwitchNetwork, because there are no hosts in cluster[uuid:{0}]",
"zh_CN": "挂载虚拟交换机失败,因为集群[uuid:{0}]中不存在任何物理机",
"arguments": [
"msg.getClusterUuid()"
],
"line": 113,
"fileName": "src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java"
},
{
"raw": "could not attach L2VirtualSwitchNetwork, because interface[%s] should be created on host[uuid:%s]",
"en_US": "could not attach L2VirtualSwitchNetwork, because interface[{0}] should be created on host[uuid:{1}]",
"zh_CN": "挂载虚拟交换机失败,因为网卡[{0}]应当在物理机[uuid:{1}]上创建",
"arguments": [
"vswitchVO.getPhysicalInterface()",
"hostUuid"
],
"line": 126,
"fileName": "src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java"
},
{
"raw": "cannot configure vxlan network for vm[uuid:%s] on the destination host[uuid:%s]",
"en_US": "cannot configure vxlan network for vm[uuid:{0}] on the destination host[uuid:{1}]",
Expand Down
16 changes: 16 additions & 0 deletions conf/i18n/messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7194,6 +7194,22 @@ There\ has\ been\ a\ L2VlanNetwork[uuid\:%s,\ name\:%s]\ attached\ to\ cluster[u
# args: l2.getUuid(),l2.getName(),msg.getClusterUuid(),l2.getPhysicalInterface(),tl2.getUuid()
There\ has\ been\ a\ l2Network[uuid\:%s,\ name\:%s]\ attached\ to\ cluster[uuid\:%s]\ that\ has\ physical\ interface[%s].\ Failed\ to\ attach\ l2Network[uuid\:%s] = There has been a l2Network[uuid:{0}, name:{1}] attached to cluster[uuid:{2}] that has physical interface[{3}]. Failed to attach l2Network[uuid:{4}]

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:84
# args: msg.getvSwitchUuid(),msg.getVlan()
could\ not\ create\ L2PortGroupNetwork,\ because\ L2VirtualSwitchNetwork[uuid\:%s]\ already\ has\ L2PortGroupNetworks\ with\ the\ same\ vlanId[%s] = could not create L2PortGroupNetwork, because L2VirtualSwitchNetwork[uuid:{0}] already has L2PortGroupNetworks with the same vlanId[{1}]

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:106
# args: vswitchVO.getPhysicalInterface(),msg.getClusterUuid()
could\ not\ attach\ L2VirtualSwitchNetwork,\ because\ interface[%s]\ in\ cluster[uuid\:%s]\ is\ already\ used\ for\ another\ L2VirtualSwitchNetwork = could not attach L2VirtualSwitchNetwork, because interface[{0}] in cluster[uuid:{1}] is already used for another L2VirtualSwitchNetwork

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:113
# args: msg.getClusterUuid()
could\ not\ attach\ L2VirtualSwitchNetwork,\ because\ there\ are\ no\ hosts\ in\ cluster[uuid\:%s] = could not attach L2VirtualSwitchNetwork, because there are no hosts in cluster[uuid:{0}]

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:126
# args: vswitchVO.getPhysicalInterface(),hostUuid
could\ not\ attach\ L2VirtualSwitchNetwork,\ because\ interface[%s]\ should\ be\ created\ on\ host[uuid\:%s] = could not attach L2VirtualSwitchNetwork, because interface[{0}] should be created on host[uuid:{1}]

# at: src/main/java/org/zstack/network/l2/vxlan/vxlanNetwork/VxlanNetworkFactory.java:231
# args: inv.getUuid(),destHostUuid
cannot\ configure\ vxlan\ network\ for\ vm[uuid\:%s]\ on\ the\ destination\ host[uuid\:%s] = cannot configure vxlan network for vm[uuid:{0}] on the destination host[uuid:{1}]
Expand Down
16 changes: 16 additions & 0 deletions conf/i18n/messages_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7231,6 +7231,22 @@ There\ has\ been\ a\ L2VlanNetwork[uuid\:%s,\ name\:%s]\ attached\ to\ cluster[u
# args: l2.getUuid(),l2.getName(),msg.getClusterUuid(),l2.getPhysicalInterface(),tl2.getUuid()
There\ has\ been\ a\ l2Network[uuid\:%s,\ name\:%s]\ attached\ to\ cluster[uuid\:%s]\ that\ has\ physical\ interface[%s].\ Failed\ to\ attach\ l2Network[uuid\:%s] = 分布式交换机挂载失败[uuid:{4}]: 分布式交换机[uuid:{0}, name:{1}]的物理接口[{3}]]已经挂载到集群[uuid:{2}]上

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:84
# args: msg.getvSwitchUuid(),msg.getVlan()
could\ not\ create\ L2PortGroupNetwork,\ because\ L2VirtualSwitchNetwork[uuid\:%s]\ already\ has\ L2PortGroupNetworks\ with\ the\ same\ vlanId[%s] = 创建端口组失败,因为虚拟交换机[uuid:{0}]已经存在vlanId[{1}]的端口组

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:106
# args: vswitchVO.getPhysicalInterface(),msg.getClusterUuid()
could\ not\ attach\ L2VirtualSwitchNetwork,\ because\ interface[%s]\ in\ cluster[uuid\:%s]\ is\ already\ used\ for\ another\ L2VirtualSwitchNetwork = 挂载虚拟交换机失败,因为集群[uuid:{1}]中的网卡[{0}]已被其他虚拟交换机使用

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:113
# args: msg.getClusterUuid()
could\ not\ attach\ L2VirtualSwitchNetwork,\ because\ there\ are\ no\ hosts\ in\ cluster[uuid\:%s] = 挂载虚拟交换机失败,因为集群[uuid:{0}]中不存在任何物理机

# at: src/main/java/org/zstack/network/l2/virtualSwitch/VirtualSwitchApiInterceptor.java:126
# args: vswitchVO.getPhysicalInterface(),hostUuid
could\ not\ attach\ L2VirtualSwitchNetwork,\ because\ interface[%s]\ should\ be\ created\ on\ host[uuid\:%s] = 挂载虚拟交换机失败,因为网卡[{0}]应当在物理机[uuid:{1}]上创建

# at: src/main/java/org/zstack/network/l2/vxlan/vxlanNetwork/VxlanNetworkFactory.java:231
# args: inv.getUuid(),destHostUuid
cannot\ configure\ vxlan\ network\ for\ vm[uuid\:%s]\ on\ the\ destination\ host[uuid\:%s] = 无法为虚拟机[uuid:{0}]在目标主机[uuid:{1}]上配置VXLAN网络
Expand Down
1 change: 1 addition & 0 deletions conf/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<class>org.zstack.network.l2.vxlan.vtep.RemoteVtepVO</class>
<class>org.zstack.network.l2.vxlan.vxlanNetworkPool.VniRangeVO</class>
<class>org.zstack.header.network.l2.L2NetworkClusterRefVO</class>
<class>org.zstack.header.network.l2.L2NetworkHostRefVO</class>
<class>org.zstack.header.network.l3.L3NetworkVO</class>
<class>org.zstack.header.network.l3.L3NetworkEO</class>
<class>org.zstack.header.network.l3.L3NetworkDnsVO</class>
Expand Down
6 changes: 3 additions & 3 deletions docs/modules/network/pages/networkResource/L2NetworkImpl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ private void deleteL2Bridge(List<String> clusterUuids, Completion completion) {
.list();
List<ErrorCode> errs = new ArrayList<>();
new While<>(hosts).step((host,compl) -> {
HypervisorType hvType = HypervisorType.valueOf(host.getHypervisorType());
L2NetworkType l2Type = L2NetworkType.valueOf(self.getType());
HostInventory hostInv = HostInventory.valueOf(host);
L2NetworkInventory l2Inv = getSelfInventory();
L2NetworkRealizationExtensionPoint ext = l2Mgr.getRealizationExtension(l2Type, hvType);
L2NetworkRealizationExtensionPoint ext = l2Mgr.getRealizationExtension(l2Inv, hostInv);
ext.delete(getSelfInventory(), host.getUuid(), new Completion(compl){
@Override
public void success() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class APIAttachL2NetworkToClusterMsg extends APIMessage implements L2Netw
@APIParam(resourceType = ClusterVO.class)
private String clusterUuid;

@APIParam(required = false, validValues = {"LinuxBridge"})
private String l2ProviderType;

@Override
public String getL2NetworkUuid() {
return l2NetworkUuid;
Expand All @@ -69,7 +72,15 @@ public void setClusterUuid(String clusterUuid) {
public void setL2NetworkUuid(String l2NetworkUuid) {
this.l2NetworkUuid = l2NetworkUuid;
}


public String getL2ProviderType() {
return l2ProviderType;
}

public void setL2ProviderType(String l2ProviderType) {
this.l2ProviderType = l2ProviderType;
}

public static APIAttachL2NetworkToClusterMsg __example__() {
APIAttachL2NetworkToClusterMsg msg = new APIAttachL2NetworkToClusterMsg();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ doc {
optional true
since "0.6"
}
column {
name "l2ProviderType"
enclosedIn ""
desc ""
location "body"
type "String"
optional true
since "4.7.21"
values ("LinuxBridge")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.zstack.header.network.l2;

import org.zstack.header.message.NeedReplyMessage;

/**
*/
public class AttachL2NetworkToClusterMsg extends NeedReplyMessage implements L2NetworkMessage {
private String l2NetworkUuid;
private String clusterUuid;
private String l2ProviderType;

public String getL2NetworkUuid() {
return l2NetworkUuid;
}

public void setL2NetworkUuid(String l2NetworkUuid) {
this.l2NetworkUuid = l2NetworkUuid;
}

public String getClusterUuid() {
return clusterUuid;
}

public void setClusterUuid(String clusterUuid) {
this.clusterUuid = clusterUuid;
}

public String getL2ProviderType() {
return l2ProviderType;
}

public void setL2ProviderType(String l2ProviderType) {
this.l2ProviderType = l2ProviderType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.zstack.header.network.l2;

import org.zstack.header.message.MessageReply;

/**
*/
public class AttachL2NetworkToClusterReply extends MessageReply {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.zstack.header.network.l2;

public enum L2NetworkAttachStatus {
None,
CheckFailed,
AttachFailed,
Attached,
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
public class L2NetworkClusterRefInventory {
private String clusterUuid;
private String l2NetworkUuid;

private String l2ProviderType;

private Timestamp createDate;
private Timestamp lastOpDate;

Expand All @@ -28,6 +31,7 @@ public static L2NetworkClusterRefInventory valueOf(L2NetworkClusterRefVO vo) {
L2NetworkClusterRefInventory inv = new L2NetworkClusterRefInventory();
inv.setClusterUuid(vo.getClusterUuid());
inv.setL2NetworkUuid(vo.getL2NetworkUuid());
inv.setL2ProviderType(vo.getL2ProviderType());
inv.setCreateDate(vo.getCreateDate());
inv.setLastOpDate(vo.getLastOpDate());
return inv;
Expand All @@ -41,6 +45,14 @@ public static List<L2NetworkClusterRefInventory> valueOf(Collection<L2NetworkClu
return invs;
}

public String getL2ProviderType() {
return l2ProviderType;
}

public void setL2ProviderType(String l2ProviderType) {
this.l2ProviderType = l2ProviderType;
}

public String getClusterUuid() {
return clusterUuid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@ public class L2NetworkClusterRefVO {
@ForeignKey(parentEntityClass = L2NetworkEO.class, onDeleteAction = ReferenceOption.CASCADE)
private String l2NetworkUuid;

@Column
private String l2ProviderType;

@Column
private Timestamp createDate;

@Column
private Timestamp lastOpDate;

public String getL2ProviderType() {
return l2ProviderType;
}

public void setL2ProviderType(String l2ProviderType) {
this.l2ProviderType = l2ProviderType;
}

@PreUpdate
private void preUpdate() {
lastOpDate = null;
Expand Down Expand Up @@ -91,4 +102,5 @@ public Timestamp getLastOpDate() {
public void setLastOpDate(Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class L2NetworkClusterRefVO_ {
public static volatile SingularAttribute<L2NetworkClusterRefVO, Long> id;
public static volatile SingularAttribute<L2NetworkClusterRefVO, String> clusterUuid;
public static volatile SingularAttribute<L2NetworkClusterRefVO, String> l2NetworkUuid;
public static volatile SingularAttribute<L2NetworkClusterRefVO, String> l2ProviderType;
public static volatile SingularAttribute<L2NetworkClusterRefVO, Timestamp> createDate;
public static volatile SingularAttribute<L2NetworkClusterRefVO, Timestamp> lastOpDate;
}
Loading

0 comments on commit 8cd8b73

Please sign in to comment.