diff --git a/client/pom.xml b/client/pom.xml index ecf232be7ac..302fe6bacbe 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -219,6 +219,11 @@ cloud-engine-storage-volume ${project.version} + + org.apache.cloudstack + cloud-plugin-hypervisor-simulator + ${project.version} + install @@ -243,7 +248,6 @@ 60000 - -XX:MaxPermSize=512m -Xmx2g ${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml ${project.build.directory}/${project.build.finalName} @@ -481,21 +485,6 @@ - - simulator - - - simulator - - - - - org.apache.cloudstack - cloud-plugin-hypervisor-simulator - ${project.version} - - - netapp diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in index 7b64f49ee20..2535c779368 100644 --- a/client/tomcatconf/componentContext.xml.in +++ b/client/tomcatconf/componentContext.xml.in @@ -36,9 +36,25 @@ --> - - + + + + + + + + + + + + + + + + + + @@ -191,6 +207,12 @@ + + @@ -199,11 +221,9 @@ - @@ -302,11 +322,9 @@ - diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in index 7e3552db67e..8f8dae5b10a 100644 --- a/client/tomcatconf/nonossComponentContext.xml.in +++ b/client/tomcatconf/nonossComponentContext.xml.in @@ -37,8 +37,24 @@ --> - + + + + + + + + + + + + + + + + + diff --git a/developer/pom.xml b/developer/pom.xml index ff47b143093..3dc276adc23 100644 --- a/developer/pom.xml +++ b/developer/pom.xml @@ -10,7 +10,7 @@ language governing permissions and limitations under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cloud-developer Apache CloudStack Developer Tools @@ -21,25 +21,98 @@ 4.2.0-SNAPSHOT + mysql mysql-connector-java - 5.1.21 - runtime + ${cs.mysql.version} + + + commons-dbcp + commons-dbcp + ${cs.dbcp.version} + + + commons-pool + commons-pool + ${cs.pool.version} + + + org.jasypt + jasypt + ${cs.jasypt.version} + + + org.apache.cloudstack + cloud-utils + ${project.version} + + + org.apache.cloudstack + cloud-server + ${project.version} + + + org.apache.cloudstack + cloud-plugin-hypervisor-simulator + ${project.version} + compile - - org.apache.cloudstack - cloud-plugin-hypervisor-simulator - ${project.version} - compile - install + + + org.codehaus.mojo + properties-maven-plugin + 1.0-alpha-2 + + + initialize + + read-project-properties + + + + ${basedir}/../utils/conf/db.properties + ${basedir}/../utils/conf/db.properties.override + + true + + + + + + maven-antrun-plugin + 1.7 + + + generate-resources + + run + + + + + + + + + + + + + + + + + + - + deploydb @@ -48,91 +121,10 @@ - - org.codehaus.mojo - properties-maven-plugin - 1.0-alpha-2 - - - initialize - - read-project-properties - - - - ${project.parent.basedir}/utils/conf/db.properties - ${project.parent.basedir}/utils/conf/db.properties.override - - true - - - - - - maven-antrun-plugin - 1.7 - - - generate-resources - - run - - - - - - - - - - - - - - - - - - - org.codehaus.mojo exec-maven-plugin 1.2.1 - - - - mysql - mysql-connector-java - ${cs.mysql.version} - - - commons-dbcp - commons-dbcp - ${cs.dbcp.version} - - - commons-pool - commons-pool - ${cs.pool.version} - - - org.jasypt - jasypt - ${cs.jasypt.version} - - - org.apache.cloudstack - cloud-utils - ${project.version} - - - org.apache.cloudstack - cloud-server - ${project.version} - - process-resources @@ -143,17 +135,11 @@ - false - true - - org.apache.cloudstack - cloud-server - com.cloud.upgrade.DatabaseCreator - ${project.parent.basedir}/utils/conf/db.properties - ${project.parent.basedir}/utils/conf/db.properties.override + ${basedir}/../utils/conf/db.properties + ${basedir}/../utils/conf/db.properties.override ${basedir}/target/db/create-schema.sql ${basedir}/target/db/create-schema-premium.sql @@ -181,7 +167,59 @@ catalina.home - ${project.parent.basedir}/utils + ${basedir}/../utils + + + paths.script + ${basedir}/target/db + + + + + + + + + + deploydb-simulator + + + deploydb-simulator + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + process-resources + create-schema-simulator + + java + + + + + com.cloud.upgrade.DatabaseCreator + + + ${basedir}/../utils/conf/db.properties + ${basedir}/../utils/conf/db.properties.override + + ${basedir}/target/db/create-schema-simulator.sql + ${basedir}/target/db/templates.simulator.sql + + com.cloud.upgrade.DatabaseUpgradeChecker + --database=simulator + --rootpassword=${db.root.password} + + + + catalina.home + ${basedir}/../utils paths.script @@ -194,4 +232,4 @@ - + \ No newline at end of file diff --git a/docs/en-US/changed-apicommands-4.1.xml b/docs/en-US/changed-apicommands-4.1.xml index f0045a56de3..13553fdf336 100644 --- a/docs/en-US/changed-apicommands-4.1.xml +++ b/docs/en-US/changed-apicommands-4.1.xml @@ -62,9 +62,20 @@ listNetworks - The following request parameters has been added: isPersistent - This parameter determines if the network or network offering listed by using this - offering are persistent or not. + The following request parameters have been added: + + + isPersistent + This parameter determines if the network or network offering listed are + persistent or not. + + + ip6gateway + + + ip6cidr + + @@ -104,7 +115,7 @@ CreateZoneCmd - The following parameter are added: ip6dns1, ip6dns2. + The following parameter have been added: ip6dns1, ip6dns2. @@ -113,7 +124,7 @@ listVirtualMachines - For nic responses, the following fields has been added. + For nic responses, the following fields have been added. ip6address @@ -132,7 +143,7 @@ listVlanIpRanges - For nic responses, the following fields has been added. + For nic responses, the following fields have been added. startipv6 @@ -166,7 +177,7 @@ - + addF5LoadBalancer diff --git a/docs/en-US/ipv6-support.xml b/docs/en-US/ipv6-support.xml index 22a5d7a5370..7367ec9ad80 100644 --- a/docs/en-US/ipv6-support.xml +++ b/docs/en-US/ipv6-support.xml @@ -106,14 +106,14 @@ Passwords - - The administrator cannot specify the IPv6 address of a VM. -
- Network Configuration for DHCPv6 - Use DUID-LL to get IPv6 address from DHCP server + Guest VM Configuration for DHCPv6 + For the guest VMs to get IPv6 address, run dhclient command manually on each of the VMs. + Use DUID-LL to set up dhclient. + The IPv6 address is lost when a VM is stopped and started. Therefore, use the same procedure + to get an IPv6 address when a VM is stopped and started. Set up dhclient by using DUID-LL. diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java new file mode 100644 index 00000000000..c94db66b202 --- /dev/null +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/AbstractScope.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.subsystem.api.storage; + +public abstract class AbstractScope implements Scope { + @Override + public boolean isSameScope(Scope scope) { + if (this.getScopeType() == scope.getScopeType() && this.getScopeId() == scope.getScopeId()) { + return true; + } else { + return false; + } + } +} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java index fce7d82cb99..0f0e9581523 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ClusterScope.java @@ -19,7 +19,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage; -public class ClusterScope implements Scope { +public class ClusterScope extends AbstractScope { private ScopeType type = ScopeType.CLUSTER; private Long clusterId; private Long podId; diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java index 71d1952c625..c5e90ac894c 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java @@ -19,7 +19,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage; -public class HostScope implements Scope { +public class HostScope extends AbstractScope { private ScopeType type = ScopeType.HOST; private Long hostId; public HostScope(Long hostId) { diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java index c1596d4f5f7..91d4734ef15 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java @@ -20,5 +20,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage; public interface Scope { public ScopeType getScopeType(); + public boolean isSameScope(Scope scope); public Long getScopeId(); } diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java index ac277af36de..2d3d41f22b5 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ZoneScope.java @@ -19,7 +19,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage; -public class ZoneScope implements Scope { +public class ZoneScope extends AbstractScope { private ScopeType type = ScopeType.ZONE; private Long zoneId; diff --git a/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java b/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java new file mode 100644 index 00000000000..e3ec48c74f0 --- /dev/null +++ b/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/ScopeTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cloudstack.engine.subsystem.api.storage; + +import static org.junit.Assert.*; +import junit.framework.Assert; + +import org.junit.Test; + +public class ScopeTest { + + @Test + public void testZoneScope() { + ZoneScope zoneScope = new ZoneScope(1L); + ZoneScope zoneScope2 = new ZoneScope(1L); + Assert.assertTrue(zoneScope.isSameScope(zoneScope2)); + + ZoneScope zoneScope3 = new ZoneScope(2L); + Assert.assertFalse(zoneScope.isSameScope(zoneScope3)); + } + + @Test + public void testClusterScope() { + ClusterScope clusterScope = new ClusterScope(1L, 1L, 1L); + ClusterScope clusterScope2 = new ClusterScope(1L, 1L, 1L); + + Assert.assertTrue(clusterScope.isSameScope(clusterScope2)); + + ClusterScope clusterScope3 = new ClusterScope(2L, 2L, 1L); + Assert.assertFalse(clusterScope.isSameScope(clusterScope3)); + } + + @Test + public void testHostScope() { + HostScope hostScope = new HostScope(1L); + HostScope hostScope2 = new HostScope(1L); + HostScope hostScope3 = new HostScope(2L); + + Assert.assertTrue(hostScope.isSameScope(hostScope2)); + Assert.assertFalse(hostScope.isSameScope(hostScope3)); + } + +} diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java index fbfade6c6aa..7b8741c87c2 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java @@ -29,6 +29,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole; +import org.apache.cloudstack.engine.subsystem.api.storage.HostScope; import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver; @@ -48,9 +49,11 @@ import org.apache.log4j.Logger; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.VolumeVO; +import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.storage.dao.VMTemplatePoolDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.utils.component.ComponentContext; @@ -74,6 +77,8 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore { protected DataStoreProvider provider; @Inject VMTemplatePoolDao templatePoolDao; + @Inject + StoragePoolHostDao poolHostDao; private VolumeDao volumeDao; @@ -152,6 +157,12 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore { vo.getDataCenterId()); } else if (vo.getScope() == ScopeType.ZONE) { return new ZoneScope(vo.getDataCenterId()); + } else if (vo.getScope() == ScopeType.HOST) { + List poolHosts = poolHostDao.listByPoolId(vo.getId()); + if (poolHosts.size() > 0) { + return new HostScope(poolHosts.get(0).getHostId()); + } + s_logger.debug("can't find a local storage in pool host table: " + vo.getId()); } return null; } diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java index 1dd71c5c27f..3a8cf17e24b 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java +++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java @@ -44,7 +44,7 @@ import com.cloud.storage.secondary.SecondaryStorageDiscoverer; import com.cloud.utils.exception.CloudRuntimeException; import org.springframework.stereotype.Component; -@Component + @Local(value=Discoverer.class) public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer implements ResourceStateAdapter, Listener { private static final Logger s_logger = Logger.getLogger(SimulatorSecondaryDiscoverer.class); diff --git a/pom.xml b/pom.xml index e75c420a616..1faafb2914d 100644 --- a/pom.xml +++ b/pom.xml @@ -182,7 +182,6 @@ ${cs.junit.version} test - org.springframework spring-core @@ -222,14 +221,12 @@ 1.9.5 test - org.springframework spring-test ${org.springframework.version} test - org.aspectj aspectjrt @@ -276,7 +273,7 @@ - + @@ -509,113 +506,5 @@ vmware-base - - simulator - - - deploydb-simulator - - - - - - org.codehaus.mojo - properties-maven-plugin - 1.0-alpha-2 - - - initialize - - read-project-properties - - - - ${project.basedir}/utils/conf/db.properties - ${project.basedir}/utils/conf/db.properties.override - - true - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - - mysql - mysql-connector-java - ${cs.mysql.version} - - - commons-dbcp - commons-dbcp - ${cs.dbcp.version} - - - commons-pool - commons-pool - ${cs.pool.version} - - - org.jasypt - jasypt - ${cs.jasypt.version} - - - org.apache.cloudstack - cloud-utils - ${project.version} - - - org.apache.cloudstack - cloud-server - ${project.version} - - - - - process-resources - create-schema - - java - - - - - false - true - - org.apache.cloudstack - cloud-server - - com.cloud.upgrade.DatabaseCreator - - - ${project.basedir}/utils/conf/db.properties - ${project.basedir}/utils/conf/db.properties.override - - ${basedir}/target/db/create-schema-simulator.sql - ${basedir}/target/db/templates.simulator.sql - - com.cloud.upgrade.DatabaseUpgradeChecker - --database=simulator - --rootpassword=${db.root.password} - - - - - catalina.home - ${project.basedir}/utils - - - - - - - diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java index f561449fe2a..8b6abf8a3e4 100644 --- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java @@ -185,6 +185,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBase implem nicResponse.setGateway(userVm.getGateway()); nicResponse.setNetmask(userVm.getNetmask()); nicResponse.setNetworkid(userVm.getNetworkUuid()); + nicResponse.setNetworkName(userVm.getNetworkName()); nicResponse.setMacAddress(userVm.getMacAddress()); nicResponse.setIp6Address(userVm.getIp6Address()); nicResponse.setIp6Gateway(userVm.getIp6Gateway()); @@ -246,6 +247,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBase implem nicResponse.setGateway(uvo.getGateway()); nicResponse.setNetmask(uvo.getNetmask()); nicResponse.setNetworkid(uvo.getNetworkUuid()); + nicResponse.setNetworkName(uvo.getNetworkName()); nicResponse.setMacAddress(uvo.getMacAddress()); nicResponse.setIp6Address(uvo.getIp6Address()); nicResponse.setIp6Gateway(uvo.getIp6Gateway()); diff --git a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java index d7238224e4e..33c49cdeae9 100644 --- a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java +++ b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java @@ -293,6 +293,9 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity { @Column(name="network_uuid") private String networkUuid; + @Column(name="network_name") + private String networkName; + @Column(name="traffic_type") @Enumerated(value=EnumType.STRING) private TrafficType trafficType; @@ -1168,6 +1171,16 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity { } + public String getNetworkName() { + return networkName; + } + + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public TrafficType getTrafficType() { return trafficType; } diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java index 779b9f23466..40a18c742dd 100644 --- a/server/src/com/cloud/network/NetworkModelImpl.java +++ b/server/src/com/cloud/network/NetworkModelImpl.java @@ -1644,6 +1644,11 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { if (usedIps.size() != 0) { allPossibleIps.removeAll(usedIps); } + + String gateway = network.getGateway(); + if ((gateway != null) && (allPossibleIps.contains(NetUtils.ip2Long(gateway)))) + allPossibleIps.remove(NetUtils.ip2Long(gateway)); + return allPossibleIps; } diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index 52e81e5c8c8..8303b0bba3c 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -2046,6 +2046,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (usedIps.size() != 0) { allPossibleIps.removeAll(usedIps); } + + String gateway = network.getGateway(); + if ((gateway != null) && (allPossibleIps.contains(NetUtils.ip2Long(gateway)))) + allPossibleIps.remove(NetUtils.ip2Long(gateway)); + return allPossibleIps; } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 1f1f12edfc1..191157a4db8 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -414,13 +414,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe @Inject S3Manager _s3Mgr; -/* - @Inject - ComponentContext _forceContextRef; // create a dependency to ComponentContext so that it can be loaded beforehead - - @Inject - EventUtils _forceEventUtilsRef; -*/ private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker")); private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AlertChecker")); private KeystoreManager _ksMgr; @@ -429,7 +422,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe private Map _availableIdsMap; - @Inject List _userAuthenticators; + List _userAuthenticators; @Inject ClusterManager _clusterMgr; private String _hashKey = null; @@ -437,6 +430,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe public ManagementServerImpl() { setRunLevel(ComponentLifecycle.RUN_LEVEL_APPLICATION_MAINLOOP); } + + public List getUserAuthenticators() { + return _userAuthenticators; + } + + public void setUserAuthenticators(List authenticators) { + _userAuthenticators = authenticators; + } @Override public boolean configure(String name, Map params) @@ -2103,13 +2104,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(QueryAsyncJobResultCmd.class); cmdList.add(AssignToLoadBalancerRuleCmd.class); cmdList.add(CreateLBStickinessPolicyCmd.class); - cmdList.add(CreateLBHealthCheckPolicyCmd .class); + cmdList.add(CreateLBHealthCheckPolicyCmd.class); cmdList.add(CreateLoadBalancerRuleCmd.class); cmdList.add(DeleteLBStickinessPolicyCmd.class); - cmdList.add(DeleteLBHealthCheckPolicyCmd .class); + cmdList.add(DeleteLBHealthCheckPolicyCmd.class); cmdList.add(DeleteLoadBalancerRuleCmd.class); cmdList.add(ListLBStickinessPoliciesCmd.class); - cmdList.add(ListLBHealthCheckPoliciesCmd .class); + cmdList.add(ListLBHealthCheckPoliciesCmd.class); cmdList.add(ListLoadBalancerRuleInstancesCmd.class); cmdList.add(ListLoadBalancerRulesCmd.class); cmdList.add(RemoveFromLoadBalancerRuleCmd.class); diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index 76bae5b4aca..7dcf091f3e3 100755 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -27,10 +27,15 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import javax.annotation.PostConstruct; import javax.inject.Inject; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; + +import com.cloud.configuration.dao.ConfigurationDao; +import com.cloud.resource.ResourceManager; + import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -88,6 +93,7 @@ public class StatsCollector { @Inject private StoragePoolHostDao _storagePoolHostDao; @Inject private SecondaryStorageVmManager _ssvmMgr; @Inject private ResourceManager _resourceMgr; + @Inject private ConfigurationDao _configDao; private ConcurrentHashMap _hostStats = new ConcurrentHashMap(); private final ConcurrentHashMap _VmStats = new ConcurrentHashMap(); @@ -107,6 +113,7 @@ public class StatsCollector { } public static StatsCollector getInstance(Map configs) { + s_instance.init(configs); return s_instance; } @@ -114,6 +121,11 @@ public class StatsCollector { s_instance = this; } + @PostConstruct + private void init(){ + init(_configDao.getConfiguration()); + } + private void init(Map configs) { _executor = Executors.newScheduledThreadPool(3, new NamedThreadFactory("StatsCollector")); diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index 4951975786f..737ed0a3bac 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -48,6 +48,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManag import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole; import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo; +import org.apache.cloudstack.engine.subsystem.api.storage.Scope; import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; @@ -1439,64 +1440,30 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { } private boolean needMoveVolume(VolumeVO rootVolumeOfVm, VolumeInfo volume) { - StoragePoolVO vmRootVolumePool = _storagePoolDao - .findById(rootVolumeOfVm.getPoolId()); - DiskOfferingVO volumeDiskOffering = _diskOfferingDao - .findById(volume.getDiskOfferingId()); - String[] volumeTags = volumeDiskOffering.getTagsArray(); - - boolean isVolumeOnSharedPool = !volumeDiskOffering - .getUseLocalStorage(); - StoragePoolVO sourcePool = _storagePoolDao.findById(volume - .getPoolId()); - List matchingVMPools = _storagePoolDao - .findPoolsByTags(vmRootVolumePool.getDataCenterId(), - vmRootVolumePool.getPodId(), - vmRootVolumePool.getClusterId(), volumeTags - ); + DataStore storeForRootVol = this.dataStoreMgr.getPrimaryDataStore(rootVolumeOfVm.getPoolId()); + DataStore storeForDataVol = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId()); - boolean moveVolumeNeeded = true; - if (matchingVMPools.size() == 0) { - String poolType; - if (vmRootVolumePool.getClusterId() != null) { - poolType = "cluster"; - } else if (vmRootVolumePool.getPodId() != null) { - poolType = "pod"; - } else { - poolType = "zone"; - } - throw new CloudRuntimeException( - "There are no storage pools in the VM's " + poolType - + " with all of the volume's tags (" - + volumeDiskOffering.getTags() + ")."); - } else { - long sourcePoolId = sourcePool.getId(); - Long sourcePoolDcId = sourcePool.getDataCenterId(); - Long sourcePoolPodId = sourcePool.getPodId(); - Long sourcePoolClusterId = sourcePool.getClusterId(); - for (StoragePoolVO vmPool : matchingVMPools) { - long vmPoolId = vmPool.getId(); - Long vmPoolDcId = vmPool.getDataCenterId(); - Long vmPoolPodId = vmPool.getPodId(); - Long vmPoolClusterId = vmPool.getClusterId(); - - // Moving a volume is not required if storage pools belongs - // to same cluster in case of shared volume or - // identical storage pool in case of local - if (sourcePoolDcId == vmPoolDcId - && sourcePoolPodId == vmPoolPodId - && sourcePoolClusterId == vmPoolClusterId - && (isVolumeOnSharedPool || sourcePoolId == vmPoolId)) { - moveVolumeNeeded = false; - break; - } - } + Scope storeForRootStoreScope = storeForRootVol.getScope(); + if (storeForRootStoreScope == null) { + throw new CloudRuntimeException("Can't get scope of data store: " + storeForRootVol.getId()); } - return moveVolumeNeeded; + Scope storeForDataStoreScope = storeForDataVol.getScope(); + if (storeForDataStoreScope == null) { + throw new CloudRuntimeException("Can't get scope of data store: " + storeForDataVol.getId()); + } + + if (storeForDataStoreScope.getScopeType() == ScopeType.ZONE) { + return false; + } + + if (storeForRootStoreScope.getScopeType() != storeForDataStoreScope.getScopeType()) { + throw new CloudRuntimeException("Can't move volume between scope: " + storeForDataStoreScope.getScopeType() + " and " + storeForRootStoreScope.getScopeType()); + } + + return !storeForRootStoreScope.isSameScope(storeForDataStoreScope); } - private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volume, Long deviceId) { String errorMsg = "Failed to attach volume: " + volume.getName() + " to VM: " + vm.getHostName(); @@ -2166,7 +2133,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { + assignedPool + " assigned by deploymentPlanner"); } - VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, null); + VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, assignedPool); tasks.add(task); } } else { diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index be5f4f4d77d..b69f31464ba 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -48,7 +48,6 @@ import org.apache.cloudstack.api.command.admin.user.RegisterCmd; import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd; import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; import com.cloud.api.ApiDBUtils; import com.cloud.api.query.dao.UserAccountJoinDao; @@ -140,7 +139,6 @@ import com.cloud.vm.dao.InstanceGroupDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; -@Component @Local(value = { AccountManager.class, AccountService.class }) public class AccountManagerImpl extends ManagerBase implements AccountManager, Manager { public static final Logger s_logger = Logger.getLogger(AccountManagerImpl.class); @@ -223,7 +221,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M private AutoScaleManager _autoscaleMgr; @Inject VolumeManager volumeMgr; - @Inject private List _userAuthenticators; private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AccountChecker")); @@ -237,6 +234,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M List _securityCheckers; int _cleanupInterval; + public List getUserAuthenticators() { + return _userAuthenticators; + } + + public void setUserAuthenticators(List authenticators) { + _userAuthenticators = authenticators; + } + @Override public boolean configure(final String name, final Map params) throws ConfigurationException { _systemAccount = _accountDao.findById(AccountVO.ACCOUNT_ID_SYSTEM); diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index 0f316a5acdd..9d51030876c 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -572,6 +572,7 @@ CREATE VIEW `cloud`.`user_vm_view` AS vpc.id vpc_id, vpc.uuid vpc_uuid, networks.uuid network_uuid, + networks.name network_name, networks.traffic_type traffic_type, networks.guest_type guest_type, user_ip_address.id public_ip_id, @@ -750,7 +751,7 @@ CREATE VIEW `cloud`.`domain_router_view` AS left join `cloud`.`networks` ON nics.network_id = networks.id left join - `cloud`.`vpc` ON networks.vpc_id = vpc.id + `cloud`.`vpc` ON domain_router.vpc_id = vpc.id left join `cloud`.`async_job` ON async_job.instance_id = vm_instance.id and async_job.instance_type = 'DomainRouter' diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py index 16d51068deb..9f0488d20ce 100644 --- a/test/integration/component/test_project_usage.py +++ b/test/integration/component/test_project_usage.py @@ -82,7 +82,7 @@ class Services: "iso": { "displaytext": "Test ISO", "name": "Test ISO", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "isextractable": True, "isfeatured": True, diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py index 4251eab9555..82d13e5a9ff 100644 --- a/test/integration/component/test_usage.py +++ b/test/integration/component/test_usage.py @@ -78,7 +78,7 @@ class Services: "iso": { "displaytext": "Test ISO", "name": "Test ISO", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "isextractable": True, "isfeatured": True, diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py index 0a7813065ae..bedf6efd8b4 100644 --- a/test/integration/component/test_volumes.py +++ b/test/integration/component/test_volumes.py @@ -77,7 +77,7 @@ class Services: { "displaytext": "Test ISO", "name": "testISO", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "ostype": 'CentOS 5.3 (64-bit)', }, diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 8228a278cc9..5bd7bb358be 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -50,7 +50,7 @@ class Services: { "displaytext": "Test ISO 1", "name": "ISO 1", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "isextractable": True, "isfeatured": True, @@ -61,7 +61,7 @@ class Services: { "displaytext": "Test ISO 2", "name": "ISO 2", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "isextractable": True, "isfeatured": True, diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py index b9dfdde8fe5..ad30122cd47 100644 --- a/test/integration/smoke/test_nic.py +++ b/test/integration/smoke/test_nic.py @@ -88,7 +88,7 @@ class Services: "iso": { "displaytext": "Test ISO", "name": "testISO", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "ostype": 'CentOS 5.3 (64-bit)', "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 8d65c00c896..0a5fbad8376 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -107,7 +107,7 @@ class Services: { "displaytext": "Test ISO", "name": "testISO", - "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", + "url": "http://people.apache.org/~tsp/dummy.iso", # Source URL where ISO is located "ostype": 'CentOS 5.3 (64-bit)', "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py index 6292c536a9d..1fe5e1641f4 100644 --- a/tools/apidoc/gen_toc.py +++ b/tools/apidoc/gen_toc.py @@ -123,6 +123,7 @@ known_categories = { 'Pool': 'Pool', 'VPC': 'VPC', 'PrivateGateway': 'VPC', + 'Simulator': 'simulator', 'StaticRoute': 'VPC', 'Tags': 'Resource tags', 'NiciraNvpDevice': 'Nicira NVP', diff --git a/tools/cli/cloudmonkey/cachemaker.py b/tools/cli/cloudmonkey/cachemaker.py index 8ac123caa4b..a625b014d38 100644 --- a/tools/cli/cloudmonkey/cachemaker.py +++ b/tools/cli/cloudmonkey/cachemaker.py @@ -100,7 +100,11 @@ def monkeycache(apis): cache['count'] = getvalue(apis[responsekey], 'count') cache['asyncapis'] = [] - for api in getvalue(apis[responsekey], 'api'): + apilist = getvalue(apis[responsekey], 'api') + if apilist == None: + print "[monkeycache] Server response issue, no apis found" + + for api in apilist: name = getvalue(api, 'name') verb, subject = splitverbsubject(name) diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index e94d53091ac..94006c9577a 100644 --- a/tools/cli/cloudmonkey/cloudmonkey.py +++ b/tools/cli/cloudmonkey/cloudmonkey.py @@ -487,9 +487,10 @@ def main(): if options.version: print "cloudmonkey", __version__ print __description__, "(%s)" % __projecturl__ + sys.exit(0) shell = CloudMonkeyShell(sys.argv[0], options.cfile) - if len(args) > 1: + if len(args) > 0: shell.onecmd(' '.join(args)) else: shell.cmdloop() diff --git a/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg b/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg index 7c733ade256..ca794605540 100644 --- a/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg +++ b/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg @@ -112,11 +112,11 @@ "logger": [ { "name": "TestClient", - "file": "/var/log/testclient.log" + "file": "/tmp/testclient.log" }, { "name": "TestCase", - "file": "/var/log/testcase.log" + "file": "/tmp/testcase.log" } ], "globalConfig": [ diff --git a/tools/marvin/pom.xml b/tools/marvin/pom.xml index 80099be1ecb..a3bd5460fd5 100644 --- a/tools/marvin/pom.xml +++ b/tools/marvin/pom.xml @@ -9,112 +9,119 @@ OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - 4.0.0 - cloud-marvin - Apache CloudStack marvin - pom - - org.apache.cloudstack - cloud-tools - 4.2.0-SNAPSHOT - ../pom.xml - - - install - - - maven-antrun-plugin - 1.7 - - - clean - clean - - run - - - - - Deleting ${project.artifactId} API sources - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - compile - compile - - exec - - - ${basedir}/marvin - python - - codegenerator.py - -s - ${basedir}/../apidoc/target/commands.xml - Generating ${project.artifactId} API classes} - - - - - package - package - - exec - - - ${exec.workingdir} - python - - setup.py - sdist - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + cloud-marvin + Apache CloudStack marvin + pom + + org.apache.cloudstack + cloud-tools + 4.2.0-SNAPSHOT + ../pom.xml + + + install + + + maven-antrun-plugin + 1.7 + + + clean + clean + + run + + + + + Deleting ${project.artifactId} API sources + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + compile + compile + + exec + + + ${basedir}/marvin + python + + codegenerator.py + -s + ${basedir}/../apidoc/target/commands.xml + Generating ${project.artifactId} API classes} + + + + + package + package + + exec + + + ${exec.workingdir} + python + + setup.py + sdist + + + + - + - - - - marvin - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - package - - exec - - - - - ${basedir}/marvin - python - - deployDataCenter.py - -i - ${user.dir}/${marvin.config} - - - - - - - + + + + marvin + + marvin.config + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + ${basedir}/marvin + python + + deployAndRun.py + -c + ${user.dir}/${marvin.config} + -t + /tmp/t.log + -r + /tmp/r.log + -f + ${basedir}/marvin/testSetupSuccess.py + + + + + test + + exec + + + + + + + + diff --git a/ui/scripts/cloud.core.callbacks.js b/ui/scripts/cloud.core.callbacks.js index 857c247d9d1..6384f9bd006 100644 --- a/ui/scripts/cloud.core.callbacks.js +++ b/ui/scripts/cloud.core.callbacks.js @@ -52,17 +52,29 @@ Below is a sample login attempt var clientApiUrl = "/client/api"; var clientConsoleUrl = "/client/console"; -$(document).ready(function() { +$(document).ready(function() { + /* + condition 1: If window.location.href contains parameter 'loginUrl', save the parameter's value to a cookie, then reload the page without any URL parameter. + (After the page is reloaded without any URL parameter, it will fall in condition 2.) + */ + if ($.urlParam('loginUrl') != 0) { + $.cookie('loginUrl', $.urlParam('loginUrl'), { expires: 1}); + document.location.href = '/client/'; + } - var url = $.urlParam("loginUrl"); - if (url != undefined && url != null && url.length > 0) { - url = unescape(clientApiUrl+"?"+url); + /* + condition 2: If window.location.href does not contain parameter 'loginUrl' but cookie 'loginUrl' exists, + save the cookie's value to g_regionUrlParam (a global variable for switching regions), + then call login API to set g_loginResponse (a global variable for single-sign-on). + */ + else if($.cookie('loginUrl') != null) { + g_regionUrlParam = '?loginUrl=' + $.cookie('loginUrl'); $.ajax({ - url: url, + url: unescape(clientApiUrl + "?" + $.cookie('loginUrl')), dataType: "json", async: false, success: function(json) { - g_loginResponse = json.loginresponse; + g_loginResponse = json.loginresponse; }, error: function() { onLogoutCallback(); @@ -73,6 +85,7 @@ $(document).ready(function() { } }); } + }); diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js index f9b5a58545c..00b06ab0e61 100644 --- a/ui/scripts/cloudStack.js +++ b/ui/scripts/cloudStack.js @@ -251,6 +251,9 @@ array1.push("&domain=" + encodeURIComponent("/")); } + g_regionUrlParam = '?loginUrl=' + escape("command=login" + array1.join("") + "&response=json"); + $.cookie('loginUrl', escape("command=login" + array1.join("") + "&response=json"), { expires: 1}); + $.ajax({ type: "POST", data: "command=login" + array1.join("") + "&response=json", @@ -382,8 +385,9 @@ g_domainid = null; g_timezoneoffset = null; g_timezone = null; - g_supportELB = null; - + g_supportELB = null; + g_regionUrlParam = null; + $.cookie('JSESSIONID', null); $.cookie('sessionKey', null); $.cookie('username', null); @@ -394,6 +398,7 @@ $.cookie('timezoneoffset', null); $.cookie('timezone', null); $.cookie('supportELB', null); + $.cookie('loginUrl', null); if(onLogoutCallback()) { //onLogoutCallback() will set g_loginResponse(single-sign-on variable) to null, then bypassLoginCheck() will show login screen. document.location.reload(); //when onLogoutCallback() returns true, reload the current document. diff --git a/ui/scripts/regions.js b/ui/scripts/regions.js index 42a3e9de57c..68191c04361 100644 --- a/ui/scripts/regions.js +++ b/ui/scripts/regions.js @@ -29,8 +29,7 @@ data: regions ? regions : [ { id: -1, name: '(Default)' } ], - activeRegionID: cloudStack.context.users.regionid ? - cloudStack.context.users.regionid : 1 + activeRegionID: cloudStack.context.users[0].regionid }); } }); @@ -55,26 +54,34 @@ fields: { id: { label: 'label.id', validation: { required: true } }, name: { label: 'label.name', validation: { required: true } }, - endpoint: { label: 'label.endpoint', validation: { required: true } }, - userapikey: { label: 'label.api.key' }, - userapisecretkey: { label: 'label.s3.secret_key' } + endpoint: { label: 'label.endpoint', validation: { required: true } } } }, - action: function(args) { + action: function(args) { + var data = { + id: args.data.id, + name: args.data.name, + endpoint: args.data.endpoint + }; + $.ajax({ url: createURL('addRegion'), - data: args.data, - success: function(json) { - var jobID = json.addregionresponse.jobid; - - args.response.success({ _custom: { jobId: jobID }}); + data: data, + success: function(json) { + var item = json.addregionresponse.region; + args.response.success({data: item}); $(window).trigger('cloudStack.refreshRegions'); }, error: function(json) { args.response.error(parseXMLHttpResponse(json)); } }); - } + }, + notification: { + poll: function(args) { + args.complete(); + } + } } }, dataProvider: function(args) { @@ -98,9 +105,15 @@ edit: { label: 'label.edit.region', action: function(args) { + var data = { + id: args.context.regions[0].id, + name: args.data.name, + endpoint: args.data.endpoint + }; + $.ajax({ url: createURL('updateRegion'), - data: args.data, + data: data, success: function(json) { args.response.success(); $(window).trigger('cloudStack.refreshRegions'); @@ -116,7 +129,15 @@ messages: { notification: function() { return 'label.remove.region'; }, confirm: function() { return 'message.remove.region'; } - }, + }, + preAction: function(args) { + var region = args.context.regions[0]; + if(region.endpoint == document.location.href) { + cloudStack.dialog.notice({ message: _l('You can not remove the region that you are currently in.') }); + return false; + } + return true; + }, action: function(args) { var region = args.context.regions[0]; @@ -139,11 +160,11 @@ title: 'label.details', fields: [ { - name: { label: 'label.name', isEditable: true }, + id: { label: 'label.id' } }, { - endpoint: { label: 'label.endpoint', isEditable: true }, - id: { label: 'label.id', isEditable: true } + name: { label: 'label.name', isEditable: true }, + endpoint: { label: 'label.endpoint', isEditable: true } } ], dataProvider: function(args) { diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index 8bcdff91574..dbcb781a6fa 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -20,6 +20,7 @@ var g_role = null; // roles - root, domain-admin, ro-admin, user var g_username = null; var g_account = null; var g_domainid = null; +var g_regionUrlParam = null; var g_enableLogging = false; var g_timezoneoffset = null; var g_timezone = null; diff --git a/ui/scripts/ui-custom/regions.js b/ui/scripts/ui-custom/regions.js index ac52776d49f..474e49817cd 100644 --- a/ui/scripts/ui-custom/regions.js +++ b/ui/scripts/ui-custom/regions.js @@ -29,23 +29,28 @@ var data = args.data; var activeRegionID = args.activeRegionID; + var currentRegion; $(data).each(function() { var region = this; var regionName = region.name; var $li = $('
  • ').append($('').html(_s(region.name))); $li.data('region-data', region); - + + if(region.endpoint == document.location.href) { + currentRegion = region; + $li.addClass('active'); + } + /* if (region.id == activeRegionID) { $li.addClass('active'); } - - $regionSwitcherButton.find('.title') - .html(regionName) - .attr('title', regionName); - - $regionList.append($li); + */ + + $regionList.append($li); }); + + $regionSwitcherButton.find('.title').html(_s(currentRegion.name)).attr('title', _s(currentRegion.name)); } } }); @@ -81,8 +86,8 @@ closeRegionSelector({ complete: function() { $('#container').prepend($('
    ').addClass('loading-overlay')); - - document.location.href = url; + + document.location.href = url + g_regionUrlParam; } }); }; diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index dd40a33934d..5988dd5f337 100755 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -632,7 +632,7 @@ public class NetUtils { Set result = new TreeSet(); long ip = ip2Long(cidr); long startNetMask = ip2Long(getCidrNetmask(size)); - long start = (ip & startNetMask) + 2; + long start = (ip & startNetMask) + 1; long end = start; end = end >> (32 - size);