Skip to content

Commit 3f29ace

Browse files
authored
Merge pull request #1771 from nitin-maharana/nitin3
CLOUDSTACK-9611: Dedicating a Guest VLAN range to Project does not work.
2 parents 5fc97c0 + 63f534f commit 3f29ace

2 files changed

Lines changed: 121 additions & 78 deletions

File tree

api/src/org/apache/cloudstack/api/command/admin/network/DedicateGuestVlanRangeCmd.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,13 @@ public class DedicateGuestVlanRangeCmd extends BaseCmd {
5050
@Parameter(name = ApiConstants.VLAN_RANGE, type = CommandType.STRING, required = true, description = "guest vlan range to be dedicated")
5151
private String vlan;
5252

53-
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "account who will own the VLAN")
53+
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the VLAN")
5454
private String accountName;
5555

5656
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "project who will own the VLAN")
5757
private Long projectId;
5858

59-
@Parameter(name = ApiConstants.DOMAIN_ID,
60-
type = CommandType.UUID,
61-
entityType = DomainResponse.class,
62-
required = true,
63-
description = "domain ID of the account owning a VLAN")
59+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning a VLAN")
6460
private Long domainId;
6561

6662
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID,

ui/scripts/system.js

Lines changed: 119 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,27 +1793,57 @@
17931793
fields: {
17941794
vlanrange: {
17951795
label: 'label.vlan.vni.range',
1796-
/* select: function(args) {
1797-
var items = [];
1798-
if(args.context.physicalNetworks[0].vlan != null && args.context.physicalNetworks[0].vlan.length > 0) {
1799-
var vlanranges = args.context.physicalNetworks[0].vlan.split(";");
1800-
for(var i = 0; i < vlanranges.length ; i++) {
1801-
items.push({id: vlanranges[i], description: vlanranges[i]});
1802-
}
1803-
}
1804-
args.response.success({data: items});
1805-
},*/
18061796
validation: {
18071797
required: true
18081798
}
18091799
},
1810-
account: {
1811-
label: 'label.account',
1812-
validation: {
1813-
required: true
1800+
scope: {
1801+
label: 'label.scope',
1802+
docID: 'helpGuestNetworkZoneScope',
1803+
select: function(args) {
1804+
var array1 = [];
1805+
1806+
array1.push({
1807+
id: 'account-specific',
1808+
description: 'label.account'
1809+
});
1810+
array1.push({
1811+
id: 'project-specific',
1812+
description: 'label.project'
1813+
});
1814+
1815+
args.response.success({
1816+
data: array1
1817+
});
1818+
1819+
args.$select.change(function() {
1820+
var $form = $(this).closest('form');
1821+
1822+
if ($(this).val() == "account-specific") {
1823+
$form.find('.form-item[rel=domainId]').css('display', 'inline-block');
1824+
$form.find('.form-item[rel=account]').css('display', 'inline-block');
1825+
$form.find('.form-item[rel=projectId]').hide();
1826+
} else if ($(this).val() == "project-specific") {
1827+
$form.find('.form-item[rel=domainId]').css('display', 'inline-block');
1828+
$form.find('.form-item[rel=account]').hide();
1829+
$form.find('.form-item[rel=projectId]').css('display', 'inline-block');
1830+
}
1831+
1832+
if (args.context.projects != null && args.context.projects.length > 0) {
1833+
$form.find('.form-item[rel=domainId]').hide();
1834+
$form.find('.form-item[rel=account]').hide();
1835+
$form.find('.form-item[rel=projectId]').hide();
1836+
}
1837+
});
1838+
},
1839+
isHidden: function(args) {
1840+
if(args.context.projects != null && args.context.projects.length > 0)
1841+
return true;
1842+
else
1843+
return false;
18141844
}
18151845
},
1816-
domainid: {
1846+
domainId: {
18171847
label: 'label.domain',
18181848
validation: {
18191849
required: true
@@ -1836,16 +1866,87 @@
18361866
}
18371867
});
18381868
}
1869+
},
1870+
account: {
1871+
label: 'label.account',
1872+
validation: {
1873+
required: true
1874+
},
1875+
dependsOn: 'domainId',
1876+
select: function (args) {
1877+
$.ajax({
1878+
url: createURL('listAccounts&domainid=' + args.domainId),
1879+
data: {
1880+
listAll: true
1881+
},
1882+
success: function (json) {
1883+
args.response.success({
1884+
data: $.map(json.listaccountsresponse.account, function (account) {
1885+
return {
1886+
id: account.name,
1887+
description: account.name
1888+
};
1889+
})
1890+
});
1891+
}
1892+
});
1893+
}
1894+
},
1895+
projectId: {
1896+
label: 'label.project',
1897+
validation: {
1898+
required: true
1899+
},
1900+
dependsOn: 'domainId',
1901+
select: function(args) {
1902+
var items = [];
1903+
$.ajax({
1904+
url: createURL("listProjects&domainid=" + args.domainId),
1905+
dataType: "json",
1906+
async: false,
1907+
success: function(json) {
1908+
projectObjs = json.listprojectsresponse.project;
1909+
$(projectObjs).each(function() {
1910+
items.push({
1911+
id: this.id,
1912+
description: this.name
1913+
});
1914+
});
1915+
}
1916+
});
1917+
args.response.success({
1918+
data: items
1919+
});
1920+
}
18391921
}
18401922
}
18411923
},
18421924
action: function (args) {
18431925
var data = {
18441926
physicalnetworkid: args.context.physicalNetworks[0].id,
1845-
vlanrange: args.data.vlanrange,
1846-
domainid: args.data.domainid,
1847-
account: args.data.account
1927+
vlanrange: args.data.vlanrange
18481928
};
1929+
1930+
var $form = args.$form;
1931+
1932+
if (($form.find('.form-item[rel=domainId]').css("display") != "none") && (args.data.domainId != null && args.data.domainId.length > 0)) {
1933+
$.extend(data, {
1934+
domainid: args.data.domainId
1935+
})
1936+
}
1937+
1938+
if (($form.find('.form-item[rel=account]').css("display") != "none") && (args.data.account != null && args.data.account.length > 0)) {
1939+
$.extend(data, {
1940+
account: args.data.account
1941+
})
1942+
}
1943+
1944+
if (($form.find('.form-item[rel=projectId]').css("display") != "none") && (args.data.projectId != null && args.data.projectId.length > 0)) {
1945+
$.extend(data, {
1946+
projectid: args.data.projectId
1947+
})
1948+
}
1949+
18491950
$.ajax({
18501951
url: createURL('dedicateGuestVlanRange'),
18511952
data: data,
@@ -18718,60 +18819,6 @@
1871818819
ucsmanagerid: args.context.ucsManagers[0].id
1871918820
},
1872018821
success: function (json) {
18721-
//for testing only (begin)
18722-
/*
18723-
json = {
18724-
"refreshucsbladesresponse": {
18725-
"count": 7,
18726-
"ucsblade": [
18727-
{
18728-
"id": "6c6a2d2c-575e-41ac-9782-eee51b0b80f8",
18729-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18730-
"bladedn": "sys/chassis-1/blade-5"
18731-
},
18732-
{
18733-
"id": "d371d470-a51f-489c-aded-54a63dfd76c7",
18734-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18735-
"bladedn": "sys/chassis-1/blade-6"
18736-
},
18737-
{
18738-
"id": "c0f64591-4a80-4083-bb7b-576220b436a2",
18739-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18740-
"bladedn": "sys/chassis-1/blade-7"
18741-
},
18742-
{
18743-
"id": "74b9b69a-cb16-42f5-aad6-06391ebdd759",
18744-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18745-
"bladedn": "sys/chassis-1/blade-1"
18746-
},
18747-
{
18748-
"id": "713a5adb-0136-484f-9acb-d9203af497be",
18749-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18750-
"bladedn": "sys/chassis-1/blade-2"
18751-
},
18752-
{
18753-
"id": "da633578-21cb-4678-9eb4-981a53198b41",
18754-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18755-
"bladedn": "sys/chassis-1/blade-4"
18756-
},
18757-
{
18758-
"id": "3d491c6e-f0b6-40b0-bf6e-f89efdd73c30",
18759-
"ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a",
18760-
"bladedn": "sys/chassis-1/blade-3"
18761-
}
18762-
]
18763-
}
18764-
};
18765-
*/
18766-
//for testing only (end)
18767-
18768-
/*
18769-
var item = json.refreshucsbladesresponse.ucsblade[0];
18770-
addExtraPropertiesToUcsBladeObject(item);
18771-
args.response.success({
18772-
data: item
18773-
});
18774-
*/
1877518822
$(window).trigger('cloudStack.fullRefresh');
1877618823
}
1877718824
});

0 commit comments

Comments
 (0)