mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
88d66e89fa
@ -1,4 +1,8 @@
|
||||
#new labels (begin) **********************************************************************************************
|
||||
label.action.enable.physical.network=Enable physical network
|
||||
label.action.disable.physical.network=Disable physical network
|
||||
message.action.enable.physical.network=Please confirm that you want to enable this physical network.
|
||||
message.action.disable.physical.network=Please confirm that you want to disable this physical network.
|
||||
label.ipaddress=IP Address
|
||||
label.vcdcname=vCenter DC name
|
||||
label.vcipaddress=vCenter IP Address
|
||||
|
||||
@ -139,6 +139,7 @@ import com.cloud.storage.swift.SwiftManager;
|
||||
import com.cloud.test.IPRangeConfig;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
@ -2178,23 +2179,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
if (forVirtualNetwork) {
|
||||
if (vlanOwner != null) {
|
||||
// verify resource limits
|
||||
//long ipResourceLimit = _resourceLimitMgr.findCorrectResourceLimitForAccount(vlanOwner, ResourceType.public_ip);
|
||||
|
||||
|
||||
long accountIpRange = NetUtils.ip2Long(endIP) - NetUtils.ip2Long(startIP) + 1;
|
||||
|
||||
//check resource limits
|
||||
_resourceLimitMgr.checkResourceLimit(vlanOwner, ResourceType.public_ip, accountIpRange);
|
||||
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug(" IPResourceLimit " + ipResourceLimit + " accountIpRange " + accountIpRange);
|
||||
// }
|
||||
// if (ipResourceLimit != -1 && accountIpRange > ipResourceLimit) { // -1
|
||||
// // means
|
||||
// // infinite
|
||||
// throw new InvalidParameterValueException(" Public IP Resource Limit is set to " + ipResourceLimit +
|
||||
// " which is less than the IP range of " + accountIpRange + " provided");
|
||||
// }
|
||||
associateIpRangeToAccount = true;
|
||||
}
|
||||
}
|
||||
@ -2204,7 +2194,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP, endIP, vlanGateway, vlanNetmask, vlanId, vlanOwner);
|
||||
Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP,
|
||||
endIP, vlanGateway, vlanNetmask, vlanId, vlanOwner);
|
||||
|
||||
if (associateIpRangeToAccount) {
|
||||
_networkMgr.associateIpAddressListToAccount(userId, vlanOwner.getId(), zoneId, vlan.getId(), null);
|
||||
|
||||
@ -3095,6 +3095,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//In Basic zone, make sure that there are no non-removed console proxies and SSVMs using the network
|
||||
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
List<VMInstanceVO> systemVms = _vmDao.listNonRemovedVmsByTypeAndNetwork(network.getId(),
|
||||
Type.ConsoleProxy, Type.SecondaryStorageVm);
|
||||
if (systemVms != null && !systemVms.isEmpty()) {
|
||||
s_logger.warn("Can't delete the network, not all consoleProxy/secondaryStorage vms are expunged");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Shutdown network first
|
||||
shutdownNetwork(networkId, context, false);
|
||||
|
||||
@ -92,5 +92,8 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
||||
|
||||
List<Long> listHostIdsByVmCount(long dcId, Long podId, Long clusterId, long accountId);
|
||||
|
||||
Long countRunningByAccount(long accountId);
|
||||
Long countRunningByAccount(long accountId);
|
||||
|
||||
List<VMInstanceVO> listNonRemovedVmsByTypeAndNetwork(long networkId, VirtualMachine.Type... types);
|
||||
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.Attribute;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
@ -41,6 +42,8 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.UpdateBuilder;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
@ -68,16 +71,20 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
protected final GenericSearchBuilder<VMInstanceVO, Long> CountVirtualRoutersByAccount;
|
||||
protected GenericSearchBuilder<VMInstanceVO, Long> CountRunningByHost;
|
||||
protected GenericSearchBuilder<VMInstanceVO, Long> CountRunningByAccount;
|
||||
protected SearchBuilder<VMInstanceVO> NetworkTypeSearch;
|
||||
|
||||
protected final Attribute _updateTimeAttr;
|
||||
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1 = "SELECT host.cluster_id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id WHERE ";
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 = " AND host.type = 'Routing' GROUP BY host.cluster_id ORDER BY 2 ASC ";
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1 =
|
||||
"SELECT host.cluster_id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id WHERE ";
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 =
|
||||
" AND host.type = 'Routing' GROUP BY host.cluster_id ORDER BY 2 ASC ";
|
||||
|
||||
private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT pod.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host_pod_ref` pod LEFT JOIN `cloud`.`vm_instance` vm ON pod.id = vm.pod_id WHERE pod.data_center_id = ? " +
|
||||
" GROUP BY pod.id ORDER BY 2 ASC ";
|
||||
|
||||
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT host.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id WHERE host.data_center_id = ? " +
|
||||
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT =
|
||||
"SELECT host.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id WHERE host.data_center_id = ? " +
|
||||
" AND host.pod_id = ? AND host.cluster_id = ? AND host.type = 'Routing' " +
|
||||
" GROUP BY host.id ORDER BY 2 ASC ";
|
||||
|
||||
@ -514,5 +521,30 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("state", State.Running);
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listNonRemovedVmsByTypeAndNetwork(long networkId, VirtualMachine.Type... types) {
|
||||
if (NetworkTypeSearch == null) {
|
||||
NicDao _nicDao = ComponentLocator.getLocator("management-server").getDao(NicDao.class);
|
||||
SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
|
||||
nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
nicSearch.and("ip4Address", nicSearch.entity().getIp4Address(), SearchCriteria.Op.NNULL);
|
||||
|
||||
NetworkTypeSearch = createSearchBuilder();
|
||||
NetworkTypeSearch.and("types", NetworkTypeSearch.entity().getType(), SearchCriteria.Op.IN);
|
||||
NetworkTypeSearch.and("removed", NetworkTypeSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
NetworkTypeSearch.join("nicSearch", nicSearch, NetworkTypeSearch.entity().getId(),
|
||||
nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||
NetworkTypeSearch.done();
|
||||
}
|
||||
|
||||
SearchCriteria<VMInstanceVO> sc = NetworkTypeSearch.create();
|
||||
if (types != null && types.length != 0) {
|
||||
sc.setParameters("types", (Object[]) types);
|
||||
}
|
||||
sc.setJoinParameters("nicSearch", "networkId", networkId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1652,6 +1652,10 @@
|
||||
|
||||
<script language="javascript">
|
||||
dictionary = {
|
||||
'label.action.enable.physical.network': '<fmt:message key="label.action.enable.physical.network"/>',
|
||||
'label.action.disable.physical.network': '<fmt:message key="label.action.disable.physical.network"/>',
|
||||
'message.action.enable.physical.network': '<fmt:message key="message.action.enable.physical.network"/>',
|
||||
'message.action.disable.physical.network': '<fmt:message key="message.action.disable.physical.network"/>',
|
||||
'label.ipaddress': '<fmt:message key="label.ipaddress"/>',
|
||||
'label.vcdcname': '<fmt:message key="label.vcdcname"/>',
|
||||
'label.vcipaddress': '<fmt:message key="label.vcipaddress"/>',
|
||||
|
||||
@ -1827,7 +1827,81 @@
|
||||
notification: {
|
||||
poll: pollAsyncJobResult
|
||||
}
|
||||
}
|
||||
},
|
||||
enable: {
|
||||
label: 'label.action.enable.physical.network',
|
||||
messages: {
|
||||
confirm: function(args) {
|
||||
return 'message.action.enable.physical.network';
|
||||
},
|
||||
notification: function(args) {
|
||||
return 'label.action.enable.physical.network';
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
$.ajax({
|
||||
url: createURL('updatePhysicalNetwork'),
|
||||
data: {
|
||||
id: args.context.physicalNetworks[0].id,
|
||||
state: 'Enabled'
|
||||
},
|
||||
success: function(json) {
|
||||
args.response.success({
|
||||
_custom: {
|
||||
jobId: json.updatephysicalnetworkresponse.jobid,
|
||||
getUpdatedItem: function(json) {
|
||||
return {
|
||||
state: 'Enabled'
|
||||
};
|
||||
},
|
||||
getActionFilter: function() {
|
||||
return cloudStack.actionFilter.physicalNetwork;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(json) { args.response.error(parseXMLHttpResponse(json)); }
|
||||
});
|
||||
},
|
||||
notification: { poll: pollAsyncJobResult }
|
||||
},
|
||||
disable: {
|
||||
label: 'label.action.disable.physical.network',
|
||||
messages: {
|
||||
confirm: function(args) {
|
||||
return 'message.action.disable.physical.network';
|
||||
},
|
||||
notification: function(args) {
|
||||
return 'label.action.disable.physical.network';
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
$.ajax({
|
||||
url: createURL('updatePhysicalNetwork'),
|
||||
data: {
|
||||
id: args.context.physicalNetworks[0].id,
|
||||
state: 'Disabled'
|
||||
},
|
||||
success: function(json) {
|
||||
args.response.success({
|
||||
_custom: {
|
||||
jobId: json.updatephysicalnetworkresponse.jobid,
|
||||
getUpdatedItem: function(json) {
|
||||
return {
|
||||
state: 'Disabled'
|
||||
};
|
||||
},
|
||||
getActionFilter: function() {
|
||||
return cloudStack.actionFilter.physicalNetwork;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(json) { args.response.error(parseXMLHttpResponse(json)); }
|
||||
});
|
||||
},
|
||||
notification: { poll: pollAsyncJobResult }
|
||||
}
|
||||
}
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
@ -1839,6 +1913,7 @@
|
||||
success: function(json) {
|
||||
physicalNetworkObjs = json.listphysicalnetworksresponse.physicalnetwork;
|
||||
args.response.success({
|
||||
actionFilter: cloudStack.actionFilter.physicalNetwork,
|
||||
data: json.listphysicalnetworksresponse.physicalnetwork
|
||||
});
|
||||
}
|
||||
@ -9223,7 +9298,17 @@
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
cloudStack.actionFilter.physicalNetwork = function(args) {
|
||||
var state = args.context.item.state;
|
||||
|
||||
if (state == 'Enabled') {
|
||||
return ['disable', 'remove'];
|
||||
} else if (state == 'Disabled') {
|
||||
return ['enable', 'remove'];
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
})($, cloudStack);
|
||||
|
||||
@ -295,11 +295,12 @@
|
||||
response: {
|
||||
success: function(args) {
|
||||
var data = args.data;
|
||||
var actionFilter = args.actionFilter;
|
||||
|
||||
$chart.listView({
|
||||
listView: $.extend(true, {}, cloudStack.sections.system.naas.networks.listView, {
|
||||
dataProvider: function(args) {
|
||||
args.response.success({ data: data });
|
||||
args.response.success({ actionFilter: actionFilter, data: data });
|
||||
},
|
||||
detailView: {
|
||||
tabs: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user