Merge branch 'master' into ui-vpc-redesign

Conflicts:
	ui/scripts/vpc.js
This commit is contained in:
Brian Federle 2013-05-15 10:18:55 -07:00
commit 59a99848b1
43 changed files with 394 additions and 176 deletions

View File

@ -25,7 +25,6 @@ import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.AlertResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;

View File

@ -27,7 +27,10 @@
<para>You can delete or archive individual alerts or events either directly by using the Quickview
or by using the Details page. If you want to delete multiple alerts or events at the same time,
you can use the respective context menu. You can delete alerts or events by category for a time
period.</para>
period. For example, you can select categories such as <emphasis role="bold"
>USER.LOGOUT</emphasis>, <emphasis role="bold">VM.DESTROY</emphasis>, <emphasis role="bold"
>VM.AG.UPDATE</emphasis>, <emphasis role="bold">CONFIGURATION.VALUE.EDI</emphasis>, and so on.
You can also view the number of events or alerts archived or deleted.</para>
<para>In order to support the delete or archive alerts, the following global parameters have been
added:</para>
<itemizedlist>

View File

@ -54,4 +54,6 @@ public interface VlanDao extends GenericDao<VlanVO, Long> {
List<VlanVO> listZoneWideNonDedicatedVlans(long zoneId);
List<VlanVO> listVlansByNetworkIdAndGateway(long networkid, String gateway);
List<VlanVO> listDedicatedVlans(long accountId);
}

View File

@ -58,6 +58,7 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao
protected SearchBuilder<VlanVO> PhysicalNetworkVlanSearch;
protected SearchBuilder<VlanVO> ZoneWideNonDedicatedVlanSearch;
protected SearchBuilder<VlanVO> VlanGatewaysearch;
protected SearchBuilder<VlanVO> DedicatedVlanSearch;
protected SearchBuilder<AccountVlanMapVO> AccountVlanMapSearch;
@ -213,6 +214,13 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao
ZoneWideNonDedicatedVlanSearch.done();
AccountVlanMapSearch.done();
DedicatedVlanSearch = createSearchBuilder();
AccountVlanMapSearch = _accountVlanMapDao.createSearchBuilder();
AccountVlanMapSearch.and("accountId", AccountVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
DedicatedVlanSearch.join("AccountVlanMapSearch", AccountVlanMapSearch, DedicatedVlanSearch.entity().getId(), AccountVlanMapSearch.entity().getVlanDbId(), JoinBuilder.JoinType.LEFTOUTER);
DedicatedVlanSearch.done();
AccountVlanMapSearch.done();
return result;
}
@ -343,4 +351,11 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao
return listBy(sc);
}
@Override
public List<VlanVO> listDedicatedVlans(long accountId) {
SearchCriteria<VlanVO> sc = DedicatedVlanSearch.create();
sc.setJoinParameters("AccountVlanMapSearch", "accountId", accountId);
return listBy(sc);
}
}

View File

@ -26,9 +26,10 @@ public interface DomainDao extends GenericDao<DomainVO, Long> {
public DomainVO create(DomainVO domain);
public DomainVO findDomainByPath(String domainPath);
public boolean isChildDomain(Long parentId, Long childId);
DomainVO findImmediateChildForParent(Long parentId);
List<DomainVO> findImmediateChildrenForParent(Long parentId);
List<DomainVO> findAllChildren(String path, Long parentId);
List<DomainVO> findInactiveDomains();
DomainVO findImmediateChildForParent(Long parentId);
List<DomainVO> findImmediateChildrenForParent(Long parentId);
List<DomainVO> findAllChildren(String path, Long parentId);
List<DomainVO> findInactiveDomains();
Set<Long> getDomainParentIds(long domainId);
List<Long> getDomainChildrenIds(String path);
}

View File

@ -32,6 +32,7 @@ import com.cloud.domain.Domain;
import com.cloud.domain.DomainVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
@ -46,6 +47,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
protected SearchBuilder<DomainVO> DomainPairSearch;
protected SearchBuilder<DomainVO> ImmediateChildDomainSearch;
protected SearchBuilder<DomainVO> FindAllChildrenSearch;
protected GenericSearchBuilder<DomainVO, Long> FindIdsOfAllChildrenSearch;
protected SearchBuilder<DomainVO> AllFieldsSearch;
public DomainDaoImpl () {
@ -70,7 +72,12 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
FindAllChildrenSearch.and("path", FindAllChildrenSearch.entity().getPath(), SearchCriteria.Op.LIKE);
FindAllChildrenSearch.and("id", FindAllChildrenSearch.entity().getId(), SearchCriteria.Op.NEQ);
FindAllChildrenSearch.done();
FindIdsOfAllChildrenSearch = createSearchBuilder(Long.class);
FindIdsOfAllChildrenSearch.selectField(FindIdsOfAllChildrenSearch.entity().getId());
FindIdsOfAllChildrenSearch.and("path", FindIdsOfAllChildrenSearch.entity().getPath(), SearchCriteria.Op.LIKE);
FindIdsOfAllChildrenSearch.done();
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ);
@ -221,7 +228,14 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
sc.setParameters("id", parentId);
return listBy(sc);
}
@Override
public List<Long> getDomainChildrenIds(String path){
SearchCriteria<Long> sc = FindIdsOfAllChildrenSearch.create();
sc.setParameters("path", path+"%");
return customSearch(sc, null);
}
@Override
public boolean isChildDomain(Long parentId, Long childId) {
if ((parentId == null) || (childId == null)) {

View File

@ -31,7 +31,7 @@ public interface EventDao extends GenericDao<EventVO, Long> {
EventVO findCompletedEvent(long startId);
public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date olderThan, Long accountId);
public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date olderThan, List<Long> accountIds);
public void archiveEvents(List<EventVO> events);

View File

@ -49,7 +49,7 @@ public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements Event
ToArchiveOrDeleteEventSearch = createSearchBuilder();
ToArchiveOrDeleteEventSearch.and("id", ToArchiveOrDeleteEventSearch.entity().getId(), Op.IN);
ToArchiveOrDeleteEventSearch.and("type", ToArchiveOrDeleteEventSearch.entity().getType(), Op.EQ);
ToArchiveOrDeleteEventSearch.and("accountId", ToArchiveOrDeleteEventSearch.entity().getAccountId(), Op.EQ);
ToArchiveOrDeleteEventSearch.and("accountIds", ToArchiveOrDeleteEventSearch.entity().getAccountId(), Op.IN);
ToArchiveOrDeleteEventSearch.and("createDateL", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.LT);
ToArchiveOrDeleteEventSearch.done();
}
@ -76,7 +76,7 @@ public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements Event
}
@Override
public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date olderThan, Long accountId) {
public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date olderThan, List<Long> accountIds) {
SearchCriteria<EventVO> sc = ToArchiveOrDeleteEventSearch.create();
if (ids != null) {
sc.setParameters("id", ids.toArray(new Object[ids.size()]));
@ -87,23 +87,24 @@ public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements Event
if (olderThan != null) {
sc.setParameters("createDateL", olderThan);
}
if (accountId != null) {
sc.setParameters("accountId", accountId);
if (accountIds != null && !accountIds.isEmpty()) {
sc.setParameters("accountIds", accountIds.toArray(new Object[accountIds.size()]));
}
return search(sc, null);
}
@Override
public void archiveEvents(List<EventVO> events) {
Transaction txn = Transaction.currentTxn();
txn.start();
for (EventVO event : events) {
event = lockRow(event.getId(), true);
event.setArchived(true);
update(event.getId(), event);
txn.commit();
if (events != null && !events.isEmpty()) {
Transaction txn = Transaction.currentTxn();
txn.start();
for (EventVO event : events) {
event = lockRow(event.getId(), true);
event.setArchived(true);
update(event.getId(), event);
txn.commit();
}
txn.close();
}
txn.close();
}
}

View File

@ -70,6 +70,7 @@ public interface PrivateIpDao extends GenericDao<PrivateIpVO, Long>{
*/
PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address);
PrivateIpVO findByIpAndSourceNetworkIdAndVpcId(long networkId, String ip4Address, long vpcId);
}

View File

@ -114,7 +114,16 @@ public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO, Long> implemen
sc.setParameters("networkId", networkId);
return findOneBy(sc);
}
@Override
public PrivateIpVO findByIpAndSourceNetworkIdAndVpcId(long networkId, String ip4Address, long vpcId) {
SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
sc.setParameters("ip", ip4Address);
sc.setParameters("networkId", networkId);
sc.setParameters("vpcId", vpcId);
return findOneBy(sc);
}
@Override
public PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address) {
SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();

View File

@ -49,4 +49,5 @@ public interface AccountDao extends GenericDao<AccountVO, Long> {
//returns only non-removed account
Account findActiveAccount(String accountName, Long domainId);
Account findActiveNonProjectAccount(String accountName, Long domainId);
List<Long> getAccountIdsForDomains(List<Long> ids);
}

View File

@ -35,8 +35,10 @@ import com.cloud.utils.Pair;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.db.Transaction;
@Component
@ -54,7 +56,8 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
protected final SearchBuilder<AccountVO> CleanupForRemovedAccountsSearch;
protected final SearchBuilder<AccountVO> CleanupForDisabledAccountsSearch;
protected final SearchBuilder<AccountVO> NonProjectAccountSearch;
protected final GenericSearchBuilder<AccountVO, Long> AccountIdsSearch;
public AccountDaoImpl() {
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("accountName", AllFieldsSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
@ -91,6 +94,11 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
NonProjectAccountSearch.and("state", NonProjectAccountSearch.entity().getState(), SearchCriteria.Op.EQ);
NonProjectAccountSearch.and("type", NonProjectAccountSearch.entity().getType(), SearchCriteria.Op.NEQ);
NonProjectAccountSearch.done();
AccountIdsSearch = createSearchBuilder(Long.class);
AccountIdsSearch.selectField(AccountIdsSearch.entity().getId());
AccountIdsSearch.and("ids", AccountIdsSearch.entity().getDomainId(), Op.IN);
AccountIdsSearch.done();
}
@Override
@ -263,5 +271,12 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
}
}
}
@Override
public List<Long> getAccountIdsForDomains(List<Long> domainIds) {
SearchCriteria<Long> sc = AccountIdsSearch.create();
sc.setParameters("ids", domainIds.toArray(new Object[domainIds.size()]));
return customSearch(sc, null);
}
}

View File

@ -3152,6 +3152,8 @@ ServerResource {
if (vmTO.getOs().startsWith("Windows")) {
clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
clock.setTimer("rtc", "catchup", null);
} else if (vmTO.getType() != VirtualMachine.Type.User) {
clock.setTimer("kvmclock", "catchup", null);
}
vm.addComp(clock);

View File

@ -465,7 +465,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
StoragePool p = conn.storagePoolLookupByName(poolname);
LibvirtStoragePoolDef pdef = getStoragePoolDef(conn, p);
if (pdef.getTargetPath().equals(path)) {
String targetPath = pdef.getTargetPath();
if (targetPath != null && targetPath.equals(path)) {
s_logger.debug("Storage pool utilizing path '" + path + "' already exists as pool "
+ poolname + ", undefining so we can re-define with correct name " + name);
if (p.isPersistent() == 1) {

View File

@ -639,7 +639,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
if (vmSpec.getLimitCpuUse()) {
long utilization = 0; // max CPU cap, default is unlimited
utilization = ((long)speed * 100 * vmSpec.getCpus()) / _host.speed ;
vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization));
//vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization)); currently xenserver doesnot support Xapi to add VCPUs params live.
callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", Long.toString(utilization), "vmname", vmSpec.getName() );
}
//vm.addToVCPUsParamsLive(conn, "weight", Integer.toString(cpuWeight));
callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", Integer.toString(cpuWeight), "vmname", vmSpec.getName() );
@ -672,6 +673,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
for (VM vm : vms) {
VM.Record vmr = vm.getRecord(conn);
try {
Map<String, String> hostParams = new HashMap<String, String>();
hostParams = host.getLicenseParams(conn);
if (hostParams.get("restrict_dmc").equalsIgnoreCase("true")) {
throw new CloudRuntimeException("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm");
}
scaleVM(conn, vm, vmSpec, host);
} catch (Exception e) {

View File

@ -139,8 +139,17 @@ public class XenServer56FP1Resource extends XenServer56Resource {
record.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
record.memoryDynamicMax = vmSpec.getMaxRam();
record.memoryDynamicMin = vmSpec.getMinRam();
record.memoryStaticMax = 8589934592L; //128GB
record.memoryStaticMin = 134217728L; //128MB
Map<String, String> hostParams = new HashMap<String, String>();
hostParams = host.getLicenseParams(conn);
if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) {
record.memoryStaticMax = 8589934592L; //8GB
record.memoryStaticMin = 134217728L; //128MB
} else {
s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm");
record.memoryStaticMax = vmSpec.getMaxRam();
record.memoryStaticMin = vmSpec.getMinRam();
}
if (guestOsTypeName.toLowerCase().contains("windows")) {
record.VCPUsMax = (long) vmSpec.getCpus();
} else {

View File

@ -110,7 +110,7 @@ public class CitrixResourceBaseTest {
@Test
public void testScaleVMF2() throws Types.XenAPIException, XmlRpcException {
doReturn(null).when(vm).setMemoryDynamicRangeAsync(conn, 536870912L, 536870912L);
doNothing().when(vm).setMemoryDynamicRange(conn, 536870912L, 536870912L);
doReturn(1).when(vmSpec).getCpus();
doNothing().when(vm).setVCPUsNumberLive(conn, 1L);
doReturn(500).when(vmSpec).getSpeed();
@ -129,12 +129,12 @@ public class CitrixResourceBaseTest {
@Test
public void testScaleVMF3() throws Types.XenAPIException, XmlRpcException {
doReturn(null).when(vm).setMemoryDynamicRangeAsync(conn, 536870912L, 536870912L);
doNothing().when(vm).setMemoryDynamicRange(conn, 536870912L, 536870912L);
doReturn(1).when(vmSpec).getCpus();
doNothing().when(vm).setVCPUsNumberLive(conn, 1L);
doReturn(500).when(vmSpec).getSpeed();
doReturn(true).when(vmSpec).getLimitCpuUse();
doNothing().when(vm).addToVCPUsParamsLive(conn, "cap", "100");
doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", "100", "vmname", "i-2-3-VM");
Map<String, String> args = (Map<String, String>)mock(HashMap.class);
when(host.callPlugin(conn, "vmops", "add_to_VCPUs_params_live", args)).thenReturn("Success");
doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", "253", "vmname", "i-2-3-VM");
@ -143,6 +143,6 @@ public class CitrixResourceBaseTest {
verify(vmSpec, times(1)).getLimitCpuUse();
verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", "253", "vmname", "i-2-3-VM");
verify(vm, times(1)).addToVCPUsParamsLive(conn, "cap", "100");
verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", "100", "vmname", "i-2-3-VM");
}
}

View File

@ -795,7 +795,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
}
private String getNameForPFPortPool(String tenantName, String identifier) {
return "PFPort-" + tenantName + "-" + identifier;
return "PortPool-" + tenantName + "-" + identifier;
}
private String getDnForPFPortPool(String tenantName, String identifier) {
@ -803,7 +803,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
}
private String getNameForPFIpPool(String tenantName, String identifier) {
return "PFIp-" + tenantName + "-" + identifier;
return "IpPool-" + tenantName + "-" + identifier;
}
private String getDnForPFIpPool(String tenantName, String identifier) {
@ -1010,8 +1010,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
xml = replaceXmlValue(xml, "natruledn", getDnForPFRule(tenantName, identifier, policyIdentifier));
xml = replaceXmlValue(xml, "natrulename", getNameForPFRule(tenantName, identifier));
xml = replaceXmlValue(xml, "descr", "PF rule for Tenant VDC " + tenantName);
xml = replaceXmlValue(xml, "ippoolname", getNameForPFIpPool(tenantName, policyIdentifier + "-" + identifier));
xml = replaceXmlValue(xml, "portpoolname", getNameForPFPortPool(tenantName, policyIdentifier + "-" + identifier));
xml = replaceXmlValue(xml, "ippoolname", getNameForPFIpPool(tenantName, identifier));
xml = replaceXmlValue(xml, "portpoolname", getNameForPFPortPool(tenantName, identifier));
xml = replaceXmlValue(xml, "ip", publicIp);
xml = replaceXmlValue(xml, "startport", startPort);
xml = replaceXmlValue(xml, "endport", endPort);
@ -1088,7 +1088,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
}
private String getNameForDNatIpPool(String tenantName, String identifier) {
return "DNATIp-" + tenantName + "-" + identifier;
return "IpPool-" + tenantName + "-" + identifier;
}
private String getDnForDNatIpPool(String tenantName, String identifier) {
@ -1135,7 +1135,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
xml = replaceXmlValue(xml, "natruledn", getDnForDNatRule(tenantName, identifier, policyIdentifier));
xml = replaceXmlValue(xml, "natrulename", getNameForDNatRule(tenantName, identifier));
xml = replaceXmlValue(xml, "descr", "DNAT rule for Tenant VDC " + tenantName);
xml = replaceXmlValue(xml, "ippoolname", getNameForDNatIpPool(tenantName, policyIdentifier + "-" + identifier));
xml = replaceXmlValue(xml, "ippoolname", getNameForDNatIpPool(tenantName, identifier));
xml = replaceXmlValue(xml, "ip", publicIp);
List<String> rules = listChildren(getDnForDNatPolicy(tenantName, policyIdentifier));

View File

@ -364,7 +364,8 @@ public class CiscoVnmcResource implements ServerResource {
} else {
String[] externalIpRange = getIpRangeFromCidr(rule.getSourceCidrList().get(0));
if (rule.getTrafficType() == TrafficType.Ingress) {
if (!rule.getProtocol().equalsIgnoreCase("icmp")) {
if (!rule.getProtocol().equalsIgnoreCase("icmp")
&& rule.getSrcPortRange() != null) {
if (!_connection.createTenantVDCIngressAclRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1],
@ -379,7 +380,8 @@ public class CiscoVnmcResource implements ServerResource {
}
}
} else {
if (rule.getProtocol().equalsIgnoreCase("tcp") || rule.getProtocol().equalsIgnoreCase("udp")) {
if ((rule.getProtocol().equalsIgnoreCase("tcp") || rule.getProtocol().equalsIgnoreCase("udp"))
&& rule.getSrcPortRange() != null) {
if (!_connection.createTenantVDCEgressAclRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(),
@ -477,7 +479,7 @@ public class CiscoVnmcResource implements ServerResource {
throw new Exception("Failed to delete ACL ingress rule for DNAT in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCDNatIpPool(tenant, policyIdentifier + "-" + rule.getId(), rule.getDstIp())) {
if (!_connection.createTenantVDCDNatIpPool(tenant, Long.toString(rule.getId()), rule.getDstIp())) {
throw new Exception("Failed to create DNAT ip pool in VNMC for guest network with vlan " + vlanId);
}
@ -572,10 +574,10 @@ public class CiscoVnmcResource implements ServerResource {
throw new Exception("Failed to delete ACL ingress rule for PF in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCPFIpPool(tenant, policyIdentifier + "-" + rule.getId(), rule.getDstIp())) {
if (!_connection.createTenantVDCPFIpPool(tenant, Long.toString(rule.getId()), rule.getDstIp())) {
throw new Exception("Failed to create PF ip pool in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCPFPortPool(tenant, policyIdentifier + "-" + rule.getId(),
if (!_connection.createTenantVDCPFPortPool(tenant, Long.toString(rule.getId()),
Integer.toString(rule.getDstPortRange()[0]), Integer.toString(rule.getDstPortRange()[1]))) {
throw new Exception("Failed to create PF port pool in VNMC for guest network with vlan " + vlanId);
}

View File

@ -36,7 +36,6 @@ import com.cloud.network.NetworkModel;
import com.cloud.network.Networks;
import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.network.PublicIpAddress;
import com.cloud.network.dao.NetworkServiceMapDao;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.PortForwardingRule;
import com.cloud.network.rules.StaticNat;
@ -47,6 +46,8 @@ import com.cloud.utils.Pair;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.PluggableService;
import com.cloud.utils.net.NetUtils;
import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext;
@ -131,14 +132,14 @@ public class MidoNetElement extends AdapterBase implements
@Inject
AccountManager _accountMgr;
@Inject
NetworkServiceMapDao _ntwkSrvcDao;
AccountDao _accountDao;
public void setMidonetApi(MidonetApi api) {
this.api = api;
}
public void setNtwkSrvcDao(NetworkServiceMapDao ntwkSrvcDao){
this._ntwkSrvcDao = ntwkSrvcDao;
public void setAccountDao(AccountDao aDao) {
this._accountDao = aDao;
}
@Override
@ -172,10 +173,13 @@ public class MidoNetElement extends AdapterBase implements
}
public boolean midoInNetwork(Network network) {
for (String pname : _ntwkSrvcDao.getDistinctProviders(network.getId())) {
if (pname.equals(getProvider().getName())) {
return true;
}
if((network.getTrafficType() == Networks.TrafficType.Public) &&
(network.getBroadcastDomainType() == Networks.BroadcastDomainType.Mido)){
return true;
}
if((network.getTrafficType() == Networks.TrafficType.Guest) &&
(network.getBroadcastDomainType() == Networks.BroadcastDomainType.Mido)){
return true;
}
return false;
}
@ -280,6 +284,11 @@ public class MidoNetElement extends AdapterBase implements
post.addRule().type(DtoRule.RevDNAT).flowAction(DtoRule.Accept).create();
}
public String getAccountUuid(Network network) {
AccountVO acc = _accountDao.findById(network.getAccountId());
return acc.getUuid();
}
public boolean associatePublicIP(Network network, final List<? extends PublicIpAddress> ipAddress)
throws ResourceUnavailableException {
@ -316,7 +325,7 @@ public class MidoNetElement extends AdapterBase implements
tenantUplink = ports[0];
providerDownlink = ports[1];
accountIdStr = String.valueOf(network.getAccountId());
accountIdStr = getAccountUuid(network);
boolean isVpc = getIsVpc(network);
long id = getRouterId(network, isVpc);
routerName = getRouterName(isVpc, id);
@ -611,7 +620,7 @@ public class MidoNetElement extends AdapterBase implements
RuleChain preNat = null;
RuleChain post = null;
String accountIdStr = String.valueOf(network.getAccountId());
String accountIdStr = getAccountUuid(network);
String networkUUIDStr = String.valueOf(network.getId());
for (StaticNat rule : rules) {
@ -659,7 +668,7 @@ public class MidoNetElement extends AdapterBase implements
return false;
}
if (canHandle(config, Service.Firewall)) {
String accountIdStr = String.valueOf(config.getAccountId());
String accountIdStr = getAccountUuid(config);
String networkUUIDStr = String.valueOf(config.getId());
RuleChain preFilter = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_PREFILTER);
RuleChain preNat = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_PRENAT);
@ -947,7 +956,7 @@ public class MidoNetElement extends AdapterBase implements
return false;
}
String accountIdStr = String.valueOf(network.getAccountId());
String accountIdStr = getAccountUuid(network);
String networkUUIDStr = String.valueOf(network.getId());
RuleChain preNat = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_PRENAT);
RuleChain postNat = getChain(accountIdStr, networkUUIDStr, RuleChainCode.TR_POST);
@ -1170,16 +1179,16 @@ public class MidoNetElement extends AdapterBase implements
return routerName + "-tenantrouter-" + chain;
}
protected RuleChain getChain(String accountID, String routerName, RuleChainCode chainCode){
return getChain("", accountID, routerName, chainCode);
protected RuleChain getChain(String accountUuid, String routerName, RuleChainCode chainCode){
return getChain("", accountUuid, routerName, chainCode);
}
protected RuleChain getChain(String networkId, String accountID,
protected RuleChain getChain(String networkId, String accountUuid,
String routerName, RuleChainCode chainCode){
String chainName = getChainName(networkId, routerName, chainCode);
MultivaluedMap findChain = new MultivaluedMapImpl();
findChain.add("tenant_id", accountID);
findChain.add("tenant_id", accountUuid);
ResourceCollection<RuleChain> ruleChains = api.getChains(findChain);
@ -1303,7 +1312,7 @@ public class MidoNetElement extends AdapterBase implements
String routerName = getRouterName(isVpc, id);
RuleChain egressChain = getChain(String.valueOf(network.getId()),
String.valueOf(network.getAccountId()),
getAccountUuid(network),
routerName,
RuleChainCode.ACL_EGRESS);
@ -1325,7 +1334,7 @@ public class MidoNetElement extends AdapterBase implements
String routerName = getRouterName(isVpc, id);
RuleChain egressChain = getChain(String.valueOf(network.getId()),
String.valueOf(network.getAccountId()),
getAccountUuid(network),
routerName,
RuleChainCode.ACL_EGRESS);
@ -1355,6 +1364,14 @@ public class MidoNetElement extends AdapterBase implements
.position(pos++)
.create();
// If it is ICMP to the router, accept that
egressChain.addRule().type(DtoRule.Accept)
.nwProto(SimpleFirewallRule.stringToProtocolNumber("icmp"))
.nwDstAddress(network.getGateway())
.nwDstLength(32)
.position(pos++)
.create();
// Everything else gets dropped
egressChain.addRule()
.type(DtoRule.Drop)
@ -1369,7 +1386,7 @@ public class MidoNetElement extends AdapterBase implements
boolean isVpc = getIsVpc(network);
long id = getRouterId(network, isVpc);
String routerName = getRouterName(isVpc, id);
String accountIdStr = String.valueOf(network.getAccountId());
String accountIdStr = getAccountUuid(network);
// Add interior port on bridge side
BridgePort bridgePort = netBridge.addInteriorPort().create();
@ -1406,6 +1423,14 @@ public class MidoNetElement extends AdapterBase implements
.position(pos++)
.create();
// If it is ICMP to the router, accept that
inc.addRule().type(DtoRule.Accept)
.nwProto(SimpleFirewallRule.stringToProtocolNumber("icmp"))
.nwDstAddress(network.getGateway())
.nwDstLength(32)
.position(pos++)
.create();
// If it is connection tracked, accept that as well
inc.addRule().type(DtoRule.Accept)
.matchReturnFlow(true)
@ -1449,27 +1474,25 @@ public class MidoNetElement extends AdapterBase implements
private Bridge getOrCreateNetworkBridge(Network network){
// Find the single bridge for this network, create if doesn't exist
return getOrCreateNetworkBridge(network.getId(), network.getAccountId());
return getOrCreateNetworkBridge(network.getId(), getAccountUuid(network));
}
private Bridge getOrCreateNetworkBridge(long networkID, long accountID){
Bridge netBridge = getNetworkBridge(networkID, accountID);
private Bridge getOrCreateNetworkBridge(long networkID, String accountUuid){
Bridge netBridge = getNetworkBridge(networkID, accountUuid);
if(netBridge == null){
String accountIdStr = String.valueOf(accountID);
String networkUUIDStr = String.valueOf(networkID);
netBridge = api.addBridge().tenantId(accountIdStr).name(networkUUIDStr).create();
netBridge = api.addBridge().tenantId(accountUuid).name(networkUUIDStr).create();
}
return netBridge;
}
private Bridge getNetworkBridge(long networkID, long accountID){
private Bridge getNetworkBridge(long networkID, String accountUuid){
MultivaluedMap qNetBridge = new MultivaluedMapImpl();
String accountIdStr = String.valueOf(accountID);
String networkUUIDStr = String.valueOf(networkID);
qNetBridge.add("tenant_id", accountIdStr);
qNetBridge.add("tenant_id", accountUuid);
for (Bridge b : this. api.getBridges(qNetBridge)) {
if(b.getName().equals(networkUUIDStr)){
@ -1497,7 +1520,7 @@ public class MidoNetElement extends AdapterBase implements
boolean isVpc = getIsVpc(network);
long id = getRouterId(network, isVpc);
return getOrCreateGuestNetworkRouter(id, network.getAccountId(), isVpc);
return getOrCreateGuestNetworkRouter(id, getAccountUuid(network), isVpc);
}
@ -1509,29 +1532,28 @@ public class MidoNetElement extends AdapterBase implements
}
}
protected Router createRouter(long id, long accountID, boolean isVpc) {
protected Router createRouter(long id, String accountUuid, boolean isVpc) {
String accountIdStr = String.valueOf(accountID);
String routerName = getRouterName(isVpc, id);
//Set up rule chains
RuleChain pre = api.addChain()
.name(getChainName(routerName, RuleChainCode.TR_PRE))
.tenantId(accountIdStr)
.tenantId(accountUuid)
.create();
RuleChain post = api.addChain()
.name(getChainName(routerName, RuleChainCode.TR_POST))
.tenantId(accountIdStr)
.tenantId(accountUuid)
.create();
// Set up NAT and filter chains for pre-routing
RuleChain preFilter = api.addChain()
.name(getChainName(routerName, RuleChainCode.TR_PREFILTER))
.tenantId(accountIdStr)
.tenantId(accountUuid)
.create();
RuleChain preNat = api.addChain()
.name(getChainName(routerName, RuleChainCode.TR_PRENAT))
.tenantId(accountIdStr)
.tenantId(accountUuid)
.create();
// Hook the chains in - first jump to Filter chain, then jump to Nat chain
@ -1545,28 +1567,27 @@ public class MidoNetElement extends AdapterBase implements
.create();
return api.addRouter()
.tenantId(accountIdStr)
.tenantId(accountUuid)
.name(routerName)
.inboundFilterId(pre.getId())
.outboundFilterId(post.getId())
.create();
}
private Router getOrCreateGuestNetworkRouter(long id, long accountID, boolean isVpc) {
Router tenantRouter = getGuestNetworkRouter(id, accountID, isVpc);
private Router getOrCreateGuestNetworkRouter(long id, String accountUuid, boolean isVpc) {
Router tenantRouter = getGuestNetworkRouter(id, accountUuid, isVpc);
if(tenantRouter == null){
tenantRouter = createRouter(id, accountID, isVpc);
tenantRouter = createRouter(id, accountUuid, isVpc);
}
return tenantRouter;
}
private Router getGuestNetworkRouter(long id, long accountID, boolean isVpc){
private Router getGuestNetworkRouter(long id, String accountUuid, boolean isVpc){
MultivaluedMap qNetRouter = new MultivaluedMapImpl();
String accountIdStr = String.valueOf(accountID);
String routerName = getRouterName(isVpc, id);
qNetRouter.add("tenant_id", accountIdStr);
qNetRouter.add("tenant_id", accountUuid);
for (Router router : api.getRouters(qNetRouter)) {
if(router.getName().equals(routerName)){
@ -1613,10 +1634,10 @@ public class MidoNetElement extends AdapterBase implements
}
private void deleteNetworkBridges(Network network){
long accountID = network.getAccountId();
String accountUuid = getAccountUuid(network);
long networkID = network.getId();
Bridge netBridge = getNetworkBridge(networkID, accountID);
Bridge netBridge = getNetworkBridge(networkID, accountUuid);
if(netBridge != null){
cleanBridge(netBridge);
@ -1632,11 +1653,11 @@ public class MidoNetElement extends AdapterBase implements
}
private void deleteGuestNetworkRouters(Network network){
long accountID = network.getAccountId();
String accountUuid = getAccountUuid(network);
boolean isVpc = getIsVpc(network);
long id = getRouterId(network, isVpc);
Router tenantRouter = getGuestNetworkRouter(id, accountID, isVpc);
Router tenantRouter = getGuestNetworkRouter(id, accountUuid, isVpc);
// Delete any peer ports corresponding to this router
for(Port peerPort : tenantRouter.getPeerPorts((new MultivaluedMapImpl()))){
@ -1677,7 +1698,7 @@ public class MidoNetElement extends AdapterBase implements
}
// Remove inbound and outbound filter chains
String accountIdStr = String.valueOf(accountID);
String accountIdStr = String.valueOf(accountUuid);
String routerName = getRouterName(isVpc, id);
RuleChain pre = api.getChain(tenantRouter.getInboundFilterId());

View File

@ -30,6 +30,8 @@ import com.cloud.network.*;
import com.cloud.network.PhysicalNetwork;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.vm.*;
import com.midokura.midonet.client.resource.Bridge;
import com.cloud.utils.net.NetUtils;
@ -46,12 +48,16 @@ import com.cloud.vm.Nic.ReservationStrategy;
import javax.ejb.Local;
import java.util.UUID;
import javax.inject.Inject;
@Component
@Local(value = NetworkGuru.class)
public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
private static final Logger s_logger = Logger.getLogger(MidoNetGuestNetworkGuru.class);
@Inject
AccountDao _accountDao;
public MidoNetGuestNetworkGuru() {
super();
_isolationMethods = new PhysicalNetwork.IsolationMethod[] { PhysicalNetwork.IsolationMethod.MIDO };
@ -118,7 +124,8 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
implemented.setCidr(network.getCidr());
}
String accountIdStr = String.valueOf(network.getAccountId());
AccountVO acc = _accountDao.findById(network.getAccountId());
String accountUUIDStr = acc.getUuid();
String routerName = "";
if (network.getVpcId() != null) {
routerName = "VPC" + String.valueOf(network.getVpcId());
@ -126,7 +133,9 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
routerName = String.valueOf(network.getId());
}
String broadcastUriStr = accountIdStr + "." + String.valueOf(network.getId()) + ":" + routerName;
String broadcastUriStr = accountUUIDStr + "."
+ String.valueOf(network.getId())
+ ":" + routerName;
implemented.setBroadcastUri(Networks.BroadcastDomainType.Mido.toUri(broadcastUriStr));
s_logger.debug("Broadcast URI set to " + broadcastUriStr);

View File

@ -34,6 +34,8 @@ import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.network.dao.NetworkVO;
import com.cloud.network.dao.IPAddressVO;
import com.cloud.vm.*;
@ -50,6 +52,8 @@ public class MidoNetPublicNetworkGuru extends PublicNetworkGuru {
// Inject any stuff we need to use (DAOs etc)
@Inject
NetworkModel _networkModel;
@Inject
AccountDao _accountDao;
// Don't need to change traffic type stuff, public is fine
@ -228,9 +232,10 @@ public class MidoNetPublicNetworkGuru extends PublicNetworkGuru {
}
private URI generateBroadcastUri(Network network){
String accountIdStr = String.valueOf(network.getAccountId());
AccountVO acc = _accountDao.findById(network.getAccountId());
String accountUUIDStr = acc.getUuid();
String networkUUIDStr = String.valueOf(network.getId());
return Networks.BroadcastDomainType.Mido.toUri(accountIdStr +
return Networks.BroadcastDomainType.Mido.toUri(accountUUIDStr +
"." +
networkUUIDStr +
":" +

View File

@ -18,12 +18,13 @@
*/
import com.cloud.network.element.MidoNetElement;
import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
import junit.framework.TestCase;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
import com.midokura.midonet.client.MidonetApi;
import com.midokura.midonet.client.resource.*;
import com.cloud.network.dao.NetworkServiceMapDao;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.cloud.network.*;
import com.cloud.vm.*;
@ -46,10 +47,6 @@ public class MidoNetElementTest extends TestCase {
//mockMgmt
MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);
ArrayList<String> arr = new ArrayList<String>();
arr.add("MidoNet");
NetworkServiceMapDao mockNSMD = mock(NetworkServiceMapDao.class);
when(mockNSMD.getDistinctProviders(anyLong())).thenReturn(arr);
//mockDhcpHost
DhcpHost mockDhcpHost = mock(DhcpHost.class);
@ -82,6 +79,14 @@ public class MidoNetElementTest extends TestCase {
when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
when(mockNetwork.getCidr()).thenReturn("1.2.3.0/24");
when(mockNetwork.getId()).thenReturn((long)2);
when(mockNetwork.getBroadcastDomainType()).thenReturn(Networks.BroadcastDomainType.Mido);
when(mockNetwork.getTrafficType()).thenReturn(Networks.TrafficType.Guest);
//mockAccountDao
AccountDao mockAccountDao = mock(AccountDao.class);
AccountVO mockAccountVO = mock(AccountVO.class);
when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
when(mockAccountVO.getUuid()).thenReturn("1");
//mockNic
NicProfile mockNic = mock(NicProfile.class);
@ -96,8 +101,8 @@ public class MidoNetElementTest extends TestCase {
when(mockVm.getType()).thenReturn(VirtualMachine.Type.User);
MidoNetElement elem = new MidoNetElement();
elem.setNtwkSrvcDao(mockNSMD);
elem.setMidonetApi(api);
elem.setAccountDao(mockAccountDao);
boolean result = false;
try {
@ -119,14 +124,16 @@ public class MidoNetElementTest extends TestCase {
public void testImplement() {
//mock
MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);
ArrayList<String> arr = new ArrayList<String>();
arr.add("MidoNet");
NetworkServiceMapDao mockNSMD = mock(NetworkServiceMapDao.class);
when(mockNSMD.getDistinctProviders(anyLong())).thenReturn(arr);
//mockAccountDao
AccountDao mockAccountDao = mock(AccountDao.class);
AccountVO mockAccountVO = mock(AccountVO.class);
when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
when(mockAccountVO.getUuid()).thenReturn("1");
MidoNetElement elem = new MidoNetElement();
elem.setNtwkSrvcDao(mockNSMD);
elem.setMidonetApi(api);
elem.setAccountDao(mockAccountDao);
//mockRPort
RouterPort mockRPort = mock(RouterPort.class);
@ -161,6 +168,8 @@ public class MidoNetElementTest extends TestCase {
when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
when(mockNetwork.getCidr()).thenReturn("1.2.3.0/24");
when(mockNetwork.getId()).thenReturn((long)2);
when(mockNetwork.getBroadcastDomainType()).thenReturn(Networks.BroadcastDomainType.Mido);
when(mockNetwork.getTrafficType()).thenReturn(Networks.TrafficType.Public);
boolean result = false;
try {

View File

@ -48,7 +48,7 @@ def add_to_VCPUs_params_live(session, args):
value = args['value']
vmname = args['vmname']
try:
cmd = ["bash", "/opt/xensource/bin/Add-To-VCPUs-Params-Live.sh", vmname, key, value]
cmd = ["bash", "/opt/xensource/bin/add_to_vcpus_params_live.sh", vmname, key, value]
txt = util.pread2(cmd)
except:
return 'false'
@ -279,7 +279,7 @@ def setLinkLocalIP(session, args):
except:
return 'can not cat network.conf'
if result.lower() == "bridge":
if result.lower().strip() == "bridge":
try:
cmd = ["brctl", "addbr", brName]
txt = util.pread2(cmd)

View File

@ -64,3 +64,4 @@ cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin

View File

@ -65,4 +65,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
swift=..,0755,/opt/xensource/bin
swiftxen=..,0755,/etc/xapi.d/plugins
s3xen=..,0755,/etc/xapi.d/plugins
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin

View File

@ -64,4 +64,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
swift=..,0755,/opt/xensource/bin
swiftxen=..,0755,/etc/xapi.d/plugins
s3xen=..,0755,/etc/xapi.d/plugins
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin

View File

@ -69,4 +69,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
swift=..,0755,/opt/xensource/bin
swiftxen=..,0755,/etc/xapi.d/plugins
s3xen=..,0755,/etc/xapi.d/plugins
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin

View File

@ -2853,6 +2853,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan.getVlanType().toString(),
ip.getSystem(), ip.getClass().getName(), ip.getUuid());
}
// increment resource count for dedicated public ip's
_resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
} else if (podId != null) {
// This VLAN is pod-wide, so create a PodVlanMapVO entry
PodVlanMapVO podVlanMapVO = new PodVlanMapVO(podId, vlan.getId());
@ -3124,6 +3126,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan.getVlanType().toString(),
ip.getSystem(), ip.getClass().getName(), ip.getUuid());
}
// increment resource count for dedicated public ip's
_resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
return vlan;
}
@ -3187,10 +3193,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (_accountVlanMapDao.remove(acctVln.get(0).getId())) {
// generate usage events to remove dedication for every ip in the range
for (IPAddressVO ip : ips) {
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getId(),
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(),
ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan.getVlanType().toString(),
ip.getSystem(), ip.getClass().getName(), ip.getUuid());
}
// decrement resource count for dedicated public ip's
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(ips.size()));
return true;
} else {
return false;

View File

@ -394,8 +394,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
addr.getDataCenterId(), addr.getId(), addr.getAddress().toString(), addr.isSourceNat(), guestType,
addr.getSystem(), addr.getClass().getName(), addr.getUuid());
}
// don't increment resource count for direct ip addresses
if (addr.getAssociatedWithNetworkId() != null) {
// don't increment resource count for direct and dedicated ip addresses
if (addr.getAssociatedWithNetworkId() != null && !isIpDedicated(addr)) {
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
}
}
@ -640,10 +640,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
s_logger.debug("Associate IP address lock acquired");
}
// Check that the maximum number of public IPs for the given
// accountId will not be exceeded
_resourceLimitMgr.checkResourceLimit(accountToLock, ResourceType.public_ip);
txn.start();
// If account has dedicated Public IP ranges, allocate IP from the dedicated range
@ -668,6 +664,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
}
if (!allocateFromDedicatedRange) {
// Check that the maximum number of public IPs for the given
// accountId will not be exceeded
_resourceLimitMgr.checkResourceLimit(accountToLock, ResourceType.public_ip);
List<VlanVO> nonDedicatedVlans = _vlanDao.listZoneWideNonDedicatedVlans(zone.getId());
for (VlanVO nonDedicatedVlan : nonDedicatedVlans) {
nonDedicatedVlanDbIds.add(nonDedicatedVlan.getId());
@ -2964,8 +2964,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
if (ip.getState() != State.Releasing) {
txn.start();
// don't decrement resource count for direct ips
if (ip.getAssociatedWithNetworkId() != null) {
// don't decrement resource count for direct and dedicated ips
if (ip.getAssociatedWithNetworkId() != null && !isIpDedicated(ip)) {
_resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip);
}

View File

@ -610,18 +610,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("Invalid network id is given");
}
Network network = _networksDao.findById(networkId);
if (network == null) {
throw new InvalidParameterValueException("Invalid network id is given");
}
accountId = network.getAccountId();
domainId = network.getDomainId();
// Validate network offering
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(network.getNetworkOfferingId());
// verify permissions
_accountMgr.checkAccess(ipOwner, null, true, network);
Account caller = UserContext.current().getCaller();
//check whether the nic belongs to user vm.
NicVO nicVO = _nicDao.findById(nicId);
@ -633,6 +622,25 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("The nic is not belongs to user vm");
}
Nic nic = _nicDao.findById(nicId);
VirtualMachine vm = _userVmDao.findById(nicVO.getInstanceId());
if (vm == null) {
throw new InvalidParameterValueException("There is no vm with the nic");
}
// verify permissions
_accountMgr.checkAccess(ipOwner, null, true, vm);
Network network = _networksDao.findById(networkId);
if (network == null) {
throw new InvalidParameterValueException("Invalid network id is given");
}
accountId = network.getAccountId();
domainId = network.getDomainId();
// Validate network offering
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(network.getNetworkOfferingId());
DataCenter dc = _dcDao.findById(network.getDataCenterId());
Long id = nicVO.getInstanceId();
@ -649,14 +657,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
}
} else if (dc.getNetworkType() == NetworkType.Basic || ntwkOff.getGuestType() == Network.GuestType.Shared) {
Account caller = UserContext.current().getCaller();
long callerUserId = UserContext.current().getCallerUserId();
_accountMgr.checkAccess(caller, SecurityChecker.AccessType.UseNetwork, false, network);
//handle the basic networks here
VirtualMachine vm = _userVmDao.findById(nicVO.getInstanceId());
if (vm == null) {
throw new InvalidParameterValueException("There is no vm with the nic");
}
VMInstanceVO vmi = (VMInstanceVO)vm;
Long podId = vmi.getPodIdToDeployIn();
if (podId == null) {
@ -718,6 +719,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("Unable to find ip address by id");
}
VirtualMachine vm = _userVmDao.findById(secIpVO.getVmId());
if (vm == null) {
throw new InvalidParameterValueException("There is no vm with the nic");
}
// verify permissions
_accountMgr.checkAccess(caller, null, true, vm);
Network network = _networksDao.findById(secIpVO.getNetworkId());
if (network == null) {
@ -727,9 +735,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
// Validate network offering
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(network.getNetworkOfferingId());
// verify permissions
_accountMgr.checkAccess(caller, null, true, network);
Long nicId = secIpVO.getNicId();
s_logger.debug("ip id = " + ipAddressId + " nic id = " + nicId);
//check is this the last secondary ip for NIC
@ -3813,10 +3818,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
s_logger.debug("Created private network " + privateNetwork);
} else {
s_logger.debug("Private network already exists: " + privateNetwork);
throw new InvalidParameterValueException("Private network for the vlan: " + vlan + " and cidr "+ cidr +" already exists " +
" in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
}
//add entry to private_ip_address table
PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNetwork.getId(), startIp);
PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), startIp, vpcId);
if (privateIp != null) {
throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" +
" in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());

View File

@ -3888,26 +3888,29 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
String privateIP = router.getPrivateIpAddress();
if (privateIP != null) {
boolean forVpc = router.getVpcId() != null;
List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
for (Nic routerNic : routerNics) {
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
if (network.getTrafficType() == TrafficType.Public) {
boolean forVpc = router.getVpcId() != null;
//Send network usage command for public nic in VPC VR
//Send network usage command for isolated guest nic of non VPC VR
if ((forVpc && network.getTrafficType() == TrafficType.Public) || (!forVpc && network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Isolated)) {
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
forVpc, routerNic.getIp4Address());
String routerType = router.getType().toString();
UserStatisticsVO previousStats = _userStatsDao.findBy(router.getAccountId(),
router.getDataCenterId(), network.getId(), null, router.getId(), router.getType().toString());
router.getDataCenterId(), network.getId(), (forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
NetworkUsageAnswer answer = null;
try {
answer = (NetworkUsageAnswer) _agentMgr.easySend(router.getHostId(), usageCmd);
} catch (Exception e) {
s_logger.warn("Error while collecting network stats from router: "+router.getInstanceName()+" from host: "+router.getHostId(), e);
s_logger.warn("Error while collecting network stats from router: " + router.getInstanceName() + " from host: " + router.getHostId(), e);
continue;
}
if (answer != null) {
if (!answer.getResult()) {
s_logger.warn("Error while collecting network stats from router: "+router.getInstanceName()+" from host: "+router.getHostId() + "; details: " + answer.getDetails());
s_logger.warn("Error while collecting network stats from router: " + router.getInstanceName() + " from host: " + router.getHostId() + "; details: " + answer.getDetails());
continue;
}
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
@ -3918,26 +3921,26 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
}
txn.start();
UserStatisticsVO stats = _userStatsDao.lock(router.getAccountId(),
router.getDataCenterId(), network.getId(), null, router.getId(), router.getType().toString());
router.getDataCenterId(), network.getId(), (forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
if (stats == null) {
s_logger.warn("unable to find stats for account: " + router.getAccountId());
continue;
}
if(previousStats != null
&& ((previousStats.getCurrentBytesReceived() != stats.getCurrentBytesReceived())
|| (previousStats.getCurrentBytesSent() != stats.getCurrentBytesSent()))){
if (previousStats != null
&& ((previousStats.getCurrentBytesReceived() != stats.getCurrentBytesReceived())
|| (previousStats.getCurrentBytesSent() != stats.getCurrentBytesSent()))){
s_logger.debug("Router stats changed from the time NetworkUsageCommand was sent. " +
"Ignoring current answer. Router: "+answer.getRouterName()+" Rcvd: " +
answer.getBytesReceived()+ "Sent: " +answer.getBytesSent());
"Ignoring current answer. Router: " + answer.getRouterName() + " Rcvd: " +
answer.getBytesReceived() + "Sent: " + answer.getBytesSent());
continue;
}
if (stats.getCurrentBytesReceived() > answer.getBytesReceived()) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Received # of bytes that's less than the last one. " +
"Assuming something went wrong and persisting it. Router: " +
answer.getRouterName()+" Reported: " + answer.getBytesReceived()
"Assuming something went wrong and persisting it. Router: " +
answer.getRouterName() + " Reported: " + answer.getBytesReceived()
+ " Stored: " + stats.getCurrentBytesReceived());
}
stats.setNetBytesReceived(stats.getNetBytesReceived() + stats.getCurrentBytesReceived());
@ -3946,13 +3949,18 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
if (stats.getCurrentBytesSent() > answer.getBytesSent()) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Received # of bytes that's less than the last one. " +
"Assuming something went wrong and persisting it. Router: " +
answer.getRouterName()+" Reported: " + answer.getBytesSent()
"Assuming something went wrong and persisting it. Router: " +
answer.getRouterName() + " Reported: " + answer.getBytesSent()
+ " Stored: " + stats.getCurrentBytesSent());
}
stats.setNetBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
}
stats.setCurrentBytesSent(answer.getBytesSent());
if (! _dailyOrHourly) {
//update agg bytes
stats.setAggBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
stats.setAggBytesReceived(stats.getNetBytesReceived() + stats.getCurrentBytesReceived());
}
_userStatsDao.update(stats.getId(), stats);
txn.commit();
} catch (Exception e) {

View File

@ -216,8 +216,8 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
throw new InvalidParameterValueException("Network ACL can be created just for networks of type " + Networks.TrafficType.Guest);
}
if(aclId != NetworkACL.DEFAULT_DENY) {
//ACL is not default DENY
if(aclId != NetworkACL.DEFAULT_DENY && aclId != NetworkACL.DEFAULT_ALLOW) {
//ACL is not default DENY/ALLOW
// ACL should be associated with a VPC
Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
if(vpc == null){
@ -254,6 +254,10 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
throw new InvalidParameterValueException("Unable to find specified ACL");
}
if((aclId == NetworkACL.DEFAULT_DENY) || (aclId == NetworkACL.DEFAULT_ALLOW)){
throw new InvalidParameterValueException("Default ACL cannot be modified");
}
Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
if(vpc == null){
throw new InvalidParameterValueException("Unable to find Vpc associated with the NetworkACL");

View File

@ -46,6 +46,8 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.configuration.dao.ResourceCountDao;
import com.cloud.configuration.dao.ResourceLimitDao;
import com.cloud.dao.EntityManager;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.VlanDao;
import com.cloud.domain.Domain;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
@ -53,6 +55,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.IPAddressVO;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.projects.Project;
@ -141,6 +144,8 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
private ServiceOfferingDao _serviceOfferingDao;
@Inject
private VMTemplateHostDao _vmTemplateHostDao;
@Inject
private VlanDao _vlanDao;
protected GenericSearchBuilder<VMTemplateHostVO, SumCount> templateSizeSearch;
@ -814,7 +819,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
} else if (type == Resource.ResourceType.snapshot) {
newCount = _snapshotDao.countSnapshotsForAccount(accountId);
} else if (type == Resource.ResourceType.public_ip) {
newCount = _ipAddressDao.countAllocatedIPsForAccount(accountId);
newCount = calculatePublicIpForAccount(accountId);
} else if (type == Resource.ResourceType.template) {
newCount = _vmTemplateDao.countTemplatesForAccount(accountId);
} else if (type == Resource.ResourceType.project) {
@ -906,6 +911,22 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
return totalVolumesSize + totalSnapshotsSize + totalTemplatesSize;
}
private long calculatePublicIpForAccount(long accountId) {
Long dedicatedCount = 0L;
Long allocatedCount = 0L;
List<VlanVO> dedicatedVlans = _vlanDao.listDedicatedVlans(accountId);
for (VlanVO dedicatedVlan : dedicatedVlans) {
List<IPAddressVO> ips = _ipAddressDao.listByVlanId(dedicatedVlan.getId());
dedicatedCount += new Long(ips.size());
}
allocatedCount = _ipAddressDao.countAllocatedIPsForAccount(accountId);
if (dedicatedCount > allocatedCount)
return dedicatedCount;
else
return allocatedCount;
}
@Override
public long getResourceCount(Account account, ResourceType type) {
return _resourceCountDao.getResourceCount(account.getId(), ResourceOwnerType.Account, type);

View File

@ -887,10 +887,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public boolean archiveEvents(ArchiveEventsCmd cmd) {
Account caller = UserContext.current().getCaller();
List<Long> ids = cmd.getIds();
boolean result =true;
List<Long> permittedAccountIds = new ArrayList<Long>();
List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), cmd.getEntityOwnerId());
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && caller.getType() == Account.ACCOUNT_TYPE_PROJECT) {
permittedAccountIds.add(caller.getId());
} else {
DomainVO domain = _domainDao.findById(caller.getDomainId());
List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
}
List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds);
ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
_accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEvents);
@ -904,10 +914,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public boolean deleteEvents(DeleteEventsCmd cmd) {
Account caller = UserContext.current().getCaller();
List<Long> ids = cmd.getIds();
boolean result =true;
List<Long> permittedAccountIds = new ArrayList<Long>();
List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), cmd.getEntityOwnerId());
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_PROJECT) {
permittedAccountIds.add(caller.getId());
} else {
DomainVO domain = _domainDao.findById(caller.getDomainId());
List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
}
List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds);
ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
_accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEvents);

View File

@ -21,7 +21,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.ejb.Local;
@ -235,8 +234,9 @@ public class IdentityDaoImpl extends GenericDaoBase<IdentityVO, Long> implements
String.format("UPDATE `%s` SET uuid=? WHERE id=?", tableName)
);
pstmtUpdate.setString(1, UUID.randomUUID().toString());
pstmtUpdate.setString(1, String.valueOf(id));
pstmtUpdate.setLong(2, id);
pstmtUpdate.executeUpdate();
}
}

View File

@ -18,7 +18,6 @@ package com.cloud.event;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
@ -58,7 +57,7 @@ public class EventControlsUnitTest extends TestCase{
_mgmtServer._eventDao = _eventDao;
_mgmtServer._accountMgr = _accountMgr;
doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class));
when(_eventDao.listToArchiveOrDeleteEvents(anyList(), anyString(), any(Date.class), anyLong())).thenReturn(_events);
when(_eventDao.listToArchiveOrDeleteEvents(anyList(), anyString(), any(Date.class), anyList())).thenReturn(_events);
}
@After

View File

@ -246,8 +246,8 @@ public class UserVmManagerTest {
}
// Test scaleVm on incompatible HV.
//@Test(expected=InvalidParameterValueException.class)
// Test scaleVm on equal service offerings.
@Test(expected=InvalidParameterValueException.class)
public void testScaleVMF2() throws Exception {
ScaleVMCmd cmd = new ScaleVMCmd();
@ -261,14 +261,11 @@ public class UserVmManagerTest {
serviceOfferingIdField.setAccessible(true);
serviceOfferingIdField.set(cmd, 1L);
//UserContext.current().setEventDetails("Vm Id: "+getId());
// Account account = (Account) new AccountVO("testaccount", 1L, "networkdomain", (short) 0, 1);
//AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId)
// UserContext.registerContext(1, account, null, true);
when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);
doReturn(Hypervisor.HypervisorType.XenServer).when(_vmInstance).getHypervisorType();
doReturn(VirtualMachine.State.Running).when(_vmInstance).getState();
doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock);
@ -285,8 +282,8 @@ public class UserVmManagerTest {
}
// Test scaleVm for Stopped vm. Full positive test.
//@Test
// Test scaleVm for Stopped vm.
@Test(expected=InvalidParameterValueException.class)
public void testScaleVMF3() throws Exception {
ScaleVMCmd cmd = new ScaleVMCmd();
@ -316,10 +313,12 @@ public class UserVmManagerTest {
when(_configMgr.getServiceOffering(1L)).thenReturn(so1);
doReturn(VirtualMachine.State.Stopped).when(_vmInstance).getState();
when(_vmDao.findById(anyLong())).thenReturn(null);
doReturn(true).when(_itMgr).upgradeVmDb(anyLong(),anyLong());
when(_vmDao.findById(anyLong())).thenReturn(_vmMock);
//when(_vmDao.findById(anyLong())).thenReturn(_vmMock);
_userVmMgr.upgradeVirtualMachine(cmd);

View File

@ -83,7 +83,7 @@ public class NetworkACLServiceTest extends TestCase{
createACLItemCmd = new CreateNetworkACLCmd(){
@Override
public Long getACLId(){
return 1L;
return 3L;
}
@Override

View File

@ -29,6 +29,8 @@ INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '5.1', 128, 0, 32);
DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max';
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.apiserver.address', 'http://localhost:8081', 'Specify the address at which the Midonet API server can be contacted (if using Midonet)');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.providerrouter.id', 'd7c5e6a3-e2f4-426b-b728-b7ce6a0448e5', 'Specifies the UUID of the Midonet provider router (if using Midonet)');
ALTER TABLE `cloud`.`load_balancer_vm_map` ADD state VARCHAR(40) NULL COMMENT 'service status updated by LB healthcheck manager';
alter table storage_pool change storage_provider_id storage_provider_name varchar(255);

View File

@ -20,6 +20,7 @@ import urllib
import base64
import hmac
import hashlib
import logging
import time
import cloudstackException
from cloudstackAPI import *
@ -37,6 +38,7 @@ class cloudConnection(object):
apiKey=None, securityKey=None,
asyncTimeout=3600, logging=None, scheme='http',
path='client/api'):
self.loglevel() #Turn off requests logs
self.apiKey = apiKey
self.securityKey = securityKey
self.mgtSvr = mgtSvr
@ -65,6 +67,13 @@ class cloudConnection(object):
self.asyncTimeout, self.logging, self.protocol,
self.path)
def loglevel(self, lvl=logging.WARNING):
"""
Turns off the INFO/DEBUG logs from `requests`
"""
requests_log = logging.getLogger("requests")
requests_log.setLevel(lvl)
def poll(self, jobid, response):
"""
polls the completion of a given jobid

View File

@ -102,8 +102,8 @@
},
'protocolnumber': {label:'Protocol Number',edit:true},
'startport': { edit: true, label: 'label.start.port' },
'endport': { edit: true, label: 'label.end.port' },
'startport': { edit: true, label: 'label.start.port', isOptional: true },
'endport': { edit: true, label: 'label.end.port', isOptional: true },
'networkid': {
label: 'Select Tier',
select: function(args) {
@ -173,7 +173,18 @@
else
delete args.data.protocolnumber;
if((args.data.protocol == 'tcp' || args.data.protocol == 'udp' || args.data.protocol == 'all') && (args.data.startport=="" || args.data.startport == undefined)){
cloudStack.dialog.notice({message:_l('Start Port or End Port value should not be blank')});
$(window).trigger('cloudStack.fullRefresh');
}
else if((args.data.protocol == 'tcp' || args.data.protocol == 'udp' || args.data.protocol == 'all') && (args.data.endport=="" || args.data.endport == undefined)){
cloudStack.dialog.notice({message:_l('Start Port or End Port value should not be blank')});
$(window).trigger('cloudStack.fullRefresh');
}
else{
$.ajax({
url: createURL('createNetworkACL'),
data: $.extend(args.data, {
@ -210,6 +221,7 @@
}
});
}
}
},
actions: {
destroy: {