mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-10164: allow users to create a VPC through the UI. (#2345)
The listNuageVspDomainTemplat cmd was called by the ui when the create vpc dialog was opened. This command failed when no nuage vsp device was present. As a consequence the ui did not show the dialog. So currently it's not possible to create a vpc through the UI with a native CloudStack deployment. This bugfix, adds robustness to the ui that in case the cmd fails the dialog will appear nonetheless . Furthermore I also changed the listNuageVspDomainTemplateCmd to always return an empty result when there is no nuage zone.
This commit is contained in:
parent
ef4adb3672
commit
8f35657ac2
|
|
@ -57,6 +57,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
|
@ -845,18 +846,23 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
|
|||
if (passedPhysicalNetworkId != null) {
|
||||
physicalNetworkId = Optional.of(passedPhysicalNetworkId);
|
||||
} else if (zoneId != null) {
|
||||
physicalNetworkId = Optional.of(getPhysicalNetworkBasedOnZone(zoneId));
|
||||
physicalNetworkId = Optional.ofNullable(getPhysicalNetworkBasedOnZone(zoneId));
|
||||
} else {
|
||||
throw new InvalidParameterValueException("No zoneid or physicalnetworkid specified.");
|
||||
}
|
||||
|
||||
List<VspDomainTemplate> domainTemplates;
|
||||
if (!physicalNetworkId.isPresent()) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
Long hostId = getNuageVspHostId(physicalNetworkId.get());
|
||||
if (hostId == null) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
ListVspDomainTemplatesCommand agentCmd = new ListVspDomainTemplatesCommand(vspDomain, keyword);
|
||||
Long hostId = getNuageVspHostId(physicalNetworkId.get());
|
||||
|
||||
ListVspDomainTemplatesAnswer answer = (ListVspDomainTemplatesAnswer) _agentMgr.easySend(hostId, agentCmd);
|
||||
domainTemplates = answer.getDomainTemplates();
|
||||
List<VspDomainTemplate> domainTemplates = answer.getDomainTemplates();
|
||||
|
||||
return domainTemplates.stream()
|
||||
.map(NuageVspManagerImpl::createDomainTemplateResponse)
|
||||
|
|
@ -926,6 +932,10 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
|
|||
@Override
|
||||
public boolean entityExist(EntityExistsCommand cmd, Long physicalNetworkId){
|
||||
Long hostId = getNuageVspHostId(physicalNetworkId);
|
||||
if (hostId == null) {
|
||||
throw new CloudRuntimeException("There is no Nuage VSP device configured on physical network " + physicalNetworkId);
|
||||
}
|
||||
|
||||
Answer answer = _agentMgr.easySend(hostId, cmd);
|
||||
if (answer != null) {
|
||||
return answer.getResult();
|
||||
|
|
@ -1168,7 +1178,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
|
|||
return config.getHostId();
|
||||
}
|
||||
|
||||
throw new CloudRuntimeException("There is no Nuage VSP device configured on physical network " + physicalNetworkId);
|
||||
return null;
|
||||
}
|
||||
|
||||
@DB
|
||||
|
|
|
|||
|
|
@ -5245,65 +5245,66 @@
|
|||
args.context.domainTemplateMap = [];
|
||||
args.context.globalDomainTemplateUsed = [];
|
||||
}
|
||||
$.ajax({
|
||||
url: createURL('listNuageVspDomainTemplates'),
|
||||
dataType: "json",
|
||||
data: {
|
||||
zoneid: args.zoneid
|
||||
},
|
||||
async: true,
|
||||
success: function (json) {
|
||||
$.ajax({
|
||||
url: createURL('listNuageVspGlobalDomainTemplate'),
|
||||
dataType: "json",
|
||||
data: {
|
||||
name: "nuagevsp.vpc.domaintemplate.name"
|
||||
},
|
||||
async: true,
|
||||
success: function(PDTjson){
|
||||
var domaintemplates = json.listnuagevspdomaintemplatesresponse.domaintemplates ? json.listnuagevspdomaintemplatesresponse.domaintemplates : [];
|
||||
var preConfiguredDomainTemplate = PDTjson.listnuagevspglobaldomaintemplateresponse.count == 1 ? PDTjson.listnuagevspglobaldomaintemplateresponse.domaintemplates[0].name : "";
|
||||
|
||||
if (!domaintemplates.length) {
|
||||
args.$form.find("[rel=nuageusedomaintemplate]").hide();
|
||||
}
|
||||
$.ajax({
|
||||
url: createURL('listNuageVspDomainTemplates'),
|
||||
dataType: "json",
|
||||
data: {
|
||||
zoneid: args.zoneid
|
||||
},
|
||||
async: true,
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
args.response.success({});
|
||||
},
|
||||
success: function (json) {
|
||||
$.ajax({
|
||||
url: createURL('listNuageVspGlobalDomainTemplate'),
|
||||
dataType: "json",
|
||||
data: {
|
||||
name: "nuagevsp.vpc.domaintemplate.name"
|
||||
},
|
||||
async: true,
|
||||
success: function(PDTjson){
|
||||
var domaintemplates = json.listnuagevspdomaintemplatesresponse.domaintemplates ? json.listnuagevspdomaintemplatesresponse.domaintemplates : [];
|
||||
var preConfiguredDomainTemplate = PDTjson.listnuagevspglobaldomaintemplateresponse.count == 1 ? PDTjson.listnuagevspglobaldomaintemplateresponse.domaintemplates[0].name : "";
|
||||
|
||||
var index = -1;
|
||||
$.each(domaintemplates, function(key,value) {
|
||||
if (preConfiguredDomainTemplate == value.name) {
|
||||
index = key;
|
||||
}
|
||||
});
|
||||
|
||||
//Set global pre configured DT as the default by placing it to the top of the drop down list.
|
||||
if (index != -1) {
|
||||
domaintemplates.unshift(domaintemplates[index]);
|
||||
domaintemplates.splice(index + 1, 1);
|
||||
args.$form.find("[rel=nuageusedomaintemplate]").show();
|
||||
args.$form.find("[rel=nuagedomaintemplatelist]").show();
|
||||
args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', true);
|
||||
args.context.globalDomainTemplateUsed[args.zoneid] = true;
|
||||
} else {
|
||||
args.context.globalDomainTemplateUsed[args.zoneid] = false;
|
||||
}
|
||||
|
||||
args.context.domainTemplateMap[args.zoneid] = domaintemplates;
|
||||
args.response.success({
|
||||
data: $.map(domaintemplates, function (dt) {
|
||||
return {
|
||||
id: dt.name,
|
||||
description: dt.description
|
||||
};
|
||||
})
|
||||
});
|
||||
if (!domaintemplates.length) {
|
||||
args.$form.find("[rel=nuageusedomaintemplate]").hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
var index = -1;
|
||||
$.each(domaintemplates, function(key,value) {
|
||||
if (preConfiguredDomainTemplate == value.name) {
|
||||
index = key;
|
||||
}
|
||||
});
|
||||
|
||||
//}
|
||||
//Set global pre configured DT as the default by placing it to the top of the drop down list.
|
||||
if (index != -1) {
|
||||
domaintemplates.unshift(domaintemplates[index]);
|
||||
domaintemplates.splice(index + 1, 1);
|
||||
args.$form.find("[rel=nuageusedomaintemplate]").show();
|
||||
args.$form.find("[rel=nuagedomaintemplatelist]").show();
|
||||
args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', true);
|
||||
args.context.globalDomainTemplateUsed[args.zoneid] = true;
|
||||
} else {
|
||||
args.context.globalDomainTemplateUsed[args.zoneid] = false;
|
||||
}
|
||||
|
||||
args.context.domainTemplateMap[args.zoneid] = domaintemplates;
|
||||
args.response.success({
|
||||
data: $.map(domaintemplates, function (dt) {
|
||||
return {
|
||||
id: dt.name,
|
||||
description: dt.description
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue