mirror of https://github.com/apache/cloudstack.git
NaaS: Fix UUID of virtual router providers
This commit is contained in:
parent
da846e9c08
commit
cdfac9a5e1
|
|
@ -23,6 +23,7 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.PlugService;
|
||||
|
|
@ -50,9 +51,11 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName = "virtual_router_providers")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the virtual router provider")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName = "physical_network_service_providers")
|
||||
@Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enabled/Disabled the service provider")
|
||||
private Boolean enabled;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.PlugService;
|
||||
|
|
@ -50,6 +51,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
|||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.LONG, required=true, description="the network service provider ID of the virtual router element")
|
||||
@IdentityMapper(entityTableName="physical_network_service_providers")
|
||||
private Long nspId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.PlugService;
|
||||
|
|
@ -31,9 +32,11 @@ public class ListVirtualRouterElementsCmd extends BaseListCmd {
|
|||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName = "virtual_router_providers")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list virtual router elements by id")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName = "physical_network_service_providers")
|
||||
@Parameter(name=ApiConstants.NSP_ID, type=CommandType.LONG, description="list virtual router elements by network service provider id")
|
||||
private Long nspId;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class VirtualRouterProviderResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
|
||||
private Long id;
|
||||
private IdentityProxy id = new IdentityProxy("virtual_router_providers");
|
||||
|
||||
@SerializedName(ApiConstants.NSP_ID) @Param(description="the physical network service provider id of the provider")
|
||||
private Long nspId;
|
||||
private IdentityProxy nspId = new IdentityProxy("physical_network_service_providers");
|
||||
|
||||
@SerializedName(ApiConstants.ENABLED) @Param(description="Enabled/Disabled the service provider")
|
||||
private Boolean enabled;
|
||||
|
|
@ -35,11 +36,7 @@ public class VirtualRouterProviderResponse extends BaseResponse implements Contr
|
|||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,19 +60,10 @@ public class VirtualRouterProviderResponse extends BaseResponse implements Contr
|
|||
}
|
||||
|
||||
public void setNspId(Long nspId) {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
this.nspId.setValue(nspId);
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
|
||||
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
|
||||
if (routers == null || routers.isEmpty()) {
|
||||
s_logger.trace("Can't find dhcp element in network " + network.getId());
|
||||
s_logger.debug("Can't find virtual router element in network " + network.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
public VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findById(cmd.getId());
|
||||
if (element == null) {
|
||||
s_logger.trace("Can't find element with network service provider id " + cmd.getId());
|
||||
s_logger.debug("Can't find element with network service provider id " + cmd.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -404,10 +404,10 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
public VirtualRouterProvider addElement(Long nspId) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.VirtualRouter);
|
||||
if (element != null) {
|
||||
s_logger.trace("There is already a virtual router element with service provider id " + nspId);
|
||||
s_logger.debug("There is already a virtual router element with service provider id " + nspId);
|
||||
return null;
|
||||
}
|
||||
element = new VirtualRouterProviderVO(nspId, null, VirtualRouterProviderType.VirtualRouter);
|
||||
element = new VirtualRouterProviderVO(nspId, VirtualRouterProviderType.VirtualRouter);
|
||||
_vrProviderDao.persist(element);
|
||||
return element;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package com.cloud.network.element;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -56,12 +57,13 @@ public class VirtualRouterProviderVO implements VirtualRouterProvider {
|
|||
Date removed;
|
||||
|
||||
public VirtualRouterProviderVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public VirtualRouterProviderVO(long nspId, String uuid, VirtualRouterProviderType type) {
|
||||
public VirtualRouterProviderVO(long nspId, VirtualRouterProviderType type) {
|
||||
this.nspId = nspId;
|
||||
this.uuid = uuid;
|
||||
this.type = type;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1983,12 +1983,13 @@ CREATE TABLE `cloud`.`network_external_firewall_device_map` (
|
|||
CREATE TABLE `cloud`.`virtual_router_providers` (
|
||||
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
|
||||
`nsp_id` bigint unsigned NOT NULL COMMENT 'Network Service Provider ID',
|
||||
`uuid` varchar(255) UNIQUE,
|
||||
`uuid` varchar(40),
|
||||
`type` varchar(255) NOT NULL COMMENT 'Virtual router, or ElbVM',
|
||||
`enabled` int(1) NOT NULL COMMENT 'Enabled or disabled',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_virtual_router_providers__nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE
|
||||
CONSTRAINT `fk_virtual_router_providers__nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `uc_virtual_router_providers__uuid` UNIQUE (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue