mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Persist the uuid of the logical router once created
This commit is contained in:
parent
af77912034
commit
dd68a00338
@ -179,6 +179,7 @@ under the License.
|
||||
<dao name="OvsTunnelAccountDao" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" singleton="false"/>
|
||||
<dao name="NiciraNvpDao" class="com.cloud.network.dao.NiciraNvpDaoImpl" singleton="false"/>
|
||||
<dao name="NiciraNvpNicMappingDao" class="com.cloud.network.dao.NiciraNvpNicMappingDaoImpl" singleton="false"/>
|
||||
<dao name="NiciraNvpRouterMappingDao" class="com.cloud.network.dao.NiciraNvpRouterMappingDaoImpl" singleton="false"/>
|
||||
<dao name="ElasticLbVmMapDao" class="com.cloud.network.lb.dao.ElasticLbVmMapDaoImpl" singleton="false"/>
|
||||
</management-server>
|
||||
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="nicira_nvp_router_map")
|
||||
public class NiciraNvpRouterMappingVO {
|
||||
//FIXME the ddl for this table should be in one of the upgrade scripts
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="logicalrouter_uuid")
|
||||
private String logicalRouterUuid;
|
||||
|
||||
@Column(name="network_id")
|
||||
private long networkId;
|
||||
|
||||
public NiciraNvpRouterMappingVO() {
|
||||
}
|
||||
|
||||
public NiciraNvpRouterMappingVO(String logicalRouterUuid, long networkId) {
|
||||
this.logicalRouterUuid = logicalRouterUuid;
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public NiciraNvpRouterMappingVO(long id, String logicalRouterUuid, long networkId) {
|
||||
this.id = id;
|
||||
this.logicalRouterUuid = logicalRouterUuid;
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLogicalRouterUuid() {
|
||||
return logicalRouterUuid;
|
||||
}
|
||||
|
||||
public void setLogicalRouterUuid(String logicalRouterUuid) {
|
||||
this.logicalRouterUuid = logicalRouterUuid;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public void setNetworkId(long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import com.cloud.network.NiciraNvpRouterMappingVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface NiciraNvpRouterMappingDao extends GenericDao<NiciraNvpRouterMappingVO, Long> {
|
||||
|
||||
public NiciraNvpRouterMappingVO findByNetworkIdI(long id);
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.network.NiciraNvpRouterMappingVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Local(value=NiciraNvpRouterMappingDao.class)
|
||||
public class NiciraNvpRouterMappingDaoImpl extends GenericDaoBase<NiciraNvpRouterMappingVO, Long> implements NiciraNvpRouterMappingDao {
|
||||
|
||||
protected final SearchBuilder<NiciraNvpRouterMappingVO> networkSearch;
|
||||
|
||||
public NiciraNvpRouterMappingDaoImpl() {
|
||||
networkSearch = createSearchBuilder();
|
||||
networkSearch.and("network_id", networkSearch.entity().getNetworkId(), Op.EQ);
|
||||
networkSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NiciraNvpRouterMappingVO findByNetworkIdI(long id) {
|
||||
SearchCriteria<NiciraNvpRouterMappingVO> sc = networkSearch.create();
|
||||
sc.setParameters("network_id", id);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -90,6 +90,7 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NiciraNvpDeviceVO;
|
||||
import com.cloud.network.NiciraNvpNicMappingVO;
|
||||
import com.cloud.network.NiciraNvpRouterMappingVO;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkVO;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
@ -98,6 +99,7 @@ import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NiciraNvpDao;
|
||||
import com.cloud.network.dao.NiciraNvpNicMappingDao;
|
||||
import com.cloud.network.dao.NiciraNvpRouterMappingDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
|
||||
@ -154,6 +156,8 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
@Inject
|
||||
NiciraNvpNicMappingDao _niciraNvpNicMappingDao;
|
||||
@Inject
|
||||
NiciraNvpRouterMappingDao _niciraNvpRouterMappingDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
@ -281,6 +285,10 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the uuid so we can easily find it during cleanup
|
||||
NiciraNvpRouterMappingVO routermapping =
|
||||
new NiciraNvpRouterMappingVO(cmd.getLogicalSwitchUuid(), network.getId());
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
@ -446,15 +454,23 @@ public class NiciraNvpElement extends AdapterBase implements
|
||||
|
||||
// Deleting the LogicalRouter will also take care of all provisioned
|
||||
// nat rules.
|
||||
/*
|
||||
* DeleteLogicalRouterCommand cmd = new
|
||||
* DeleteLogicalRouterCommand(""); DeleteLogicalRouterAnswer answer
|
||||
* = (DeleteLogicalRouterAnswer)
|
||||
* _agentMgr.easySend(niciraNvpHost.getId(), cmd); if
|
||||
* (answer.getResult() == false) {
|
||||
* s_logger.error("Failed to delete LogicalRouter for network " +
|
||||
* network.getDisplayText()); return false; }
|
||||
*/}
|
||||
NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
|
||||
.findByNetworkIdI(network.getId());
|
||||
if (routermapping == null) {
|
||||
s_logger.error("No logical router uuid found for network "
|
||||
+ network.getDisplayText());
|
||||
return false;
|
||||
}
|
||||
|
||||
DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
|
||||
DeleteLogicalRouterAnswer answer =
|
||||
(DeleteLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to delete LogicalRouter for network "
|
||||
+ network.getDisplayText());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -146,6 +146,7 @@ DROP TABLE IF EXISTS `cloud`.`s2s_vpn_gateway`;
|
||||
DROP TABLE IF EXISTS `cloud`.`s2s_vpn_connection`;
|
||||
DROP TABLE IF EXISTS `cloud`,`external_nicira_nvp_devices`;
|
||||
DROP TABLE IF EXISTS `cloud`,`nicira_nvp_nic_map`;
|
||||
DROP TABLE IF EXISTS `cloud`,`nicira_nvp_router_map`;
|
||||
|
||||
CREATE TABLE `cloud`.`version` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
@ -2370,5 +2371,13 @@ CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`nicira_nvp_router_map` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`logicalrouter_uuid` varchar(255) NOT NULL UNIQUE COMMENT 'nicira uuid of logical router',
|
||||
`network_id` bigint unsigned NOT NULL UNIQUE COMMENT 'cloudstack id of the network',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_nicira_nvp_router_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user