Enabled the traffic lable support the hyperv hypervisor type. Modified the physical_network_traffic_types table to introduce hyperv_network lable column.

Modified associated VO's and impls classes. Modified the List/Update/Add TrafficType command api's and response classes.
Fixed the Unit tests
This commit is contained in:
Rajesh Battala 2013-11-08 19:49:10 +05:30
parent 4674ae4dd3
commit 19e9849d86
17 changed files with 94 additions and 16 deletions

View File

@ -116,11 +116,11 @@ public interface NetworkService {
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType,
String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan);
String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan, String hypervLabel);
PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id);
PhysicalNetworkTrafficType updatePhysicalNetworkTrafficType(Long id, String xenLabel, String kvmLabel, String vmwareLabel);
PhysicalNetworkTrafficType updatePhysicalNetworkTrafficType(Long id, String xenLabel, String kvmLabel, String vmwareLabel, String hypervLabel);
boolean deletePhysicalNetworkTrafficType(Long id);

View File

@ -37,4 +37,6 @@ public interface PhysicalNetworkTrafficType extends InternalIdentity, Identity {
String getVmwareNetworkLabel();
String getSimulatorNetworkLabel();
String getHypervNetworkLabel();
}

View File

@ -355,6 +355,7 @@ public class ApiConstants {
public static final String XEN_NETWORK_LABEL = "xennetworklabel";
public static final String KVM_NETWORK_LABEL = "kvmnetworklabel";
public static final String VMWARE_NETWORK_LABEL = "vmwarenetworklabel";
public static final String HYPERV_NETWORK_LABEL = "hypervnetworklabel";
public static final String NETWORK_SERVICE_PROVIDER_ID = "nspid";
public static final String SERVICE_LIST = "servicelist";
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";

View File

@ -60,6 +60,9 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.VMWARE_NETWORK_LABEL, type=CommandType.STRING, description="The network name label of the physical device dedicated to this traffic on a VMware host")
private String vmwareLabel;
@Parameter(name=ApiConstants.HYPERV_NETWORK_LABEL, type=CommandType.STRING, description="The network name label of the physical device dedicated to this traffic on a Hyperv host")
private String hypervLabel;
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="The VLAN id to be used for Management traffic by VMware host")
private String vlan;
@ -88,6 +91,10 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
return vmwareLabel;
}
public String getHypervLabel() {
return hypervLabel;
}
public String getSimulatorLabel() {
//simulators will have no labels
return null;
@ -130,7 +137,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException {
PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getSimulatorLabel(), getVlan());
PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getSimulatorLabel(), getVlan(), getHypervLabel());
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());

View File

@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.BaseCmd.CommandType;
import org.apache.cloudstack.api.response.TrafficTypeResponse;
import org.apache.log4j.Logger;
@ -53,6 +54,8 @@ public class UpdateTrafficTypeCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.VMWARE_NETWORK_LABEL, type=CommandType.STRING, description="The network name label of the physical device dedicated to this traffic on a VMware host")
private String vmwareLabel;
@Parameter(name=ApiConstants.HYPERV_NETWORK_LABEL, type=CommandType.STRING, description="The network name label of the physical device dedicated to this traffic on a Hyperv host")
private String hypervLabel;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -73,6 +76,10 @@ public class UpdateTrafficTypeCmd extends BaseAsyncCmd {
return vmwareLabel;
}
public String getHypervLabel() {
return hypervLabel;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -89,7 +96,7 @@ public class UpdateTrafficTypeCmd extends BaseAsyncCmd {
@Override
public void execute(){
PhysicalNetworkTrafficType result = _networkService.updatePhysicalNetworkTrafficType(getId(), getXenLabel(), getKvmLabel(), getVmwareLabel());
PhysicalNetworkTrafficType result = _networkService.updatePhysicalNetworkTrafficType(getId(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getHypervLabel());
if (result != null) {
TrafficTypeResponse response = _responseGenerator.createTrafficTypeResponse(result);
response.setResponseName(getCommandName());

View File

@ -45,6 +45,9 @@ public class TrafficTypeResponse extends BaseResponse {
@SerializedName(ApiConstants.VMWARE_NETWORK_LABEL) @Param(description="The network name label of the physical device dedicated to this traffic on a VMware host")
private String vmwareNetworkLabel;
@SerializedName(ApiConstants.HYPERV_NETWORK_LABEL) @Param(description="The network name label of the physical device dedicated to this traffic on a HyperV host")
private String hypervNetworkLabel;
@Override
public String getObjectId() {
@ -82,10 +85,17 @@ public class TrafficTypeResponse extends BaseResponse {
public String getKvmLabel() {
return kvmNetworkLabel;
}
public String getHypervLabel() {
return hypervNetworkLabel;
}
public void setXenLabel(String xenLabel) {
this.xenNetworkLabel = xenLabel;
}
public void setHypervLabel(String hypervLabel) {
this.hypervNetworkLabel = hypervLabel;
}
public void setKvmLabel(String kvmLabel) {
this.kvmNetworkLabel = kvmLabel;

View File

@ -27,7 +27,7 @@ public interface DataStoreProvider {
static final String S3_IMAGE = "S3";
static final String SWIFT_IMAGE = "Swift";
static final String SAMPLE_IMAGE = "Sample";
static final String SMB = "NFS";
static final String DEFAULT_PRIMARY = "DefaultPrimary";
static enum DataStoreProviderType {

View File

@ -41,6 +41,7 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNe
final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> vmWareAllFieldsSearch;
final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> simulatorAllFieldsSearch;
final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> ovmAllFieldsSearch;
final GenericSearchBuilder<PhysicalNetworkTrafficTypeVO, String> hypervAllFieldsSearch;
protected PhysicalNetworkTrafficTypeDaoImpl() {
super();
@ -55,6 +56,13 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNe
kvmAllFieldsSearch.selectFields(kvmAllFieldsSearch.entity().getKvmNetworkLabel());
kvmAllFieldsSearch.done();
hypervAllFieldsSearch = createSearchBuilder(String.class);
hypervAllFieldsSearch.and("physicalNetworkId", hypervAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
hypervAllFieldsSearch.and("trafficType", hypervAllFieldsSearch.entity().getTrafficType(), Op.EQ);
hypervAllFieldsSearch.selectFields(hypervAllFieldsSearch.entity().getHypervNetworkLabel());
hypervAllFieldsSearch.done();
xenAllFieldsSearch = createSearchBuilder(String.class);
xenAllFieldsSearch.and("physicalNetworkId", xenAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
xenAllFieldsSearch.and("trafficType", xenAllFieldsSearch.entity().getTrafficType(), Op.EQ);
@ -114,7 +122,10 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNe
sc = ovmAllFieldsSearch.create();
} else if (hType == HypervisorType.BareMetal) {
return null;
} else {
} else if (hType == HypervisorType.Hyperv) {
sc = hypervAllFieldsSearch.create();
}
else {
assert(false) : "We don't handle this hypervisor type";
return null;
}

View File

@ -61,19 +61,23 @@ public class PhysicalNetworkTrafficTypeVO implements PhysicalNetworkTrafficType
@Column(name = "simulator_network_label")
private String simulatorNetworkLabel;
@Column(name = "hyperv_network_label")
private String hypervNetworkLabel;
@Column(name = "vlan")
private String vlan;
public PhysicalNetworkTrafficTypeVO() {
}
public PhysicalNetworkTrafficTypeVO(long physicalNetworkId, TrafficType trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan) {
public PhysicalNetworkTrafficTypeVO(long physicalNetworkId, TrafficType trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan, String hypervLabel) {
this.physicalNetworkId = physicalNetworkId;
this.trafficType = trafficType;
this.xenNetworkLabel = xenLabel;
this.kvmNetworkLabel = kvmLabel;
this.vmwareNetworkLabel = vmwareLabel;
this.simulatorNetworkLabel = simulatorLabel;
this.hypervNetworkLabel = hypervLabel;
this.setVlan(vlan);
this.uuid = UUID.randomUUID().toString();
}
@ -146,4 +150,13 @@ public class PhysicalNetworkTrafficTypeVO implements PhysicalNetworkTrafficType
this.uuid = uuid;
}
public void setHypervNetworkLabel(String hypervNetworkLable) {
this.hypervNetworkLabel = hypervNetworkLable;
}
@Override
public String getHypervNetworkLabel() {
return hypervNetworkLabel;
}
}

View File

@ -315,7 +315,7 @@ public class ManagementServerMock {
_znet = _networkService.getPhysicalNetwork(id);
List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
if (nets == null || nets.isEmpty()) {
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), null, null, null, null, null);
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), null, null, null, null, null, null);
}
} catch (InvalidParameterValueException e) {
List<String> isolationMethods = new ArrayList<String>();
@ -325,7 +325,7 @@ public class ManagementServerMock {
null, "znet");
List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
if (nets == null || nets.isEmpty()) {
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), null, null, null, null, null);
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), null, null, null, null, null, null);
}
}
if (_znet.getState() != PhysicalNetwork.State.Enabled) {
@ -344,7 +344,7 @@ public class ManagementServerMock {
}
if (!found) {
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Guest.toString(),
null, null, null, null, null);
null, null, null, null, null, null);
}
Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> providers =

View File

@ -2696,6 +2696,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setXenLabel(result.getXenNetworkLabel());
response.setKvmLabel(result.getKvmNetworkLabel());
response.setVmwareLabel(result.getVmwareNetworkLabel());
response.setHypervLabel(result.getHypervNetworkLabel());
response.setObjectName("traffictype");
return response;

View File

@ -275,6 +275,11 @@ public enum Config {
KvmPrivateNetwork("Hidden", ManagementServer.class, String.class, "kvm.private.network.device", null, "Specify the private bridge on host for private network", null),
KvmGuestNetwork("Hidden", ManagementServer.class, String.class, "kvm.guest.network.device", null, "Specify the private bridge on host for private network", null),
KvmSshToAgentEnabled("Advanced", ManagementServer.class, Boolean.class, "kvm.ssh.to.agent", "true", "Specify whether or not the management server is allowed to SSH into KVM Agents", null),
// Hyperv
HypervPublicNetwork("Hidden", ManagementServer.class, String.class, "hyperv.public.network.device", null, "Specify the public virtual switch on host for public network", null),
HypervPrivateNetwork("Hidden", ManagementServer.class, String.class, "hyperv.private.network.device", null, "Specify the virtual switch on host for private network", null),
HypervGuestNetwork("Hidden", ManagementServer.class, String.class, "hyperv.guest.network.device", null, "Specify the virtual switch on host for private network", null),
// Usage
UsageExecutionTimezone("Usage", ManagementServer.class, String.class, "usage.execution.timezone", null, "The timezone to use for usage job execution time", null),

View File

@ -1738,7 +1738,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
_networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(),
TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(),
mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(),
mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan());
mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan(), mgmtTraffic.getHypervNetworkLabel());
s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network "
+ mgmtPhyNetwork.getId() + " with same configure of management traffic type");
}

View File

@ -1179,6 +1179,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
break;
case VMware : label = mgmtTraffic.getVmwareNetworkLabel();
break;
case Hyperv:
label = mgmtTraffic.getHypervNetworkLabel();
break;
}
return label;
}
@ -1204,6 +1207,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
break;
case VMware : label = storageTraffic.getVmwareNetworkLabel();
break;
case Hyperv:
label = storageTraffic.getHypervNetworkLabel();
break;
}
return label;
}
@ -1549,6 +1555,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
case VMware:
label = publicTraffic.getVmwareNetworkLabel();
break;
case Hyperv:
label = publicTraffic.getHypervNetworkLabel();
break;
}
return label;
}
@ -1578,6 +1587,10 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
case VMware:
label = guestTraffic.getVmwareNetworkLabel();
break;
case Hyperv:
label = guestTraffic.getHypervNetworkLabel();
break;
}
return label;
}

View File

@ -3542,7 +3542,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_CREATE, eventDescription = "Creating Physical Network TrafficType", create = true)
public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficTypeStr, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan) {
public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficTypeStr, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan, String hypervLabel) {
// verify input parameters
PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
@ -3592,7 +3592,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
if (xenLabel == null) {
xenLabel = getDefaultXenNetworkLabel(trafficType);
}
PhysicalNetworkTrafficTypeVO pNetworktrafficType = new PhysicalNetworkTrafficTypeVO(physicalNetworkId, trafficType, xenLabel, kvmLabel, vmwareLabel, simulatorLabel, vlan);
PhysicalNetworkTrafficTypeVO pNetworktrafficType = new PhysicalNetworkTrafficTypeVO(physicalNetworkId, trafficType, xenLabel, kvmLabel, vmwareLabel, simulatorLabel, vlan, hypervLabel);
pNetworktrafficType = _pNTrafficTypeDao.persist(pNetworktrafficType);
return pNetworktrafficType;
@ -3636,7 +3636,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
@Override
@ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_UPDATE, eventDescription = "Updating physical network TrafficType", async = true)
public PhysicalNetworkTrafficType updatePhysicalNetworkTrafficType(Long id, String xenLabel, String kvmLabel, String vmwareLabel) {
public PhysicalNetworkTrafficType updatePhysicalNetworkTrafficType(Long id, String xenLabel, String kvmLabel, String vmwareLabel, String hypervLabel) {
PhysicalNetworkTrafficTypeVO trafficType = _pNTrafficTypeDao.findById(id);
@ -3662,6 +3662,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
}
trafficType.setVmwareNetworkLabel(vmwareLabel);
}
if (hypervLabel != null) {
if("".equals(hypervLabel)){
hypervLabel = null;
}
trafficType.setHypervNetworkLabel(hypervLabel);
}
_pNTrafficTypeDao.update(id, trafficType);
return trafficType;

View File

@ -520,7 +520,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
*/
@Override
public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType,
String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan) {
String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan, String hypervLabel) {
// TODO Auto-generated method stub
return null;
}
@ -547,7 +547,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
*/
@Override
public PhysicalNetworkTrafficType updatePhysicalNetworkTrafficType(Long id, String xenLabel, String kvmLabel,
String vmwareLabel) {
String vmwareLabel, String hypervLabel) {
// TODO Auto-generated method stub
return null;
}

View File

@ -493,6 +493,7 @@ CREATE TABLE `load_balancer_cert_map` (
CONSTRAINT `fk_load_balancer_cert_map__load_balancer_id` FOREIGN KEY (`load_balancer_id`) REFERENCES `load_balancing_rules` (`id`) ON DELETE CASCADE);
ALTER TABLE `cloud`.`host` ADD COLUMN `cpu_sockets` int(10) unsigned DEFAULT NULL COMMENT "the number of CPU sockets on the host" AFTER pod_id;
ALTER TABLE `cloud`.`physical_network_traffic_types` ADD COLUMN `hyperv_network_label` varchar(255) DEFAULT NULL COMMENT 'The network name label of the physical device dedicated to this traffic on a HyperV host';
DROP VIEW IF EXISTS `cloud`.`host_view`;
CREATE VIEW `cloud`.`host_view` AS