From e4b22d0fca89e12f44c99e90fd73e4bb1fa814b4 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 21 Nov 2013 03:39:58 -0800 Subject: [PATCH] Replace all tabs, particularly the ones in the comments --- awsapi/src/com/cloud/bridge/model/SAcl.java | 124 ++-- .../src/com/cloud/bridge/model/SBucket.java | 170 ++--- awsapi/src/com/cloud/bridge/model/SHost.java | 154 ++-- .../src/com/cloud/bridge/model/SObjectVO.java | 2 +- .../cloud/bridge/service/EC2RestServlet.java | 4 +- .../bridge/service/EC2SoapServiceImpl.java | 10 +- .../cloud/bridge/service/S3RestServlet.java | 2 +- .../service/controller/s3/S3BucketAction.java | 2 +- .../service/controller/s3/S3ObjectAction.java | 2 +- .../controller/s3/ServiceProvider.java | 2 +- .../bridge/service/core/ec2/EC2Engine.java | 6 +- .../service/core/ec2/EC2RunInstances.java | 2 +- .../service/core/ec2/EC2VolumeFilterSet.java | 2 +- .../bridge/service/core/s3/S3Engine.java | 12 +- .../cloud/bridge/service/core/s3/S3Grant.java | 4 +- .../com/cloud/bridge/util/EC2RestAuth.java | 2 +- .../com/cloud/bridge/util/JsonAccessor.java | 10 +- .../src/com/cloud/stack/CloudStackClient.java | 4 +- .../VirtualRoutingResource.java | 76 +- .../cloud/resource/ServerResourceBase.java | 2 +- .../cloud/serializer/SerializerHelper.java | 2 +- .../src/com/xensource/xenapi/Connection.java | 2 +- .../src/com/xensource/xenapi/Marshalling.java | 18 +- .../com/xensource/xenapi/XenAPIObject.java | 2 +- .../configuration/ConfigurationManager.java | 4 +- .../entity/api/db/EngineHostVO.java | 2 +- .../cloud/capacity/dao/CapacityDaoImpl.java | 8 +- .../src/com/cloud/dc/dao/VlanDaoImpl.java | 10 +- engine/schema/src/com/cloud/host/HostVO.java | 2 +- .../com/cloud/network/dao/PortProfileDao.java | 2 +- .../schema/src/com/cloud/vm/VMInstanceVO.java | 2 +- .../com/cloud/vm/dao/ConsoleProxyDaoImpl.java | 2 +- .../cloud/entity/api/db/VMEntityVO.java | 2 +- .../cluster/ClusterServiceServletAdapter.java | 2 +- .../db/src/com/cloud/utils/db/GlobalLock.java | 20 +- .../db/TransactionContextBuilderTest.java | 12 +- .../framework/async/AsyncCallFuture.java | 2 +- .../framework/rpc/RpcProviderImpl.java | 2 +- .../framework/rpc/RpcServiceEndpoint.java | 6 +- .../AsyncSampleListenerStyleCaller.java | 16 +- .../codestyle/ClientOnlyEventDrivenStyle.java | 2 +- .../framework/jobs/AsyncJobDispatcher.java | 4 +- .../framework/jobs/AsyncJobManager.java | 12 +- .../jobs/dao/AsyncJobJoinMapDao.java | 4 +- .../jobs/dao/AsyncJobJoinMapDaoImpl.java | 92 +-- .../jobs/impl/AsyncJobManagerImpl.java | 64 +- .../com/cloud/netapp/NetappManagerImpl.java | 2 +- .../BaremetalDnsmasqResource.java | 2 +- .../resource/HypervDirectConnectResource.java | 2 +- .../test/HypervDirectConnectResourceTest.java | 2 +- .../cloud/ovm/hypervisor/OvmResourceBase.java | 6 +- .../ovm/src/com/cloud/ovm/object/Test.java | 28 +- .../hypervisor/vmware/VmwareCleanupMaid.java | 18 +- .../vmware/manager/VmwareManagerImpl.java | 14 +- .../manager/VmwareStorageManagerImpl.java | 4 +- .../vmware/resource/VmwareResource.java | 4 +- .../network/dao/CiscoNexusVSMDeviceDao.java | 40 +- .../network/element/CiscoNexusVSMElement.java | 2 +- .../resource/VmwareStorageProcessor.java | 2 +- .../motion/VmwareStorageMotionStrategy.java | 2 +- .../network/resource/F5BigIpResource.java | 2 +- .../management/ContrailElementImpl.java | 374 +++++----- .../contrail/management/ContrailGuru.java | 2 +- .../management/ContrailManagerImpl.java | 24 +- .../IntegrationTestConfiguration.java | 12 +- .../management/MockAccountManager.java | 62 +- .../management/PublicNetworkTest.java | 2 +- .../contrail/management/TestDbSetup.java | 2 +- .../network/resource/JuniperSrxResource.java | 2 +- .../commands/ListExternalFirewallsCmd.java | 12 +- .../resource/MockablePaloAltoResource.java | 62 +- .../resource/PaloAltoResourceTest.java | 414 +++++------ pom.xml | 2 + .../src/com/cloud/alert/AlertManagerImpl.java | 2 +- .../src/com/cloud/configuration/Config.java | 2 +- .../consoleproxy/ConsoleProxyManager.java | 6 +- .../consoleproxy/ConsoleProxyManagerImpl.java | 12 +- .../src/com/cloud/ha/RecreatableFencer.java | 2 +- .../cloud/network/PortProfileManagerImpl.java | 4 +- .../VirtualNetworkApplianceManager.java | 2 +- .../ConsoleProxyPasswordBasedEncryptor.java | 2 +- .../cloud/servlet/ConsoleProxyServlet.java | 2 +- .../SecondaryStorageManagerImpl.java | 80 +-- .../secondary/SecondaryStorageVmManager.java | 8 +- server/src/com/cloud/test/DatabaseConfig.java | 8 +- server/src/com/cloud/test/IPRangeConfig.java | 44 +- server/src/com/cloud/test/PodZoneConfig.java | 32 +- .../test/com/cloud/keystore/KeystoreTest.java | 48 +- .../network/vpn/RemoteAccessVpnTest.java | 78 +- .../src/main/java/rdpclient/MockServer.java | 212 +++--- .../test/java/rdpclient/MockServerTest.java | 224 +++--- .../ConsoleProxyPasswordBasedEncryptor.java | 2 +- .../storage/template/DownloadManager.java | 2 +- .../storage/template/UploadManagerImpl.java | 22 +- .../cloud/test/longrun/BuildGuestNetwork.java | 188 ++--- .../test/longrun/PerformanceWithAPI.java | 308 ++++---- test/src/com/cloud/test/longrun/User.java | 334 ++++----- .../cloud/test/longrun/VirtualMachine.java | 140 ++-- .../com/cloud/test/longrun/guestNetwork.java | 148 ++-- .../com/cloud/test/regression/ConfigTest.java | 192 ++--- .../test/regression/DelegatedAdminTest.java | 198 ++--- .../src/com/cloud/test/regression/Deploy.java | 156 ++-- .../cloud/test/regression/EventsApiTest.java | 284 ++++---- test/src/com/cloud/test/regression/HA.java | 100 +-- .../test/regression/LoadBalancingTest.java | 228 +++--- .../test/regression/PortForwardingTest.java | 230 +++--- .../com/cloud/test/regression/SanityTest.java | 120 ++-- test/src/com/cloud/test/regression/Test.java | 110 +-- .../com/cloud/test/regression/TestCase.java | 190 ++--- .../cloud/test/regression/TestCaseEngine.java | 442 ++++++------ .../com/cloud/test/regression/VMApiTest.java | 128 ++-- .../test/stress/StressTestDirectAttach.java | 74 +- .../cloud/test/stress/TestClientWithAPI.java | 2 +- test/src/com/cloud/test/stress/WgetTest.java | 230 +++--- .../test/ui/AbstractSeleniumTestCase.java | 44 +- .../com/cloud/test/ui/AddAndDeleteAISO.java | 162 ++--- .../cloud/test/ui/AddAndDeleteATemplate.java | 162 ++--- .../src/com/cloud/test/ui/UIScenarioTest.java | 104 +-- .../com/cloud/test/utils/ConsoleProxy.java | 140 ++-- .../com/cloud/test/utils/IpSqlGenerator.java | 126 ++-- .../com/cloud/test/utils/ProxyLoadTemp.java | 124 ++-- test/src/com/cloud/test/utils/SignEC2.java | 226 +++--- .../src/com/cloud/test/utils/SignRequest.java | 170 ++--- .../cloud/test/utils/SqlDataGenerator.java | 46 +- test/src/com/cloud/test/utils/TestClient.java | 680 +++++++++--------- tools/apidoc/XmlToHtmlConverter.java | 246 +++---- .../utils/component/ComponentLifecycle.java | 12 +- utils/src/com/cloud/utils/nio/Link.java | 48 +- .../hypervisor/vmware/mo/DatacenterMO.java | 4 +- .../hypervisor/vmware/mo/HttpNfcLeaseMO.java | 2 +- .../vmware/mo/VirtualMachineMO.java | 8 +- .../hypervisor/vmware/util/VmwareContext.java | 42 +- .../vmware/util/VmwareContextPool.java | 4 +- .../hypervisor/vmware/mo/VmwareMOTest.java | 22 +- 134 files changed, 4479 insertions(+), 4477 deletions(-) diff --git a/awsapi/src/com/cloud/bridge/model/SAcl.java b/awsapi/src/com/cloud/bridge/model/SAcl.java index 63ed5e4d38f..f2300db33dd 100644 --- a/awsapi/src/com/cloud/bridge/model/SAcl.java +++ b/awsapi/src/com/cloud/bridge/model/SAcl.java @@ -65,35 +65,35 @@ public interface SAcl { */ //public static OrderedPair getCannedAccessControls ( String aclRequestString, String target ); - /* { - if ( aclRequestString.equalsIgnoreCase( "public-read" )) - // All users granted READ access. - return new OrderedPair (PERMISSION_READ,GRANTEE_ALLUSERS); - else if (aclRequestString.equalsIgnoreCase( "public-read-write" )) - // All users granted READ and WRITE access - return new OrderedPair ((PERMISSION_READ | PERMISSION_WRITE),GRANTEE_ALLUSERS); - else if (aclRequestString.equalsIgnoreCase( "authenticated-read" )) - // Authenticated users have READ access - return new OrderedPair (PERMISSION_READ,GRANTEE_AUTHENTICATED); - else if (aclRequestString.equalsIgnoreCase( "private" )) - // Only Owner gets FULL_CONTROL - return new OrderedPair (PERMISSION_FULL,GRANTEE_USER); - else if (aclRequestString.equalsIgnoreCase( "bucket-owner-read" )) - { - // Object Owner gets FULL_CONTROL, Bucket Owner gets READ - if ( target.equalsIgnoreCase( "SBucket" )) - return new OrderedPair (PERMISSION_READ, GRANTEE_USER); - else - return new OrderedPair (PERMISSION_FULL, GRANTEE_USER); - } - else if (aclRequestString.equalsIgnoreCase( "bucket-owner-full-control" )) - { - // Object Owner gets FULL_CONTROL, Bucket Owner gets FULL_CONTROL - // This is equivalent to private when used with PUT Bucket - return new OrderedPair (PERMISSION_FULL,GRANTEE_USER); - } - else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" ); - } + /* { + if ( aclRequestString.equalsIgnoreCase( "public-read" )) + // All users granted READ access. + return new OrderedPair (PERMISSION_READ,GRANTEE_ALLUSERS); + else if (aclRequestString.equalsIgnoreCase( "public-read-write" )) + // All users granted READ and WRITE access + return new OrderedPair ((PERMISSION_READ | PERMISSION_WRITE),GRANTEE_ALLUSERS); + else if (aclRequestString.equalsIgnoreCase( "authenticated-read" )) + // Authenticated users have READ access + return new OrderedPair (PERMISSION_READ,GRANTEE_AUTHENTICATED); + else if (aclRequestString.equalsIgnoreCase( "private" )) + // Only Owner gets FULL_CONTROL + return new OrderedPair (PERMISSION_FULL,GRANTEE_USER); + else if (aclRequestString.equalsIgnoreCase( "bucket-owner-read" )) + { + // Object Owner gets FULL_CONTROL, Bucket Owner gets READ + if ( target.equalsIgnoreCase( "SBucket" )) + return new OrderedPair (PERMISSION_READ, GRANTEE_USER); + else + return new OrderedPair (PERMISSION_FULL, GRANTEE_USER); + } + else if (aclRequestString.equalsIgnoreCase( "bucket-owner-full-control" )) + { + // Object Owner gets FULL_CONTROL, Bucket Owner gets FULL_CONTROL + // This is equivalent to private when used with PUT Bucket + return new OrderedPair (PERMISSION_FULL,GRANTEE_USER); + } + else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" ); + } */ /** Return a Triple * < permission1, permission2, symbol > @@ -111,39 +111,39 @@ public interface SAcl { * @param ownerID - An ID for the owner, if used in place of symbols "A" or "*" */ //public static Triple getCannedAccessControls ( String aclRequestString, String target, String ownerID ); - /* throws UnsupportedException - { - if ( aclRequestString.equalsIgnoreCase( "public-read" )) + /* throws UnsupportedException + { + if ( aclRequestString.equalsIgnoreCase( "public-read" )) // Owner gets FULL_CONTROL and the anonymous principal (the 'A' symbol here) is granted READ access. - return new Triple (PERMISSION_FULL, PERMISSION_READ,"A"); - else if (aclRequestString.equalsIgnoreCase( "public-read-write" )) - // Owner gets FULL_CONTROL and the anonymous principal (the 'A' symbol here) is granted READ and WRITE access - return new Triple (PERMISSION_FULL, (PERMISSION_READ | PERMISSION_WRITE),"A"); - else if (aclRequestString.equalsIgnoreCase( "authenticated-read" )) - // Owner gets FULL_CONTROL and ANY principal authenticated as a registered S3 user (the '*' symbol here) is granted READ access - return new Triple (PERMISSION_FULL, PERMISSION_READ,"*"); - else if (aclRequestString.equalsIgnoreCase( "private" )) - // This is termed the "private" or default ACL, "Owner gets FULL_CONTROL" - return new Triple (PERMISSION_FULL, PERMISSION_FULL,null); - else if (aclRequestString.equalsIgnoreCase( "bucket-owner-read" )) - { - // Object Owner gets FULL_CONTROL, Bucket Owner gets READ - // This is equivalent to private when used with PUT Bucket - if ( target.equalsIgnoreCase( "SBucket" )) - return new Triple (PERMISSION_FULL,PERMISSION_FULL ,null); - else - return new Triple (PERMISSION_FULL,PERMISSION_READ,ownerID); - } - else if (aclRequestString.equalsIgnoreCase( "bucket-owner-full-control" )) - { - // Object Owner gets FULL_CONTROL, Bucket Owner gets FULL_CONTROL - // This is equivalent to private when used with PUT Bucket - if ( target.equalsIgnoreCase( "SBucket" )) - return new Triple (PERMISSION_FULL, PERMISSION_FULL, null); - else - return new Triple (PERMISSION_FULL,PERMISSION_FULL, ownerID); - } - else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" ); - } + return new Triple (PERMISSION_FULL, PERMISSION_READ,"A"); + else if (aclRequestString.equalsIgnoreCase( "public-read-write" )) + // Owner gets FULL_CONTROL and the anonymous principal (the 'A' symbol here) is granted READ and WRITE access + return new Triple (PERMISSION_FULL, (PERMISSION_READ | PERMISSION_WRITE),"A"); + else if (aclRequestString.equalsIgnoreCase( "authenticated-read" )) + // Owner gets FULL_CONTROL and ANY principal authenticated as a registered S3 user (the '*' symbol here) is granted READ access + return new Triple (PERMISSION_FULL, PERMISSION_READ,"*"); + else if (aclRequestString.equalsIgnoreCase( "private" )) + // This is termed the "private" or default ACL, "Owner gets FULL_CONTROL" + return new Triple (PERMISSION_FULL, PERMISSION_FULL,null); + else if (aclRequestString.equalsIgnoreCase( "bucket-owner-read" )) + { + // Object Owner gets FULL_CONTROL, Bucket Owner gets READ + // This is equivalent to private when used with PUT Bucket + if ( target.equalsIgnoreCase( "SBucket" )) + return new Triple (PERMISSION_FULL,PERMISSION_FULL ,null); + else + return new Triple (PERMISSION_FULL,PERMISSION_READ,ownerID); + } + else if (aclRequestString.equalsIgnoreCase( "bucket-owner-full-control" )) + { + // Object Owner gets FULL_CONTROL, Bucket Owner gets FULL_CONTROL + // This is equivalent to private when used with PUT Bucket + if ( target.equalsIgnoreCase( "SBucket" )) + return new Triple (PERMISSION_FULL, PERMISSION_FULL, null); + else + return new Triple (PERMISSION_FULL,PERMISSION_FULL, ownerID); + } + else throw new UnsupportedException( "Unknown Canned Access Policy: " + aclRequestString + " is not supported" ); + } */ } diff --git a/awsapi/src/com/cloud/bridge/model/SBucket.java b/awsapi/src/com/cloud/bridge/model/SBucket.java index c87d390d228..3ccd78e8d75 100644 --- a/awsapi/src/com/cloud/bridge/model/SBucket.java +++ b/awsapi/src/com/cloud/bridge/model/SBucket.java @@ -37,91 +37,91 @@ public interface SBucket { public static final int VERSIONING_ENABLED = 1; public static final int VERSIONING_SUSPENDED = 2; - /* private Long id; - - private String name; - private String ownerCanonicalId; - - private SHost shost; - private Date createTime; - - private int versioningStatus; - - private Set objectsInBucket = new HashSet(); - - public SBucket() { - versioningStatus = VERSIONING_NULL; - } - - public Long getId() { - return id; - } + /* private Long id; + + private String name; + private String ownerCanonicalId; + + private SHost shost; + private Date createTime; + + private int versioningStatus; + + private Set objectsInBucket = new HashSet(); + + public SBucket() { + versioningStatus = VERSIONING_NULL; + } + + public Long getId() { + return id; + } - private void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getOwnerCanonicalId() { - return ownerCanonicalId; - } - - public void setOwnerCanonicalId(String ownerCanonicalId) { - this.ownerCanonicalId = ownerCanonicalId; - } - - public SHost getShost() { - return shost; - } - - public void setShost(SHost shost) { - this.shost = shost; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public int getVersioningStatus() { - return versioningStatus; - } - - public void setVersioningStatus( int versioningStatus ) { - this.versioningStatus = versioningStatus; - } - - public Set getObjectsInBucket() { - return objectsInBucket; - } + private void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwnerCanonicalId() { + return ownerCanonicalId; + } + + public void setOwnerCanonicalId(String ownerCanonicalId) { + this.ownerCanonicalId = ownerCanonicalId; + } + + public SHost getShost() { + return shost; + } + + public void setShost(SHost shost) { + this.shost = shost; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public int getVersioningStatus() { + return versioningStatus; + } + + public void setVersioningStatus( int versioningStatus ) { + this.versioningStatus = versioningStatus; + } + + public Set getObjectsInBucket() { + return objectsInBucket; + } - public void setObjectsInBucket(Set objectsInBucket) { - this.objectsInBucket = objectsInBucket; - } - - @Override - public boolean equals(Object other) { - if(this == other) - return true; - - if(!(other instanceof SBucket)) - return false; - - return getName().equals(((SBucket)other).getName()); - } - - @Override - public int hashCode() { - return getName().hashCode(); - }*/ + public void setObjectsInBucket(Set objectsInBucket) { + this.objectsInBucket = objectsInBucket; + } + + @Override + public boolean equals(Object other) { + if(this == other) + return true; + + if(!(other instanceof SBucket)) + return false; + + return getName().equals(((SBucket)other).getName()); + } + + @Override + public int hashCode() { + return getName().hashCode(); + }*/ } diff --git a/awsapi/src/com/cloud/bridge/model/SHost.java b/awsapi/src/com/cloud/bridge/model/SHost.java index 69fbe23e138..9d4da0f9695 100644 --- a/awsapi/src/com/cloud/bridge/model/SHost.java +++ b/awsapi/src/com/cloud/bridge/model/SHost.java @@ -31,90 +31,90 @@ public interface SHost { STORAGE_HOST_TYPE_NFS, //1 STORAGE_HOST_TYPE_CASTOR //2 } - /* private Long id; - - private String host; - private int hostType; - private MHostVO mhost; - private String exportRoot; - private String userOnHost; - private String userPassword; - - private Set buckets = new HashSet(); - private Set mounts = new HashSet(); - - public SHost() { - } - - public Long getId() { - return id; - } + /* private Long id; + + private String host; + private int hostType; + private MHostVO mhost; + private String exportRoot; + private String userOnHost; + private String userPassword; + + private Set buckets = new HashSet(); + private Set mounts = new HashSet(); + + public SHost() { + } + + public Long getId() { + return id; + } - private void setId(Long id) { - this.id = id; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getHostType() { - return hostType; - } + private void setId(Long id) { + this.id = id; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getHostType() { + return hostType; + } - public void setHostType(int hostType) { - this.hostType = hostType; - } + public void setHostType(int hostType) { + this.hostType = hostType; + } - public String getExportRoot() { - return exportRoot; - } + public String getExportRoot() { + return exportRoot; + } - public void setExportRoot(String exportRoot) { - this.exportRoot = exportRoot; - } + public void setExportRoot(String exportRoot) { + this.exportRoot = exportRoot; + } - public String getUserOnHost() { - return userOnHost; - } - - public void setUserOnHost(String userOnHost) { - this.userOnHost = userOnHost; - } - - public String getUserPassword() { - return userPassword; - } - - public void setUserPassword(String userPassword) { - this.userPassword = userPassword; - } - - public MHostVO getMhost() { - return mhost; - } + public String getUserOnHost() { + return userOnHost; + } + + public void setUserOnHost(String userOnHost) { + this.userOnHost = userOnHost; + } + + public String getUserPassword() { + return userPassword; + } + + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + public MHostVO getMhost() { + return mhost; + } - public void setMhost(MHostVO mhost) { - this.mhost = mhost; - } + public void setMhost(MHostVO mhost) { + this.mhost = mhost; + } - public Set getBuckets() { - return buckets; - } + public Set getBuckets() { + return buckets; + } - public void setBuckets(Set buckets) { - this.buckets = buckets; - } - - public Set getMounts() { - return mounts; - } + public void setBuckets(Set buckets) { + this.buckets = buckets; + } + + public Set getMounts() { + return mounts; + } - public void setMounts(Set mounts) { - this.mounts = mounts; - }*/ + public void setMounts(Set mounts) { + this.mounts = mounts; + }*/ } diff --git a/awsapi/src/com/cloud/bridge/model/SObjectVO.java b/awsapi/src/com/cloud/bridge/model/SObjectVO.java index d0ae845a3dc..d477221da9f 100644 --- a/awsapi/src/com/cloud/bridge/model/SObjectVO.java +++ b/awsapi/src/com/cloud/bridge/model/SObjectVO.java @@ -54,7 +54,7 @@ public class SObjectVO { private int nextSequence; @Column(name = "DeletionMark") - private String deletionMark; // This must also a unique ID to give to the REST client + private String deletionMark; // This must also a unique ID to give to the REST client @Column(name = "CreateTime") @Temporal(value = TemporalType.TIMESTAMP) diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java index 6d9eee0a8ae..f0a5818233e 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java +++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java @@ -492,7 +492,7 @@ public class EC2RestServlet extends HttpServlet { response.sendError(530, "Missing cert parameter"); return; } -// logger.debug( "SetCertificate cert: [" + certificate[0] + "]" ); +// logger.debug( "SetCertificate cert: [" + certificate[0] + "]" ); String[] accessKey = request.getParameterValues("AWSAccessKeyId"); if (null == accessKey || 0 == accessKey.length) { @@ -574,7 +574,7 @@ public class EC2RestServlet extends HttpServlet { certStore.store(fsOut, keystorePassword.toCharArray()); // -> dis-associate the cert's uniqueId with the Cloud API keys - /* UserCredentialsDao credentialDao = new UserCredentialsDao(); + /* UserCredentialsDao credentialDao = new UserCredentialsDao(); credentialDao.setCertificateId( accessKey[0], null ); */txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB); diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index 1b6d73917ae..589c48b78a4 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -749,7 +749,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { /** * ec2-run-instances - * + * * @param runInstances * * @see RunInstances @@ -885,7 +885,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { /** * @param modifyInstanceAttribute - * @return + * @return */ public static ModifyInstanceAttributeResponse toModifyInstanceAttributeResponse(Boolean status) { ModifyInstanceAttributeResponse miat = new ModifyInstanceAttributeResponse(); @@ -1453,7 +1453,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { Calendar cal = inst.getCreated(); if (null == cal) { cal = Calendar.getInstance(); -// cal.set( 1970, 1, 1 ); +// cal.set( 1970, 1, 1 ); } param7.setLaunchTime(cal); @@ -1924,7 +1924,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { Calendar cal = EC2RestAuth.parseDateString(engineResponse.getCreated()); if (null == cal) { cal = Calendar.getInstance(); -// cal.set( 1970, 1, 1 ); +// cal.set( 1970, 1, 1 ); } param1.setCreateTime(cal); @@ -1974,7 +1974,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { param3.setStatus("error"); param3.setProgress("0%"); } -// param3.setStatus( snap.getState()); +// param3.setStatus( snap.getState()); String ownerId = snap.getDomainId() + ":" + snap.getAccountName(); diff --git a/awsapi/src/com/cloud/bridge/service/S3RestServlet.java b/awsapi/src/com/cloud/bridge/service/S3RestServlet.java index 9102310929a..d5898678be1 100644 --- a/awsapi/src/com/cloud/bridge/service/S3RestServlet.java +++ b/awsapi/src/com/cloud/bridge/service/S3RestServlet.java @@ -392,7 +392,7 @@ public class S3RestServlet extends HttpServlet { return new S3BucketAction(); // for ListAllMyBuckets } - // Because there is a leading / at position 0 of pathInfo, now subtract this to process the remainder + // Because there is a leading / at position 0 of pathInfo, now subtract this to process the remainder pathInfo = pathInfo.substring(1); if (ServiceProvider.getInstance().getUseSubDomain()) diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java b/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java index 8a247bf52fd..d0ff1100fa9 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java @@ -893,7 +893,7 @@ public class S3BucketAction implements ServletAction { public void executePutBucketWebsite(HttpServletRequest request, HttpServletResponse response) throws IOException { // TODO -- LoPri - Undertake checks on Put Bucket Website // Tested using configuration \nAllowOverride FileInfo AuthConfig Limit... in httpd.conf - // Need some way of using AllowOverride to allow use of .htaccess and then pushing .httaccess file to bucket subdirectory of mount point + // Need some way of using AllowOverride to allow use of .htaccess and then pushing .httaccess file to bucket subdirectory of mount point // Currently has noop effect in the sense that a running apachectl process sees the directory contents without further action response.setStatus(200); } diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java b/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java index aa7f366d220..8bd28ffa4c6 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java @@ -599,7 +599,7 @@ public class S3ObjectAction implements ServletAction { //System.out.println( oneLine.length() + " body data: " + oneLine ); temp.append(oneLine); } -// else System.out.println( oneLine.length() + " preamble: " + oneLine ); +// else System.out.println( oneLine.length() + " preamble: " + oneLine ); } // [B] Authenticate the POST request after we have all the headers diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java b/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java index 74a4dd7159e..d103d6cab69 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java @@ -81,7 +81,7 @@ public class ServiceProvider extends ManagerBase { private final Timer timer = new Timer(); private MHostVO mhost; private Properties properties; - private boolean useSubDomain = false; // use DNS sub domain for bucket name + private boolean useSubDomain = false; // use DNS sub domain for bucket name private String serviceEndpoint = null; private String multipartDir = null; // illegal bucket name used as a folder for storing multiparts private String masterDomain = ".s3.amazonaws.com"; diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index 25aec1b1d5c..843fdb274cc 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -861,7 +861,7 @@ public class EC2Engine extends ManagerBase { CloudStackZone zone = findZone(); //CloudStackNetwork net = findNetwork(zone); -// CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb"); +// CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb"); CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), caller.getName(), caller.getDomainId(), null); ec2Address.setAssociatedInstanceId(resp.getId()); @@ -1213,12 +1213,12 @@ public class EC2Engine extends ManagerBase { throw new EC2ServiceException(ServerError.InternalError, "No Customize Disk Offering Found"); } -// // -> no volume name is given in the Amazon request but is required in the cloud API +// // -> no volume name is given in the Amazon request but is required in the cloud API CloudStackVolume vol = getApi().createVolume(UUID.randomUUID().toString(), null, diskOfferingId, null, size, snapshotId, toZoneId(request.getZoneName(), null)); if (vol != null) { resp.setAttached(vol.getAttached()); resp.setCreated(vol.getCreated()); -// resp.setDevice(); +// resp.setDevice(); resp.setDeviceId(vol.getDeviceId()); resp.setHypervisor(vol.getHypervisor()); resp.setId(vol.getId()); diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstances.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstances.java index 796b446d98a..e7be61aca36 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstances.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstances.java @@ -29,7 +29,7 @@ public class EC2RunInstances { private String keyName; private int maxCount; private int minCount; - private Integer size; // <- in gigs + private Integer size; // <- in gigs private List groupIdSet; private List groupNameSet; diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java index dea7eb22e81..26b2003ac92 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java @@ -50,7 +50,7 @@ public class EC2VolumeFilterSet { filterTypes.put("tag-key", "string"); filterTypes.put("tag-value", "string"); filterTypes.put("volume-id", "string"); - // filterTypes.put( "tag:*", "null" ); + // filterTypes.put( "tag:*", "null" ); } public void addFilter(EC2Filter param) { diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java index deff55728f4..54b0c11ac6c 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java @@ -120,7 +120,7 @@ public class S3Engine { static SAclDao s_saclDao; static BucketPolicyDao s_bPolicy; - private final int LOCK_ACQUIRING_TIMEOUT_SECONDS = 10; // ten seconds + private final int LOCK_ACQUIRING_TIMEOUT_SECONDS = 10; // ten seconds private final Map bucketAdapters = new HashMap(); @@ -775,7 +775,7 @@ public class S3Engine { if (bucket == null) throw new NoSuchObjectException("Bucket " + bucketName + " does not exist"); - // Is the caller allowed to write the object? + // Is the caller allowed to write the object? // The allocObjectItem checks for the bucket policy PutObject permissions OrderedPair object_objectitem_pair = allocObjectItem(bucket, key, meta, acl, null); OrderedPair host_storagelocation_pair = getBucketStorageHost(bucket); @@ -1028,7 +1028,7 @@ public class S3Engine { return response; } - // [D] Return the contents of the object inline + // [D] Return the contents of the object inline // -> extract the meta data that corresponds the specific versioned item List itemMetaData = metaDao.getByTarget("SObjectItem", item.getId()); @@ -1137,7 +1137,7 @@ public class S3Engine { response.setResultDescription("" + wantVersion + ""); } } - } else { // If versioning is off then we do delete the null object + } else { // If versioning is off then we do delete the null object S3PolicyContext context = new S3PolicyContext(PolicyActions.DeleteObject, bucketName); context.setKeyName(nameKey); verifyAccess(context, "SBucket", sbucket.getId(), SAcl.PERMISSION_WRITE); @@ -1540,7 +1540,7 @@ public class S3Engine { * Note that canned policies can be set when the object's contents are set */ public void setCannedAccessControls(String cannedAccessPolicy, String target, long objectId, SBucketVO bucket) { - // Find the permission and symbol for the principal corresponding to the requested cannedAccessPolicy + // Find the permission and symbol for the principal corresponding to the requested cannedAccessPolicy Triple permission_permission_symbol_triple = SAclVO.getCannedAccessControls(cannedAccessPolicy, target, bucket.getOwnerCanonicalId()); if (null == permission_permission_symbol_triple.getThird()) setSingleAcl(target, objectId, permission_permission_symbol_triple.getFirst()); @@ -1672,7 +1672,7 @@ public class S3Engine { if (hasPermission(s_saclDao.listGrants(target, targetId, "*"), requestedPermission)) return; } - // No privileges implies that no access is allowed in the case of an anonymous user + // No privileges implies that no access is allowed in the case of an anonymous user throw new PermissionDeniedException("Access Denied - ACLs do not give user the required permission"); } diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java index 6a8364c0ec3..0d29b426ce2 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java @@ -31,8 +31,8 @@ import com.cloud.bridge.service.exception.UnsupportedException; * canonicalUserID */ public class S3Grant { - private int grantee; // SAcl.GRANTEE_USER etc - private int permission; // SAcl.PERMISSION_READ etc + private int grantee; // SAcl.GRANTEE_USER etc + private int permission; // SAcl.PERMISSION_READ etc private String canonicalUserID; public S3Grant() { diff --git a/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java b/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java index fe7e2cd75df..19e91602218 100644 --- a/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java +++ b/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java @@ -68,7 +68,7 @@ public class EC2RestAuth { } catch (Exception e) { } - // -> the time zone is GMT if not defined + // -> the time zone is GMT if not defined try { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); cal.setTime(formatter.parse(created)); diff --git a/awsapi/src/com/cloud/bridge/util/JsonAccessor.java b/awsapi/src/com/cloud/bridge/util/JsonAccessor.java index c9ceec68102..281dc803eeb 100644 --- a/awsapi/src/com/cloud/bridge/util/JsonAccessor.java +++ b/awsapi/src/com/cloud/bridge/util/JsonAccessor.java @@ -32,8 +32,8 @@ import com.google.gson.JsonPrimitive; * JsonAccessor provides the functionality to allow navigating JSON object graph using simple expressions, * for example, following property access expressions are all valid ones * - * rootobj.level1obj[1].property - * this[0].level1obj[1].property + * rootobj.level1obj[1].property + * this[0].level1obj[1].property * */ public class JsonAccessor { @@ -132,9 +132,9 @@ public class JsonAccessor { /* * Return - * -1 : property expression can not be resolved - * 0 : match to a null JSON object - * 1+ : matched, for array element, the count of the elements inside the array + * -1 : property expression can not be resolved + * 0 : match to a null JSON object + * 1+ : matched, for array element, the count of the elements inside the array */ public int getMatchCount(String propPath) { JsonElement jsonElement = tryEval(propPath); diff --git a/awsapi/src/com/cloud/stack/CloudStackClient.java b/awsapi/src/com/cloud/stack/CloudStackClient.java index 2c072a17433..8ffc9e9edcc 100644 --- a/awsapi/src/com/cloud/stack/CloudStackClient.java +++ b/awsapi/src/com/cloud/stack/CloudStackClient.java @@ -42,8 +42,8 @@ public class CloudStackClient { private String _serviceUrl; - private long _pollIntervalMs = 2000; // 1 second polling interval - private long _pollTimeoutMs = 600000; // 10 minutes polling timeout + private long _pollIntervalMs = 2000; // 1 second polling interval + private long _pollTimeoutMs = 600000; // 10 minutes polling timeout public CloudStackClient(String serviceRootUrl) { assert (serviceRootUrl != null); diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 18f58aed364..ab8bcc2c3cd 100755 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -1014,54 +1014,54 @@ public class VirtualRoutingResource implements Manager { } // protected Answer execute(final SetFirewallRuleCommand cmd) { - // String args; - // if(cmd.getProtocol().toLowerCase().equals(NetUtils.NAT_PROTO)){ - // //1:1 NAT needs instanceip;publicip;domrip;op - // if(cmd.isCreate()) { + // String args; + // if(cmd.getProtocol().toLowerCase().equals(NetUtils.NAT_PROTO)){ + // //1:1 NAT needs instanceip;publicip;domrip;op + // if(cmd.isCreate()) { // args = "-A"; // } else { // args = "-D"; // } // - // args += " -l " + cmd.getPublicIpAddress(); - // args += " -i " + cmd.getRouterIpAddress(); - // args += " -r " + cmd.getPrivateIpAddress(); - // args += " -G " + cmd.getProtocol(); - // }else{ - // if (cmd.isEnable()) { - // args = "-A"; - // } else { - // args = "-D"; - // } + // args += " -l " + cmd.getPublicIpAddress(); + // args += " -i " + cmd.getRouterIpAddress(); + // args += " -r " + cmd.getPrivateIpAddress(); + // args += " -G " + cmd.getProtocol(); + // }else{ + // if (cmd.isEnable()) { + // args = "-A"; + // } else { + // args = "-D"; + // } // - // args += " -P " + cmd.getProtocol().toLowerCase(); - // args += " -l " + cmd.getPublicIpAddress(); - // args += " -p " + cmd.getPublicPort(); - // args += " -n " + cmd.getRouterName(); - // args += " -i " + cmd.getRouterIpAddress(); - // args += " -r " + cmd.getPrivateIpAddress(); - // args += " -d " + cmd.getPrivatePort(); - // args += " -N " + cmd.getVlanNetmask(); + // args += " -P " + cmd.getProtocol().toLowerCase(); + // args += " -l " + cmd.getPublicIpAddress(); + // args += " -p " + cmd.getPublicPort(); + // args += " -n " + cmd.getRouterName(); + // args += " -i " + cmd.getRouterIpAddress(); + // args += " -r " + cmd.getPrivateIpAddress(); + // args += " -d " + cmd.getPrivatePort(); + // args += " -N " + cmd.getVlanNetmask(); // - // String oldPrivateIP = cmd.getOldPrivateIP(); - // String oldPrivatePort = cmd.getOldPrivatePort(); + // String oldPrivateIP = cmd.getOldPrivateIP(); + // String oldPrivatePort = cmd.getOldPrivatePort(); // - // if (oldPrivateIP != null) { - // args += " -w " + oldPrivateIP; - // } + // if (oldPrivateIP != null) { + // args += " -w " + oldPrivateIP; + // } // - // if (oldPrivatePort != null) { - // args += " -x " + oldPrivatePort; - // } - // } + // if (oldPrivatePort != null) { + // args += " -x " + oldPrivatePort; + // } + // } // - // final Script command = new Script(_firewallPath, _timeout, s_logger); - // String [] argsArray = args.split(" "); - // for (String param : argsArray) { - // command.add(param); - // } - // String result = command.execute(); - // return new Answer(cmd, result == null, result); + // final Script command = new Script(_firewallPath, _timeout, s_logger); + // String [] argsArray = args.split(" "); + // for (String param : argsArray) { + // command.add(param); + // } + // String result = command.execute(); + // return new Answer(cmd, result == null, result); // } protected String getDefaultScriptsDir() { diff --git a/core/src/com/cloud/resource/ServerResourceBase.java b/core/src/com/cloud/resource/ServerResourceBase.java index 8d9a83aa87d..358ca905a7a 100755 --- a/core/src/com/cloud/resource/ServerResourceBase.java +++ b/core/src/com/cloud/resource/ServerResourceBase.java @@ -108,7 +108,7 @@ public abstract class ServerResourceBase implements ServerResource { } } // } catch (final SocketException e) { - // s_logger.warn("Error looking at " + nicName, e); + // s_logger.warn("Error looking at " + nicName, e); // } s_logger.debug("Skipping nic " + nicName); } diff --git a/core/src/com/cloud/serializer/SerializerHelper.java b/core/src/com/cloud/serializer/SerializerHelper.java index 04551f3f06c..42fbf07ab5c 100644 --- a/core/src/com/cloud/serializer/SerializerHelper.java +++ b/core/src/com/cloud/serializer/SerializerHelper.java @@ -130,7 +130,7 @@ public class SerializerHelper { } } //else - // l.add(new Pair(paramName, "")); + // l.add(new Pair(paramName, "")); } catch (IllegalArgumentException e) { s_logger.error("Illegal argument exception when calling POJO " + o.getClass().getName() + " get method for property: " + propName); diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java index 22f64d34fd3..20ed00118b1 100644 --- a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java +++ b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java @@ -271,7 +271,7 @@ public class Connection public XmlRpcClientConfigImpl getConfig() { - return config; + return config; } private XmlRpcClient getClientFromURL(URL url) { diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java b/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java index e2ee9d6ed9e..7a9f6d76123 100644 --- a/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java +++ b/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java @@ -29,8 +29,8 @@ public final class Marshalling { o instanceof Double || o instanceof Date) { return o; - } else if (o instanceof Long) { - return o.toString(); + } else if (o instanceof Long) { + return o.toString(); } else if (o instanceof Map) { Map result = new HashMap(); Map m = (Map)o; @@ -46,14 +46,14 @@ public final class Marshalling { result.add(toXMLRPC(e)); } return result; - } else if (o instanceof XenAPIObject) { - return ((XenAPIObject) o).toWireString(); - } else if (o instanceof Enum) { - return o.toString(); - }else if (o == null){ - return ""; + } else if (o instanceof XenAPIObject) { + return ((XenAPIObject) o).toWireString(); + } else if (o instanceof Enum) { + return o.toString(); + }else if (o == null){ + return ""; } else { - throw new RuntimeException ("=============don't know how to marshall:({[" + o + "]})"); + throw new RuntimeException ("=============don't know how to marshall:({[" + o + "]})"); } } } diff --git a/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java b/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java index 700e3299604..a9fbec1eda6 100644 --- a/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java +++ b/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java @@ -14,5 +14,5 @@ package com.xensource.xenapi; public abstract class XenAPIObject { - public abstract String toWireString(); + public abstract String toWireString(); } diff --git a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java index 7ff9761e431..ece907d75ed 100755 --- a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java +++ b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java @@ -119,8 +119,8 @@ public interface ConfigurationManager { // * @return newly created disk offering // */ // DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, -// boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops, -// Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate); +// boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops, +// Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate); /** * Creates a new pod diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java index 64ec21b858c..910dea440e4 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostVO.java @@ -142,7 +142,7 @@ public class EngineHostVO implements EngineHost, Identity { private String hypervisorVersion; @Column(name = "update_count", updatable = true, nullable = false) - protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code. + protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code. @Column(name = "uuid") private String uuid; diff --git a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java index d599aff214d..a44b8784d7d 100755 --- a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java +++ b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java @@ -146,13 +146,13 @@ public class CapacityDaoImpl extends GenericDaoBase implements * * */ private static final String LIST_CLUSTERS_CROSSING_THRESHOLD = "SELECT clusterList.cluster_id " - + "FROM ( SELECT cluster.cluster_id cluster_id, ( (sum(cluster.used) + sum(cluster.reserved) + ?)/sum(cluster.total) ) ratio, cluster.configValue value " - + "FROM ( SELECT capacity.cluster_id cluster_id, capacity.used_capacity used, capacity.reserved_capacity reserved, capacity.total_capacity * overcommit.value total, " + + "FROM ( SELECT cluster.cluster_id cluster_id, ( (sum(cluster.used) + sum(cluster.reserved) + ?)/sum(cluster.total) ) ratio, cluster.configValue value " + + "FROM ( SELECT capacity.cluster_id cluster_id, capacity.used_capacity used, capacity.reserved_capacity reserved, capacity.total_capacity * overcommit.value total, " + "CASE (SELECT count(*) FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ? ) " - + "WHEN 1 THEN ( CASE WHEN (SELECT details.value FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ?) is NULL " + + "WHEN 1 THEN ( CASE WHEN (SELECT details.value FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ?) is NULL " + "THEN (SELECT config.value FROM `cloud`.`configuration` config WHERE config.name = ?)" + "ELSE (SELECT details.value FROM `cloud`.`cluster_details` details WHERE details.cluster_id = capacity.cluster_id AND details.name = ? ) END )" - + "ELSE ( SELECT config.value FROM `cloud`.`configuration` config WHERE config.name = ?) " + + "ELSE ( SELECT config.value FROM `cloud`.`configuration` config WHERE config.name = ?) " + "END configValue " + "FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster_details` overcommit ON overcommit.cluster_id = capacity.cluster_id " + "WHERE capacity.data_center_id = ? AND capacity.capacity_type = ? AND capacity.total_capacity > 0 AND overcommit.name = ?) cluster " diff --git a/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java index f32cb3aa022..0bd8d3a1d2c 100755 --- a/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java +++ b/engine/schema/src/com/cloud/dc/dao/VlanDaoImpl.java @@ -287,11 +287,11 @@ public class VlanDaoImpl extends GenericDaoBase implements VlanDao } return null; -// String ipAddress = _ipAddressDao.assignIpAddress(accountId, domainId, vlan.getId(), false).getAddress(); -// if (ipAddress == null) { -// return null; -// } -// return new Pair(ipAddress, vlan); +// String ipAddress = _ipAddressDao.assignIpAddress(accountId, domainId, vlan.getId(), false).getAddress(); +// if (ipAddress == null) { +// return null; +// } +// return new Pair(ipAddress, vlan); } diff --git a/engine/schema/src/com/cloud/host/HostVO.java b/engine/schema/src/com/cloud/host/HostVO.java index 7e069fe2067..07b87a8fa9f 100755 --- a/engine/schema/src/com/cloud/host/HostVO.java +++ b/engine/schema/src/com/cloud/host/HostVO.java @@ -138,7 +138,7 @@ public class HostVO implements Host { private String hypervisorVersion; @Column(name = "update_count", updatable = true, nullable = false) - protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code. + protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code. @Column(name = "uuid") private String uuid; diff --git a/engine/schema/src/com/cloud/network/dao/PortProfileDao.java b/engine/schema/src/com/cloud/network/dao/PortProfileDao.java index 240e96f5b77..1aa966641eb 100644 --- a/engine/schema/src/com/cloud/network/dao/PortProfileDao.java +++ b/engine/schema/src/com/cloud/network/dao/PortProfileDao.java @@ -44,7 +44,7 @@ public interface PortProfileDao extends GenericDao { * List listByVlanId(int vlanId); * * List all uplink portprofiles (these represent physical ports). - * List listAllUplinkPortProfiles(); // we may have to provide some filter, like clusterId or zoneId or something. + * List listAllUplinkPortProfiles(); // we may have to provide some filter, like clusterId or zoneId or something. * */ } \ No newline at end of file diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java index ca163320fef..7cce74ea317 100644 --- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java +++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java @@ -118,7 +118,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject im // // query SQL for returnning console proxy assignment info as following - // proxy vm id, count of assignment + // proxy vm id, count of assignment // private static final String PROXY_ASSIGNMENT_MATRIX = "SELECT c.id, count(runningVm.id) AS count " + " FROM console_proxy AS c LEFT JOIN vm_instance AS i ON c.id=i.id LEFT JOIN" diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java index 399ec21795e..716cc90f304 100644 --- a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java +++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java @@ -117,7 +117,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject components = ComponentContext.getApplicationContext().getBeansOfType(DbAnnotatedBase.class); - for(Map.Entry entry : components.entrySet()) { - System.out.println(entry.getKey()); - entry.getValue().MethodWithClassDbAnnotated(); - } + /* + Map components = ComponentContext.getApplicationContext().getBeansOfType(DbAnnotatedBase.class); + for(Map.Entry entry : components.entrySet()) { + System.out.println(entry.getKey()); + entry.getValue().MethodWithClassDbAnnotated(); + } */ for (DbAnnotatedBase entry : _list) { entry.MethodWithClassDbAnnotated(); diff --git a/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java b/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java index 36cfcd60c4b..b0af593ee67 100644 --- a/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java +++ b/framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallFuture.java @@ -26,7 +26,7 @@ public class AsyncCallFuture implements Future, AsyncCompletionCallback Object _completed = new Object(); boolean _done = false; - T _resultObject; // we will store a copy of the result object + T _resultObject; // we will store a copy of the result object public AsyncCallFuture() { } diff --git a/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcProviderImpl.java b/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcProviderImpl.java index f476054d769..cc0b8f5987e 100644 --- a/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcProviderImpl.java +++ b/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcProviderImpl.java @@ -35,7 +35,7 @@ public class RpcProviderImpl implements RpcProvider { private TransportProvider _transportProvider; private String _transportAddress; - private RpcTransportEndpoint _transportEndpoint = new RpcTransportEndpoint(); // transport attachment at RPC layer + private RpcTransportEndpoint _transportEndpoint = new RpcTransportEndpoint(); // transport attachment at RPC layer private MessageSerializer _messageSerializer; private List _serviceEndpoints = new ArrayList(); diff --git a/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServiceEndpoint.java b/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServiceEndpoint.java index 83d8d631ca2..2b11900ea5c 100644 --- a/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServiceEndpoint.java +++ b/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServiceEndpoint.java @@ -21,10 +21,10 @@ package org.apache.cloudstack.framework.rpc; public interface RpcServiceEndpoint { /* * @return - * true call has been handled - * false can not find the call handler + * true call has been handled + * false can not find the call handler * @throws - * RpcException, exception when + * RpcException, exception when */ boolean onCallReceive(RpcServerCall call); } diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java index 883fa507ecb..e94152959f0 100644 --- a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java +++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java @@ -26,13 +26,13 @@ public class AsyncSampleListenerStyleCaller { public void MethodThatWillCallAsyncMethod() { String vol = new String(); - /* _ds.createVolume(vol, - new AsyncCompletionCallback() { - @Override - public void complete(String resultObject) { - // TODO Auto-generated method stub - - } - });*/ + /* _ds.createVolume(vol, + new AsyncCompletionCallback() { + @Override + public void complete(String resultObject) { + // TODO Auto-generated method stub + + } + });*/ } } diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java index 1cea7932d80..9d6ab174940 100644 --- a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java +++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java @@ -32,7 +32,7 @@ public class ClientOnlyEventDrivenStyle { String cmd = new String(); RpcCallbackDispatcher callbackDispatcher = RpcCallbackDispatcher.create(this); callbackDispatcher.setCallback(callbackDispatcher.getTarget().OnAsyncCallRpcServiceCallback(null, null)); - _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000).setCallbackDispatcher(callbackDispatcher).setContext("Context Object") // save context object for callback handler + _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000).setCallbackDispatcher(callbackDispatcher).setContext("Context Object") // save context object for callback handler .apply(); } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java index 042243a11ae..9ec4b5d5c81 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java @@ -20,8 +20,8 @@ import com.cloud.utils.component.Adapter; // // We extend it from Adapter interface for -// 1) getName()/setName() -// 2) Confirming to general adapter pattern used across CloudStack +// 1) getName()/setName() +// 2) Confirming to general adapter pattern used across CloudStack // public interface AsyncJobDispatcher extends Adapter { void runJob(AsyncJob job); diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java index 980d2744bc2..a4ac3d06dab 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java @@ -75,7 +75,7 @@ public interface AsyncJobManager extends Manager { * * @param jobId upper job that is going to wait the completion of a down-level job * @param joinJobId down-level job - * @Param wakeupHandler wake-up handler + * @Param wakeupHandler wake-up handler * @Param wakeupDispatcher wake-up dispatcher * @param wakeupTopicsOnMessageBus * @param wakeupIntervalInMilliSeconds @@ -97,11 +97,11 @@ public interface AsyncJobManager extends Manager { * * @param joinJobId down-level job for upper level job to join with * @param joinStatus AsyncJobConstants status code to indicate success or failure of the - * down-level job + * down-level job * @param joinResult object-stream serialized result object - * this is primarily used by down-level job to pass error exception objects - * for legacy code to work. To help pass exception object easier, we use - * object-stream based serialization instead of GSON + * this is primarily used by down-level job to pass error exception objects + * for legacy code to work. To help pass exception object easier, we use + * object-stream based serialization instead of GSON */ void completeJoin(long joinJobId, JobInfo.Status joinStatus, String joinResult); @@ -118,7 +118,7 @@ public interface AsyncJobManager extends Manager { * @param timeoutInMiliseconds time out to break out the whole wait process * @param predicate * @return true, predicate condition is satisfied - * false, wait is timed out + * false, wait is timed out */ boolean waitAndCheck(AsyncJob job, String[] wakupTopicsOnMessageBus, long checkIntervalInMilliSeconds, long timeoutInMiliseconds, Predicate predicate); diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDao.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDao.java index 9dd574741c2..044bffa899d 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDao.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDao.java @@ -38,10 +38,10 @@ public interface AsyncJobJoinMapDao extends GenericDao void completeJoin(long joinJobId, JobInfo.Status joinStatus, String joinResult, long completeMsid); -// List wakeupScan(); +// List wakeupScan(); List findJobsToWake(long joinedJobId); List findJobsToWakeBetween(Date cutDate); -// List wakeupByJoinedJobCompletion(long joinedJobId); +// List wakeupByJoinedJobCompletion(long joinedJobId); } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java index eeaee015ad2..f27c49ce295 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobJoinMapDaoImpl.java @@ -82,7 +82,7 @@ public class AsyncJobJoinMapDaoImpl extends GenericDaoBase wakeupScan() { -// List standaloneList = new ArrayList(); +// List standaloneList = new ArrayList(); // -// Date cutDate = DateUtil.currentGMTTime(); +// Date cutDate = DateUtil.currentGMTTime(); // -// TransactionLegacy txn = TransactionLegacy.currentTxn(); +// TransactionLegacy txn = TransactionLegacy.currentTxn(); // PreparedStatement pstmt = null; // try { -// txn.start(); +// txn.start(); // -// // -// // performance sensitive processing, do it in plain SQL -// // -// String sql = "UPDATE async_job SET job_pending_signals=? WHERE id IN " + -// "(SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ?)"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setInt(1, AsyncJob.Constants.SIGNAL_MASK_WAKEUP); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(3, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.executeUpdate(); -// pstmt.close(); +// // +// // performance sensitive processing, do it in plain SQL +// // +// String sql = "UPDATE async_job SET job_pending_signals=? WHERE id IN " + +// "(SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ?)"; +// pstmt = txn.prepareStatement(sql); +// pstmt.setInt(1, AsyncJob.Constants.SIGNAL_MASK_WAKEUP); +// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.setString(3, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.executeUpdate(); +// pstmt.close(); // -// sql = "UPDATE sync_queue_item SET queue_proc_msid=NULL, queue_proc_number=NULL WHERE content_id IN " + -// "(SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ?)"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.executeUpdate(); -// pstmt.close(); +// sql = "UPDATE sync_queue_item SET queue_proc_msid=NULL, queue_proc_number=NULL WHERE content_id IN " + +// "(SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ?)"; +// pstmt = txn.prepareStatement(sql); +// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.executeUpdate(); +// pstmt.close(); // -// sql = "SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ? AND job_id NOT IN (SELECT content_id FROM sync_queue_item)"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// ResultSet rs = pstmt.executeQuery(); -// while(rs.next()) { -// standaloneList.add(rs.getLong(1)); -// } -// rs.close(); -// pstmt.close(); +// sql = "SELECT job_id FROM async_job_join_map WHERE next_wakeup < ? AND expiration > ? AND job_id NOT IN (SELECT content_id FROM sync_queue_item)"; +// pstmt = txn.prepareStatement(sql); +// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// ResultSet rs = pstmt.executeQuery(); +// while(rs.next()) { +// standaloneList.add(rs.getLong(1)); +// } +// rs.close(); +// pstmt.close(); // -// // update for next wake-up -// sql = "UPDATE async_job_join_map SET next_wakeup=DATE_ADD(next_wakeup, INTERVAL wakeup_interval SECOND) WHERE next_wakeup < ? AND expiration > ?"; -// pstmt = txn.prepareStatement(sql); -// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); -// pstmt.executeUpdate(); -// pstmt.close(); +// // update for next wake-up +// sql = "UPDATE async_job_join_map SET next_wakeup=DATE_ADD(next_wakeup, INTERVAL wakeup_interval SECOND) WHERE next_wakeup < ? AND expiration > ?"; +// pstmt = txn.prepareStatement(sql); +// pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.setString(2, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); +// pstmt.executeUpdate(); +// pstmt.close(); // -// txn.commit(); -// } catch (SQLException e) { -// s_logger.error("Unexpected exception", e); -// } +// txn.commit(); +// } catch (SQLException e) { +// s_logger.error("Unexpected exception", e); +// } // // return standaloneList; -// } +// } @Override public List findJobsToWake(long joinedJobId) { diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java index fc7578ddd27..02411933441 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java @@ -86,12 +86,12 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, private static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class); - private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds - private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC = 60; // 60 seconds + private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds + private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC = 60; // 60 seconds private static final int MAX_ONETIME_SCHEDULE_SIZE = 50; private static final int HEARTBEAT_INTERVAL = 2000; - private static final int GC_INTERVAL = 10000; // 10 seconds + private static final int GC_INTERVAL = 10000; // 10 seconds @Inject private SyncQueueItemDao _queueItemDao; @@ -357,38 +357,38 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, // I removed the temporary solution already. I think my changes should fix the deadlock. /* - ------------------------ - LATEST DETECTED DEADLOCK - ------------------------ - 130625 20:03:10 - *** (1) TRANSACTION: - TRANSACTION 0 98087127, ACTIVE 0 sec, process no 1489, OS thread id 139837829175040 fetching rows, thread declared inside InnoDB 494 - mysql tables in use 2, locked 1 - LOCK WAIT 3 lock struct(s), heap size 368, 2 row lock(s), undo log entries 1 - MySQL thread id 28408, query id 368571321 localhost 127.0.0.1 cloud preparing - UPDATE async_job SET job_pending_signals=1 WHERE id IN (SELECT job_id FROM async_job_join_map WHERE join_job_id = 9) - *** (1) WAITING FOR THIS LOCK TO BE GRANTED: - RECORD LOCKS space id 0 page no 1275 n bits 80 index `PRIMARY` of table `cloud`.`async_job` trx id 0 98087127 lock_mode X locks rec but not gap waiting - Record lock, heap no 9 PHYSICAL RECORD: n_fields 26; compact format; info bits 0 - 0: len 8; hex 0000000000000008; asc ;; 1: len 6; hex 000005d8b0d8; asc ;; 2: len 7; hex 00000009270110; asc ' ;; 3: len 8; hex 0000000000000002; asc ;; 4: len 8; hex 0000000000000002; asc ;; 5: SQL NULL; 6: SQL NULL; 7: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e636f6d6d; asc org.apache.cloudstack.api.comm;...(truncated); 8: len 30; hex 7b226964223a2232222c22706879736963616c6e6574776f726b6964223a; asc {"id":"2","physicalnetworkid":;...(truncated); 9: len 4; hex 80000000; asc ;; 10: len 4; hex 80000001; asc ;; 11: len 4; hex 80000000; asc ;; 12: len 4; hex 80000000; asc ;; 13: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e72657370; asc org.apache.cloudstack.api.resp;...(truncated); 14: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 15: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 16: len 8; hex 8000124f06cfd5b6; asc O ;; 17: len 8; hex 8000124f06cfd5b6; asc O ;; 18: SQL NULL; 19: SQL NULL; 20: len 30; hex 66376466396532362d323139622d346338652d393231332d393766653636; asc f7df9e26-219b-4c8e-9213-97fe66;...(truncated); 21: len 30; hex 36623238306364362d663436652d343563322d383833642d333863616439; asc 6b280cd6-f46e-45c2-883d-38cad9;...(truncated); 22: SQL NULL; 23: len 21; hex 4170694173796e634a6f6244697370617463686572; asc ApiAsyncJobDispatcher;; 24: SQL NULL; 25: len 4; hex 80000000; asc ;; + ------------------------ + LATEST DETECTED DEADLOCK + ------------------------ + 130625 20:03:10 + *** (1) TRANSACTION: + TRANSACTION 0 98087127, ACTIVE 0 sec, process no 1489, OS thread id 139837829175040 fetching rows, thread declared inside InnoDB 494 + mysql tables in use 2, locked 1 + LOCK WAIT 3 lock struct(s), heap size 368, 2 row lock(s), undo log entries 1 + MySQL thread id 28408, query id 368571321 localhost 127.0.0.1 cloud preparing + UPDATE async_job SET job_pending_signals=1 WHERE id IN (SELECT job_id FROM async_job_join_map WHERE join_job_id = 9) + *** (1) WAITING FOR THIS LOCK TO BE GRANTED: + RECORD LOCKS space id 0 page no 1275 n bits 80 index `PRIMARY` of table `cloud`.`async_job` trx id 0 98087127 lock_mode X locks rec but not gap waiting + Record lock, heap no 9 PHYSICAL RECORD: n_fields 26; compact format; info bits 0 + 0: len 8; hex 0000000000000008; asc ;; 1: len 6; hex 000005d8b0d8; asc ;; 2: len 7; hex 00000009270110; asc ' ;; 3: len 8; hex 0000000000000002; asc ;; 4: len 8; hex 0000000000000002; asc ;; 5: SQL NULL; 6: SQL NULL; 7: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e636f6d6d; asc org.apache.cloudstack.api.comm;...(truncated); 8: len 30; hex 7b226964223a2232222c22706879736963616c6e6574776f726b6964223a; asc {"id":"2","physicalnetworkid":;...(truncated); 9: len 4; hex 80000000; asc ;; 10: len 4; hex 80000001; asc ;; 11: len 4; hex 80000000; asc ;; 12: len 4; hex 80000000; asc ;; 13: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e72657370; asc org.apache.cloudstack.api.resp;...(truncated); 14: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 15: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 16: len 8; hex 8000124f06cfd5b6; asc O ;; 17: len 8; hex 8000124f06cfd5b6; asc O ;; 18: SQL NULL; 19: SQL NULL; 20: len 30; hex 66376466396532362d323139622d346338652d393231332d393766653636; asc f7df9e26-219b-4c8e-9213-97fe66;...(truncated); 21: len 30; hex 36623238306364362d663436652d343563322d383833642d333863616439; asc 6b280cd6-f46e-45c2-883d-38cad9;...(truncated); 22: SQL NULL; 23: len 21; hex 4170694173796e634a6f6244697370617463686572; asc ApiAsyncJobDispatcher;; 24: SQL NULL; 25: len 4; hex 80000000; asc ;; - *** (2) TRANSACTION: - TRANSACTION 0 98087128, ACTIVE 0 sec, process no 1489, OS thread id 139837671909120 fetching rows, thread declared inside InnoDB 492 - mysql tables in use 2, locked 1 - 3 lock struct(s), heap size 368, 2 row lock(s), undo log entries 1 - MySQL thread id 28406, query id 368571323 localhost 127.0.0.1 cloud preparing - UPDATE async_job SET job_pending_signals=1 WHERE id IN (SELECT job_id FROM async_job_join_map WHERE join_job_id = 8) - *** (2) HOLDS THE LOCK(S): - RECORD LOCKS space id 0 page no 1275 n bits 80 index `PRIMARY` of table `cloud`.`async_job` trx id 0 98087128 lock_mode X locks rec but not gap - Record lock, heap no 9 PHYSICAL RECORD: n_fields 26; compact format; info bits 0 - 0: len 8; hex 0000000000000008; asc ;; 1: len 6; hex 000005d8b0d8; asc ;; 2: len 7; hex 00000009270110; asc ' ;; 3: len 8; hex 0000000000000002; asc ;; 4: len 8; hex 0000000000000002; asc ;; 5: SQL NULL; 6: SQL NULL; 7: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e636f6d6d; asc org.apache.cloudstack.api.comm;...(truncated); 8: len 30; hex 7b226964223a2232222c22706879736963616c6e6574776f726b6964223a; asc {"id":"2","physicalnetworkid":;...(truncated); 9: len 4; hex 80000000; asc ;; 10: len 4; hex 80000001; asc ;; 11: len 4; hex 80000000; asc ;; 12: len 4; hex 80000000; asc ;; 13: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e72657370; asc org.apache.cloudstack.api.resp;...(truncated); 14: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 15: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 16: len 8; hex 8000124f06cfd5b6; asc O ;; 17: len 8; hex 8000124f06cfd5b6; asc O ;; 18: SQL NULL; 19: SQL NULL; 20: len 30; hex 66376466396532362d323139622d346338652d393231332d393766653636; asc f7df9e26-219b-4c8e-9213-97fe66;...(truncated); 21: len 30; hex 36623238306364362d663436652d343563322d383833642d333863616439; asc 6b280cd6-f46e-45c2-883d-38cad9;...(truncated); 22: SQL NULL; 23: len 21; hex 4170694173796e634a6f6244697370617463686572; asc ApiAsyncJobDispatcher;; 24: SQL NULL; 25: len 4; hex 80000000; asc ;; + *** (2) TRANSACTION: + TRANSACTION 0 98087128, ACTIVE 0 sec, process no 1489, OS thread id 139837671909120 fetching rows, thread declared inside InnoDB 492 + mysql tables in use 2, locked 1 + 3 lock struct(s), heap size 368, 2 row lock(s), undo log entries 1 + MySQL thread id 28406, query id 368571323 localhost 127.0.0.1 cloud preparing + UPDATE async_job SET job_pending_signals=1 WHERE id IN (SELECT job_id FROM async_job_join_map WHERE join_job_id = 8) + *** (2) HOLDS THE LOCK(S): + RECORD LOCKS space id 0 page no 1275 n bits 80 index `PRIMARY` of table `cloud`.`async_job` trx id 0 98087128 lock_mode X locks rec but not gap + Record lock, heap no 9 PHYSICAL RECORD: n_fields 26; compact format; info bits 0 + 0: len 8; hex 0000000000000008; asc ;; 1: len 6; hex 000005d8b0d8; asc ;; 2: len 7; hex 00000009270110; asc ' ;; 3: len 8; hex 0000000000000002; asc ;; 4: len 8; hex 0000000000000002; asc ;; 5: SQL NULL; 6: SQL NULL; 7: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e636f6d6d; asc org.apache.cloudstack.api.comm;...(truncated); 8: len 30; hex 7b226964223a2232222c22706879736963616c6e6574776f726b6964223a; asc {"id":"2","physicalnetworkid":;...(truncated); 9: len 4; hex 80000000; asc ;; 10: len 4; hex 80000001; asc ;; 11: len 4; hex 80000000; asc ;; 12: len 4; hex 80000000; asc ;; 13: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e72657370; asc org.apache.cloudstack.api.resp;...(truncated); 14: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 15: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 16: len 8; hex 8000124f06cfd5b6; asc O ;; 17: len 8; hex 8000124f06cfd5b6; asc O ;; 18: SQL NULL; 19: SQL NULL; 20: len 30; hex 66376466396532362d323139622d346338652d393231332d393766653636; asc f7df9e26-219b-4c8e-9213-97fe66;...(truncated); 21: len 30; hex 36623238306364362d663436652d343563322d383833642d333863616439; asc 6b280cd6-f46e-45c2-883d-38cad9;...(truncated); 22: SQL NULL; 23: len 21; hex 4170694173796e634a6f6244697370617463686572; asc ApiAsyncJobDispatcher;; 24: SQL NULL; 25: len 4; hex 80000000; asc ;; - *** (2) WAITING FOR THIS LOCK TO BE GRANTED: - RECORD LOCKS space id 0 page no 1275 n bits 80 index `PRIMARY` of table `cloud`.`async_job` trx id 0 98087128 lock_mode X locks rec but not gap waiting - Record lock, heap no 10 PHYSICAL RECORD: n_fields 26; compact format; info bits 0 - 0: len 8; hex 0000000000000009; asc ;; 1: len 6; hex 000005d8b0d7; asc ;; 2: len 7; hex 00000009280110; asc ( ;; 3: len 8; hex 0000000000000002; asc ;; 4: len 8; hex 0000000000000002; asc ;; 5: SQL NULL; 6: SQL NULL; 7: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e636f6d6d; asc org.apache.cloudstack.api.comm;...(truncated); 8: len 30; hex 7b226964223a2233222c22706879736963616c6e6574776f726b6964223a; asc {"id":"3","physicalnetworkid":;...(truncated); 9: len 4; hex 80000000; asc ;; 10: len 4; hex 80000001; asc ;; 11: len 4; hex 80000000; asc ;; 12: len 4; hex 80000000; asc ;; 13: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e72657370; asc org.apache.cloudstack.api.resp;...(truncated); 14: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 15: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 16: len 8; hex 8000124f06cfd5b6; asc O ;; 17: len 8; hex 8000124f06cfd5b6; asc O ;; 18: SQL NULL; 19: SQL NULL; 20: len 30; hex 62313065306432342d336233352d343663622d386361622d623933623562; asc b10e0d24-3b35-46cb-8cab-b93b5b;...(truncated); 21: len 30; hex 39353664383563632d383336622d346663612d623738622d646238343739; asc 956d85cc-836b-4fca-b78b-db8479;...(truncated); 22: SQL NULL; 23: len 21; hex 4170694173796e634a6f6244697370617463686572; asc ApiAsyncJobDispatcher;; 24: SQL NULL; 25: len 4; hex 80000000; asc ;; + *** (2) WAITING FOR THIS LOCK TO BE GRANTED: + RECORD LOCKS space id 0 page no 1275 n bits 80 index `PRIMARY` of table `cloud`.`async_job` trx id 0 98087128 lock_mode X locks rec but not gap waiting + Record lock, heap no 10 PHYSICAL RECORD: n_fields 26; compact format; info bits 0 + 0: len 8; hex 0000000000000009; asc ;; 1: len 6; hex 000005d8b0d7; asc ;; 2: len 7; hex 00000009280110; asc ( ;; 3: len 8; hex 0000000000000002; asc ;; 4: len 8; hex 0000000000000002; asc ;; 5: SQL NULL; 6: SQL NULL; 7: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e636f6d6d; asc org.apache.cloudstack.api.comm;...(truncated); 8: len 30; hex 7b226964223a2233222c22706879736963616c6e6574776f726b6964223a; asc {"id":"3","physicalnetworkid":;...(truncated); 9: len 4; hex 80000000; asc ;; 10: len 4; hex 80000001; asc ;; 11: len 4; hex 80000000; asc ;; 12: len 4; hex 80000000; asc ;; 13: len 30; hex 6f72672e6170616368652e636c6f7564737461636b2e6170692e72657370; asc org.apache.cloudstack.api.resp;...(truncated); 14: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 15: len 8; hex 80001a6f7bb0d0a8; asc o{ ;; 16: len 8; hex 8000124f06cfd5b6; asc O ;; 17: len 8; hex 8000124f06cfd5b6; asc O ;; 18: SQL NULL; 19: SQL NULL; 20: len 30; hex 62313065306432342d336233352d343663622d386361622d623933623562; asc b10e0d24-3b35-46cb-8cab-b93b5b;...(truncated); 21: len 30; hex 39353664383563632d383336622d346663612d623738622d646238343739; asc 956d85cc-836b-4fca-b78b-db8479;...(truncated); 22: SQL NULL; 23: len 21; hex 4170694173796e634a6f6244697370617463686572; asc ApiAsyncJobDispatcher;; 24: SQL NULL; 25: len 4; hex 80000000; asc ;; - *** WE ROLL BACK TRANSACTION (2) + *** WE ROLL BACK TRANSACTION (2) */ _joinMapDao.completeJoin(joinJobId, joinStatus, joinResult, getMsid()); diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java index 66239bdaeb9..de47a0307e1 100644 --- a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java +++ b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java @@ -972,7 +972,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { s_logger.warn("Unable to associate LUN ", uhe); throw new ServerException("Unable to associate LUN", uhe); } catch (NaAPIFailedException naf) { - if (naf.getErrno() == 9008) { //initiator group already contains node + if (naf.getErrno() == 9008) { //initiator group already contains node return returnVal; } s_logger.warn("Unable to associate LUN ", naf); diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDnsmasqResource.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDnsmasqResource.java index 765a166f978..6d5c19c80ba 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDnsmasqResource.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDnsmasqResource.java @@ -77,7 +77,7 @@ public class BaremetalDnsmasqResource extends BaremetalDhcpResourceBase { /* String prepareCmd = String.format("sh /usr/bin/prepare_dnsmasq.sh %1$s %2$s %3$s", _gateway, _dns, _ip); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) { - throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed"); + throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed"); } */ diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java index 165d706d006..2594a1a1ecd 100644 --- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java +++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java @@ -294,7 +294,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S @Override public final PingCommand getCurrentStatus(final long id) { - // TODO, need to report VM states on host + // TODO, need to report VM states on host PingCommand pingCmd = new PingRoutingCommand(getType(), id, null, null); if (s_logger.isDebugEnabled()) { diff --git a/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java b/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java index 33694603f74..0d772cd0eb8 100644 --- a/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java +++ b/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java @@ -194,7 +194,7 @@ public class HypervDirectConnectResourceTest { // TODO Auto-generated catch block e.printStackTrace(); } - } + } Assert.assertTrue( "Need to put a sample working virtual disk at " + testVolWorks.getPath(), testVolWorks.exists()); diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java index cbaa0f12a53..00fb76d652c 100755 --- a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java +++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java @@ -262,10 +262,10 @@ public class OvmResourceBase implements ServerResource, HypervisorResource { /* try { - _canBridgeFirewall = canBridgeFirewall(); + _canBridgeFirewall = canBridgeFirewall(); } catch (XmlRpcException e) { - s_logger.error("Failed to detect whether the host supports security groups.", e); - _canBridgeFirewall = false; + s_logger.error("Failed to detect whether the host supports security groups.", e); + _canBridgeFirewall = false; } */ diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java index e3dcc051961..d0ed652980e 100755 --- a/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java +++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java @@ -29,11 +29,11 @@ public class Test { public static void main(String[] args) { try { /*Connection c = new Connection("192.168.105.155", "oracle", "password"); - Utils util = new UtilsImpl(c); + Utils util = new UtilsImpl(c); Storage storage = new StorageImpl(c); String[] res = util.listDir("/etc", 1); for (String s : res) { - System.out.println(s); + System.out.println(s); } @@ -51,7 +51,7 @@ public class Test { System.out.println(pool.getAgentVersion()); String[] srs = storage.listSr(); for (int i=0; i res = OvmHost.getPerformanceStats(c, "xenbr0"); -// System.out.println(res.toString()); -// String stxt = "{\"vifs\": [{\"bridge\": \"xenbr0\", \"mac\": \"00:16:3E:5C:B1:D1\", \"type\": \"netfront\"}], \"powerState\": \"RUNNING\", \"disks\": [], \"cpuNum\": 1, \"memory\": 536870912, \"rootDisk\": {\"path\": \"/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/MyTest/System.img\", \"type\": \"w\"}}"; -// OvmVm.Details ddd = Coder.fromJson(stxt, OvmVm.Details.class); -// System.out.println(ddd.vifs.size()); -// System.out.println(ddd.rootDisk.path); +// Map res = OvmHost.getPerformanceStats(c, "xenbr0"); +// System.out.println(res.toString()); +// String stxt = "{\"vifs\": [{\"bridge\": \"xenbr0\", \"mac\": \"00:16:3E:5C:B1:D1\", \"type\": \"netfront\"}], \"powerState\": \"RUNNING\", \"disks\": [], \"cpuNum\": 1, \"memory\": 536870912, \"rootDisk\": {\"path\": \"/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/MyTest/System.img\", \"type\": \"w\"}}"; +// OvmVm.Details ddd = Coder.fromJson(stxt, OvmVm.Details.class); +// System.out.println(ddd.vifs.size()); +// System.out.println(ddd.rootDisk.path); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java index 9ad026eeb71..7d29b0c8f67 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java @@ -65,14 +65,14 @@ public class VmwareCleanupMaid { _vmName = vmName; } -// @Override -// public int cleanup(CheckPointManager checkPointMgr) { -// -// // save a check-point in case we crash at current run so that we won't lose it -// _checkPoint = checkPointMgr.pushCheckPoint(new VmwareCleanupMaid(_vCenterAddress, _dcMorValue, _vmName)); -// addLeftOverVM(this); -// return 0; -// } +// @Override +// public int cleanup(CheckPointManager checkPointMgr) { +// +// // save a check-point in case we crash at current run so that we won't lose it +// _checkPoint = checkPointMgr.pushCheckPoint(new VmwareCleanupMaid(_vCenterAddress, _dcMorValue, _vmName)); +// addLeftOverVM(this); +// return 0; +// } public String getCleanupProcedure() { return null; @@ -134,7 +134,7 @@ public class VmwareCleanupMaid { } catch (Throwable e) { s_logger.warn("Unable to destroy left over dummy VM " + cleanupMaid.getVmName()); } finally { -// FIXME mgr.popCleanupCheckpoint(cleanupMaid.getCheckPoint()); +// FIXME mgr.popCleanupCheckpoint(cleanupMaid.getCheckPoint()); } } diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java index 1ef5c902b2b..32ae0d2dbfa 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java @@ -131,8 +131,8 @@ import com.cloud.vm.DomainRouterVO; public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener, VmwareDatacenterService { private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class); - private static final int STARTUP_DELAY = 60000; // 60 seconds - private static final long DEFAULT_HOST_SCAN_INTERVAL = 600000; // every 10 minutes + private static final int STARTUP_DELAY = 60000; // 60 seconds + private static final long DEFAULT_HOST_SCAN_INTERVAL = 600000; // every 10 minutes private long _hostScanInterval = DEFAULT_HOST_SCAN_INTERVAL; int _timeout; @@ -190,7 +190,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw String _managemetPortGroupName; String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString(); String _recycleHungWorker = "false"; - long _hungWorkerTimeout = 7200000; // 2 hour + long _hungWorkerTimeout = 7200000; // 2 hour int _additionalPortRangeStart; int _additionalPortRangeSize; int _routerExtraPublicNics = 2; @@ -472,7 +472,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw hostSpec.setUserName(userName); hostSpec.setPassword(password); hostSpec.setHostName(host); - hostSpec.setForce(true); // forcely take over the host + hostSpec.setForce(true); // forcely take over the host ManagedObjectReference morTask = serviceContext.getService().addHostTask(morCluster, hostSpec, true, null, null); boolean taskResult = vclient.waitForTask(morTask); @@ -600,9 +600,9 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw // there are pending tasks on the subject VM /* if(System.currentTimeMillis() - startTick > _hungWorkerTimeout) { - if(s_logger.isInfoEnabled()) - s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000); - return true; + if(s_logger.isInfoEnabled()) + s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000); + return true; } */ return false; diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java index 0ad9fc1b0ac..561406ad98a 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java @@ -116,7 +116,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { Script command = new Script(false, "tar", 0, s_logger); command.setWorkDir(path); command.add("-cf", name + ".ova"); - command.add(name + ".ovf"); // OVF file should be the first file in OVA archive + command.add(name + ".ovf"); // OVF file should be the first file in OVA archive command.add(name + "-disk0.vmdk"); s_logger.info("Package OVA with commmand: " + command.toString()); @@ -214,7 +214,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { Script command = new Script(false, "tar", 0, s_logger); command.setWorkDir(installFullPath); command.add("-cf", volumeUuid + ".ova"); - command.add(volumeUuid + ".ovf"); // OVF file should be the first file in OVA archive + command.add(volumeUuid + ".ovf"); // OVF file should be the first file in OVA archive command.add(volumeUuid + "-disk0.vmdk"); command.execute(); diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 3751ce235fd..cb56176fc26 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -313,9 +313,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa protected String _name; - protected final long _ops_timeout = 900000; // 15 minutes time out to time + protected final long _ops_timeout = 900000; // 15 minutes time out to time - protected final int _shutdown_waitMs = 300000; // wait up to 5 minutes for shutdown + protected final int _shutdown_waitMs = 300000; // wait up to 5 minutes for shutdown @Inject protected VolumeOrchestrationService volMgr; diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java b/plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java index 0d364129d4e..7863f432bf2 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java +++ b/plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java @@ -44,7 +44,7 @@ public interface CiscoNexusVSMDeviceDao extends GenericDao getCiscoNexusVSMs(ListCiscoNexusVSMsCmd cmd) { // If clusterId is defined, then it takes precedence, and we will return - // the VSM associated with this cluster. + // the VSM associated with this cluster. Long clusterId = cmd.getClusterId(); Long zoneId = cmd.getZoneId(); diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java index b8a5b854499..534b19e597c 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java +++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java @@ -311,7 +311,7 @@ public class VmwareStorageProcessor implements StorageProcessor { throw new Exception("Unable to create a dummy VM for volume creation"); } - String vmdkFilePair[] = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, null, vmdkName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, true // we only use the first file in the pair, linked or not will not matter + String vmdkFilePair[] = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, null, vmdkName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, true // we only use the first file in the pair, linked or not will not matter ); String volumeDatastorePath = vmdkFilePair[0]; synchronized (this) { diff --git a/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java b/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java index c1ebcd8f0ee..64fc1fac0d2 100644 --- a/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java +++ b/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java @@ -132,7 +132,7 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy { // Migration across cluster needs to be done in three phases. // 1. Send a migrate command to source resource to initiate migration - // Run validations against target!! + // Run validations against target!! // 2. Complete the process. Update the volume details. MigrateWithStorageCommand migrateWithStorageCmd = new MigrateWithStorageCommand(to, volumeToFilerto, destHost.getGuid()); MigrateWithStorageAnswer migrateWithStorageAnswer = (MigrateWithStorageAnswer)agentMgr.send(srcHost.getId(), migrateWithStorageCmd); diff --git a/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java b/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java index 51885b62ccd..e102ed8d817 100644 --- a/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java +++ b/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java @@ -591,7 +591,7 @@ public class F5BigIpResource implements ServerResource { } } - // Login + // Login private void login() throws ExecutionException { try { diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailElementImpl.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailElementImpl.java index dfbe7d34dbb..85efca5a99e 100644 --- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailElementImpl.java +++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailElementImpl.java @@ -74,24 +74,24 @@ import com.cloud.network.IpAddress; public class ContrailElementImpl extends AdapterBase implements ContrailElement, IpDeployer, StaticNatServiceProvider { - private static final Map> _capabilities = InitCapabilities(); + private static final Map> _capabilities = InitCapabilities(); - @Inject ContrailManager _manager; - @Inject NicDao _nicDao; - @Inject ServerDBSync _dbSync; - private static final Logger s_logger = - Logger.getLogger(ContrailElement.class); - + @Inject ContrailManager _manager; + @Inject NicDao _nicDao; + @Inject ServerDBSync _dbSync; + private static final Logger s_logger = + Logger.getLogger(ContrailElement.class); + @Override public boolean configure(String name, Map params) throws ConfigurationException { - s_logger.debug("configure"); - return true; + s_logger.debug("configure"); + return true; } // PluggableService @Override public List> getCommands() { - List> cmdList = new ArrayList>(); + List> cmdList = new ArrayList>(); cmdList.add(CreateServiceInstanceCmd.class); return cmdList; } @@ -103,212 +103,212 @@ public class ContrailElementImpl extends AdapterBase } private static Map> InitCapabilities() { - Map> capabilities = new HashMap>(); - capabilities.put(Service.Connectivity, null); - capabilities.put(Service.Dhcp, new HashMap()); + Map> capabilities = new HashMap>(); + capabilities.put(Service.Connectivity, null); + capabilities.put(Service.Dhcp, new HashMap()); capabilities.put(Service.StaticNat, null); capabilities.put(Service.SourceNat, null); - return capabilities; + return capabilities; } - @Override - public Map> getCapabilities() { - return _capabilities; - } + @Override + public Map> getCapabilities() { + return _capabilities; + } - /** - * Network add/update. - */ - @Override - public boolean implement(Network network, NetworkOffering offering, - DeployDestination dest, ReservationContext context) - throws ConcurrentOperationException, ResourceUnavailableException, - InsufficientCapacityException { - s_logger.debug("NetworkElement implement: " + network.getName() + ", traffic type: " + network.getTrafficType()); - if (network.getTrafficType() == TrafficType.Guest) { - s_logger.debug("ignore network " + network.getName()); - return true; - } - VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(network.getUuid(), - _manager.getCanonicalName(network), network.getTrafficType()); - - if (vnModel == null) { - vnModel = new VirtualNetworkModel(network, network.getUuid(), - _manager.getCanonicalName(network), network.getTrafficType()); - vnModel.setProperties(_manager.getModelController(), network); - } - try { - if (!vnModel.verify(_manager.getModelController())) { - vnModel.update(_manager.getModelController()); - } - _manager.getDatabase().getVirtualNetworks().add(vnModel); - } catch (Exception ex) { - s_logger.warn("virtual-network update: ", ex); - } - return true; - } - - @Override - public boolean prepare(Network network, NicProfile nicProfile, - VirtualMachineProfile vm, - DeployDestination dest, ReservationContext context) - throws ConcurrentOperationException, ResourceUnavailableException, - InsufficientCapacityException { - - s_logger.debug("NetworkElement prepare: " + network.getName() + ", traffic type: " + network.getTrafficType()); - - if (network.getTrafficType() == TrafficType.Guest) { - s_logger.debug("ignore network " + network.getName()); - return true; - } - - s_logger.debug("network: " + network.getId()); - - VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(network.getUuid(), + /** + * Network add/update. + */ + @Override + public boolean implement(Network network, NetworkOffering offering, + DeployDestination dest, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException, + InsufficientCapacityException { + s_logger.debug("NetworkElement implement: " + network.getName() + ", traffic type: " + network.getTrafficType()); + if (network.getTrafficType() == TrafficType.Guest) { + s_logger.debug("ignore network " + network.getName()); + return true; + } + VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType()); - - if (vnModel == null) { - // There is no notification after a physical network is associated with the VRouter NetworkOffering - // this may be the first time we see this network. - return false; - } - VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid()); - if (vmModel == null) { - VMInstanceVO vmVo = (VMInstanceVO) vm.getVirtualMachine(); - vmModel = new VirtualMachineModel(vmVo, vm.getUuid()); - vmModel.setProperties(_manager.getModelController(), vmVo); - } + if (vnModel == null) { + vnModel = new VirtualNetworkModel(network, network.getUuid(), + _manager.getCanonicalName(network), network.getTrafficType()); + vnModel.setProperties(_manager.getModelController(), network); + } + try { + if (!vnModel.verify(_manager.getModelController())) { + vnModel.update(_manager.getModelController()); + } + _manager.getDatabase().getVirtualNetworks().add(vnModel); + } catch (Exception ex) { + s_logger.warn("virtual-network update: ", ex); + } + return true; + } - NicVO nic = _nicDao.findById(nicProfile.getId()); - assert nic != null; + @Override + public boolean prepare(Network network, NicProfile nicProfile, + VirtualMachineProfile vm, + DeployDestination dest, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException, + InsufficientCapacityException { - VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid()); - if (vmiModel == null) { - vmiModel = new VMInterfaceModel(nic.getUuid()); - vmiModel.addToVirtualMachine(vmModel); + s_logger.debug("NetworkElement prepare: " + network.getName() + ", traffic type: " + network.getTrafficType()); + + if (network.getTrafficType() == TrafficType.Guest) { + s_logger.debug("ignore network " + network.getName()); + return true; + } + + s_logger.debug("network: " + network.getId()); + + VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(network.getUuid(), + _manager.getCanonicalName(network), network.getTrafficType()); + + if (vnModel == null) { + // There is no notification after a physical network is associated with the VRouter NetworkOffering + // this may be the first time we see this network. + return false; + } + + VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid()); + if (vmModel == null) { + VMInstanceVO vmVo = (VMInstanceVO) vm.getVirtualMachine(); + vmModel = new VirtualMachineModel(vmVo, vm.getUuid()); + vmModel.setProperties(_manager.getModelController(), vmVo); + } + + NicVO nic = _nicDao.findById(nicProfile.getId()); + assert nic != null; + + VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid()); + if (vmiModel == null) { + vmiModel = new VMInterfaceModel(nic.getUuid()); + vmiModel.addToVirtualMachine(vmModel); vmiModel.addToVirtualNetwork(vnModel); - } - - try { - vmiModel.build(_manager.getModelController(), (VMInstanceVO) vm.getVirtualMachine(), nic); - } catch (IOException ex) { - s_logger.warn("vm interface set", ex); - return false; - } + } + + try { + vmiModel.build(_manager.getModelController(), (VMInstanceVO) vm.getVirtualMachine(), nic); + } catch (IOException ex) { + s_logger.warn("vm interface set", ex); + return false; + } - InstanceIpModel ipModel = vmiModel.getInstanceIp(); - if (ipModel == null) { - ipModel = new InstanceIpModel(vm.getInstanceName(), nic.getDeviceId()); - ipModel.addToVMInterface(vmiModel); - } - ipModel.setAddress(nicProfile.getIp4Address()); + InstanceIpModel ipModel = vmiModel.getInstanceIp(); + if (ipModel == null) { + ipModel = new InstanceIpModel(vm.getInstanceName(), nic.getDeviceId()); + ipModel.addToVMInterface(vmiModel); + } + ipModel.setAddress(nicProfile.getIp4Address()); - try { - vmModel.update(_manager.getModelController()); - } catch (Exception ex) { - s_logger.warn("virtual-machine-update", ex); - return false; - } - _manager.getDatabase().getVirtualMachines().add(vmModel); + try { + vmModel.update(_manager.getModelController()); + } catch (Exception ex) { + s_logger.warn("virtual-machine-update", ex); + return false; + } + _manager.getDatabase().getVirtualMachines().add(vmModel); - return true; - } + return true; + } - @Override - public boolean release(Network network, NicProfile nicProfile, - VirtualMachineProfile vm, - ReservationContext context) throws ConcurrentOperationException, - ResourceUnavailableException { - if (network.getTrafficType() == TrafficType.Guest) { - return true; - } else if (!_manager.isManagedPhysicalNetwork(network)) { - s_logger.debug("release ignore network " + network.getId()); - return true; - } + @Override + public boolean release(Network network, NicProfile nicProfile, + VirtualMachineProfile vm, + ReservationContext context) throws ConcurrentOperationException, + ResourceUnavailableException { + if (network.getTrafficType() == TrafficType.Guest) { + return true; + } else if (!_manager.isManagedPhysicalNetwork(network)) { + s_logger.debug("release ignore network " + network.getId()); + return true; + } - NicVO nic = _nicDao.findById(nicProfile.getId()); - assert nic != null; + NicVO nic = _nicDao.findById(nicProfile.getId()); + assert nic != null; - VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid()); - if (vmModel == null) { - s_logger.debug("vm " + vm.getInstanceName() + " not in local database"); - return true; - } - VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid()); - if (vmiModel != null) { - try { - vmiModel.destroy(_manager.getModelController()); - } catch (IOException ex) { - s_logger.warn("virtual-machine-interface delete", ex); - } - vmModel.removeSuccessor(vmiModel); - } + VirtualMachineModel vmModel = _manager.getDatabase().lookupVirtualMachine(vm.getUuid()); + if (vmModel == null) { + s_logger.debug("vm " + vm.getInstanceName() + " not in local database"); + return true; + } + VMInterfaceModel vmiModel = vmModel.getVMInterface(nic.getUuid()); + if (vmiModel != null) { + try { + vmiModel.destroy(_manager.getModelController()); + } catch (IOException ex) { + s_logger.warn("virtual-machine-interface delete", ex); + } + vmModel.removeSuccessor(vmiModel); + } - if (!vmModel.hasDescendents()) { - _manager.getDatabase().getVirtualMachines().remove(vmModel); - try { - vmModel.delete(_manager.getModelController()); - } catch (IOException e) { - return false; - } - } + if (!vmModel.hasDescendents()) { + _manager.getDatabase().getVirtualMachines().remove(vmModel); + try { + vmModel.delete(_manager.getModelController()); + } catch (IOException e) { + return false; + } + } - return true; - } + return true; + } - /** - * Network disable - */ - @Override - public boolean shutdown(Network network, ReservationContext context, - boolean cleanup) throws ConcurrentOperationException, - ResourceUnavailableException { - s_logger.debug("NetworkElement shutdown"); - return true; - } + /** + * Network disable + */ + @Override + public boolean shutdown(Network network, ReservationContext context, + boolean cleanup) throws ConcurrentOperationException, + ResourceUnavailableException { + s_logger.debug("NetworkElement shutdown"); + return true; + } - /** - * Network delete - */ - @Override - public boolean destroy(Network network, ReservationContext context) - throws ConcurrentOperationException, ResourceUnavailableException { - s_logger.debug("NetworkElement destroy"); - return true; - } + /** + * Network delete + */ + @Override + public boolean destroy(Network network, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException { + s_logger.debug("NetworkElement destroy"); + return true; + } - @Override - public boolean isReady(PhysicalNetworkServiceProvider provider) { - return true; - } + @Override + public boolean isReady(PhysicalNetworkServiceProvider provider) { + return true; + } - @Override - public boolean shutdownProviderInstances( - PhysicalNetworkServiceProvider provider, ReservationContext context) - throws ConcurrentOperationException, ResourceUnavailableException { - s_logger.debug("NetworkElement shutdown ProviderInstances"); - return true; - } + @Override + public boolean shutdownProviderInstances( + PhysicalNetworkServiceProvider provider, ReservationContext context) + throws ConcurrentOperationException, ResourceUnavailableException { + s_logger.debug("NetworkElement shutdown ProviderInstances"); + return true; + } - @Override - public boolean canEnableIndividualServices() { - return true; - } + @Override + public boolean canEnableIndividualServices() { + return true; + } - @Override - public boolean verifyServicesCombination(Set services) { - // TODO Auto-generated method stub - s_logger.debug("NetworkElement verifyServices"); - s_logger.debug("Services: " + services); - return true; - } + @Override + public boolean verifyServicesCombination(Set services) { + // TODO Auto-generated method stub + s_logger.debug("NetworkElement verifyServices"); + s_logger.debug("Services: " + services); + return true; + } @Override public IpDeployer getIpDeployer(Network network) { - return this; + return this; } @Override diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailGuru.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailGuru.java index ca53f416f89..86b3abaeff7 100644 --- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailGuru.java +++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailGuru.java @@ -76,7 +76,7 @@ public class ContrailGuru extends AdapterBase implements NetworkGuru { @Override public String getName() { - return "ContrailGuru"; + return "ContrailGuru"; } @Override diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java index 4eaafca17cf..3664d1375d9 100644 --- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java +++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java @@ -650,17 +650,17 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager @Override public void createPublicNetworks() { - List types = new ArrayList(Arrays.asList(TrafficType.Public)); - List dbNets = findJuniperManagedNetworks(types); - if (dbNets == null) { - return; - } - for (NetworkVO net: dbNets) { - VirtualNetworkModel vnModel = _database.lookupVirtualNetwork(net.getUuid(), getCanonicalName(net), - TrafficType.Public); - if (vnModel != null) { - continue; - } + List types = new ArrayList(Arrays.asList(TrafficType.Public)); + List dbNets = findJuniperManagedNetworks(types); + if (dbNets == null) { + return; + } + for (NetworkVO net: dbNets) { + VirtualNetworkModel vnModel = _database.lookupVirtualNetwork(net.getUuid(), getCanonicalName(net), + TrafficType.Public); + if (vnModel != null) { + continue; + } vnModel = new VirtualNetworkModel(net, net.getUuid(), getCanonicalName(net), net.getTrafficType()); vnModel.build(_controller, net); try { @@ -678,7 +678,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager Map providerMap = new HashMap(); providerMap.put(Service.Connectivity.getName(), Provider.JuniperContrail.getName()); _networksDao.update(net.getId(), net, providerMap); - } + } } public boolean createFloatingIp(PublicIpAddress ip) { diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/IntegrationTestConfiguration.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/IntegrationTestConfiguration.java index dec4a9e4953..d9126fc0160 100644 --- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/IntegrationTestConfiguration.java +++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/IntegrationTestConfiguration.java @@ -531,12 +531,12 @@ public class IntegrationTestConfiguration { AffinityGroupService mock = Mockito.mock(AffinityGroupService.class); try { final AffinityGroupVO gmock = new AffinityGroupVO("grp1", "grp-type", "affinity group", 1, AccountVO.ACCOUNT_ID_SYSTEM, ControlledEntity.ACLType.Account); - Transaction.execute(new TransactionCallbackNoReturn() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - _affinityGroupDao.persist(gmock); - } - }); + Transaction.execute(new TransactionCallbackNoReturn() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) { + _affinityGroupDao.persist(gmock); + } + }); Mockito.when(mock.createAffinityGroupInternal(Mockito.any(String.class), Mockito.any(Long.class), Mockito.any(String.class), Mockito.any(String.class), Mockito.any(String.class))).thenReturn(gmock); } catch (Exception e) { e.printStackTrace(); diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java index 195e932f08d..82dd49f6927 100644 --- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java +++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java @@ -67,14 +67,14 @@ public class MockAccountManager extends ManagerBase implements AccountManager { private static final Logger s_logger = Logger.getLogger(MockAccountManager.class); - @Inject AccountDao _accountDao; + @Inject AccountDao _accountDao; @Inject ResourceCountDao _resourceCountDao; @Inject AccountJoinDao _accountJoinDao; - @Inject UserDao _userDao; - - UserVO _systemUser; - AccountVO _systemAccount; + @Inject UserDao _userDao; + + UserVO _systemUser; + AccountVO _systemAccount; @Override public boolean configure(final String name, final Map params) throws ConfigurationException { @@ -335,38 +335,38 @@ public class MockAccountManager extends ManagerBase implements AccountManager { return null; } - @Override - public Account getActiveAccountById(long accountId) { - // TODO Auto-generated method stub - return null; - } + @Override + public Account getActiveAccountById(long accountId) { + // TODO Auto-generated method stub + return null; + } - @Override - public Account getAccount(long accountId) { + @Override + public Account getAccount(long accountId) { return _systemAccount; - } + } - @Override - public Account createAccount(String accountName, short accountType, - Long domainId, String networkDomain, Map details, - String uuid) { - final AccountVO account = new AccountVO(accountName, domainId, networkDomain, accountType, uuid); - Transaction.execute(new TransactionCallbackNoReturn() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { + @Override + public Account createAccount(String accountName, short accountType, + Long domainId, String networkDomain, Map details, + String uuid) { + final AccountVO account = new AccountVO(accountName, domainId, networkDomain, accountType, uuid); + Transaction.execute(new TransactionCallbackNoReturn() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) { - _accountDao.persist(account); - _resourceCountDao.createResourceCounts(account.getId(), ResourceLimit.ResourceOwnerType.Account); - } - }); + _accountDao.persist(account); + _resourceCountDao.createResourceCounts(account.getId(), ResourceLimit.ResourceOwnerType.Account); + } + }); return account; - } + } - @Override - public void logoutUser(long userId) { - // TODO Auto-generated method stub - - } + @Override + public void logoutUser(long userId) { + // TODO Auto-generated method stub + + } } diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java index e214eb0bd30..8b4e67c44fa 100644 --- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java +++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/PublicNetworkTest.java @@ -122,7 +122,7 @@ public class PublicNetworkTest extends TestCase { @Test public void testPublicNetwork() throws IOException { - DataCenter zone = _server.getZone(); + DataCenter zone = _server.getZone(); List networks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Public); assertNotNull(networks); assertFalse(networks.isEmpty()); diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java index 460f7804186..ed506f33cb1 100644 --- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java +++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/TestDbSetup.java @@ -41,7 +41,7 @@ public class TestDbSetup { public static void startMysqlServer(int port, String startMysqlScript) throws Exception { try { - String cwd = new java.io.File(".").getCanonicalPath(); + String cwd = new java.io.File(".").getCanonicalPath(); Runtime r = Runtime.getRuntime(); String script = startMysqlScript; if (script == null) { diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java b/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java index 71040693f58..a0bb46d1572 100644 --- a/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java +++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java @@ -3209,7 +3209,7 @@ public class JuniperSrxResource implements ServerResource { } /* - * Usage + * Usage */ private ExternalNetworkResourceUsageAnswer getUsageAnswer(ExternalNetworkResourceUsageCommand cmd) throws ExecutionException { diff --git a/plugins/network-elements/palo-alto/src/com/cloud/api/commands/ListExternalFirewallsCmd.java b/plugins/network-elements/palo-alto/src/com/cloud/api/commands/ListExternalFirewallsCmd.java index ebced7e2039..948544f0dca 100644 --- a/plugins/network-elements/palo-alto/src/com/cloud/api/commands/ListExternalFirewallsCmd.java +++ b/plugins/network-elements/palo-alto/src/com/cloud/api/commands/ListExternalFirewallsCmd.java @@ -36,7 +36,7 @@ import org.apache.cloudstack.api.response.ExternalFirewallResponse; @APICommand(name = "listExternalFirewalls", description="List external firewall appliances.", responseObject = ExternalFirewallResponse.class) public class ListExternalFirewallsCmd extends BaseListCmd { - public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName()); + public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName()); private static final String s_name = "listexternalfirewallsresponse"; ///////////////////////////////////////////////////// @@ -70,15 +70,15 @@ public class ListExternalFirewallsCmd extends BaseListCmd { @Override public void execute(){ - List externalFirewalls = _paElementService.listExternalFirewalls(this); + List externalFirewalls = _paElementService.listExternalFirewalls(this); ListResponse listResponse = new ListResponse(); List responses = new ArrayList(); for (Host externalFirewall : externalFirewalls) { - ExternalFirewallResponse response = _paElementService.createExternalFirewallResponse(externalFirewall); - response.setObjectName("externalfirewall"); - response.setResponseName(getCommandName()); - responses.add(response); + ExternalFirewallResponse response = _paElementService.createExternalFirewallResponse(externalFirewall); + response.setObjectName("externalfirewall"); + response.setResponseName(getCommandName()); + responses.add(response); } listResponse.setResponses(responses); diff --git a/plugins/network-elements/palo-alto/test/com/cloud/network/resource/MockablePaloAltoResource.java b/plugins/network-elements/palo-alto/test/com/cloud/network/resource/MockablePaloAltoResource.java index 9a9eb6e0c2e..350a4d2a356 100755 --- a/plugins/network-elements/palo-alto/test/com/cloud/network/resource/MockablePaloAltoResource.java +++ b/plugins/network-elements/palo-alto/test/com/cloud/network/resource/MockablePaloAltoResource.java @@ -96,12 +96,12 @@ import java.io.StringWriter; public class MockablePaloAltoResource extends PaloAltoResource { - private HashMap context; - public void setMockContext(HashMap context) { - this.context = context; - } + private HashMap context; + public void setMockContext(HashMap context) { + this.context = context; + } - /* Fake the calls to the Palo Alto API */ + /* Fake the calls to the Palo Alto API */ protected String request(PaloAltoMethod method, Map params) throws ExecutionException { if (method != PaloAltoMethod.GET && method != PaloAltoMethod.POST) { throw new ExecutionException("Invalid http method used to access the Palo Alto API."); @@ -116,8 +116,8 @@ public class MockablePaloAltoResource extends PaloAltoResource { // 'config' requests if (params.containsKey("type") && params.get("type").equals("config") && params.containsKey("action")) { - // action = 'get' - if (params.get("action").equals("get")) { + // action = 'get' + if (params.get("action").equals("get")) { // get interface for type // | public_using_ethernet if (params.get("xpath").equals("/config/devices/entry/network/interface/ethernet/entry[@name='ethernet1/1']")) { @@ -146,7 +146,7 @@ public class MockablePaloAltoResource extends PaloAltoResource { } } - // get public interface IP | has_public_interface + // get public interface IP | has_public_interface if (params.get("xpath").equals("/config/devices/entry/network/interface/ethernet/entry[@name='ethernet1/1']/layer3/units/entry[@name='ethernet1/1.9999']/ip/entry[@name='192.168.80.102/32']")) { if (context.containsKey("has_public_interface") && context.get("has_public_interface").equals("true")) { response = ""; @@ -169,7 +169,7 @@ public class MockablePaloAltoResource extends PaloAltoResource { response = ""; } - // get source nat | has_src_nat_rule + // get source nat | has_src_nat_rule if (params.get("xpath").equals("/config/devices/entry/vsys/entry[@name='vsys1']/rulebase/nat/rules/entry[@name='src_nat.3954']")) { if (context.containsKey("has_src_nat_rule") && context.get("has_src_nat_rule").equals("true")) { response = "untrusttrust10.5.80.1/20anyanyipv4ethernet1/1.9999192.168.80.102/32ethernet1/1.9999"; @@ -241,10 +241,10 @@ public class MockablePaloAltoResource extends PaloAltoResource { } } - } + } - // action = 'set' - if (params.get("action").equals("set")) { + // action = 'set' + if (params.get("action").equals("set")) { // set management profile if (params.get("xpath").equals("/config/devices/entry/network/profiles/interface-management-profile/entry[@name='Ping']")) { response = "command succeeded"; @@ -324,10 +324,10 @@ public class MockablePaloAltoResource extends PaloAltoResource { response = "command succeeded"; context.put("has_service_tcp_80", "true"); } - } + } - // action = 'delete' - if (params.get("action").equals("delete")) { + // action = 'delete' + if (params.get("action").equals("delete")) { // remove egress firewall rule if (params.get("xpath").equals("/config/devices/entry/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='policy_0']")) { response = "command succeeded"; @@ -396,24 +396,24 @@ public class MockablePaloAltoResource extends PaloAltoResource { context.remove("has_private_interface"); } - } + } } // end 'config' // 'op' requests if (params.containsKey("type") && params.get("type").equals("op")) { - // check if there are pending changes - if (params.get("cmd").equals("")) { + // check if there are pending changes + if (params.get("cmd").equals("")) { if (context.containsKey("firewall_has_pending_changes") && context.get("firewall_has_pending_changes").equals("true")) { response = "yes"; } else { response = "no"; } - } + } - // add a config lock - if (params.get("cmd").equals("")) { + // add a config lock + if (params.get("cmd").equals("")) { response = "Successfully acquired lock. Other administrators will not be able to modify configuration for scope shared until lock is released"; - } + } // check job status if (params.get("cmd").equals("1")) { @@ -424,23 +424,23 @@ public class MockablePaloAltoResource extends PaloAltoResource { } } - // load from running config - if (params.get("cmd").equals("running-config.xml")) { + // load from running config + if (params.get("cmd").equals("running-config.xml")) { response = "Config loaded from running-config.xml"; - } + } - // remove config lock - if (params.get("cmd").equals("")) { + // remove config lock + if (params.get("cmd").equals("")) { response = "Config lock released for scope shared"; - } + } } // end 'op' // 'commit' requests if (params.containsKey("type") && params.get("type").equals("commit")) { - // cmd = '' - if (params.get("cmd").equals("")) { + // cmd = '' + if (params.get("cmd").equals("")) { response = "Commit job enqueued with jobid 11"; - } + } } // end 'commit' diff --git a/plugins/network-elements/palo-alto/test/com/cloud/network/resource/PaloAltoResourceTest.java b/plugins/network-elements/palo-alto/test/com/cloud/network/resource/PaloAltoResourceTest.java index c2704734c6c..d8bc52b394f 100755 --- a/plugins/network-elements/palo-alto/test/com/cloud/network/resource/PaloAltoResourceTest.java +++ b/plugins/network-elements/palo-alto/test/com/cloud/network/resource/PaloAltoResourceTest.java @@ -106,8 +106,8 @@ import javax.xml.transform.Source; import java.io.StringWriter; public class PaloAltoResourceTest { - // configuration data - private String _test_name = "PaloAltoTestDevice"; + // configuration data + private String _test_name = "PaloAltoTestDevice"; private String _test_zoneId = "TestZone"; private String _test_ip = "192.168.80.2"; private String _test_username = "admin"; @@ -118,101 +118,101 @@ public class PaloAltoResourceTest { private String _test_privateZone = "trust"; private String _test_virtualRouter = "default"; - MockablePaloAltoResource _resource; - Map _resource_params; - HashMap _context; - - @Before - public void setUp() { - _resource = new MockablePaloAltoResource(); - _resource_params = new HashMap(); // params to be passed to configure() - _resource_params.put("name", _test_name); - _resource_params.put("zoneId", _test_zoneId); - _resource_params.put("ip", _test_ip); - _resource_params.put("username", _test_username); - _resource_params.put("password", _test_password); - _resource_params.put("publicinterface", _test_publicInterface); - _resource_params.put("privateinterface", _test_privateInterface); - _resource_params.put("publicnetwork", _test_publicZone); - _resource_params.put("privatenetwork", _test_privateZone); - _resource_params.put("pavr", _test_virtualRouter); - _resource_params.put("guid", "aaaaa-bbbbb-ccccc"); + MockablePaloAltoResource _resource; + Map _resource_params; + HashMap _context; + + @Before + public void setUp() { + _resource = new MockablePaloAltoResource(); + _resource_params = new HashMap(); // params to be passed to configure() + _resource_params.put("name", _test_name); + _resource_params.put("zoneId", _test_zoneId); + _resource_params.put("ip", _test_ip); + _resource_params.put("username", _test_username); + _resource_params.put("password", _test_password); + _resource_params.put("publicinterface", _test_publicInterface); + _resource_params.put("privateinterface", _test_privateInterface); + _resource_params.put("publicnetwork", _test_publicZone); + _resource_params.put("privatenetwork", _test_privateZone); + _resource_params.put("pavr", _test_virtualRouter); + _resource_params.put("guid", "aaaaa-bbbbb-ccccc"); - _context = new HashMap(); // global context - _context.put("name", _test_name); - _context.put("zone_id", _test_zoneId); - _context.put("ip", _test_ip); - _context.put("username", _test_username); - _context.put("password", _test_password); - _context.put("public_interface", _test_publicInterface); - _context.put("private_interface", _test_privateInterface); - _context.put("public_zone", _test_publicZone); - _context.put("private_zone", _test_privateZone); - _context.put("pa_vr", _test_virtualRouter); - // -- - _context.put("public_using_ethernet", "true"); - _context.put("private_using_ethernet", "true"); - _context.put("has_management_profile", "true"); - _context.put("enable_console_output", "false"); // CHANGE TO "true" TO ENABLE CONSOLE LOGGING OF TESTS - _resource.setMockContext(_context); - } + _context = new HashMap(); // global context + _context.put("name", _test_name); + _context.put("zone_id", _test_zoneId); + _context.put("ip", _test_ip); + _context.put("username", _test_username); + _context.put("password", _test_password); + _context.put("public_interface", _test_publicInterface); + _context.put("private_interface", _test_privateInterface); + _context.put("public_zone", _test_publicZone); + _context.put("private_zone", _test_privateZone); + _context.put("pa_vr", _test_virtualRouter); + // -- + _context.put("public_using_ethernet", "true"); + _context.put("private_using_ethernet", "true"); + _context.put("has_management_profile", "true"); + _context.put("enable_console_output", "false"); // CHANGE TO "true" TO ENABLE CONSOLE LOGGING OF TESTS + _resource.setMockContext(_context); + } - @Test (expected=ConfigurationException.class) - public void resourceConfigureFailure() throws ConfigurationException { - _resource.configure("PaloAltoResource", new HashMap()); - } - - @Test - public void resourceConfigureWithoutManagementProfile() throws ConfigurationException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: resourceConfigureWithoutManagementProfile"); - System.out.println("---------------------------------------------------"); - } + @Test (expected=ConfigurationException.class) + public void resourceConfigureFailure() throws ConfigurationException { + _resource.configure("PaloAltoResource", new HashMap()); + } + + @Test + public void resourceConfigureWithoutManagementProfile() throws ConfigurationException { + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: resourceConfigureWithoutManagementProfile"); + System.out.println("---------------------------------------------------"); + } _context.remove("has_management_profile"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); - } + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); + } - @Test - public void resourceConfigureWithManagementProfile() throws ConfigurationException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: resourceConfigureWithManagementProfile"); - System.out.println("---------------------------------------------------"); - } - _resource.configure("PaloAltoResource", _resource_params); - } + @Test + public void resourceConfigureWithManagementProfile() throws ConfigurationException { + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: resourceConfigureWithManagementProfile"); + System.out.println("---------------------------------------------------"); + } + _resource.configure("PaloAltoResource", _resource_params); + } - @Test (expected=ConfigurationException.class) - public void simulateFirewallNotConfigurable() throws ConfigurationException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: simulateFirewallNotConfigurable"); - System.out.println("---------------------------------------------------"); - } - _context.put("firewall_has_pending_changes", "true"); + @Test (expected=ConfigurationException.class) + public void simulateFirewallNotConfigurable() throws ConfigurationException { + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: simulateFirewallNotConfigurable"); + System.out.println("---------------------------------------------------"); + } + _context.put("firewall_has_pending_changes", "true"); _context.remove("has_management_profile"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); - } + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); + } - @Test (expected=ConfigurationException.class) - public void simulateFirewallCommitFailure() throws ConfigurationException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: simulateFirewallCommitFailure"); - System.out.println("---------------------------------------------------"); - } - _context.put("simulate_commit_failure", "true"); + @Test (expected=ConfigurationException.class) + public void simulateFirewallCommitFailure() throws ConfigurationException { + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: simulateFirewallCommitFailure"); + System.out.println("---------------------------------------------------"); + } + _context.put("simulate_commit_failure", "true"); _context.remove("has_management_profile"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); - } + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); + } - @Test + @Test public void testInitialize() throws ConfigurationException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: testInitialization"); - System.out.println("---------------------------------------------------"); - } - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: testInitialization"); + System.out.println("---------------------------------------------------"); + } + _resource.configure("PaloAltoResource", _resource_params); StartupCommand[] sc = _resource.initialize(); assertTrue(sc.length == 1); @@ -221,16 +221,16 @@ public class PaloAltoResourceTest { assertTrue("TestZone".equals(sc[0].getDataCenter())); } - @Test // implement public & private interfaces, source nat, guest network - public void implementGuestNetwork() throws ConfigurationException, ExecutionException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: implementGuestNetwork"); - System.out.println("---------------------------------------------------"); - } - _resource.configure("PaloAltoResource", _resource_params); + @Test // implement public & private interfaces, source nat, guest network + public void implementGuestNetwork() throws ConfigurationException, ExecutionException { + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: implementGuestNetwork"); + System.out.println("---------------------------------------------------"); + } + _resource.configure("PaloAltoResource", _resource_params); - IpAddressTO ip = new IpAddressTO(Long.valueOf("1"), "192.168.80.102", true, false, true, "untagged", null, null, null, 100, false); - IpAddressTO[] ips = new IpAddressTO[1]; + IpAddressTO ip = new IpAddressTO(Long.valueOf("1"), "192.168.80.102", true, false, true, "untagged", null, null, null, 100, false); + IpAddressTO[] ips = new IpAddressTO[1]; ips[0] = ip; IpAssocCommand cmd = new IpAssocCommand(ips); cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.3.96.1"); @@ -239,23 +239,23 @@ public class PaloAltoResourceTest { IpAssocAnswer answer = (IpAssocAnswer) _resource.executeRequest(cmd); assertTrue(answer.getResult()); - } + } - @Test // remove public & private interface details, source nat, guest network - public void shutdownGuestNetwork() throws ConfigurationException, ExecutionException { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: shutdownGuestNetwork"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + @Test // remove public & private interface details, source nat, guest network + public void shutdownGuestNetwork() throws ConfigurationException, ExecutionException { + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: shutdownGuestNetwork"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); - IpAddressTO ip = new IpAddressTO(Long.valueOf("1"), "192.168.80.102", false, false, true, "untagged", null, null, null, 100, false); - IpAddressTO[] ips = new IpAddressTO[1]; + IpAddressTO ip = new IpAddressTO(Long.valueOf("1"), "192.168.80.102", false, false, true, "untagged", null, null, null, 100, false); + IpAddressTO[] ips = new IpAddressTO[1]; ips[0] = ip; IpAssocCommand cmd = new IpAssocCommand(ips); cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.3.96.1"); @@ -264,21 +264,21 @@ public class PaloAltoResourceTest { IpAssocAnswer answer = (IpAssocAnswer) _resource.executeRequest(cmd); assertTrue(answer.getResult()); - } + } - @Test + @Test public void addIngressFirewallRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: addIngressFirewallRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: addIngressFirewallRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -297,20 +297,20 @@ public class PaloAltoResourceTest { assertTrue(answer.getResult()); } - @Test + @Test public void removeIngressFirewallRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: removeIngressFirewallRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _context.put("has_ingress_fw_rule", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: removeIngressFirewallRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _context.put("has_ingress_fw_rule", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -329,17 +329,17 @@ public class PaloAltoResourceTest { @Test public void addEgressFirewallRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: addEgressFirewallRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: addEgressFirewallRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -359,20 +359,20 @@ public class PaloAltoResourceTest { assertTrue(answer.getResult()); } - @Test + @Test public void removeEgressFirewallRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: removeEgressFirewallRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _context.put("has_egress_fw_rule", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: removeEgressFirewallRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _context.put("has_egress_fw_rule", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -392,17 +392,17 @@ public class PaloAltoResourceTest { @Test public void addStaticNatRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: addStaticNatRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: addStaticNatRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -420,18 +420,18 @@ public class PaloAltoResourceTest { @Test public void removeStaticNatRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: removeStaticNatRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _context.put("has_stc_nat_rule", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: removeStaticNatRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _context.put("has_stc_nat_rule", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -449,17 +449,17 @@ public class PaloAltoResourceTest { @Test public void addPortForwardingRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: addPortForwardingRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: addPortForwardingRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); @@ -477,18 +477,18 @@ public class PaloAltoResourceTest { @Test public void removePortForwardingRule() throws ConfigurationException, Exception { - if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { - System.out.println("\nTEST: removePortForwardingRule"); - System.out.println("---------------------------------------------------"); - } - _context.put("has_public_interface", "true"); - _context.put("has_private_interface", "true"); - _context.put("has_src_nat_rule", "true"); - _context.put("has_isolation_fw_rule", "true"); - _context.put("has_service_tcp_80", "true"); - _context.put("has_dst_nat_rule", "true"); - _resource.setMockContext(_context); - _resource.configure("PaloAltoResource", _resource_params); + if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) { + System.out.println("\nTEST: removePortForwardingRule"); + System.out.println("---------------------------------------------------"); + } + _context.put("has_public_interface", "true"); + _context.put("has_private_interface", "true"); + _context.put("has_src_nat_rule", "true"); + _context.put("has_isolation_fw_rule", "true"); + _context.put("has_service_tcp_80", "true"); + _context.put("has_dst_nat_rule", "true"); + _resource.setMockContext(_context); + _resource.configure("PaloAltoResource", _resource_params); long vlanId = 3954; List rules = new ArrayList(); diff --git a/pom.xml b/pom.xml index 71d052fe8c2..80a572b853e 100644 --- a/pom.xml +++ b/pom.xml @@ -445,6 +445,7 @@ ${basedir}/${cs.target.dir}/classes ${basedir}/${cs.target.dir}/test-classes + diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 715d7705f30..eac7fe9a8f9 100755 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -324,7 +324,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi } // Calculate CPU and RAM capacities - // get all hosts...even if they are not in 'UP' state + // get all hosts...even if they are not in 'UP' state List hosts = _resourceMgr.listAllNotInMaintenanceHostsInOneZone(Host.Type.Routing, null); for (HostVO host : hosts) { _capacityMgr.updateCapacityForHost(host); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 97c9f0e0da8..80e13704d33 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -602,7 +602,7 @@ public enum Config { MigrateWait("Advanced", AgentManager.class, Integer.class, "migratewait", "3600", "Time (in seconds) to wait for VM migrate finish", null), HAWorkers("Advanced", AgentManager.class, Integer.class, "ha.workers", "5", "Number of ha worker threads.", null), MountParent("Advanced", ManagementServer.class, String.class, "mount.parent", "/var/cloudstack/mnt", "The mount point on the Management Server for Secondary Storage.", null), -// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null), +// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null), SystemVMUseLocalStorage( "Advanced", ManagementServer.class, diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java index f92a1800704..3e3a25fc52c 100755 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java @@ -23,13 +23,13 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService { public static final int DEFAULT_PROXY_CAPACITY = 50; public static final int DEFAULT_STANDBY_CAPACITY = 10; - public static final int DEFAULT_PROXY_VM_RAMSIZE = 1024; // 1G - public static final int DEFAULT_PROXY_VM_CPUMHZ = 500; // 500 MHz + public static final int DEFAULT_PROXY_VM_RAMSIZE = 1024; // 1G + public static final int DEFAULT_PROXY_VM_CPUMHZ = 500; // 500 MHz public static final int DEFAULT_PROXY_CMD_PORT = 8001; public static final int DEFAULT_PROXY_VNC_PORT = 0; public static final int DEFAULT_PROXY_URL_PORT = 80; - public static final int DEFAULT_PROXY_SESSION_TIMEOUT = 300000; // 5 minutes + public static final int DEFAULT_PROXY_SESSION_TIMEOUT = 300000; // 5 minutes public static final String ALERT_SUBJECT = "proxy-alert"; public static final String CERTIFICATE_NAME = "CPVMCertificate"; diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 8c34aa4d0e5..1c41890a0a7 100755 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -144,12 +144,12 @@ import com.cloud.vm.dao.VMInstanceDao; // // Possible console proxy state transition cases -// Stopped --> Starting -> Running -// HA -> Stopped -> Starting -> Running -// Migrating -> Running (if previous state is Running before it enters into Migrating state -// Migrating -> Stopped (if previous state is not Running before it enters into Migrating state) -// Running -> HA (if agent lost connection) -// Stopped -> Destroyed +// Stopped --> Starting -> Running +// HA -> Stopped -> Starting -> Running +// Migrating -> Running (if previous state is Running before it enters into Migrating state +// Migrating -> Stopped (if previous state is not Running before it enters into Migrating state) +// Running -> HA (if agent lost connection) +// Stopped -> Destroyed // // Starting, HA, Migrating, Running state are all counted as "Open" for available capacity calculation // because sooner or later, it will be driven into Running state diff --git a/server/src/com/cloud/ha/RecreatableFencer.java b/server/src/com/cloud/ha/RecreatableFencer.java index 909d32f5745..80bdd1d71d3 100644 --- a/server/src/com/cloud/ha/RecreatableFencer.java +++ b/server/src/com/cloud/ha/RecreatableFencer.java @@ -58,7 +58,7 @@ public class RecreatableFencer extends AdapterBase implements FenceBuilder { for (VolumeVO vol : vols) { if (!vol.isRecreatable()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Unable to f ence off volumes that are not recreatable: " + vol); + s_logger.debug("Unable to f ence off volumes that are not recreatable: " + vol); } return null; } diff --git a/server/src/com/cloud/network/PortProfileManagerImpl.java b/server/src/com/cloud/network/PortProfileManagerImpl.java index 14d7e212f9b..a7d64f06c38 100644 --- a/server/src/com/cloud/network/PortProfileManagerImpl.java +++ b/server/src/com/cloud/network/PortProfileManagerImpl.java @@ -40,7 +40,7 @@ public class PortProfileManagerImpl { @DB public PortProfileVO addPortProfile(String portProfName, long vsmId, int vlanId, PortType pType, BindingType bType) { - // In this function, we create a port profile record in the port_profile table. + // In this function, we create a port profile record in the port_profile table. // First, check if a port profile with the given name already exists. If it does, throw an exception. if (_portProfileDao.findByName(portProfName) != null) { @@ -63,7 +63,7 @@ public class PortProfileManagerImpl { // In this function, we create a port profile record in the port_profile table. - // First, check if a port profile with the given name already exists. If it does, throw an exception. + // First, check if a port profile with the given name already exists. If it does, throw an exception. PortProfileVO portProfileObj; portProfileObj = _portProfileDao.findByName(portProfName); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java index 39868b5d21a..ce02bde9d99 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -63,7 +63,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA "Name of the default router template on LXC.", true, ConfigKey.Scope.Zone, null); public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M - public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz + public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz public static final boolean USE_POD_VLAN = false; /** diff --git a/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java b/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java index 894271d8312..a00fe59abd6 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java +++ b/server/src/com/cloud/servlet/ConsoleProxyPasswordBasedEncryptor.java @@ -170,7 +170,7 @@ public class ConsoleProxyPasswordBasedEncryptor { random.nextBytes(ivBytes); KeyIVPair keyIvPair = new KeyIVPair("8x/xUBgX0Up+3UEo39dSeG277JhVj31+ElHkN5+EC0Q=", "Y2SUiIN6JXTdKNK/ZMDyVtLB7gAM9MCCiyrP1xd3bSQ="); - //keyIvPair.setKeyBytes(keyBytes); + //keyIvPair.setKeyBytes(keyBytes); //keyIvPair.setIvBytes(ivBytes); Gson gson = new GsonBuilder().create(); diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index c39e11cb330..0a7f8fea000 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -432,7 +432,7 @@ public class ConsoleProxyServlet extends HttpServlet { Mac mac = Mac.getInstance("HmacSHA1"); long ts = normalizedHashTime.getTime(); - ts = ts / 60000; // round up to 1 minute + ts = ts / 60000; // round up to 1 minute String secretKey = s_ms.getHashKey(); SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1"); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 91908d56711..0e5b0c8852a 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -140,18 +140,18 @@ import com.cloud.vm.dao.VMInstanceDao; // // Possible secondary storage vm state transition cases -// Creating -> Destroyed -// Creating -> Stopped --> Starting -> Running -// HA -> Stopped -> Starting -> Running -// Migrating -> Running (if previous state is Running before it enters into Migrating state -// Migrating -> Stopped (if previous state is not Running before it enters into Migrating state) -// Running -> HA (if agent lost connection) -// Stopped -> Destroyed +// Creating -> Destroyed +// Creating -> Stopped --> Starting -> Running +// HA -> Stopped -> Starting -> Running +// Migrating -> Running (if previous state is Running before it enters into Migrating state +// Migrating -> Stopped (if previous state is not Running before it enters into Migrating state) +// Running -> HA (if agent lost connection) +// Stopped -> Destroyed // -// Creating state indicates of record creating and IP address allocation are ready, it is a transient -// state which will soon be switching towards Running if everything goes well. -// Stopped state indicates the readiness of being able to start (has storage and IP resources allocated) -// Starting state can only be entered from Stopped states +// Creating state indicates of record creating and IP address allocation are ready, it is a transient +// state which will soon be switching towards Running if everything goes well. +// Stopped state indicates the readiness of being able to start (has storage and IP resources allocated) +// Starting state can only be entered from Stopped states // // Starting, HA, Migrating, Creating and Running state are all counted as "Open" for available capacity calculation // because sooner or later, it will be driven into Running state @@ -212,7 +212,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar UserVmDetailsDao _vmDetailsDao; @Inject protected ResourceManager _resourceMgr; - //@Inject // TODO this is a very strange usage, a singleton class need to inject itself? + //@Inject // TODO this is a very strange usage, a singleton class need to inject itself? protected SecondaryStorageVmManager _ssvmMgr; @Inject NetworkDao _networkDao; @@ -1286,42 +1286,42 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar /* StartupCommand firstCmd = startup[0]; if (!(firstCmd instanceof StartupStorageCommand)) { - return null; + return null; } com.cloud.host.Host.Type type = null; StartupStorageCommand ssCmd = ((StartupStorageCommand) firstCmd); if (ssCmd.getHostType() == Host.Type.SecondaryStorageCmdExecutor) { - type = ssCmd.getHostType(); + type = ssCmd.getHostType(); } else { - if (ssCmd.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) { - type = Host.Type.SecondaryStorage; - if (resource != null && resource instanceof DummySecondaryStorageResource) { - host.setResource(null); - } - } else if (ssCmd.getResourceType() == Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE) { - type = Host.Type.LocalSecondaryStorage; - } else { - type = Host.Type.Storage; - } + if (ssCmd.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) { + type = Host.Type.SecondaryStorage; + if (resource != null && resource instanceof DummySecondaryStorageResource) { + host.setResource(null); + } + } else if (ssCmd.getResourceType() == Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE) { + type = Host.Type.LocalSecondaryStorage; + } else { + type = Host.Type.Storage; + } - final Map hostDetails = ssCmd.getHostDetails(); - if (hostDetails != null) { - if (details != null) { - details.putAll(hostDetails); - } else { - details = hostDetails; - } - } + final Map hostDetails = ssCmd.getHostDetails(); + if (hostDetails != null) { + if (details != null) { + details.putAll(hostDetails); + } else { + details = hostDetails; + } + } - host.setDetails(details); - host.setParent(ssCmd.getParent()); - host.setTotalSize(ssCmd.getTotalSize()); - host.setHypervisorType(HypervisorType.None); - host.setType(type); - if (ssCmd.getNfsShare() != null) { - host.setStorageUrl(ssCmd.getNfsShare()); - } + host.setDetails(details); + host.setParent(ssCmd.getParent()); + host.setTotalSize(ssCmd.getTotalSize()); + host.setHypervisorType(HypervisorType.None); + host.setType(type); + if (ssCmd.getNfsShare() != null) { + host.setStorageUrl(ssCmd.getNfsShare()); + } } */ return null; // no need to handle this event anymore since secondary storage is not in host table anymore. diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageVmManager.java b/server/src/com/cloud/storage/secondary/SecondaryStorageVmManager.java index e431b0e3133..a1af95c3ff2 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageVmManager.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageVmManager.java @@ -27,11 +27,11 @@ import com.cloud.vm.SecondaryStorageVmVO; public interface SecondaryStorageVmManager extends Manager { - public static final int DEFAULT_SS_VM_RAMSIZE = 256; // 256M - public static final int DEFAULT_SS_VM_CPUMHZ = 500; // 500 MHz + public static final int DEFAULT_SS_VM_RAMSIZE = 256; // 256M + public static final int DEFAULT_SS_VM_CPUMHZ = 500; // 500 MHz public static final int DEFAULT_SS_VM_MTUSIZE = 1500; - public static final int DEFAULT_SS_VM_CAPACITY = 50; // max command execution session per SSVM - public static final int DEFAULT_STANDBY_CAPACITY = 10; // standy capacity to reserve per zone + public static final int DEFAULT_SS_VM_CAPACITY = 50; // max command execution session per SSVM + public static final int DEFAULT_STANDBY_CAPACITY = 10; // standy capacity to reserve per zone public static final String ALERT_SUBJECT = "secondarystoragevm-alert"; diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java index e65642723b4..c4101152032 100755 --- a/server/src/com/cloud/test/DatabaseConfig.java +++ b/server/src/com/cloud/test/DatabaseConfig.java @@ -1085,7 +1085,7 @@ public class DatabaseConfig { } catch (SQLException ex) { s_logger.error("error creating vm template: " + ex); } finally { - txn.close(); + txn.close(); } */ /* @@ -1108,7 +1108,7 @@ public class DatabaseConfig { } catch (SQLException ex) { s_logger.error("error creating vm template: " + ex); } finally { - txn.close(); + txn.close(); } */ } @@ -1294,7 +1294,7 @@ public class DatabaseConfig { } catch (SQLException ex) { s_logger.error("error updating admin user", ex); } finally { - txn.close(); + txn.close(); } updateSql = "update account set domain_id = 1 where id = 1"; @@ -1305,7 +1305,7 @@ public class DatabaseConfig { } catch (SQLException ex) { s_logger.error("error updating system user", ex); } finally { - txn.close(); + txn.close(); } */ } diff --git a/server/src/com/cloud/test/IPRangeConfig.java b/server/src/com/cloud/test/IPRangeConfig.java index a88780361bd..084bce3bb94 100755 --- a/server/src/com/cloud/test/IPRangeConfig.java +++ b/server/src/com/cloud/test/IPRangeConfig.java @@ -568,30 +568,30 @@ public class IPRangeConfig { "Unable to start DB connection to read guest cidr network. Please contact Cloud Support."); } -// public static String getGuestIpNetwork() { -// return DatabaseConfig.getDatabaseValueString("SELECT * FROM `cloud`.`configuration` WHERE name = \"guest.ip.network\"", "value", -// "Unable to start DB connection to read guest IP network. Please contact Cloud Support."); -// } -// -// public static String getGuestNetmask() { -// return DatabaseConfig.getDatabaseValueString("SELECT * FROM `cloud`.`configuration` WHERE name = \"guest.netmask\"", "value", -// "Unable to start DB connection to read guest netmask. Please contact Cloud Support."); -// } +// public static String getGuestIpNetwork() { +// return DatabaseConfig.getDatabaseValueString("SELECT * FROM `cloud`.`configuration` WHERE name = \"guest.ip.network\"", "value", +// "Unable to start DB connection to read guest IP network. Please contact Cloud Support."); +// } +// +// public static String getGuestNetmask() { +// return DatabaseConfig.getDatabaseValueString("SELECT * FROM `cloud`.`configuration` WHERE name = \"guest.netmask\"", "value", +// "Unable to start DB connection to read guest netmask. Please contact Cloud Support."); +// } -// public static String getGuestSubnet() { -// String guestIpNetwork = getGuestIpNetwork(); -// String guestNetmask = getGuestNetmask(); -// -// if (guestIpNetwork == null || guestIpNetwork.isEmpty()) printError("Please enter a valid guest IP network address."); -// if (guestNetmask == null || guestNetmask.isEmpty()) printError("Please enter a valid guest IP network netmask"); -// -// return NetUtils.getSubNet(guestIpNetwork, guestNetmask); -// } +// public static String getGuestSubnet() { +// String guestIpNetwork = getGuestIpNetwork(); +// String guestNetmask = getGuestNetmask(); +// +// if (guestIpNetwork == null || guestIpNetwork.isEmpty()) printError("Please enter a valid guest IP network address."); +// if (guestNetmask == null || guestNetmask.isEmpty()) printError("Please enter a valid guest IP network netmask"); +// +// return NetUtils.getSubNet(guestIpNetwork, guestNetmask); +// } -// public static long getGuestCidrSize() { -// String guestNetmask = getGuestNetmask(); -// return NetUtils.getCidrSize(guestNetmask); -// } +// public static long getGuestCidrSize() { +// String guestNetmask = getGuestNetmask(); +// return NetUtils.getCidrSize(guestNetmask); +// } public static boolean validCIDR(final String cidr) { if (cidr == null || cidr.isEmpty()) { diff --git a/server/src/com/cloud/test/PodZoneConfig.java b/server/src/com/cloud/test/PodZoneConfig.java index 22c44a58027..4800e34cdc6 100644 --- a/server/src/com/cloud/test/PodZoneConfig.java +++ b/server/src/com/cloud/test/PodZoneConfig.java @@ -75,7 +75,7 @@ public class PodZoneConfig { private String checkPodCidrSubnets(long dcId, HashMap> currentPodCidrSubnets) { -// DataCenterDao _dcDao = null; +// DataCenterDao _dcDao = null; // final ComponentLocator locator = ComponentLocator.getLocator("management-server"); // _dcDao = locator.getDao(DataCenterDao.class); @@ -86,7 +86,7 @@ public class PodZoneConfig { String zoneName = PodZoneConfig.getZoneName(dcId); //get the guest network cidr and guest netmask from the zone -// DataCenterVO dcVo = _dcDao.findById(dcId); +// DataCenterVO dcVo = _dcDao.findById(dcId); String guestNetworkCidr = IPRangeConfig.getGuestNetworkCidr(dcId); @@ -236,9 +236,9 @@ public class PodZoneConfig { String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask); List vlans = _vlanDao.findByZone(zoneId); for (VlanVO vlan : vlans) { - String currentVlanSubnet = NetUtils.getSubNet(vlan.getVlanGateway(), vlan.getVlanNetmask()); - if (newVlanSubnet.equals(currentVlanSubnet)) - return genReturnList("false", "The VLAN with ID " + vlan.getVlanId() + " in zone " + zone + " has the same subnet. Please specify a different gateway/netmask."); + String currentVlanSubnet = NetUtils.getSubNet(vlan.getVlanGateway(), vlan.getVlanNetmask()); + if (newVlanSubnet.equals(currentVlanSubnet)) + return genReturnList("false", "The VLAN with ID " + vlan.getVlanId() + " in zone " + zone + " has the same subnet. Please specify a different gateway/netmask."); } */ @@ -259,20 +259,20 @@ public class PodZoneConfig { /* else { - // Check if a VLAN actually exists in the specified zone - long vlanDbId = getVlanDbId(zone, vlanId); - if (vlanDbId == -1) - return genReturnList("false", "A VLAN with ID " + vlanId + " does not exist in zone " + zone); + // Check if a VLAN actually exists in the specified zone + long vlanDbId = getVlanDbId(zone, vlanId); + if (vlanDbId == -1) + return genReturnList("false", "A VLAN with ID " + vlanId + " does not exist in zone " + zone); - // Check if there are any public IPs that are in the specified vlan. - List ips = _publicIpAddressDao.listByVlanDbId(vlanDbId); - if (ips.size() != 0) - return genReturnList("false", "Please delete all IP addresses that are in VLAN " + vlanId + " before deleting the VLAN."); + // Check if there are any public IPs that are in the specified vlan. + List ips = _publicIpAddressDao.listByVlanDbId(vlanDbId); + if (ips.size() != 0) + return genReturnList("false", "Please delete all IP addresses that are in VLAN " + vlanId + " before deleting the VLAN."); - // Delete the vlan - _vlanDao.delete(vlanDbId); + // Delete the vlan + _vlanDao.delete(vlanDbId); - return genReturnList("true", "Successfully deleted VLAN."); + return genReturnList("true", "Successfully deleted VLAN."); } */ } diff --git a/server/test/com/cloud/keystore/KeystoreTest.java b/server/test/com/cloud/keystore/KeystoreTest.java index 83355a6ba8f..612f035cce2 100644 --- a/server/test/com/cloud/keystore/KeystoreTest.java +++ b/server/test/com/cloud/keystore/KeystoreTest.java @@ -74,7 +74,7 @@ public class KeystoreTest extends TestCase { /* public void testKeystoreSave() throws Exception { - KeystoreVO ksVo; + KeystoreVO ksVo; ComponentLocator locator = ComponentLocator.getCurrentLocator(); @@ -98,15 +98,15 @@ public class KeystoreTest extends TestCase { } public void testStripeKey() throws Exception { - Pattern regex = Pattern.compile("(^[\\-]+[^\\-]+[\\-]+[\\n]?)([^\\-]+)([\\-]+[^\\-]+[\\-]+$)"); - Matcher m = regex.matcher("-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAm4bLUORp9oM65GV9XrPrbs+K563DjUR1M8mP1HaE+Y4lX5pk\nvQjC/xoEqSs5pxDDWXAkoexvxij8A4AWcsKU1Q+ep2E+GcytBoz8XINGvgb8cQNn\n/4PlVWKp7j5SDDNCfleYvmiRn8k6P4mxVJOHKzwb/IwQcKghyqAF1w==\n-----END RSA PRIVATE KEY-----"); - if(m.find()) { - String content = m.group(2); - assertTrue(content.startsWith("MIIEpAIBAAKCAQE")); - assertTrue(content.endsWith("KghyqAF1w==\n")); - } else { - assertTrue(false); - } + Pattern regex = Pattern.compile("(^[\\-]+[^\\-]+[\\-]+[\\n]?)([^\\-]+)([\\-]+[^\\-]+[\\-]+$)"); + Matcher m = regex.matcher("-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAm4bLUORp9oM65GV9XrPrbs+K563DjUR1M8mP1HaE+Y4lX5pk\nvQjC/xoEqSs5pxDDWXAkoexvxij8A4AWcsKU1Q+ep2E+GcytBoz8XINGvgb8cQNn\n/4PlVWKp7j5SDDNCfleYvmiRn8k6P4mxVJOHKzwb/IwQcKghyqAF1w==\n-----END RSA PRIVATE KEY-----"); + if(m.find()) { + String content = m.group(2); + assertTrue(content.startsWith("MIIEpAIBAAKCAQE")); + assertTrue(content.endsWith("KghyqAF1w==\n")); + } else { + assertTrue(false); + } } public void testKeystoreManager() throws Exception { @@ -122,10 +122,10 @@ public class KeystoreTest extends TestCase { assertTrue(ksBits != null); try { - KeyStore ks = CertificateHelper.loadKeystore(ksBits, "vmops.com"); - assertTrue(ks != null); + KeyStore ks = CertificateHelper.loadKeystore(ksBits, "vmops.com"); + assertTrue(ks != null); } catch(Exception e) { - assertTrue(false); + assertTrue(false); } KeystoreDao ksDao = locator.getDao(KeystoreDao.class); @@ -137,18 +137,18 @@ public class KeystoreTest extends TestCase { UserVmResponse vm = new UserVmResponse(); vm.setId(Long.toString(3L)); /* - vm.setAccountName("admin"); - vm.setName("i-2-3-KY"); - vm.setDisplayName("i-2-3-KY"); - vm.setDomainId(1L); - vm.setDomainName("ROOT"); - vm.setCreated(new Date()); - vm.setState("Running"); - vm.setZoneId(1L); - vm.setZoneName("KY"); - vm.setHostId(1L); + vm.setAccountName("admin"); + vm.setName("i-2-3-KY"); + vm.setDisplayName("i-2-3-KY"); + vm.setDomainId(1L); + vm.setDomainName("ROOT"); + vm.setCreated(new Date()); + vm.setState("Running"); + vm.setZoneId(1L); + vm.setZoneName("KY"); + vm.setHostId(1L); - vm.setObjectName("virtualmachine"); + vm.setObjectName("virtualmachine"); */ String result = ApiSerializerHelper.toSerializedString(vm); // String result = "org.apache.cloudstack.api.response.UserVmResponse/virtualmachine/{\"id\":{\"_tableName\":\"vm_instance\",\"_value\":3},\"name\":\"i-2-3-KY\",\"displayname\":\"i-2-3-KY\",\"account\":\"admin\",\"projectid\":{\"_tableName\":\"projects\"},\"domainid\":{\"_tableName\":\"domain\",\"_value\":1},\"domain\":\"ROOT\",\"created\":\"2011-11-02T21:54:07-0700\",\"state\":\"Running\",\"haenable\":false,\"groupid\":{\"_tableName\":\"instance_group\"},\"zoneid\":{\"_tableName\":\"data_center\",\"_value\":1},\"zonename\":\"KY\",\"hostid\":{\"_tableName\":\"host\",\"_value\":1},\"hostname\":\"xenserver-basic\",\"templateid\":{\"_tableName\":\"vm_template\",\"_value\":2},\"templatename\":\"CentOS 5.3(64-bit) no GUI (XenServer)\",\"templatedisplaytext\":\"CentOS 5.3(64-bit) no GUI (XenServer)\",\"passwordenabled\":false,\"isoid\":{\"_tableName\":\"vm_template\"},\"serviceofferingid\":{\"_tableName\":\"disk_offering\",\"_value\":7},\"serviceofferingname\":\"Small Instance\",\"cpunumber\":1,\"cpuspeed\":500,\"memory\":512,\"guestosid\":{\"_tableName\":\"guest_os\",\"_value\":12},\"rootdeviceid\":0,\"rootdevicetype\":\"NetworkFilesystem\",\"securitygroup\":[],\"jobid\":{\"_tableName\":\"async_job\"},\"nic\":[{\"id\":7,\"networkid\":200,\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\",\"ipaddress\":\"10.1.1.116\",\"isolationuri\":\"vlan://1699\",\"broadcasturi\":\"vlan://1699\",\"traffictype\":\"Guest\",\"type\":\"Virtual\",\"isdefault\":true,\"macaddress\":\"02:00:39:a7:00:01\"}],\"hypervisor\":\"XenServer\"}"; diff --git a/server/test/com/cloud/network/vpn/RemoteAccessVpnTest.java b/server/test/com/cloud/network/vpn/RemoteAccessVpnTest.java index e1ca0ee012c..0ca3f6e44f8 100644 --- a/server/test/com/cloud/network/vpn/RemoteAccessVpnTest.java +++ b/server/test/com/cloud/network/vpn/RemoteAccessVpnTest.java @@ -23,34 +23,34 @@ import org.junit.Test; public class RemoteAccessVpnTest { private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnTest.class); -// private static void addDaos(MockComponentLocator locator) { -// locator.addDao("AccountDao", AccountDaoImpl.class); -// locator.addDao("VpnUserDao", VpnUserDaoImpl.class); -// locator.addDao("FirewallRulesDao", FirewallRulesDaoImpl.class); -// locator.addDao("IPAddressDao", IPAddressDaoImpl.class); -// locator.addDao("DomainDao", DomainDaoImpl.class); -// locator.addDao("UsageEventDao", UsageEventDaoImpl.class); -// locator.addDao("RemoteAccessVpnDao", RemoteAccessVpnDaoImpl.class); -// locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class); +// private static void addDaos(MockComponentLocator locator) { +// locator.addDao("AccountDao", AccountDaoImpl.class); +// locator.addDao("VpnUserDao", VpnUserDaoImpl.class); +// locator.addDao("FirewallRulesDao", FirewallRulesDaoImpl.class); +// locator.addDao("IPAddressDao", IPAddressDaoImpl.class); +// locator.addDao("DomainDao", DomainDaoImpl.class); +// locator.addDao("UsageEventDao", UsageEventDaoImpl.class); +// locator.addDao("RemoteAccessVpnDao", RemoteAccessVpnDaoImpl.class); +// locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class); // -// } -// -// private static void addManagers(MockComponentLocator locator) { -// locator.addManager("AccountManager", MockAccountManagerImpl.class); -// locator.addManager("DomainManager", MockDomainManagerImpl.class); -// locator.addManager("NetworkManager", MockNetworkManagerImpl.class); -// locator.addManager("NetworkModel", MockNetworkModelImpl.class); -// locator.addManager("RulesManager", MockRulesManagerImpl.class); -// locator.addManager("FirewallManager", MockFirewallManagerImpl.class); -// } +// } +// +// private static void addManagers(MockComponentLocator locator) { +// locator.addManager("AccountManager", MockAccountManagerImpl.class); +// locator.addManager("DomainManager", MockDomainManagerImpl.class); +// locator.addManager("NetworkManager", MockNetworkManagerImpl.class); +// locator.addManager("NetworkModel", MockNetworkModelImpl.class); +// locator.addManager("RulesManager", MockRulesManagerImpl.class); +// locator.addManager("FirewallManager", MockFirewallManagerImpl.class); +// } -// @Before -// public void setUp() { -// locator = new MockComponentLocator("management-server"); -// addDaos(locator); -// addManagers(locator); -// s_logger.info("Finished setUp"); -// } +// @Before +// public void setUp() { +// locator = new MockComponentLocator("management-server"); +// addDaos(locator); +// addManagers(locator); +// s_logger.info("Finished setUp"); +// } @After public void tearDown() throws Exception { @@ -58,19 +58,19 @@ public class RemoteAccessVpnTest { @Test public void testInjected() throws Exception { -// List>> list = -// new ArrayList>>(); -// list.add(new Pair>("RemoteAccessVPNServiceProvider", MockRemoteAccessVPNServiceProvider.class)); -// locator.addAdapterChain(RemoteAccessVPNServiceProvider.class, list); -// s_logger.info("Finished add adapter"); -// locator.makeActive(new DefaultInterceptorLibrary()); -// s_logger.info("Finished make active"); -// RemoteAccessVpnManagerImpl vpnMgr = ComponentLocator.inject(RemoteAccessVpnManagerImpl.class); -// s_logger.info("Finished inject"); -// Assert.assertTrue(vpnMgr.configure("RemoteAccessVpnMgr",new HashMap()) ); -// Assert.assertTrue(vpnMgr.start()); -// int numProviders = vpnMgr.getRemoteAccessVPNServiceProviders().size(); -// Assert.assertTrue(numProviders > 0); +// List>> list = +// new ArrayList>>(); +// list.add(new Pair>("RemoteAccessVPNServiceProvider", MockRemoteAccessVPNServiceProvider.class)); +// locator.addAdapterChain(RemoteAccessVPNServiceProvider.class, list); +// s_logger.info("Finished add adapter"); +// locator.makeActive(new DefaultInterceptorLibrary()); +// s_logger.info("Finished make active"); +// RemoteAccessVpnManagerImpl vpnMgr = ComponentLocator.inject(RemoteAccessVpnManagerImpl.class); +// s_logger.info("Finished inject"); +// Assert.assertTrue(vpnMgr.configure("RemoteAccessVpnMgr",new HashMap()) ); +// Assert.assertTrue(vpnMgr.start()); +// int numProviders = vpnMgr.getRemoteAccessVPNServiceProviders().size(); +// Assert.assertTrue(numProviders > 0); } } diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/MockServer.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/MockServer.java index b1419174911..4db900c1c6b 100644 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/MockServer.java +++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/MockServer.java @@ -41,157 +41,157 @@ public class MockServer implements Runnable { protected boolean verbose = System.getProperty("rdpclient.MockServer.debug", "false").equals("true"); public MockServer(Packet packets[]) { - this.packets = packets; + this.packets = packets; } public void start() throws IOException { - serverSocket = new ServerSocket(0); + serverSocket = new ServerSocket(0); - shutdown = false; - exception = null; - shutdowned = false; + shutdown = false; + exception = null; + shutdowned = false; - new Thread(this).start(); + new Thread(this).start(); } public void run() { - try { - Socket socket = serverSocket.accept(); + try { + Socket socket = serverSocket.accept(); - InputStream is = socket.getInputStream(); - OutputStream os = socket.getOutputStream(); + InputStream is = socket.getInputStream(); + OutputStream os = socket.getOutputStream(); - try { - for (int i = 0; i < packets.length && !shutdown; i++) { + try { + for (int i = 0; i < packets.length && !shutdown; i++) { - Packet packet = packets[i]; - switch (packet.type) { - case CLIENT: { - // Read client data and compare it with mock data - // (unless "ignore" option is set) - byte actualData[] = new byte[packet.data.length]; - int actualDataLength = is.read(actualData); + Packet packet = packets[i]; + switch (packet.type) { + case CLIENT: { + // Read client data and compare it with mock data + // (unless "ignore" option is set) + byte actualData[] = new byte[packet.data.length]; + int actualDataLength = is.read(actualData); - if (verbose) - System.out.println("[" + this + "] INFO: Data is read: {" + Arrays.toString(Arrays.copyOf(actualData, actualDataLength)) + "}."); + if (verbose) + System.out.println("[" + this + "] INFO: Data is read: {" + Arrays.toString(Arrays.copyOf(actualData, actualDataLength)) + "}."); - if (!packet.ignore) { - // Compare actual data with expected data - if (actualDataLength != packet.data.length) { - throw new AssertionError("Actual length of client request for packet #" + (i + 1) + " (\"" + packet.id + "\")" - + " does not match length of expected client request. Actual length: " + actualDataLength + ", expected legnth: " - + packet.data.length + "."); - } + if (!packet.ignore) { + // Compare actual data with expected data + if (actualDataLength != packet.data.length) { + throw new AssertionError("Actual length of client request for packet #" + (i + 1) + " (\"" + packet.id + "\")" + + " does not match length of expected client request. Actual length: " + actualDataLength + ", expected legnth: " + + packet.data.length + "."); + } - for (int j = 0; j < packet.data.length; j++) { + for (int j = 0; j < packet.data.length; j++) { - if (packet.data[j] != actualData[j]) { - throw new AssertionError("Actual byte #" + (j + 1) + " of client request for packet #" + (i + 1) + " (\"" + packet.id - + "\")" + " does not match corresponding byte of expected client request. Actual byte: " + actualData[j] - + ", expected byte: " + packet.data[j] + "."); - } - } - } - break; - } - case SERVER: { - // Send mock data to client - os.write(packet.data); + if (packet.data[j] != actualData[j]) { + throw new AssertionError("Actual byte #" + (j + 1) + " of client request for packet #" + (i + 1) + " (\"" + packet.id + + "\")" + " does not match corresponding byte of expected client request. Actual byte: " + actualData[j] + + ", expected byte: " + packet.data[j] + "."); + } + } + } + break; + } + case SERVER: { + // Send mock data to client + os.write(packet.data); - if (verbose) - System.out.println("[" + this + "] INFO: Data is written: {" + Arrays.toString(packet.data) + "}."); + if (verbose) + System.out.println("[" + this + "] INFO: Data is written: {" + Arrays.toString(packet.data) + "}."); - break; - } - case UPGRADE_TO_SSL: { - // Attach SSL context to socket + break; + } + case UPGRADE_TO_SSL: { + // Attach SSL context to socket - final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); - SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, null, serverSocket.getLocalPort(), true); - sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites()); - sslSocket.setUseClientMode(false); - sslSocket.startHandshake(); - is = sslSocket.getInputStream(); - os = sslSocket.getOutputStream(); + final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, null, serverSocket.getLocalPort(), true); + sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites()); + sslSocket.setUseClientMode(false); + sslSocket.startHandshake(); + is = sslSocket.getInputStream(); + os = sslSocket.getOutputStream(); - break; - } - default: - throw new RuntimeException("Unknown packet type: " + packet.type); - } + break; + } + default: + throw new RuntimeException("Unknown packet type: " + packet.type); + } - } - } finally { - try { - is.close(); - } catch (Throwable e) { - } - try { - os.close(); - } catch (Throwable e) { - } - try { - socket.close(); - } catch (Throwable e) { - } - try { - serverSocket.close(); - } catch (Throwable e) { - } - } - } catch (Throwable e) { - System.err.println("Error in mock server: " + e.getMessage()); - e.printStackTrace(System.err); - exception = e; - } - shutdowned = true; - if (verbose) - System.out.println("[" + this + "] INFO: Mock server shutdowned."); + } + } finally { + try { + is.close(); + } catch (Throwable e) { + } + try { + os.close(); + } catch (Throwable e) { + } + try { + socket.close(); + } catch (Throwable e) { + } + try { + serverSocket.close(); + } catch (Throwable e) { + } + } + } catch (Throwable e) { + System.err.println("Error in mock server: " + e.getMessage()); + e.printStackTrace(System.err); + exception = e; + } + shutdowned = true; + if (verbose) + System.out.println("[" + this + "] INFO: Mock server shutdowned."); } public void shutdown() { - shutdown = true; + shutdown = true; } public InetSocketAddress getAddress() { - return (InetSocketAddress) serverSocket.getLocalSocketAddress(); + return (InetSocketAddress) serverSocket.getLocalSocketAddress(); } public Throwable getException() { - return exception; + return exception; } public static class Packet { - public static enum PacketType { - SERVER, CLIENT, UPGRADE_TO_SSL; - } + public static enum PacketType { + SERVER, CLIENT, UPGRADE_TO_SSL; + } - public String id = ""; + public String id = ""; - public Packet() { - } + public Packet() { + } - public Packet(String id) { - this.id = id; - } + public Packet(String id) { + this.id = id; + } - public PacketType type; + public PacketType type; - public boolean ignore = false; + public boolean ignore = false; - public byte data[]; + public byte data[]; } public boolean isShutdowned() { - return shutdowned; + return shutdowned; } public void waitUntilShutdowned(long timeToWaitMiliseconds) throws InterruptedException { - long deadline = System.currentTimeMillis() + timeToWaitMiliseconds; - while (!shutdowned && System.currentTimeMillis() < deadline) { - Thread.sleep(10); - } + long deadline = System.currentTimeMillis() + timeToWaitMiliseconds; + while (!shutdowned && System.currentTimeMillis() < deadline) { + Thread.sleep(10); + } } } diff --git a/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java b/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java index 89eed8a7c44..ee286f01ee6 100644 --- a/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java +++ b/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java @@ -36,154 +36,154 @@ public class MockServerTest extends TestCase { public void testIsMockServerCanRespond() throws Exception { - final byte[] mockClientData = new byte[] { 0x01, 0x02, 0x03 }; - final byte[] mockServerData = new byte[] { 0x03, 0x02, 0x01 }; + final byte[] mockClientData = new byte[] { 0x01, 0x02, 0x03 }; + final byte[] mockServerData = new byte[] { 0x03, 0x02, 0x01 }; - MockServer server = new MockServer(new Packet[] { new Packet("Client hello") { - { - type = CLIENT; - data = mockClientData; - } - }, new Packet("Server hello") { - { - type = SERVER; - data = mockServerData; - } - } }); + MockServer server = new MockServer(new Packet[] { new Packet("Client hello") { + { + type = CLIENT; + data = mockClientData; + } + }, new Packet("Server hello") { + { + type = SERVER; + data = mockServerData; + } + } }); - server.start(); + server.start(); - // Connect to server and send and receive mock data + // Connect to server and send and receive mock data - Socket socket = SocketFactory.getDefault().createSocket(); - try { - socket.connect(server.getAddress()); + Socket socket = SocketFactory.getDefault().createSocket(); + try { + socket.connect(server.getAddress()); - InputStream is = socket.getInputStream(); - OutputStream os = socket.getOutputStream(); + InputStream is = socket.getInputStream(); + OutputStream os = socket.getOutputStream(); - // Write mock data to server - os.write(mockClientData); + // Write mock data to server + os.write(mockClientData); - // Read data from server - byte actualData[] = new byte[mockServerData.length]; - int actualDataLength = is.read(actualData); + // Read data from server + byte actualData[] = new byte[mockServerData.length]; + int actualDataLength = is.read(actualData); - // Compare mock data with actual data - assertEquals("Unexpected length of actual data read from server.", mockServerData.length, actualDataLength); + // Compare mock data with actual data + assertEquals("Unexpected length of actual data read from server.", mockServerData.length, actualDataLength); - for (int i = 0; i < actualDataLength; i++) { - assertEquals("Unexpected byte #" + i + " in response", mockServerData[i], actualData[i]); - } + for (int i = 0; i < actualDataLength; i++) { + assertEquals("Unexpected byte #" + i + " in response", mockServerData[i], actualData[i]); + } - server.waitUntilShutdowned(1 * 1000 /* up to 1 second */); + server.waitUntilShutdowned(1 * 1000 /* up to 1 second */); - assertNull("Unexpected exception at mock server side.", server.getException()); - assertTrue("Server is not shutdowned at after conversation.", server.isShutdowned()); + assertNull("Unexpected exception at mock server side.", server.getException()); + assertTrue("Server is not shutdowned at after conversation.", server.isShutdowned()); - } finally { - socket.close(); - } + } finally { + socket.close(); + } } public void testIsMockServerCanUpgradeConnectionToSsl() throws Exception { - final byte[] mockClientData1 = new byte[] { 0x01, 0x02, 0x03 }; - final byte[] mockServerData1 = new byte[] { 0x03, 0x02, 0x01 }; + final byte[] mockClientData1 = new byte[] { 0x01, 0x02, 0x03 }; + final byte[] mockServerData1 = new byte[] { 0x03, 0x02, 0x01 }; - final byte[] mockClientData2 = new byte[] { 0x02, 0x04, 0x02, 0x03 }; - final byte[] mockServerData2 = new byte[] { 0x02, 0x02, 0x01, 0x04 }; + final byte[] mockClientData2 = new byte[] { 0x02, 0x04, 0x02, 0x03 }; + final byte[] mockServerData2 = new byte[] { 0x02, 0x02, 0x01, 0x04 }; - MockServer server = new MockServer(new Packet[] { new Packet("Client hello") { - { - type = CLIENT; - data = mockClientData1; - } - }, new Packet("Server hello") { - { - type = SERVER; - data = mockServerData1; - } - }, new Packet("Upgrade connection to SSL") { - { - type = UPGRADE_TO_SSL; - } - }, new Packet("Client data over SSL") { - { - type = CLIENT; - data = mockClientData2; - } - }, new Packet("Server data over SSL") { - { - type = SERVER; - data = mockServerData2; - } - } }); + MockServer server = new MockServer(new Packet[] { new Packet("Client hello") { + { + type = CLIENT; + data = mockClientData1; + } + }, new Packet("Server hello") { + { + type = SERVER; + data = mockServerData1; + } + }, new Packet("Upgrade connection to SSL") { + { + type = UPGRADE_TO_SSL; + } + }, new Packet("Client data over SSL") { + { + type = CLIENT; + data = mockClientData2; + } + }, new Packet("Server data over SSL") { + { + type = SERVER; + data = mockServerData2; + } + } }); - server.start(); + server.start(); - // Connect to server and send and receive mock data + // Connect to server and send and receive mock data - Socket socket = SocketFactory.getDefault().createSocket(); - try { - InetSocketAddress address = server.getAddress(); - socket.connect(address); + Socket socket = SocketFactory.getDefault().createSocket(); + try { + InetSocketAddress address = server.getAddress(); + socket.connect(address); - // Send hello data over plain connection - { - InputStream is = socket.getInputStream(); - OutputStream os = socket.getOutputStream(); + // Send hello data over plain connection + { + InputStream is = socket.getInputStream(); + OutputStream os = socket.getOutputStream(); - // Write mock data to server - os.write(mockClientData1); + // Write mock data to server + os.write(mockClientData1); - // Read data from server - byte actualData[] = new byte[mockServerData1.length]; - int actualDataLength = is.read(actualData); + // Read data from server + byte actualData[] = new byte[mockServerData1.length]; + int actualDataLength = is.read(actualData); - // Compare mock data with actual data - assertEquals("Unexpected length of actual data read from server.", mockServerData1.length, actualDataLength); + // Compare mock data with actual data + assertEquals("Unexpected length of actual data read from server.", mockServerData1.length, actualDataLength); - for (int i = 0; i < actualDataLength; i++) { - assertEquals("Unexpected byte #" + i + " in response", mockServerData1[i], actualData[i]); - } - } + for (int i = 0; i < actualDataLength; i++) { + assertEquals("Unexpected byte #" + i + " in response", mockServerData1[i], actualData[i]); + } + } - // Upgrade connection to SSL and send mock data - { - //System.setProperty("javax.net.debug", "ssl"); + // Upgrade connection to SSL and send mock data + { + //System.setProperty("javax.net.debug", "ssl"); - final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); - SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, address.getHostName(), address.getPort(), true); - sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites()); - sslSocket.startHandshake(); + final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, address.getHostName(), address.getPort(), true); + sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites()); + sslSocket.startHandshake(); - InputStream is = sslSocket.getInputStream(); - OutputStream os = sslSocket.getOutputStream(); + InputStream is = sslSocket.getInputStream(); + OutputStream os = sslSocket.getOutputStream(); - // Write mock data to server - os.write(mockClientData2); + // Write mock data to server + os.write(mockClientData2); - // Read data from server - byte actualData[] = new byte[mockServerData2.length]; - int actualDataLength = is.read(actualData); + // Read data from server + byte actualData[] = new byte[mockServerData2.length]; + int actualDataLength = is.read(actualData); - // Compare mock data with actual data - assertEquals("Unexpected length of actual data read from server.", mockServerData2.length, actualDataLength); + // Compare mock data with actual data + assertEquals("Unexpected length of actual data read from server.", mockServerData2.length, actualDataLength); - for (int i = 0; i < actualDataLength; i++) { - assertEquals("Unexpected byte #" + i + " in response", mockServerData2[i], actualData[i]); - } + for (int i = 0; i < actualDataLength; i++) { + assertEquals("Unexpected byte #" + i + " in response", mockServerData2[i], actualData[i]); + } - } + } - server.waitUntilShutdowned(1 * 1000 /* up to 1 second */); + server.waitUntilShutdowned(1 * 1000 /* up to 1 second */); - assertNull("Unexpected exception at mock server side.", server.getException()); - assertTrue("Server is not shutdowned at after conversation.", server.isShutdowned()); - } finally { - socket.close(); - } + assertNull("Unexpected exception at mock server side.", server.getException()); + assertTrue("Server is not shutdowned at after conversation.", server.isShutdowned()); + } finally { + socket.close(); + } } } diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java index 56827c96e08..1fea310159a 100644 --- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java +++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java @@ -176,7 +176,7 @@ public class ConsoleProxyPasswordBasedEncryptor { random.nextBytes(ivBytes); KeyIVPair keyIvPair = new KeyIVPair("8x/xUBgX0Up+3UEo39dSeG277JhVj31+ElHkN5+EC0Q=", "Y2SUiIN6JXTdKNK/ZMDyVtLB7gAM9MCCiyrP1xd3bSQ="); - //keyIvPair.setKeyBytes(keyBytes); + //keyIvPair.setKeyBytes(keyBytes); //keyIvPair.setIvBytes(ivBytes); Gson gson = new GsonBuilder().create(); diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManager.java b/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManager.java index 3badaae1880..11080612d34 100644 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManager.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManager.java @@ -43,7 +43,7 @@ public interface DownloadManager extends Manager { * @param url the url from where to download from * @param hvm whether the template is a hardware virtual machine * @param accountId the accountId of the iso owner (null if public iso) - * @param descr description of the template + * @param descr description of the template * @param user username used for authentication to the server * @param password password used for authentication to the server * @param maxDownloadSizeInBytes (optional) max download size for the template, in bytes. diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java b/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java index ef7d0c6df81..6af9da4f015 100755 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java @@ -611,21 +611,21 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager { command = new Script("/bin/bash", s_logger); command.add("-c"); command.add("iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j DROP;" + - "iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j HTTP;" + - "iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j DROP;" + - "iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j HTTP;" + - "iptables -F HTTP;" + - "iptables -X HTTP;" + - "iptables -N HTTP;" + - "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j DROP;" + - "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j DROP;" + - "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j HTTP;" + + "iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j HTTP;" + + "iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j DROP;" + + "iptables -D INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j HTTP;" + + "iptables -F HTTP;" + + "iptables -X HTTP;" + + "iptables -N HTTP;" + + "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j DROP;" + + "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j DROP;" + + "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j HTTP;" + "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j HTTP;"); result = command.execute(); if (result != null) { - s_logger.warn("Error in opening up httpd port err=" + result ); - return false; + s_logger.warn("Error in opening up httpd port err=" + result ); + return false; }*/ command = new Script("/bin/bash", s_logger); diff --git a/test/src/com/cloud/test/longrun/BuildGuestNetwork.java b/test/src/com/cloud/test/longrun/BuildGuestNetwork.java index 3775e19ab9b..1208dc33dfb 100644 --- a/test/src/com/cloud/test/longrun/BuildGuestNetwork.java +++ b/test/src/com/cloud/test/longrun/BuildGuestNetwork.java @@ -27,102 +27,102 @@ import org.apache.log4j.Logger; public class BuildGuestNetwork { - public static final Logger s_logger= Logger.getLogger(BuildGuestNetwork.class.getClass()); - private static final int _apiPort=8096; - private static final int _developerPort=8080; - private static final String _apiUrl = "/client/api"; - private static int numVM=1; - private static long zoneId=-1L; - private static long templateId=3; - private static long serviceOfferingId=1; - + public static final Logger s_logger= Logger.getLogger(BuildGuestNetwork.class.getClass()); + private static final int _apiPort=8096; + private static final int _developerPort=8080; + private static final String _apiUrl = "/client/api"; + private static int numVM=1; + private static long zoneId=-1L; + private static long templateId=3; + private static long serviceOfferingId=1; + - public static void main (String[] args){ - - List argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - String host = "http://localhost"; - int numThreads = 1; - - while (iter.hasNext()){ - String arg = iter.next(); - if (arg.equals("-h")){ - host="http://"+iter.next(); - } - if (arg.equals("-t")){ - numThreads=Integer.parseInt(iter.next()); - } - if (arg.equals("-n")){ - numVM=Integer.parseInt(iter.next()); - } - if (arg.equals("-z")){ - zoneId=Integer.parseInt(iter.next()); - } - - if (arg.equals("-e")){ - templateId=Integer.parseInt(iter.next()); - } - - if (arg.equals("-s")){ - serviceOfferingId=Integer.parseInt(iter.next()); - } - } - - final String server = host + ":" + _apiPort + "/"; - final String developerServer = host + ":" + _developerPort + _apiUrl; - s_logger.info("Starting test in "+numThreads+" thread(s). Each thread is launching "+numVM+" VMs"); - - for (int i=0; i argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + String host = "http://localhost"; + int numThreads = 1; + + while (iter.hasNext()){ + String arg = iter.next(); + if (arg.equals("-h")){ + host="http://"+iter.next(); + } + if (arg.equals("-t")){ + numThreads=Integer.parseInt(iter.next()); + } + if (arg.equals("-n")){ + numVM=Integer.parseInt(iter.next()); + } + if (arg.equals("-z")){ + zoneId=Integer.parseInt(iter.next()); + } + + if (arg.equals("-e")){ + templateId=Integer.parseInt(iter.next()); + } + + if (arg.equals("-s")){ + serviceOfferingId=Integer.parseInt(iter.next()); + } + } + + final String server = host + ":" + _apiPort + "/"; + final String developerServer = host + ":" + _developerPort + _apiUrl; + s_logger.info("Starting test in "+numThreads+" thread(s). Each thread is launching "+numVM+" VMs"); + + for (int i=0; i argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - String host = "http://localhost"; - int numThreads = 1; - - while (iter.hasNext()){ - String arg = iter.next(); - if (arg.equals("-h")){ - host="http://"+iter.next(); - } - if (arg.equals("-t")){ - numThreads=Integer.parseInt(iter.next()); - } - if (arg.equals("-n")){ - numVM=Integer.parseInt(iter.next()); - } - } - - final String server = host + ":" + _apiPort + "/"; - final String developerServer = host + ":" + _developerPort + _apiUrl; - - s_logger.info("Starting test in "+numThreads+" thread(s). Each thread is launching "+numVM+" VMs"); - - for (int i=0; i argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + String host = "http://localhost"; + int numThreads = 1; + + while (iter.hasNext()){ + String arg = iter.next(); + if (arg.equals("-h")){ + host="http://"+iter.next(); + } + if (arg.equals("-t")){ + numThreads=Integer.parseInt(iter.next()); + } + if (arg.equals("-n")){ + numVM=Integer.parseInt(iter.next()); + } + } + + final String server = host + ":" + _apiPort + "/"; + final String developerServer = host + ":" + _developerPort + _apiUrl; + + s_logger.info("Starting test in "+numThreads+" thread(s). Each thread is launching "+numVM+" VMs"); + + for (int i=0; i errorInfo = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "errorCode", "description" }); - s_logger - .error("create ip forwarding rule (linux) test failed with errorCode: " - + errorInfo.get("errorCode") - + " and description: " - + errorInfo.get("description")); - } else { - s_logger.error("internal error processing request: " - + method.getStatusText()); - } - return responseCode; - } - + String url = myUser.getDeveloperServer() + "?command=createOrUpdateIpForwardingRule" + + "&publicIp=" + encodedPublicIp + + "&publicPort="+encodedPublicPort+"&privateIp=" + encodedPrivateIp + + "&privatePort=" + encodedPrivatePort + "&protocol=tcp&apiKey=" + encodedApiKey + + "&signature=" + encodedSignature; + + s_logger.info("Trying to create IP forwarding rule: "+url); + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + responseCode = client.executeMethod(method); + s_logger.info("create ip forwarding rule response code: " + + responseCode); + if (responseCode == 200) { + s_logger.info("The rule is created successfully"); + } else if (responseCode == 500) { + InputStream is = method.getResponseBodyAsStream(); + Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "errorCode", "description" }); + s_logger + .error("create ip forwarding rule (linux) test failed with errorCode: " + + errorInfo.get("errorCode") + + " and description: " + + errorInfo.get("description")); + } else { + s_logger.error("internal error processing request: " + + method.getStatusText()); + } + return responseCode; + } + } \ No newline at end of file diff --git a/test/src/com/cloud/test/longrun/User.java b/test/src/com/cloud/test/longrun/User.java index f601f010789..98960db7cf5 100644 --- a/test/src/com/cloud/test/longrun/User.java +++ b/test/src/com/cloud/test/longrun/User.java @@ -32,207 +32,207 @@ import com.cloud.test.stress.TestClientWithAPI; public class User { - public static final Logger s_logger= Logger.getLogger(User.class.getClass()); - - private ArrayList virtualMachines; - private ArrayList publicIp; - private String server; - private String developerServer; - private String userName; - private String userId; - private String apiKey; - private String secretKey; - private String password; - private String encryptedPassword; - + public static final Logger s_logger= Logger.getLogger(User.class.getClass()); + + private ArrayList virtualMachines; + private ArrayList publicIp; + private String server; + private String developerServer; + private String userName; + private String userId; + private String apiKey; + private String secretKey; + private String password; + private String encryptedPassword; + - public User(String userName, String password, String server, String developerServer) - { - this.server=server; - this.developerServer=developerServer; - this.userName=userName; - this.password=password; - this.virtualMachines = new ArrayList(); - this.publicIp = new ArrayList(); - } - - public ArrayList getVirtualMachines() { - return virtualMachines; - } + public User(String userName, String password, String server, String developerServer) + { + this.server=server; + this.developerServer=developerServer; + this.userName=userName; + this.password=password; + this.virtualMachines = new ArrayList(); + this.publicIp = new ArrayList(); + } + + public ArrayList getVirtualMachines() { + return virtualMachines; + } - public void setVirtualMachines(ArrayList virtualMachines) { - this.virtualMachines = virtualMachines; - } + public void setVirtualMachines(ArrayList virtualMachines) { + this.virtualMachines = virtualMachines; + } - public String getUserId() { - return userId; - } + public String getUserId() { + return userId; + } - public void setUserId(String userId) { - this.userId = userId; - } - + public void setUserId(String userId) { + this.userId = userId; + } + - public ArrayList getPublicIp() { - return publicIp; - } + public ArrayList getPublicIp() { + return publicIp; + } - public void setPublicIp(ArrayList publicIp) { - this.publicIp = publicIp; - } + public void setPublicIp(ArrayList publicIp) { + this.publicIp = publicIp; + } - public String getServer() { - return server; - } + public String getServer() { + return server; + } - public void setServer(String server) { - this.server = server; - } + public void setServer(String server) { + this.server = server; + } - public String getUserName() { - return userName; - } + public String getUserName() { + return userName; + } - public void setUserName(String userName) { - this.userName = userName; - } + public void setUserName(String userName) { + this.userName = userName; + } - public String getApiKey() { - return apiKey; - } + public String getApiKey() { + return apiKey; + } - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } - public String getPassword() { - return password; - } + public String getPassword() { + return password; + } - public void setPassword(String password) { - this.password = password; - } - - public String getSecretKey() { - return secretKey; - } + public void setPassword(String password) { + this.password = password; + } + + public String getSecretKey() { + return secretKey; + } - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + - public String getDeveloperServer() { - return developerServer; - } + public String getDeveloperServer() { + return developerServer; + } - public void setDeveloperServer(String developerServer) { - this.developerServer = developerServer; - } + public void setDeveloperServer(String developerServer) { + this.developerServer = developerServer; + } - public void launchUser() throws IOException { - String encodedUsername = URLEncoder.encode(this.getUserName(), "UTF-8"); - this.encryptedPassword=TestClientWithAPI.createMD5Password(this.getPassword()); - String encodedPassword = URLEncoder.encode(this.encryptedPassword, "UTF-8"); - String url = this.server + "?command=createUser&username=" + encodedUsername - + "&password=" + encodedPassword - + "&firstname=Test&lastname=Test&email=alena@vmops.com&domainId=1"; - String userIdStr=null; - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(url); - int responseCode = client.executeMethod(method); + public void launchUser() throws IOException { + String encodedUsername = URLEncoder.encode(this.getUserName(), "UTF-8"); + this.encryptedPassword=TestClientWithAPI.createMD5Password(this.getPassword()); + String encodedPassword = URLEncoder.encode(this.encryptedPassword, "UTF-8"); + String url = this.server + "?command=createUser&username=" + encodedUsername + + "&password=" + encodedPassword + + "&firstname=Test&lastname=Test&email=alena@vmops.com&domainId=1"; + String userIdStr=null; + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + int responseCode = client.executeMethod(method); - if (responseCode == 200) { - InputStream is = method.getResponseBodyAsStream(); - Map userIdValues = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "id" }); - userIdStr = userIdValues.get("id"); - if ((userIdStr != null) && (Long.parseLong(userIdStr)!=-1)) { - this.setUserId(userIdStr); - } - } - } - - public void retrievePublicIp(long zoneId) throws IOException{ - - String encodedApiKey = URLEncoder.encode(this.apiKey, "UTF-8"); - String encodedZoneId=URLEncoder.encode(""+zoneId,"UTF-8"); - String requestToSign = "apiKey=" + encodedApiKey - + "&command=associateIpAddress" + "&zoneId="+encodedZoneId; - requestToSign = requestToSign.toLowerCase(); - String signature = TestClientWithAPI.signRequest(requestToSign, this.secretKey); - String encodedSignature = URLEncoder.encode(signature, "UTF-8"); + if (responseCode == 200) { + InputStream is = method.getResponseBodyAsStream(); + Map userIdValues = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "id" }); + userIdStr = userIdValues.get("id"); + if ((userIdStr != null) && (Long.parseLong(userIdStr)!=-1)) { + this.setUserId(userIdStr); + } + } + } + + public void retrievePublicIp(long zoneId) throws IOException{ + + String encodedApiKey = URLEncoder.encode(this.apiKey, "UTF-8"); + String encodedZoneId=URLEncoder.encode(""+zoneId,"UTF-8"); + String requestToSign = "apiKey=" + encodedApiKey + + "&command=associateIpAddress" + "&zoneId="+encodedZoneId; + requestToSign = requestToSign.toLowerCase(); + String signature = TestClientWithAPI.signRequest(requestToSign, this.secretKey); + String encodedSignature = URLEncoder.encode(signature, "UTF-8"); - String url = this.developerServer + "?command=associateIpAddress" + "&apiKey=" - + encodedApiKey + "&zoneId="+encodedZoneId+"&signature=" - + encodedSignature; + String url = this.developerServer + "?command=associateIpAddress" + "&apiKey=" + + encodedApiKey + "&zoneId="+encodedZoneId+"&signature=" + + encodedSignature; - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(url); - int responseCode=client.executeMethod(method); - if (responseCode == 200) { - InputStream is = method.getResponseBodyAsStream(); - Map values = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "ipaddress" }); - this.getPublicIp().add(values.get("ipaddress")); - s_logger.info("Ip address is " + values.get("ipaddress")); - } else if (responseCode == 500) { - InputStream is = method.getResponseBodyAsStream(); - Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "errorcode", "description" }); - s_logger.error("associate ip test failed with errorCode: " - + errorInfo.get("errorCode") + " and description: " - + errorInfo.get("description")); - } else { - s_logger.error("internal error processing request: " - + method.getStatusText()); - } - - } - - public void registerUser()throws HttpException, IOException{ - - String encodedUsername = URLEncoder.encode(this.userName, "UTF-8"); - String encodedPassword = URLEncoder.encode(this.password, "UTF-8"); - String url = server + "?command=register&username=" + encodedUsername - + "&domainid=1"; - s_logger.info("registering: " + this.userName+" with url "+url); - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(url); - int responseCode = client.executeMethod(method); - if (responseCode == 200) { - InputStream is = method.getResponseBodyAsStream(); - Map requestKeyValues = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "apikey", "secretkey" }); - this.setApiKey(requestKeyValues.get("apikey")); - this.setSecretKey(requestKeyValues.get("secretkey")); - } else if (responseCode == 500) { - InputStream is = method.getResponseBodyAsStream(); - Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "errorcode", "description" }); - s_logger.error("registration failed with errorCode: " - + errorInfo.get("errorCode") + " and description: " - + errorInfo.get("description")); - } else { - s_logger.error("internal error processing request: " - + method.getStatusText()); - } - } - + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + int responseCode=client.executeMethod(method); + if (responseCode == 200) { + InputStream is = method.getResponseBodyAsStream(); + Map values = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "ipaddress" }); + this.getPublicIp().add(values.get("ipaddress")); + s_logger.info("Ip address is " + values.get("ipaddress")); + } else if (responseCode == 500) { + InputStream is = method.getResponseBodyAsStream(); + Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "errorcode", "description" }); + s_logger.error("associate ip test failed with errorCode: " + + errorInfo.get("errorCode") + " and description: " + + errorInfo.get("description")); + } else { + s_logger.error("internal error processing request: " + + method.getStatusText()); + } + + } + + public void registerUser()throws HttpException, IOException{ + + String encodedUsername = URLEncoder.encode(this.userName, "UTF-8"); + String encodedPassword = URLEncoder.encode(this.password, "UTF-8"); + String url = server + "?command=register&username=" + encodedUsername + + "&domainid=1"; + s_logger.info("registering: " + this.userName+" with url "+url); + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + int responseCode = client.executeMethod(method); + if (responseCode == 200) { + InputStream is = method.getResponseBodyAsStream(); + Map requestKeyValues = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "apikey", "secretkey" }); + this.setApiKey(requestKeyValues.get("apikey")); + this.setSecretKey(requestKeyValues.get("secretkey")); + } else if (responseCode == 500) { + InputStream is = method.getResponseBodyAsStream(); + Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "errorcode", "description" }); + s_logger.error("registration failed with errorCode: " + + errorInfo.get("errorCode") + " and description: " + + errorInfo.get("description")); + } else { + s_logger.error("internal error processing request: " + + method.getStatusText()); + } + } + } diff --git a/test/src/com/cloud/test/longrun/VirtualMachine.java b/test/src/com/cloud/test/longrun/VirtualMachine.java index 1d75953b2b3..0aaa2897da8 100644 --- a/test/src/com/cloud/test/longrun/VirtualMachine.java +++ b/test/src/com/cloud/test/longrun/VirtualMachine.java @@ -32,85 +32,85 @@ import java.io.IOException; public class VirtualMachine { - public static final Logger s_logger= Logger.getLogger(VirtualMachine.class.getClass()); - - private String privateIp; - private String userId; - - - public VirtualMachine(String userId){ - this.userId=userId; - } - - - public String getPrivateIp() { - return privateIp; - } + public static final Logger s_logger= Logger.getLogger(VirtualMachine.class.getClass()); + + private String privateIp; + private String userId; + + + public VirtualMachine(String userId){ + this.userId=userId; + } + + + public String getPrivateIp() { + return privateIp; + } - public void setPrivateIp(String privateIp) { - this.privateIp = privateIp; - } + public void setPrivateIp(String privateIp) { + this.privateIp = privateIp; + } - public String getUserId() { - return userId; - } + public String getUserId() { + return userId; + } - public void setUserId(String userId) { - this.userId = userId; - } + public void setUserId(String userId) { + this.userId = userId; + } - public void deployVM(long zoneId, long serviceOfferingId, long templateId, String server, String apiKey, String secretKey) throws IOException{ + public void deployVM(long zoneId, long serviceOfferingId, long templateId, String server, String apiKey, String secretKey) throws IOException{ - String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8"); - String encodedServiceOfferingId = URLEncoder.encode("" - + serviceOfferingId, "UTF-8"); - String encodedTemplateId = URLEncoder.encode("" + templateId, - "UTF-8"); - String encodedApiKey=URLEncoder.encode(apiKey, "UTF-8"); - String requestToSign = "apiKey=" + encodedApiKey - + "&command=deployVirtualMachine&serviceOfferingId=" - + encodedServiceOfferingId + "&templateId=" - + encodedTemplateId + "&zoneId=" + encodedZoneId; - - requestToSign = requestToSign.toLowerCase(); - String signature = TestClientWithAPI.signRequest(requestToSign, secretKey); - String encodedSignature = URLEncoder.encode(signature, "UTF-8"); - String url = server + "?command=deployVirtualMachine" - + "&zoneId=" + encodedZoneId + "&serviceOfferingId=" - + encodedServiceOfferingId + "&templateId=" - + encodedTemplateId + "&apiKey=" + encodedApiKey - + "&signature=" + encodedSignature; - - s_logger.info("Sending this request to deploy a VM: "+url); - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(url); - int responseCode = client.executeMethod(method); - s_logger.info("deploy linux vm response code: " + responseCode); - if (responseCode == 200) { - InputStream is = method.getResponseBodyAsStream(); - Map values = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "id", "ipaddress" }); - long linuxVMId = Long.parseLong(values.get("id")); - s_logger.info("got linux virtual machine id: " + linuxVMId); - this.setPrivateIp(values.get("ipaddress")); + String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8"); + String encodedServiceOfferingId = URLEncoder.encode("" + + serviceOfferingId, "UTF-8"); + String encodedTemplateId = URLEncoder.encode("" + templateId, + "UTF-8"); + String encodedApiKey=URLEncoder.encode(apiKey, "UTF-8"); + String requestToSign = "apiKey=" + encodedApiKey + + "&command=deployVirtualMachine&serviceOfferingId=" + + encodedServiceOfferingId + "&templateId=" + + encodedTemplateId + "&zoneId=" + encodedZoneId; + + requestToSign = requestToSign.toLowerCase(); + String signature = TestClientWithAPI.signRequest(requestToSign, secretKey); + String encodedSignature = URLEncoder.encode(signature, "UTF-8"); + String url = server + "?command=deployVirtualMachine" + + "&zoneId=" + encodedZoneId + "&serviceOfferingId=" + + encodedServiceOfferingId + "&templateId=" + + encodedTemplateId + "&apiKey=" + encodedApiKey + + "&signature=" + encodedSignature; + + s_logger.info("Sending this request to deploy a VM: "+url); + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + int responseCode = client.executeMethod(method); + s_logger.info("deploy linux vm response code: " + responseCode); + if (responseCode == 200) { + InputStream is = method.getResponseBodyAsStream(); + Map values = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "id", "ipaddress" }); + long linuxVMId = Long.parseLong(values.get("id")); + s_logger.info("got linux virtual machine id: " + linuxVMId); + this.setPrivateIp(values.get("ipaddress")); - } else if (responseCode == 500) { - InputStream is = method.getResponseBodyAsStream(); - Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, - new String[] { "errorcode", "description" }); - s_logger.error("deploy linux vm test failed with errorCode: " - + errorInfo.get("errorCode") + " and description: " - + errorInfo.get("description")); - } else { - s_logger.error("internal error processing request: " - + method.getStatusText()); - } - } - - + } else if (responseCode == 500) { + InputStream is = method.getResponseBodyAsStream(); + Map errorInfo = TestClientWithAPI.getSingleValueFromXML(is, + new String[] { "errorcode", "description" }); + s_logger.error("deploy linux vm test failed with errorCode: " + + errorInfo.get("errorCode") + " and description: " + + errorInfo.get("description")); + } else { + s_logger.error("internal error processing request: " + + method.getStatusText()); + } + } + + } diff --git a/test/src/com/cloud/test/longrun/guestNetwork.java b/test/src/com/cloud/test/longrun/guestNetwork.java index a4254e17d94..70997081839 100644 --- a/test/src/com/cloud/test/longrun/guestNetwork.java +++ b/test/src/com/cloud/test/longrun/guestNetwork.java @@ -24,84 +24,84 @@ import com.trilead.ssh2.Session; public class guestNetwork implements Runnable{ - public static final Logger s_logger= Logger.getLogger(guestNetwork.class.getClass()); - - private String publicIp; - private ArrayList virtualMachines; - private int retryNum; - - public guestNetwork(String publicIp, int retryNum){ - this.publicIp=publicIp; - this.retryNum=retryNum; - } - - public ArrayList getVirtualMachines() { - return virtualMachines; - } + public static final Logger s_logger= Logger.getLogger(guestNetwork.class.getClass()); + + private String publicIp; + private ArrayList virtualMachines; + private int retryNum; + + public guestNetwork(String publicIp, int retryNum){ + this.publicIp=publicIp; + this.retryNum=retryNum; + } + + public ArrayList getVirtualMachines() { + return virtualMachines; + } - public void setVirtualMachines(ArrayList virtualMachines) { - this.virtualMachines = virtualMachines; - } + public void setVirtualMachines(ArrayList virtualMachines) { + this.virtualMachines = virtualMachines; + } - public void run(){ - NDC.push("Following thread has started"+Thread.currentThread().getName()); - int retry = 0; - - //Start copying files between machines in the network - s_logger.info("The size of the array is " + this.virtualMachines.size()); - while (true) { - try { - if (retry > 0) { - s_logger.info("Retry attempt : " + retry - + " ...sleeping 120 seconds before next attempt"); - Thread.sleep(120000); - } - for (VirtualMachine vm: this.virtualMachines ){ - - s_logger.info("Attempting to SSH into linux host " + this.publicIp - + " with retry attempt: " + retry); - Connection conn = new Connection(this.publicIp); - conn.connect(null, 600000, 600000); + public void run(){ + NDC.push("Following thread has started"+Thread.currentThread().getName()); + int retry = 0; + + //Start copying files between machines in the network + s_logger.info("The size of the array is " + this.virtualMachines.size()); + while (true) { + try { + if (retry > 0) { + s_logger.info("Retry attempt : " + retry + + " ...sleeping 120 seconds before next attempt"); + Thread.sleep(120000); + } + for (VirtualMachine vm: this.virtualMachines ){ + + s_logger.info("Attempting to SSH into linux host " + this.publicIp + + " with retry attempt: " + retry); + Connection conn = new Connection(this.publicIp); + conn.connect(null, 600000, 600000); - s_logger.info("SSHed successfully into linux host " + this.publicIp); + s_logger.info("SSHed successfully into linux host " + this.publicIp); - boolean isAuthenticated = conn.authenticateWithPassword("root", - "password"); + boolean isAuthenticated = conn.authenticateWithPassword("root", + "password"); - if (isAuthenticated == false) { - s_logger.info("Authentication failed"); - } - //execute copy command - Session sess = conn.openSession(); - String fileName; - Random ran = new Random(); - fileName=Math.abs(ran.nextInt())+"-file"; - String copyCommand = new String ("./scpScript "+vm.getPrivateIp()+" "+fileName); - s_logger.info("Executing " + copyCommand); - sess.execCommand(copyCommand); - Thread.sleep(120000); - sess.close(); - - //execute wget command - sess = conn.openSession(); - String downloadCommand = new String ("wget http://172.16.0.220/scripts/checkDiskSpace.sh; chmod +x *sh; ./checkDiskSpace.sh; rm -rf checkDiskSpace.sh"); - s_logger.info("Executing " + downloadCommand); - sess.execCommand(downloadCommand); - Thread.sleep(120000); - sess.close(); - - //close the connection - conn.close(); - } - }catch (Exception ex) { - s_logger.error(ex); - retry++; - if (retry == retryNum) { - s_logger.info("Performance Guest Network test failed with error " - + ex.getMessage()) ; - } - } - } + if (isAuthenticated == false) { + s_logger.info("Authentication failed"); + } + //execute copy command + Session sess = conn.openSession(); + String fileName; + Random ran = new Random(); + fileName=Math.abs(ran.nextInt())+"-file"; + String copyCommand = new String ("./scpScript "+vm.getPrivateIp()+" "+fileName); + s_logger.info("Executing " + copyCommand); + sess.execCommand(copyCommand); + Thread.sleep(120000); + sess.close(); + + //execute wget command + sess = conn.openSession(); + String downloadCommand = new String ("wget http://172.16.0.220/scripts/checkDiskSpace.sh; chmod +x *sh; ./checkDiskSpace.sh; rm -rf checkDiskSpace.sh"); + s_logger.info("Executing " + downloadCommand); + sess.execCommand(downloadCommand); + Thread.sleep(120000); + sess.close(); + + //close the connection + conn.close(); + } + }catch (Exception ex) { + s_logger.error(ex); + retry++; + if (retry == retryNum) { + s_logger.info("Performance Guest Network test failed with error " + + ex.getMessage()) ; + } + } + } - } + } } diff --git a/test/src/com/cloud/test/regression/ConfigTest.java b/test/src/com/cloud/test/regression/ConfigTest.java index 7e4ca64de17..17401ce5470 100644 --- a/test/src/com/cloud/test/regression/ConfigTest.java +++ b/test/src/com/cloud/test/regression/ConfigTest.java @@ -29,103 +29,103 @@ import com.trilead.ssh2.Connection; import com.trilead.ssh2.Session; public class ConfigTest extends TestCase{ - public static final Logger s_logger = Logger.getLogger(ConfigTest.class.getName()); - - public ConfigTest(){ - this.setClient(); - this.setParam(new HashMap()); - } - - public boolean executeTest(){ - - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i()); + } + + public boolean executeTest(){ + + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i()); - } - - public boolean executeTest(){ - int error=0; - - for (Document eachElement: this.getInputFile()) { - - Element rootElement = eachElement.getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i()); + } + + public boolean executeTest(){ + int error=0; + + for (Document eachElement: this.getInputFile()) { + + Element rootElement = eachElement.getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i()); - } + public static final Logger s_logger = Logger.getLogger(Deploy.class.getName()); + + public Deploy(){ + this.setClient(); + this.setParam(new HashMap()); + } - - public boolean executeTest() { - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - String host = null; - String file = null; - - while (iter.hasNext()) { - String arg = iter.next(); - // management server host - if (arg.equals("-h")) { - host = iter.next(); - } - if (arg.equals("-f")) { - file = iter.next(); - } - } - - Deploy deploy = new Deploy (); - - ArrayList inputFile = new ArrayList(); - inputFile.add(file); - deploy.setInputFile(inputFile); - deploy.setTestCaseName("Management server deployment"); - deploy.getParam().put("hostip", host); - deploy.getParam().put("apicommands", "../metadata/func/commands"); - deploy.setCommands(); - - s_logger.info("Starting deployment against host " + host); - - boolean result = deploy.executeTest(); - if (result == false) { - s_logger.error("DEPLOYMENT FAILED"); - System.exit(1); + + public boolean executeTest() { + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + String host = null; + String file = null; + + while (iter.hasNext()) { + String arg = iter.next(); + // management server host + if (arg.equals("-h")) { + host = iter.next(); + } + if (arg.equals("-f")) { + file = iter.next(); + } + } + + Deploy deploy = new Deploy (); + + ArrayList inputFile = new ArrayList(); + inputFile.add(file); + deploy.setInputFile(inputFile); + deploy.setTestCaseName("Management server deployment"); + deploy.getParam().put("hostip", host); + deploy.getParam().put("apicommands", "../metadata/func/commands"); + deploy.setCommands(); + + s_logger.info("Starting deployment against host " + host); + + boolean result = deploy.executeTest(); + if (result == false) { + s_logger.error("DEPLOYMENT FAILED"); + System.exit(1); } else { - s_logger.info("DEPLOYMENT IS SUCCESSFUL"); + s_logger.info("DEPLOYMENT IS SUCCESSFUL"); } - - } - + + } + } diff --git a/test/src/com/cloud/test/regression/EventsApiTest.java b/test/src/com/cloud/test/regression/EventsApiTest.java index d929899d23e..1eea211991f 100644 --- a/test/src/com/cloud/test/regression/EventsApiTest.java +++ b/test/src/com/cloud/test/regression/EventsApiTest.java @@ -30,149 +30,149 @@ import com.trilead.ssh2.Session; public class EventsApiTest extends TestCase{ public static final Logger s_logger = Logger.getLogger(EventsApiTest.class.getName()); - - - public EventsApiTest(){ - this.setClient(); - this.setParam(new HashMap()); - } - - public boolean executeTest(){ - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i()); + } + + public boolean executeTest(){ + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i expectedEvents = new HashMap(); - expectedEvents.put("VM.START", 1); - boolean eventResult = ApiCommand.verifyEvents(expectedEvents, "INFO", "http://" + this.getParam().get("hostip") + ":8096", "userid=" + this.getParam().get("userid1") + "&type=VM.START"); - s_logger.info("Test case 97 - listEvent command verification result is " + eventResult); - - //verify error events - eventResult = ApiCommand.verifyEvents("../metadata/error_events.properties", "ERROR", "http://" + this.getParam().get("hostip") + ":8096", this.getParam().get("erroruseraccount")); - s_logger.info("listEvent command verification result is " + eventResult); - - - if (error != 0) - return false; - else - return true; - } + if (isAuthenticated == false) { + s_logger.info("Authentication failed for root with password"); + return false; + } + + Session sess = conn.openSession(); + s_logger.info("Executing : " + commandElement.getTextContent()); + sess.execCommand(commandElement.getTextContent()); + Thread.sleep(60000); + sess.close(); + conn.close(); + + } catch (Exception ex) { + s_logger.error(ex); + return false; + } + } + } + + else { + //new command + ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands()); + + //send a command + api.sendCommand(this.getClient(), null); + + + //verify the response of the command + if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) { + s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl()); + error++; + } + else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) { + //verify if response is suppposed to be empty + if (api.getResponseType() == ResponseType.EMPTY) { + if (api.isEmpty() == true) { + s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Empty response was returned as expected. Command was sent with url " + api.getUrl()); + } + else { + s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl()); + } + } else { + if (api.isEmpty() != false) + s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl()); + else { + //set parameters for the future use + if (api.setParam(this.getParam()) == false) { + s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl()); + return false; + } + else if (api.getTestCaseInfo() != null){ + s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Command was sent with the url " + api.getUrl()); + } + } + } + } + else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) { + s_logger.error("Command " + api.getName() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl()); + if (api.getRequired() == true) { + s_logger.info("The command is required for the future use, so exiging"); + return false; + } + error++; + } + else if (api.getTestCaseInfo() != null){ + s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Command that was supposed to fail, failed. Command was sent with url " + api.getUrl()); + + } + } + } + + //verify events with userid parameter - test case 97 + HashMap expectedEvents = new HashMap(); + expectedEvents.put("VM.START", 1); + boolean eventResult = ApiCommand.verifyEvents(expectedEvents, "INFO", "http://" + this.getParam().get("hostip") + ":8096", "userid=" + this.getParam().get("userid1") + "&type=VM.START"); + s_logger.info("Test case 97 - listEvent command verification result is " + eventResult); + + //verify error events + eventResult = ApiCommand.verifyEvents("../metadata/error_events.properties", "ERROR", "http://" + this.getParam().get("hostip") + ":8096", this.getParam().get("erroruseraccount")); + s_logger.info("listEvent command verification result is " + eventResult); + + + if (error != 0) + return false; + else + return true; + } } diff --git a/test/src/com/cloud/test/regression/HA.java b/test/src/com/cloud/test/regression/HA.java index 1060511b948..dde5dcf5ef2 100644 --- a/test/src/com/cloud/test/regression/HA.java +++ b/test/src/com/cloud/test/regression/HA.java @@ -25,54 +25,54 @@ import com.cloud.test.regression.ApiCommand.ResponseType; public class HA extends TestCase{ - public static final Logger s_logger = Logger.getLogger(HA.class.getName()); - - public HA(){ - this.setClient(); - } - - public boolean executeTest(){ - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i()); - } - - public boolean executeTest(){ - - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i port = new ArrayList(); -// for (int i=1; i<65536; i++){ -// port.add(Integer.toString(i)); -// } -// -// //try all public ports -// for (String portValue : port) { -// try { -// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + -// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue; -// HttpClient client = new HttpClient(); -// HttpMethod method = new GetMethod(url); -// int responseCode = client.executeMethod(method); -// if (responseCode != 200 ) { -// error++; -// s_logger.error("Can't create LB rule for the public port " + portValue + ". Request was sent with url " + url); -// } -// }catch (Exception ex) { -// s_logger.error(ex); -// } -// } -// -// //try all private ports -// for (String portValue : port) { -// try { -// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + -// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue; -// HttpClient client = new HttpClient(); -// HttpMethod method = new GetMethod(url); -// int responseCode = client.executeMethod(method); -// if (responseCode != 200 ) { -// error++; -// s_logger.error("Can't create LB rule for the private port " + portValue + ". Request was sent with url " + url); -// } -// }catch (Exception ex) { -// s_logger.error(ex); -// } -// } + public static final Logger s_logger = Logger.getLogger(LoadBalancingTest.class.getName()); + + public LoadBalancingTest(){ + this.setClient(); + this.setParam(new HashMap()); + } + + public boolean executeTest(){ + + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i port = new ArrayList(); +// for (int i=1; i<65536; i++){ +// port.add(Integer.toString(i)); +// } +// +// //try all public ports +// for (String portValue : port) { +// try { +// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + +// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue; +// HttpClient client = new HttpClient(); +// HttpMethod method = new GetMethod(url); +// int responseCode = client.executeMethod(method); +// if (responseCode != 200 ) { +// error++; +// s_logger.error("Can't create LB rule for the public port " + portValue + ". Request was sent with url " + url); +// } +// }catch (Exception ex) { +// s_logger.error(ex); +// } +// } +// +// //try all private ports +// for (String portValue : port) { +// try { +// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + +// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue; +// HttpClient client = new HttpClient(); +// HttpMethod method = new GetMethod(url); +// int responseCode = client.executeMethod(method); +// if (responseCode != 200 ) { +// error++; +// s_logger.error("Can't create LB rule for the private port " + portValue + ". Request was sent with url " + url); +// } +// }catch (Exception ex) { +// s_logger.error(ex); +// } +// } - - if (error != 0) - return false; - else - return true; - } + + if (error != 0) + return false; + else + return true; + } } diff --git a/test/src/com/cloud/test/regression/PortForwardingTest.java b/test/src/com/cloud/test/regression/PortForwardingTest.java index 73522989181..3de3d123f05 100644 --- a/test/src/com/cloud/test/regression/PortForwardingTest.java +++ b/test/src/com/cloud/test/regression/PortForwardingTest.java @@ -26,121 +26,121 @@ import org.w3c.dom.NodeList; import com.cloud.test.regression.ApiCommand.ResponseType; public class PortForwardingTest extends TestCase{ - public static final Logger s_logger = Logger.getLogger(PortForwardingTest.class.getName()); - - public PortForwardingTest(){ - this.setClient(); - this.setParam(new HashMap()); - } - - public boolean executeTest(){ - - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i port = new ArrayList(); -// for (int i=1; i<65536; i++){ -// port.add(Integer.toString(i)); -// } -// -// //try all public ports -// for (String portValue : port) { -// try { -// s_logger.info("public port is " + portValue); -// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + -// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue; -// HttpClient client = new HttpClient(); -// HttpMethod method = new GetMethod(url); -// int responseCode = client.executeMethod(method); -// if (responseCode != 200 ) { -// error++; -// s_logger.error("Can't create portForwarding rule for the public port " + portValue + ". Request was sent with url " + url); -// } -// }catch (Exception ex) { -// s_logger.error(ex); -// } -// } -// -// //try all private ports -// for (String portValue : port) { -// try { -// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + -// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue; -// HttpClient client = new HttpClient(); -// HttpMethod method = new GetMethod(url); -// int responseCode = client.executeMethod(method); -// if (responseCode != 200 ) { -// error++; -// s_logger.error("Can't create portForwarding rule for the private port " + portValue + ". Request was sent with url " + url); -// } -// }catch (Exception ex) { -// s_logger.error(ex); -// } -// } + public static final Logger s_logger = Logger.getLogger(PortForwardingTest.class.getName()); + + public PortForwardingTest(){ + this.setClient(); + this.setParam(new HashMap()); + } + + public boolean executeTest(){ + + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i port = new ArrayList(); +// for (int i=1; i<65536; i++){ +// port.add(Integer.toString(i)); +// } +// +// //try all public ports +// for (String portValue : port) { +// try { +// s_logger.info("public port is " + portValue); +// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + +// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue; +// HttpClient client = new HttpClient(); +// HttpMethod method = new GetMethod(url); +// int responseCode = client.executeMethod(method); +// if (responseCode != 200 ) { +// error++; +// s_logger.error("Can't create portForwarding rule for the public port " + portValue + ". Request was sent with url " + url); +// } +// }catch (Exception ex) { +// s_logger.error(ex); +// } +// } +// +// //try all private ports +// for (String portValue : port) { +// try { +// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") + +// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue; +// HttpClient client = new HttpClient(); +// HttpMethod method = new GetMethod(url); +// int responseCode = client.executeMethod(method); +// if (responseCode != 200 ) { +// error++; +// s_logger.error("Can't create portForwarding rule for the private port " + portValue + ". Request was sent with url " + url); +// } +// }catch (Exception ex) { +// s_logger.error(ex); +// } +// } - - if (error != 0) - return false; - else - return true; - } + + if (error != 0) + return false; + else + return true; + } } diff --git a/test/src/com/cloud/test/regression/SanityTest.java b/test/src/com/cloud/test/regression/SanityTest.java index 07b370fa518..08fb91ad07b 100644 --- a/test/src/com/cloud/test/regression/SanityTest.java +++ b/test/src/com/cloud/test/regression/SanityTest.java @@ -23,64 +23,64 @@ import org.apache.log4j.Logger; public class SanityTest extends TestCase{ - public static final Logger s_logger = Logger.getLogger(SanityTest.class.getName()); - - public SanityTest(){ - this.setClient(); - } - - public boolean executeTest(){ - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - //Analyze each command, send request and build the array list of api commands - for (int i=0; i()); - } - - public boolean executeTest(){ - - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i port = new ArrayList(); - for (int j=1; j<1000; j++){ - port.add(Integer.toString(j)); - } - - //try all public ports - for (String portValue : port) { - try { - s_logger.info("public port is " + portValue); - String url = "http://" + this.getParam().get("hostip") + ":8096/?command=createNetworkRule&publicPort=" + portValue + "&privatePort=22&protocol=tcp&isForward=true&securityGroupId=1&account=admin"; - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(url); - int responseCode = client.executeMethod(method); - if (responseCode != 200 ) { - error++; - s_logger.error("Can't create portForwarding network rule for the public port " + portValue + ". Request was sent with url " + url); - } - }catch (Exception ex) { - s_logger.error(ex); - } - } - - - if (error != 0) - return false; - else - return true; - } + public static final Logger s_logger = Logger.getLogger(Test.class.getName()); + + public Test(){ + this.setClient(); + this.setParam(new HashMap()); + } + + public boolean executeTest(){ + + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i port = new ArrayList(); + for (int j=1; j<1000; j++){ + port.add(Integer.toString(j)); + } + + //try all public ports + for (String portValue : port) { + try { + s_logger.info("public port is " + portValue); + String url = "http://" + this.getParam().get("hostip") + ":8096/?command=createNetworkRule&publicPort=" + portValue + "&privatePort=22&protocol=tcp&isForward=true&securityGroupId=1&account=admin"; + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + int responseCode = client.executeMethod(method); + if (responseCode != 200 ) { + error++; + s_logger.error("Can't create portForwarding network rule for the public port " + portValue + ". Request was sent with url " + url); + } + }catch (Exception ex) { + s_logger.error(ex); + } + } + + + if (error != 0) + return false; + else + return true; + } } diff --git a/test/src/com/cloud/test/regression/TestCase.java b/test/src/com/cloud/test/regression/TestCase.java index ae605607168..03957eecc75 100644 --- a/test/src/com/cloud/test/regression/TestCase.java +++ b/test/src/com/cloud/test/regression/TestCase.java @@ -34,107 +34,107 @@ import org.w3c.dom.Document; public abstract class TestCase{ - - public static Logger s_logger = Logger.getLogger(TestCase.class.getName()); - private Connection conn; - private ArrayList inputFile = new ArrayList (); - private HttpClient client; - private String testCaseName; - private HashMap param = new HashMap (); - private HashMap commands = new HashMap (); - - public HashMap getParam() { - return param; - } + + public static Logger s_logger = Logger.getLogger(TestCase.class.getName()); + private Connection conn; + private ArrayList inputFile = new ArrayList (); + private HttpClient client; + private String testCaseName; + private HashMap param = new HashMap (); + private HashMap commands = new HashMap (); + + public HashMap getParam() { + return param; + } - public void setParam(HashMap param) { - this.param = param; - } - - - public HashMap getCommands() { - return commands; - } + public void setParam(HashMap param) { + this.param = param; + } + + + public HashMap getCommands() { + return commands; + } - public void setCommands() { - File asyncCommands = null; - if (param.get("apicommands") == null) { - s_logger.info("Unable to get the list of commands, exiting"); - System.exit(1); - } else { - asyncCommands = new File(param.get("apicommands")); - } - try { - Properties pro = new Properties(); - FileInputStream in = new FileInputStream(asyncCommands); - pro.load(in); - Enumeration en = pro.propertyNames(); - while (en.hasMoreElements()) { - String key = (String) en.nextElement(); - commands.put(key, pro.getProperty(key)); - } - } catch (Exception ex) { - s_logger.info("Unable to find the file " + param.get("apicommands") + " due to following exception " + ex); - } - - } + public void setCommands() { + File asyncCommands = null; + if (param.get("apicommands") == null) { + s_logger.info("Unable to get the list of commands, exiting"); + System.exit(1); + } else { + asyncCommands = new File(param.get("apicommands")); + } + try { + Properties pro = new Properties(); + FileInputStream in = new FileInputStream(asyncCommands); + pro.load(in); + Enumeration en = pro.propertyNames(); + while (en.hasMoreElements()) { + String key = (String) en.nextElement(); + commands.put(key, pro.getProperty(key)); + } + } catch (Exception ex) { + s_logger.info("Unable to find the file " + param.get("apicommands") + " due to following exception " + ex); + } + + } - public Connection getConn() { - return conn; - } + public Connection getConn() { + return conn; + } - public void setConn(String dbPassword) { - this.conn = null; - try { - Class.forName("com.mysql.jdbc.Driver"); - this.conn=DriverManager.getConnection("jdbc:mysql://" + param.get("db") + "/cloud", "root", dbPassword); - if (!this.conn.isValid(0)) { - s_logger.error("Connection to DB failed to establish"); - } - - }catch (Exception ex) { - s_logger.error(ex); - } - } + public void setConn(String dbPassword) { + this.conn = null; + try { + Class.forName("com.mysql.jdbc.Driver"); + this.conn=DriverManager.getConnection("jdbc:mysql://" + param.get("db") + "/cloud", "root", dbPassword); + if (!this.conn.isValid(0)) { + s_logger.error("Connection to DB failed to establish"); + } + + }catch (Exception ex) { + s_logger.error(ex); + } + } - public void setInputFile (ArrayList fileNameInput) { - for (String fileName: fileNameInput) { - File file = new File(fileName); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - Document doc = null; - try { - DocumentBuilder builder = factory.newDocumentBuilder(); - doc = builder.parse(file); - doc.getDocumentElement().normalize(); - } catch (Exception ex) { - s_logger.error("Unable to load " + fileName + " due to ", ex); - } - this.inputFile.add(doc); - } - } + public void setInputFile (ArrayList fileNameInput) { + for (String fileName: fileNameInput) { + File file = new File(fileName); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + Document doc = null; + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + doc = builder.parse(file); + doc.getDocumentElement().normalize(); + } catch (Exception ex) { + s_logger.error("Unable to load " + fileName + " due to ", ex); + } + this.inputFile.add(doc); + } + } - public ArrayList getInputFile() { - return inputFile; - } - - public void setTestCaseName(String testCaseName) { - this.testCaseName = testCaseName; - } - - public String getTestCaseName(){ - return this.testCaseName; - } + public ArrayList getInputFile() { + return inputFile; + } + + public void setTestCaseName(String testCaseName) { + this.testCaseName = testCaseName; + } + + public String getTestCaseName(){ + return this.testCaseName; + } - public void setClient() { - HttpClient client = new HttpClient(); - this.client = client; - } - - public HttpClient getClient() { - return this.client; - } - - //abstract methods - public abstract boolean executeTest(); + public void setClient() { + HttpClient client = new HttpClient(); + this.client = client; + } + + public HttpClient getClient() { + return this.client; + } + + //abstract methods + public abstract boolean executeTest(); } diff --git a/test/src/com/cloud/test/regression/TestCaseEngine.java b/test/src/com/cloud/test/regression/TestCaseEngine.java index 0496314061d..68584e0db49 100644 --- a/test/src/com/cloud/test/regression/TestCaseEngine.java +++ b/test/src/com/cloud/test/regression/TestCaseEngine.java @@ -37,252 +37,252 @@ import org.w3c.dom.NodeList; public class TestCaseEngine { - public static final Logger s_logger = Logger.getLogger(TestCaseEngine.class - .getName()); - public static String fileName = "../metadata/adapter.xml"; - public static HashMap globalParameters = new HashMap(); - protected static HashMap _componentMap = new HashMap(); - protected static HashMap> _inputFile = new HashMap>(); - protected static String testCaseName = new String(); - protected static ArrayList _keys = new ArrayList(); - private static ThreadLocal result = new ThreadLocal(); - public static int _numThreads = 1; - public static boolean _repeat = false; - public static boolean _printUrl = false; - public static String type = "All"; - public static boolean isSanity = false; - public static boolean isRegression = false; - private static int failure = 0; + public static final Logger s_logger = Logger.getLogger(TestCaseEngine.class + .getName()); + public static String fileName = "../metadata/adapter.xml"; + public static HashMap globalParameters = new HashMap(); + protected static HashMap _componentMap = new HashMap(); + protected static HashMap> _inputFile = new HashMap>(); + protected static String testCaseName = new String(); + protected static ArrayList _keys = new ArrayList(); + private static ThreadLocal result = new ThreadLocal(); + public static int _numThreads = 1; + public static boolean _repeat = false; + public static boolean _printUrl = false; + public static String type = "All"; + public static boolean isSanity = false; + public static boolean isRegression = false; + private static int failure = 0; - public static void main(String args[]) { + public static void main(String args[]) { - // Parameters - List argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - while (iter.hasNext()) { - String arg = iter.next(); - // is stress? - if (arg.equals("-t")) { - _numThreads = Integer.parseInt(iter.next()); - } - // do you want to print url for all commands? - if (arg.equals("-p")) { - _printUrl = true; - } - - //type of the test: sanity, regression, all (default) - if (arg.equals("-type")) { - type = iter.next(); - } - - if (arg.equals("-repeat")) { - _repeat = Boolean.valueOf(iter.next()); - } - - if (arg.equals("-filename")) { - fileName = iter.next(); - } - } - - if (type.equalsIgnoreCase("sanity")) - isSanity = true; - else if (type.equalsIgnoreCase("regression")) - isRegression = true; + // Parameters + List argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + while (iter.hasNext()) { + String arg = iter.next(); + // is stress? + if (arg.equals("-t")) { + _numThreads = Integer.parseInt(iter.next()); + } + // do you want to print url for all commands? + if (arg.equals("-p")) { + _printUrl = true; + } + + //type of the test: sanity, regression, all (default) + if (arg.equals("-type")) { + type = iter.next(); + } + + if (arg.equals("-repeat")) { + _repeat = Boolean.valueOf(iter.next()); + } + + if (arg.equals("-filename")) { + fileName = iter.next(); + } + } + + if (type.equalsIgnoreCase("sanity")) + isSanity = true; + else if (type.equalsIgnoreCase("regression")) + isRegression = true; - try { - // parse adapter.xml file to get list of tests to execute - File file = new File(fileName); - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(file); - doc.getDocumentElement().normalize(); - Element root = doc.getDocumentElement(); + try { + // parse adapter.xml file to get list of tests to execute + File file = new File(fileName); + DocumentBuilderFactory factory = DocumentBuilderFactory + .newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(file); + doc.getDocumentElement().normalize(); + Element root = doc.getDocumentElement(); - // set global parameters - setGlobalParams(root); + // set global parameters + setGlobalParams(root); - // populate _componentMap - setComponent(root); + // populate _componentMap + setComponent(root); - // set error to 0 by default + // set error to 0 by default - // execute test - for (int i = 0; i < _numThreads; i++) { - if (_numThreads > 1) { - s_logger.info("STARTING STRESS TEST IN " + // execute test + for (int i = 0; i < _numThreads; i++) { + if (_numThreads > 1) { + s_logger.info("STARTING STRESS TEST IN " + _numThreads + " THREADS"); - } else { - s_logger.info("STARTING FUNCTIONAL TEST"); - } - new Thread(new Runnable() { - public void run() { - do { - if (_numThreads == 1) { - try { - for (String key : _keys) { - Class c = Class.forName(_componentMap.get(key)); - TestCase component = (TestCase) c.newInstance(); - executeTest(key, c, component); - } - } catch (Exception ex1) { - s_logger.error(ex1); - } finally { - if (failure > 0) { - System.exit(1); - } - } - } else { - Random ran = new Random(); - Integer randomNumber = (Integer) Math.abs(ran - .nextInt(_keys.size())); - try { - String key = _keys.get(randomNumber); - Class c = Class.forName(_componentMap - .get(key)); - TestCase component = (TestCase) c - .newInstance(); - executeTest(key, c, component); - } catch (Exception e) { - s_logger.error("Error in thread ", e); - } - } - } while (_repeat); - } - }).start(); - } + } else { + s_logger.info("STARTING FUNCTIONAL TEST"); + } + new Thread(new Runnable() { + public void run() { + do { + if (_numThreads == 1) { + try { + for (String key : _keys) { + Class c = Class.forName(_componentMap.get(key)); + TestCase component = (TestCase) c.newInstance(); + executeTest(key, c, component); + } + } catch (Exception ex1) { + s_logger.error(ex1); + } finally { + if (failure > 0) { + System.exit(1); + } + } + } else { + Random ran = new Random(); + Integer randomNumber = (Integer) Math.abs(ran + .nextInt(_keys.size())); + try { + String key = _keys.get(randomNumber); + Class c = Class.forName(_componentMap + .get(key)); + TestCase component = (TestCase) c + .newInstance(); + executeTest(key, c, component); + } catch (Exception e) { + s_logger.error("Error in thread ", e); + } + } + } while (_repeat); + } + }).start(); + } - } catch (Exception exc) { - s_logger.error(exc); - } - } + } catch (Exception exc) { + s_logger.error(exc); + } + } - public static void setGlobalParams(Element rootElement) { - NodeList globalParam = rootElement.getElementsByTagName("globalparam"); - Element parameter = (Element) globalParam.item(0); - NodeList paramLst = parameter.getElementsByTagName("param"); + public static void setGlobalParams(Element rootElement) { + NodeList globalParam = rootElement.getElementsByTagName("globalparam"); + Element parameter = (Element) globalParam.item(0); + NodeList paramLst = parameter.getElementsByTagName("param"); - for (int i = 0; i < paramLst.getLength(); i++) { - Element paramElement = (Element) paramLst.item(i); + for (int i = 0; i < paramLst.getLength(); i++) { + Element paramElement = (Element) paramLst.item(i); - if (paramElement.getNodeType() == Node.ELEMENT_NODE) { - Element itemElement = (Element) paramElement; - NodeList itemName = itemElement.getElementsByTagName("name"); - Element itemNameElement = (Element) itemName.item(0); - NodeList itemVariable = itemElement - .getElementsByTagName("variable"); - Element itemVariableElement = (Element) itemVariable.item(0); - globalParameters.put(itemVariableElement.getTextContent(), - itemNameElement.getTextContent()); - } - } - } + if (paramElement.getNodeType() == Node.ELEMENT_NODE) { + Element itemElement = (Element) paramElement; + NodeList itemName = itemElement.getElementsByTagName("name"); + Element itemNameElement = (Element) itemName.item(0); + NodeList itemVariable = itemElement + .getElementsByTagName("variable"); + Element itemVariableElement = (Element) itemVariable.item(0); + globalParameters.put(itemVariableElement.getTextContent(), + itemNameElement.getTextContent()); + } + } + } - public static void setComponent(Element rootElement) { - NodeList testLst = rootElement.getElementsByTagName("test"); - for (int j = 0; j < testLst.getLength(); j++) { - Element testElement = (Element) testLst.item(j); + public static void setComponent(Element rootElement) { + NodeList testLst = rootElement.getElementsByTagName("test"); + for (int j = 0; j < testLst.getLength(); j++) { + Element testElement = (Element) testLst.item(j); - if (testElement.getNodeType() == Node.ELEMENT_NODE) { - Element itemElement = (Element) testElement; + if (testElement.getNodeType() == Node.ELEMENT_NODE) { + Element itemElement = (Element) testElement; - // get test case name - NodeList testCaseNameList = itemElement - .getElementsByTagName("testname"); - if (testCaseNameList != null) { - testCaseName = ((Element) testCaseNameList.item(0)) - .getTextContent(); - } - - if (isSanity == true && !testCaseName.equals("SANITY TEST")) - continue; - else if (isRegression == true && !(testCaseName.equals("SANITY TEST") || testCaseName.equals("REGRESSION TEST"))) - continue; + // get test case name + NodeList testCaseNameList = itemElement + .getElementsByTagName("testname"); + if (testCaseNameList != null) { + testCaseName = ((Element) testCaseNameList.item(0)) + .getTextContent(); + } + + if (isSanity == true && !testCaseName.equals("SANITY TEST")) + continue; + else if (isRegression == true && !(testCaseName.equals("SANITY TEST") || testCaseName.equals("REGRESSION TEST"))) + continue; - // set class name - NodeList className = itemElement.getElementsByTagName("class"); - if ((className.getLength() == 0) || (className == null)) { - _componentMap.put(testCaseName, - "com.cloud.test.regression.VMApiTest"); - } else { - String name = ((Element) className.item(0)) - .getTextContent(); - _componentMap.put(testCaseName, name); - } + // set class name + NodeList className = itemElement.getElementsByTagName("class"); + if ((className.getLength() == 0) || (className == null)) { + _componentMap.put(testCaseName, + "com.cloud.test.regression.VMApiTest"); + } else { + String name = ((Element) className.item(0)) + .getTextContent(); + _componentMap.put(testCaseName, name); + } - // set input file name - NodeList inputFileNameLst = itemElement - .getElementsByTagName("filename"); - _inputFile.put(testCaseName, new ArrayList()); - for (int k = 0; k < inputFileNameLst.getLength(); k++) { - String inputFileName = ((Element) inputFileNameLst.item(k)) - .getTextContent(); - _inputFile.get(testCaseName).add(inputFileName); - } - } - } - - //If sanity test required, make sure that SANITY TEST componennt got loaded - if (isSanity == true && _componentMap.size() == 0) { - s_logger.error("FAILURE!!! Failed to load SANITY TEST component. Verify that the test is uncommented in adapter.xml"); - System.exit(1); - } - - if (isRegression == true && _componentMap.size() != 2) { - s_logger.error("FAILURE!!! Failed to load SANITY TEST or REGRESSION TEST components. Verify that these tests are uncommented in adapter.xml"); - System.exit(1); - } + // set input file name + NodeList inputFileNameLst = itemElement + .getElementsByTagName("filename"); + _inputFile.put(testCaseName, new ArrayList()); + for (int k = 0; k < inputFileNameLst.getLength(); k++) { + String inputFileName = ((Element) inputFileNameLst.item(k)) + .getTextContent(); + _inputFile.get(testCaseName).add(inputFileName); + } + } + } + + //If sanity test required, make sure that SANITY TEST componennt got loaded + if (isSanity == true && _componentMap.size() == 0) { + s_logger.error("FAILURE!!! Failed to load SANITY TEST component. Verify that the test is uncommented in adapter.xml"); + System.exit(1); + } + + if (isRegression == true && _componentMap.size() != 2) { + s_logger.error("FAILURE!!! Failed to load SANITY TEST or REGRESSION TEST components. Verify that these tests are uncommented in adapter.xml"); + System.exit(1); + } - // put all keys from _componentMap to the ArrayList - Set set = _componentMap.entrySet(); - Iterator it = set.iterator(); - while (it.hasNext()) { - Map.Entry me = (Map.Entry) it.next(); - String key = (String) me.getKey(); - _keys.add(key); - } + // put all keys from _componentMap to the ArrayList + Set set = _componentMap.entrySet(); + Iterator it = set.iterator(); + while (it.hasNext()) { + Map.Entry me = (Map.Entry) it.next(); + String key = (String) me.getKey(); + _keys.add(key); + } - } + } - public static boolean executeTest(String key, Class c, TestCase component) { - boolean finalResult = false; - try { - s_logger.info("Starting \"" + key + "\" test...\n\n"); + public static boolean executeTest(String key, Class c, TestCase component) { + boolean finalResult = false; + try { + s_logger.info("Starting \"" + key + "\" test...\n\n"); - // set global parameters - HashMap updateParam = new HashMap(); - updateParam.putAll(globalParameters); - component.setParam(updateParam); + // set global parameters + HashMap updateParam = new HashMap(); + updateParam.putAll(globalParameters); + component.setParam(updateParam); - // set DB ip address - component.setConn(globalParameters.get("dbPassword")); + // set DB ip address + component.setConn(globalParameters.get("dbPassword")); - // set commands list - component.setCommands(); + // set commands list + component.setCommands(); - // set input file - if (_inputFile.get(key) != null) { - component.setInputFile(_inputFile.get(key)); - } + // set input file + if (_inputFile.get(key) != null) { + component.setInputFile(_inputFile.get(key)); + } - // set test case name - if (key != null) { - component.setTestCaseName(testCaseName); - } + // set test case name + if (key != null) { + component.setTestCaseName(testCaseName); + } - // execute method - result.set(component.executeTest()); - if (result.get().toString().equals("false")) { - s_logger.error("FAILURE!!! Test \"" + key + "\" failed\n\n\n"); - failure++; - } else { - finalResult = true; - s_logger.info("SUCCESS!!! Test \"" + key + "\" passed\n\n\n"); - } + // execute method + result.set(component.executeTest()); + if (result.get().toString().equals("false")) { + s_logger.error("FAILURE!!! Test \"" + key + "\" failed\n\n\n"); + failure++; + } else { + finalResult = true; + s_logger.info("SUCCESS!!! Test \"" + key + "\" passed\n\n\n"); + } - } catch (Exception ex) { - s_logger.error("error during test execution ", ex); - } - return finalResult; - } + } catch (Exception ex) { + s_logger.error("error during test execution ", ex); + } + return finalResult; + } } diff --git a/test/src/com/cloud/test/regression/VMApiTest.java b/test/src/com/cloud/test/regression/VMApiTest.java index 5685f078a39..32f22bc9b27 100644 --- a/test/src/com/cloud/test/regression/VMApiTest.java +++ b/test/src/com/cloud/test/regression/VMApiTest.java @@ -28,68 +28,68 @@ import com.cloud.test.regression.ApiCommand.ResponseType; public class VMApiTest extends TestCase{ public static final Logger s_logger = Logger.getLogger(VMApiTest.class.getName()); - - - public VMApiTest(){ - this.setClient(); - this.setParam(new HashMap()); - } - - public boolean executeTest(){ - int error=0; - Element rootElement = this.getInputFile().get(0).getDocumentElement(); - NodeList commandLst = rootElement.getElementsByTagName("command"); - - //Analyze each command, send request and build the array list of api commands - for (int i=0; i()); + } + + public boolean executeTest(){ + int error=0; + Element rootElement = this.getInputFile().get(0).getDocumentElement(); + NodeList commandLst = rootElement.getElementsByTagName("command"); + + //Analyze each command, send request and build the array list of api commands + for (int i=0; i argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - while (iter.hasNext()) { - String arg = iter.next(); - // host - if (arg.equals("-h")) { - host = iter.next(); - } - //password - - if (arg.equals("-p")) { - password = iter.next(); - } - - } - - int i = 0; - if (host == null || host.equals("")) { - s_logger - .info("Did not receive a host back from test, ignoring ssh test"); - System.exit(2); - } - - if (password == null){ - s_logger.info("Did not receive a password back from test, ignoring ssh test"); - System.exit(2); - } - int retry = 0; + + public static void main (String[] args) { + + // Parameters + List argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + while (iter.hasNext()) { + String arg = iter.next(); + // host + if (arg.equals("-h")) { + host = iter.next(); + } + //password + + if (arg.equals("-p")) { + password = iter.next(); + } + + } + + int i = 0; + if (host == null || host.equals("")) { + s_logger + .info("Did not receive a host back from test, ignoring ssh test"); + System.exit(2); + } + + if (password == null){ + s_logger.info("Did not receive a password back from test, ignoring ssh test"); + System.exit(2); + } + int retry = 0; - try { - if (retry > 0) { - s_logger.info("Retry attempt : " + retry - + " ...sleeping 120 seconds before next attempt"); - Thread.sleep(120000); - } + try { + if (retry > 0) { + s_logger.info("Retry attempt : " + retry + + " ...sleeping 120 seconds before next attempt"); + Thread.sleep(120000); + } - s_logger.info("Attempting to SSH into linux host " + host - + " with retry attempt: " + retry); + s_logger.info("Attempting to SSH into linux host " + host + + " with retry attempt: " + retry); - Connection conn = new Connection(host); - conn.connect(null, 60000, 60000); + Connection conn = new Connection(host); + conn.connect(null, 60000, 60000); - s_logger.info("User + ssHed successfully into linux host " + host); + s_logger.info("User + ssHed successfully into linux host " + host); - boolean isAuthenticated = conn.authenticateWithPassword("root", - password); + boolean isAuthenticated = conn.authenticateWithPassword("root", + password); - if (isAuthenticated == false) { - s_logger.info("Authentication failed for root with password" + password); - System.exit(2); - } - - boolean success = false; - String linuxCommand = null; - - if (i % 10 == 0) - linuxCommand = "rm -rf *; wget http://192.168.1.250/dump.bin && ls -al dump.bin"; - else - linuxCommand = "wget http://192.168.1.250/dump.bin && ls -al dump.bin"; - - Session sess = conn.openSession(); - sess.execCommand(linuxCommand); + if (isAuthenticated == false) { + s_logger.info("Authentication failed for root with password" + password); + System.exit(2); + } + + boolean success = false; + String linuxCommand = null; + + if (i % 10 == 0) + linuxCommand = "rm -rf *; wget http://192.168.1.250/dump.bin && ls -al dump.bin"; + else + linuxCommand = "wget http://192.168.1.250/dump.bin && ls -al dump.bin"; + + Session sess = conn.openSession(); + sess.execCommand(linuxCommand); - InputStream stdout = sess.getStdout(); - InputStream stderr = sess.getStderr(); - + InputStream stdout = sess.getStdout(); + InputStream stderr = sess.getStderr(); + - byte[] buffer = new byte[8192]; - while (true) { - if ((stdout.available() == 0) && (stderr.available() == 0)) { - int conditions = sess.waitForCondition( - ChannelCondition.STDOUT_DATA - | ChannelCondition.STDERR_DATA - | ChannelCondition.EOF, 120000); + byte[] buffer = new byte[8192]; + while (true) { + if ((stdout.available() == 0) && (stderr.available() == 0)) { + int conditions = sess.waitForCondition( + ChannelCondition.STDOUT_DATA + | ChannelCondition.STDERR_DATA + | ChannelCondition.EOF, 120000); - if ((conditions & ChannelCondition.TIMEOUT) != 0) { - s_logger - .info("Timeout while waiting for data from peer."); - System.exit(2); - } + if ((conditions & ChannelCondition.TIMEOUT) != 0) { + s_logger + .info("Timeout while waiting for data from peer."); + System.exit(2); + } - if ((conditions & ChannelCondition.EOF) != 0) { - if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) { - break; - } - } - } + if ((conditions & ChannelCondition.EOF) != 0) { + if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) { + break; + } + } + } - while (stdout.available() > 0) { - success = true; - int len = stdout.read(buffer); - if (len > 0) // this check is somewhat paranoid - s_logger.info(new String(buffer, 0, len)); - } + while (stdout.available() > 0) { + success = true; + int len = stdout.read(buffer); + if (len > 0) // this check is somewhat paranoid + s_logger.info(new String(buffer, 0, len)); + } - while (stderr.available() > 0) { - /* int len = */stderr.read(buffer); - } - } + while (stderr.available() > 0) { + /* int len = */stderr.read(buffer); + } + } - sess.close(); - conn.close(); - - if (!success) { - retry++; - if (retry == MAX_RETRY_LINUX) { - System.exit(2); - } - } - } catch (Exception e) { - retry++; - s_logger.error("SSH Linux Network test fail with error"); - if (retry == MAX_RETRY_LINUX) { - s_logger.error("Ssh test failed"); - System.exit(2); - } - } - } + sess.close(); + conn.close(); + + if (!success) { + retry++; + if (retry == MAX_RETRY_LINUX) { + System.exit(2); + } + } + } catch (Exception e) { + retry++; + s_logger.error("SSH Linux Network test fail with error"); + if (retry == MAX_RETRY_LINUX) { + s_logger.error("Ssh test failed"); + System.exit(2); + } + } + } } diff --git a/test/src/com/cloud/test/ui/AbstractSeleniumTestCase.java b/test/src/com/cloud/test/ui/AbstractSeleniumTestCase.java index 1f3724460ea..9b0ae45d728 100644 --- a/test/src/com/cloud/test/ui/AbstractSeleniumTestCase.java +++ b/test/src/com/cloud/test/ui/AbstractSeleniumTestCase.java @@ -31,30 +31,30 @@ import com.thoughtworks.selenium.DefaultSelenium; @RunWith(JUnit4.class) public abstract class AbstractSeleniumTestCase { - protected static DefaultSelenium selenium; - private static SeleniumServer seleniumServer; + protected static DefaultSelenium selenium; + private static SeleniumServer seleniumServer; - @BeforeClass - public static void setUp() throws Exception { - System.out.println("*** Starting selenium ... ***"); - RemoteControlConfiguration seleniumConfig = new RemoteControlConfiguration(); - seleniumConfig.setPort(4444); - seleniumServer = new SeleniumServer(seleniumConfig); - seleniumServer.start(); + @BeforeClass + public static void setUp() throws Exception { + System.out.println("*** Starting selenium ... ***"); + RemoteControlConfiguration seleniumConfig = new RemoteControlConfiguration(); + seleniumConfig.setPort(4444); + seleniumServer = new SeleniumServer(seleniumConfig); + seleniumServer.start(); - String host = System.getProperty("myParam", "localhost"); - selenium = createSeleniumClient("http://" + host + ":" + "8080/client/"); - selenium.start(); - System.out.println("*** Started selenium ***"); - } + String host = System.getProperty("myParam", "localhost"); + selenium = createSeleniumClient("http://" + host + ":" + "8080/client/"); + selenium.start(); + System.out.println("*** Started selenium ***"); + } - @AfterClass - public static void tearDown() throws Exception { - selenium.stop(); - } + @AfterClass + public static void tearDown() throws Exception { + selenium.stop(); + } - protected static DefaultSelenium createSeleniumClient(String url) - throws Exception { - return new DefaultSelenium("localhost", 4444, "*firefox", url); - } + protected static DefaultSelenium createSeleniumClient(String url) + throws Exception { + return new DefaultSelenium("localhost", 4444, "*firefox", url); + } } diff --git a/test/src/com/cloud/test/ui/AddAndDeleteAISO.java b/test/src/com/cloud/test/ui/AddAndDeleteAISO.java index c8e5997553b..e4eedf85e26 100644 --- a/test/src/com/cloud/test/ui/AddAndDeleteAISO.java +++ b/test/src/com/cloud/test/ui/AddAndDeleteAISO.java @@ -24,94 +24,94 @@ import com.thoughtworks.selenium.SeleniumException; public class AddAndDeleteAISO extends AbstractSeleniumTestCase { - @Test - public void testAddAndDeleteISO() throws Exception { - try { - selenium.open("/client/"); - selenium.type("account_username", "admin"); - selenium.type("account_password", "password"); - selenium.click("loginbutton"); - Thread.sleep(3000); - assertTrue(selenium.isTextPresent("admin")); - selenium.click("//div[@id='leftmenu_templates']/div"); - selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]"); - Thread.sleep(3000); - selenium.click("label"); + @Test + public void testAddAndDeleteISO() throws Exception { + try { + selenium.open("/client/"); + selenium.type("account_username", "admin"); + selenium.type("account_password", "password"); + selenium.click("loginbutton"); + Thread.sleep(3000); + assertTrue(selenium.isTextPresent("admin")); + selenium.click("//div[@id='leftmenu_templates']/div"); + selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]"); + Thread.sleep(3000); + selenium.click("label"); - selenium.type("add_iso_name", "abc"); - selenium.type("add_iso_display_text", "abc"); - String iso_url = System.getProperty("add_iso_url", "http://10.91.28.6/ISO/Fedora-11-i386-DVD.iso"); - selenium.type("add_iso_url", iso_url); - String iso_zone = System.getProperty("add_iso_zone", "All Zones"); - selenium.select("add_iso_zone", "label="+iso_zone); - String iso_os_type = System.getProperty("add_iso_os_type", "Fedora 11"); - selenium.select("add_iso_os_type", "label="+iso_os_type); - selenium.click("//div[28]/div[11]/button[1]"); - Thread.sleep(3000); - int i=1; - try - { - for(;;i++) - { - System.out.println("i= "+i); - selenium.click("//div[" +i+ "]/div/div[2]/span/span"); - } - } - catch(Exception ex) { - } + selenium.type("add_iso_name", "abc"); + selenium.type("add_iso_display_text", "abc"); + String iso_url = System.getProperty("add_iso_url", "http://10.91.28.6/ISO/Fedora-11-i386-DVD.iso"); + selenium.type("add_iso_url", iso_url); + String iso_zone = System.getProperty("add_iso_zone", "All Zones"); + selenium.select("add_iso_zone", "label="+iso_zone); + String iso_os_type = System.getProperty("add_iso_os_type", "Fedora 11"); + selenium.select("add_iso_os_type", "label="+iso_os_type); + selenium.click("//div[28]/div[11]/button[1]"); + Thread.sleep(3000); + int i=1; + try + { + for(;;i++) + { + System.out.println("i= "+i); + selenium.click("//div[" +i+ "]/div/div[2]/span/span"); + } + } + catch(Exception ex) { + } - for (int second = 0;; second++) { - if (second >= 60) fail("timeout"); - try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {} - Thread.sleep(10000); - } + for (int second = 0;; second++) { + if (second >= 60) fail("timeout"); + try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {} + Thread.sleep(10000); + } - assertTrue(selenium.isTextPresent("Adding succeeded")); - Thread.sleep(3000); - int status=1; - while(!selenium.isTextPresent("Ready")) - { - for(int j =1;j<=i;j++) + assertTrue(selenium.isTextPresent("Adding succeeded")); + Thread.sleep(3000); + int status=1; + while(!selenium.isTextPresent("Ready")) + { + for(int j =1;j<=i;j++) - { - if (selenium.isTextPresent("Ready")) - { - status=0; - break; - } - selenium.click("//div["+j+"]/div/div[2]/span/span"); - } - if(status==0){ - break; - } - else - { - selenium.click("//div[@id='leftmenu_submenu_featured_iso']/div/div[2]"); - Thread.sleep(3000); - selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]"); - Thread.sleep(3000); - } + { + if (selenium.isTextPresent("Ready")) + { + status=0; + break; + } + selenium.click("//div["+j+"]/div/div[2]/span/span"); + } + if(status==0){ + break; + } + else + { + selenium.click("//div[@id='leftmenu_submenu_featured_iso']/div/div[2]"); + Thread.sleep(3000); + selenium.click("//div[@id='leftmenu_submenu_my_iso']/div/div[2]"); + Thread.sleep(3000); + } - } - selenium.click("link=Delete ISO"); - selenium.click("//div[28]/div[11]/button[1]"); - for (int second = 0;; second++) { - if (second >= 60) fail("timeout"); - try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {} - Thread.sleep(1000); - } + } + selenium.click("link=Delete ISO"); + selenium.click("//div[28]/div[11]/button[1]"); + for (int second = 0;; second++) { + if (second >= 60) fail("timeout"); + try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {} + Thread.sleep(1000); + } - assertTrue(selenium.isTextPresent("Delete ISO action succeeded")); - selenium.click("main_logout"); - selenium.waitForPageToLoad("30000"); - assertTrue(selenium.isTextPresent("Welcome to Management Console")); + assertTrue(selenium.isTextPresent("Delete ISO action succeeded")); + selenium.click("main_logout"); + selenium.waitForPageToLoad("30000"); + assertTrue(selenium.isTextPresent("Welcome to Management Console")); - } catch (SeleniumException ex) { + } catch (SeleniumException ex) { - System.err.println(ex.getMessage()); - fail(ex.getMessage()); + System.err.println(ex.getMessage()); + fail(ex.getMessage()); - throw ex; - } - } + throw ex; + } + } } \ No newline at end of file diff --git a/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java b/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java index 29404bf477c..ed4b770d85f 100644 --- a/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java +++ b/test/src/com/cloud/test/ui/AddAndDeleteATemplate.java @@ -24,92 +24,92 @@ import com.thoughtworks.selenium.SeleniumException; public class AddAndDeleteATemplate extends AbstractSeleniumTestCase { - @Test - public void testAddAndDeleteTemplate() throws Exception { - try { - selenium.open("/client/"); - selenium.type("account_username", "admin"); - selenium.type("account_password", "password"); - selenium.click("loginbutton"); - Thread.sleep(3000); - assertTrue(selenium.isTextPresent("admin")); - selenium.click("//div[@id='leftmenu_templates']/div"); - selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]"); - Thread.sleep(3000); - selenium.click("label"); - selenium.type("add_template_name", "abc"); - selenium.type("add_template_display_text", "abc"); - String template_url = System.getProperty("add_template_url", "http://10.91.28.6/templates/centos53-x86_64/latest/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2"); - selenium.type("add_template_url", template_url); - String template_zone = System.getProperty("add_template_zone", "All Zones"); - selenium.select("add_template_zone", "label="+template_zone); - String template_os_type = System.getProperty("add_template_os_type", "CentOS 5.3 (32-bit)"); - selenium.select("add_template_os_type", "label="+template_os_type); - selenium.click("//div[28]/div[11]/button[1]"); - Thread.sleep(3000); - int i=1; - try - { - for(;;i++) - { - System.out.println("i= "+i); - selenium.click("//div[" +i+ "]/div/div[2]/span/span"); - } - } - catch(Exception ex) { - } + @Test + public void testAddAndDeleteTemplate() throws Exception { + try { + selenium.open("/client/"); + selenium.type("account_username", "admin"); + selenium.type("account_password", "password"); + selenium.click("loginbutton"); + Thread.sleep(3000); + assertTrue(selenium.isTextPresent("admin")); + selenium.click("//div[@id='leftmenu_templates']/div"); + selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]"); + Thread.sleep(3000); + selenium.click("label"); + selenium.type("add_template_name", "abc"); + selenium.type("add_template_display_text", "abc"); + String template_url = System.getProperty("add_template_url", "http://10.91.28.6/templates/centos53-x86_64/latest/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2"); + selenium.type("add_template_url", template_url); + String template_zone = System.getProperty("add_template_zone", "All Zones"); + selenium.select("add_template_zone", "label="+template_zone); + String template_os_type = System.getProperty("add_template_os_type", "CentOS 5.3 (32-bit)"); + selenium.select("add_template_os_type", "label="+template_os_type); + selenium.click("//div[28]/div[11]/button[1]"); + Thread.sleep(3000); + int i=1; + try + { + for(;;i++) + { + System.out.println("i= "+i); + selenium.click("//div[" +i+ "]/div/div[2]/span/span"); + } + } + catch(Exception ex) { + } - for (int second = 0;; second++) { - if (second >= 60) fail("timeout"); - try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {} - Thread.sleep(10000); - } + for (int second = 0;; second++) { + if (second >= 60) fail("timeout"); + try { if (selenium.isVisible("//div[@id='after_action_info_container_on_top']")) break; } catch (Exception e) {} + Thread.sleep(10000); + } - assertTrue(selenium.isTextPresent("Adding succeeded")); - Thread.sleep(3000); - int status=1; - while(!selenium.isTextPresent("Ready")) - { - for(int j =1;j<=i;j++) + assertTrue(selenium.isTextPresent("Adding succeeded")); + Thread.sleep(3000); + int status=1; + while(!selenium.isTextPresent("Ready")) + { + for(int j =1;j<=i;j++) - { - if (selenium.isTextPresent("Ready")) - { - status=0; - break; - } - selenium.click("//div["+j+"]/div/div[2]/span/span"); - } - if(status==0){ - break; - } - else - { - selenium.click("//div[@id='leftmenu_submenu_featured_template']/div/div[2]"); - Thread.sleep(3000); - selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]"); - Thread.sleep(3000); - } + { + if (selenium.isTextPresent("Ready")) + { + status=0; + break; + } + selenium.click("//div["+j+"]/div/div[2]/span/span"); + } + if(status==0){ + break; + } + else + { + selenium.click("//div[@id='leftmenu_submenu_featured_template']/div/div[2]"); + Thread.sleep(3000); + selenium.click("//div[@id='leftmenu_submenu_my_template']/div/div[2]"); + Thread.sleep(3000); + } - } - selenium.click("link=Delete Template"); - selenium.click("//div[28]/div[11]/button[1]"); - for (int second = 0;; second++) { - if (second >= 60) fail("timeout"); - try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {} - Thread.sleep(1000); - } + } + selenium.click("link=Delete Template"); + selenium.click("//div[28]/div[11]/button[1]"); + for (int second = 0;; second++) { + if (second >= 60) fail("timeout"); + try { if (selenium.isVisible("after_action_info_container_on_top")) break; } catch (Exception e) {} + Thread.sleep(1000); + } - assertTrue(selenium.isTextPresent("Delete Template action succeeded")); - selenium.click("main_logout"); - selenium.waitForPageToLoad("30000"); - assertTrue(selenium.isTextPresent("Welcome to Management Console")); - } catch (SeleniumException ex) { + assertTrue(selenium.isTextPresent("Delete Template action succeeded")); + selenium.click("main_logout"); + selenium.waitForPageToLoad("30000"); + assertTrue(selenium.isTextPresent("Welcome to Management Console")); + } catch (SeleniumException ex) { - System.err.println(ex.getMessage()); - fail(ex.getMessage()); + System.err.println(ex.getMessage()); + fail(ex.getMessage()); - throw ex; - } - } + throw ex; + } + } } \ No newline at end of file diff --git a/test/src/com/cloud/test/ui/UIScenarioTest.java b/test/src/com/cloud/test/ui/UIScenarioTest.java index 32619b05b36..3dbc1e8043e 100644 --- a/test/src/com/cloud/test/ui/UIScenarioTest.java +++ b/test/src/com/cloud/test/ui/UIScenarioTest.java @@ -24,61 +24,61 @@ import com.thoughtworks.selenium.SeleniumException; public class UIScenarioTest extends AbstractSeleniumTestCase { - @Test - public void testLoginStartStopVMScenario() throws Exception { - try { - selenium.open("/client/"); - selenium.type("account_username", "admin"); - selenium.type("account_password", "password"); - selenium.click("loginbutton"); - Thread.sleep(3000); - assertTrue(selenium.isTextPresent("admin")); - selenium.click("//div[@id='leftmenu_instances']/div"); - selenium - .click("//div[@id='leftmenu_instances_stopped_instances']/div/span"); + @Test + public void testLoginStartStopVMScenario() throws Exception { + try { + selenium.open("/client/"); + selenium.type("account_username", "admin"); + selenium.type("account_password", "password"); + selenium.click("loginbutton"); + Thread.sleep(3000); + assertTrue(selenium.isTextPresent("admin")); + selenium.click("//div[@id='leftmenu_instances']/div"); + selenium + .click("//div[@id='leftmenu_instances_stopped_instances']/div/span"); - Thread.sleep(3000); - selenium.click("//div[@id='midmenu_startvm_link']/div/div[2]"); - selenium.click("//div[39]/div[11]/button[1]"); + Thread.sleep(3000); + selenium.click("//div[@id='midmenu_startvm_link']/div/div[2]"); + selenium.click("//div[39]/div[11]/button[1]"); - for (int second = 0;; second++) { - if (second >= 60) - fail("timeout"); - try { - if (selenium.isVisible("//div/p[@id='after_action_info']")) - break; - } catch (Exception e) { - } - Thread.sleep(10000); - } - assertTrue(selenium - .isTextPresent("Start Instance action succeeded")); - selenium - .click("//div[@id='leftmenu_instances_running_instances']/div/span"); + for (int second = 0;; second++) { + if (second >= 60) + fail("timeout"); + try { + if (selenium.isVisible("//div/p[@id='after_action_info']")) + break; + } catch (Exception e) { + } + Thread.sleep(10000); + } + assertTrue(selenium + .isTextPresent("Start Instance action succeeded")); + selenium + .click("//div[@id='leftmenu_instances_running_instances']/div/span"); - Thread.sleep(3000); - selenium.click("//div[@id='midmenu_stopvm_link']/div/div[2]"); - selenium.click("//div[39]/div[11]/button[1]"); - for (int second = 0;; second++) { - if (second >= 60) - fail("timeout"); - try { - if (selenium.isVisible("//div/p[@id='after_action_info']")) - break; - } catch (Exception e) { - } - Thread.sleep(10000); - } + Thread.sleep(3000); + selenium.click("//div[@id='midmenu_stopvm_link']/div/div[2]"); + selenium.click("//div[39]/div[11]/button[1]"); + for (int second = 0;; second++) { + if (second >= 60) + fail("timeout"); + try { + if (selenium.isVisible("//div/p[@id='after_action_info']")) + break; + } catch (Exception e) { + } + Thread.sleep(10000); + } - assertTrue(selenium.isTextPresent("Stop Instance action succeeded")); - selenium.click("main_logout"); - selenium.waitForPageToLoad("30000"); - assertTrue(selenium.isTextPresent("Welcome to Management Console")); + assertTrue(selenium.isTextPresent("Stop Instance action succeeded")); + selenium.click("main_logout"); + selenium.waitForPageToLoad("30000"); + assertTrue(selenium.isTextPresent("Welcome to Management Console")); - } catch (SeleniumException ex) { - fail(ex.getMessage()); - System.err.println(ex.getMessage()); - throw ex; - } - } + } catch (SeleniumException ex) { + fail(ex.getMessage()); + System.err.println(ex.getMessage()); + throw ex; + } + } } diff --git a/test/src/com/cloud/test/utils/ConsoleProxy.java b/test/src/com/cloud/test/utils/ConsoleProxy.java index 2783b2374bb..2ab78a95a5f 100644 --- a/test/src/com/cloud/test/utils/ConsoleProxy.java +++ b/test/src/com/cloud/test/utils/ConsoleProxy.java @@ -25,90 +25,90 @@ import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; public class ConsoleProxy implements Runnable { - public static String proxyIp; - private String command; - private int connectionsMade; - private long responseTime; - public static final Logger s_logger = Logger.getLogger(ConsoleProxy.class - .getClass()); + public static String proxyIp; + private String command; + private int connectionsMade; + private long responseTime; + public static final Logger s_logger = Logger.getLogger(ConsoleProxy.class + .getClass()); - public ConsoleProxy(String port, String sid, String host) { - this.command = "https://" + proxyIp - + ".realhostip.com:8000/getscreen?w=100&h=75&host=" + host - + "&port=" + port + "&sid=" + sid; - s_logger.info("Command for a console proxy is " + this.command); - this.connectionsMade=0; - this.responseTime=0; - } + public ConsoleProxy(String port, String sid, String host) { + this.command = "https://" + proxyIp + + ".realhostip.com:8000/getscreen?w=100&h=75&host=" + host + + "&port=" + port + "&sid=" + sid; + s_logger.info("Command for a console proxy is " + this.command); + this.connectionsMade=0; + this.responseTime=0; + } - public int getConnectionsMade() { - return this.connectionsMade; - } - - public long getResponseTime() { - return this.responseTime; - } - - public void run() { - while (true){ - - Script myScript = new Script("wget"); - myScript.add(command); - myScript.execute(); - long begin = System.currentTimeMillis(); - wgetInt process = new wgetInt(); - String response = myScript.execute(process); - long end = process.getEnd(); - if (response!=null){ - s_logger.info("Content lenght is incorrect: "+response); - } - - long duration = (end - begin); - this.connectionsMade++; - this.responseTime=this.responseTime+duration; - try{ - Thread.sleep(1000); - }catch (InterruptedException e){ - - } - - } - } + public int getConnectionsMade() { + return this.connectionsMade; + } + + public long getResponseTime() { + return this.responseTime; + } + + public void run() { + while (true){ + + Script myScript = new Script("wget"); + myScript.add(command); + myScript.execute(); + long begin = System.currentTimeMillis(); + wgetInt process = new wgetInt(); + String response = myScript.execute(process); + long end = process.getEnd(); + if (response!=null){ + s_logger.info("Content lenght is incorrect: "+response); + } + + long duration = (end - begin); + this.connectionsMade++; + this.responseTime=this.responseTime+duration; + try{ + Thread.sleep(1000); + }catch (InterruptedException e){ + + } + + } + } - public class wgetInt extends OutputInterpreter { - private long end; - - public long getEnd() { - return end; - } + public class wgetInt extends OutputInterpreter { + private long end; + + public long getEnd() { + return end; + } - public void setEnd(long end) { - this.end = end; - } + public void setEnd(long end) { + this.end = end; + } - @Override - public String interpret(BufferedReader reader) throws IOException { - // TODO Auto-generated method stub - end = System.currentTimeMillis(); - String status = null; - String line = null; + @Override + public String interpret(BufferedReader reader) throws IOException { + // TODO Auto-generated method stub + end = System.currentTimeMillis(); + String status = null; + String line = null; while ((line = reader.readLine()) != null) { int index = line.indexOf("Length:"); if (index == -1) { continue; } else{ - int index1 = line.indexOf("Length: 1827"); - if (index1 == -1) { + int index1 = line.indexOf("Length: 1827"); + if (index1 == -1) { return status; } - else - status=line; + else + status=line; } - + } - return status; - } + return status; + } - } + } } diff --git a/test/src/com/cloud/test/utils/IpSqlGenerator.java b/test/src/com/cloud/test/utils/IpSqlGenerator.java index 9bb802e1f7a..9ae22ebad38 100644 --- a/test/src/com/cloud/test/utils/IpSqlGenerator.java +++ b/test/src/com/cloud/test/utils/IpSqlGenerator.java @@ -22,67 +22,67 @@ import java.io.FileOutputStream; import java.util.StringTokenizer; public class IpSqlGenerator { - public static void main (String[] args) { - try { - if (args.length != 5) { - System.out.println("Usage -- generate-ip.sh "); - System.out.println("Example -- generate-ip.sh public 192.168.1.1 192.168.1.255 1 1"); - System.out.println(" will generate ips ranging from public ips 192.168.1.1 to 192.168.1.255 for dc 1 and pod 1"); - return; - } - - String type = args[0]; - - StringTokenizer st = new StringTokenizer(args[1], "."); - int ipS1 = Integer.parseInt(st.nextToken()); - int ipS2 = Integer.parseInt(st.nextToken()); - int ipS3 = Integer.parseInt(st.nextToken()); - int ipS4 = Integer.parseInt(st.nextToken()); - - st = new StringTokenizer(args[2], "."); - int ipE1 = Integer.parseInt(st.nextToken()); - int ipE2 = Integer.parseInt(st.nextToken()); - int ipE3 = Integer.parseInt(st.nextToken()); - int ipE4 = Integer.parseInt(st.nextToken()); - - String dcId = args[3]; - String podId = args[4]; - - if (type.equals("private")) { - FileOutputStream fs = new FileOutputStream(new File("private-ips.sql")); - DataOutputStream out = new DataOutputStream(fs); - for (int i = ipS1; i <= ipE1; i++) { - for (int j = ipS2; j <= ipE2; j++) { - for (int k = ipS3; k <= ipE3; k++) { - for (int l = ipS4; l <= ipE4; l++) { - out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('" - + i + "." + j + "." + k + "." + l + "'," + dcId + "," + podId + ");\r\n"); - } - } - } - } - out.writeBytes("\r\n"); - out.flush(); - out.close(); - } else { - FileOutputStream fs = new FileOutputStream(new File("public-ips.sql")); - DataOutputStream out = new DataOutputStream(fs); - for (int i = ipS1; i <= ipE1; i++) { - for (int j = ipS2; j <= ipE2; j++) { - for (int k = ipS3; k <= ipE3; k++) { - for (int l = ipS4; l <= ipE4; l++) { - out.writeBytes("INSERT INTO `vmops`.`user_ip_address` (ip_address, data_center_id) VALUES ('" - + i + "." + j + "." + k + "." + l + "'," + dcId + ");\r\n"); - } - } - } - } - out.writeBytes("\r\n"); - out.flush(); - out.close(); - } - } catch (Exception e) { - - } - } + public static void main (String[] args) { + try { + if (args.length != 5) { + System.out.println("Usage -- generate-ip.sh "); + System.out.println("Example -- generate-ip.sh public 192.168.1.1 192.168.1.255 1 1"); + System.out.println(" will generate ips ranging from public ips 192.168.1.1 to 192.168.1.255 for dc 1 and pod 1"); + return; + } + + String type = args[0]; + + StringTokenizer st = new StringTokenizer(args[1], "."); + int ipS1 = Integer.parseInt(st.nextToken()); + int ipS2 = Integer.parseInt(st.nextToken()); + int ipS3 = Integer.parseInt(st.nextToken()); + int ipS4 = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(args[2], "."); + int ipE1 = Integer.parseInt(st.nextToken()); + int ipE2 = Integer.parseInt(st.nextToken()); + int ipE3 = Integer.parseInt(st.nextToken()); + int ipE4 = Integer.parseInt(st.nextToken()); + + String dcId = args[3]; + String podId = args[4]; + + if (type.equals("private")) { + FileOutputStream fs = new FileOutputStream(new File("private-ips.sql")); + DataOutputStream out = new DataOutputStream(fs); + for (int i = ipS1; i <= ipE1; i++) { + for (int j = ipS2; j <= ipE2; j++) { + for (int k = ipS3; k <= ipE3; k++) { + for (int l = ipS4; l <= ipE4; l++) { + out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('" + + i + "." + j + "." + k + "." + l + "'," + dcId + "," + podId + ");\r\n"); + } + } + } + } + out.writeBytes("\r\n"); + out.flush(); + out.close(); + } else { + FileOutputStream fs = new FileOutputStream(new File("public-ips.sql")); + DataOutputStream out = new DataOutputStream(fs); + for (int i = ipS1; i <= ipE1; i++) { + for (int j = ipS2; j <= ipE2; j++) { + for (int k = ipS3; k <= ipE3; k++) { + for (int l = ipS4; l <= ipE4; l++) { + out.writeBytes("INSERT INTO `vmops`.`user_ip_address` (ip_address, data_center_id) VALUES ('" + + i + "." + j + "." + k + "." + l + "'," + dcId + ");\r\n"); + } + } + } + } + out.writeBytes("\r\n"); + out.flush(); + out.close(); + } + } catch (Exception e) { + + } + } } diff --git a/test/src/com/cloud/test/utils/ProxyLoadTemp.java b/test/src/com/cloud/test/utils/ProxyLoadTemp.java index e2052b35c93..638818d60e3 100644 --- a/test/src/com/cloud/test/utils/ProxyLoadTemp.java +++ b/test/src/com/cloud/test/utils/ProxyLoadTemp.java @@ -26,38 +26,38 @@ import org.apache.log4j.Logger; public class ProxyLoadTemp { - public static final Logger s_logger= Logger.getLogger(ProxyLoadTemp.class.getClass()); - public static int numThreads=0; - public static ArrayList proxyList = new ArrayList(); - public static long begin; - public static long end; - public static long sum=0; - - public ProxyLoadTemp(){ - } - - public static void main (String[] args){ - begin= System.currentTimeMillis(); - Runtime.getRuntime().addShutdownHook(new ShutdownThread(new ProxyLoadTemp())); - ConsoleProxy.proxyIp="172-16-1-101"; - - try + public static final Logger s_logger= Logger.getLogger(ProxyLoadTemp.class.getClass()); + public static int numThreads=0; + public static ArrayList proxyList = new ArrayList(); + public static long begin; + public static long end; + public static long sum=0; + + public ProxyLoadTemp(){ + } + + public static void main (String[] args){ + begin= System.currentTimeMillis(); + Runtime.getRuntime().addShutdownHook(new ShutdownThread(new ProxyLoadTemp())); + ConsoleProxy.proxyIp="172-16-1-101"; + + try { - BufferedReader consoleInput = new BufferedReader(new FileReader("console.input")); - boolean eof = false; - s_logger.info("Started reading file"); - while (!eof){ - String line = consoleInput.readLine(); - s_logger.info("Line is "+line); - if (line == null){ - s_logger.info("Line "+numThreads+" is null"); + BufferedReader consoleInput = new BufferedReader(new FileReader("console.input")); + boolean eof = false; + s_logger.info("Started reading file"); + while (!eof){ + String line = consoleInput.readLine(); + s_logger.info("Line is "+line); + if (line == null){ + s_logger.info("Line "+numThreads+" is null"); eof=true; - } - else{ - String[] result=null; + } + else{ + String[] result=null; try { - s_logger.info("Starting parsing line "+line); + s_logger.info("Starting parsing line "+line); result= parseLine(line, "[,]"); s_logger.info("Line retrieved from the file is "+result[0]+" "+result[1]+" "+result[2]); ConsoleProxy proxy = new ConsoleProxy(result[0], result[1], result[2]); @@ -67,42 +67,42 @@ public class ProxyLoadTemp { } catch (Exception ex){ - s_logger.warn(ex); + s_logger.warn(ex); } - } - - } - }catch(Exception e){ - s_logger.warn(e); + } + } - - } - - public static class ShutdownThread extends Thread { - ProxyLoadTemp temp; - public ShutdownThread(ProxyLoadTemp temp) { - this.temp = temp; - } - public void run() { - s_logger.info("Program was running in "+numThreads+" threads"); - - for (int j=0; j argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - while (iter.hasNext()) { - String arg = iter.next(); + public static String url; + public static String secretkey; + public static String host; + public static String port; + public static String command; + public static String accessPoint; + public static final Logger s_logger = Logger + .getLogger(SignRequest.class.getName()); + + + public static void main (String[] args) { + // Parameters + List argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + while (iter.hasNext()) { + String arg = iter.next(); - if (arg.equals("-u")) { - url = iter.next(); - } - } - - Properties prop = new Properties(); - try { - prop.load(new FileInputStream("../conf/tool.properties")); - } catch (IOException ex) { - s_logger.error("Error reading from ../conf/tool.properties", ex); - System.exit(2); - } - - host = prop.getProperty("host"); - secretkey = prop.getProperty("secretkey"); - port = prop.getProperty("port"); - - - if (host == null) { - s_logger.info("Please set host in tool.properties file"); - System.exit(1); - } - - if (port == null) { - s_logger.info("Please set port in tool.properties file"); - System.exit(1); - } - - if (url == null) { - s_logger.info("Please specify url with -u option"); - System.exit(1); - } - - if (secretkey == null) { - s_logger.info("Please set secretkey in tool.properties file"); - System.exit(1); - } - - if (prop.get("apikey") == null) { - s_logger.info("Please set apikey in tool.properties file"); - System.exit(1); - } - - if (prop.get("accesspoint") == null) { - s_logger.info("Please set apikey in tool.properties file"); - System.exit(1); - } - - - - TreeMap param = new TreeMap(); - - String req = "GET\n" + host + ":" + prop.getProperty("port") + "\n/" + prop.getProperty("accesspoint") + "\n"; - String temp = ""; - param.put("AWSAccessKeyId", prop.getProperty("apikey")); - param.put("Expires",prop.getProperty("expires")); - param.put("SignatureMethod", "HmacSHA1"); - param.put("SignatureVersion", "2"); - param.put("Version", prop.getProperty("version")); - param.put("id", "1"); - - StringTokenizer str1 = new StringTokenizer (url, "&"); - while(str1.hasMoreTokens()) { - String newEl = str1.nextToken(); - StringTokenizer str2 = new StringTokenizer(newEl, "="); - String name = str2.nextToken(); - String value= str2.nextToken(); - param.put(name, value); - } - - //sort url hash map by key - Set c = param.entrySet(); - Iterator it = c.iterator(); - while (it.hasNext()) { - Map.Entry me = (Map.Entry)it.next(); - String key = (String) me.getKey(); - String value = (String) me.getValue(); - try { - temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&"; - } catch (Exception ex) { - s_logger.error("Unable to set parameter " + value + " for the command " + param.get("command")); - } - - } - temp = temp.substring(0, temp.length()-1 ); - String requestToSign = req + temp; - String signature = UtilsForTest.signRequest(requestToSign, secretkey); - String encodedSignature = ""; - try { - encodedSignature = URLEncoder.encode(signature, "UTF-8"); - } catch (Exception ex) { - s_logger.error(ex); - } - String url = "http://" + host + ":" + prop.getProperty("port") + "/" + prop.getProperty("accesspoint") + "?" + temp + "&Signature=" + encodedSignature; - s_logger.info("Url is " + url); - - } + if (arg.equals("-u")) { + url = iter.next(); + } + } + + Properties prop = new Properties(); + try { + prop.load(new FileInputStream("../conf/tool.properties")); + } catch (IOException ex) { + s_logger.error("Error reading from ../conf/tool.properties", ex); + System.exit(2); + } + + host = prop.getProperty("host"); + secretkey = prop.getProperty("secretkey"); + port = prop.getProperty("port"); + + + if (host == null) { + s_logger.info("Please set host in tool.properties file"); + System.exit(1); + } + + if (port == null) { + s_logger.info("Please set port in tool.properties file"); + System.exit(1); + } + + if (url == null) { + s_logger.info("Please specify url with -u option"); + System.exit(1); + } + + if (secretkey == null) { + s_logger.info("Please set secretkey in tool.properties file"); + System.exit(1); + } + + if (prop.get("apikey") == null) { + s_logger.info("Please set apikey in tool.properties file"); + System.exit(1); + } + + if (prop.get("accesspoint") == null) { + s_logger.info("Please set apikey in tool.properties file"); + System.exit(1); + } + + + + TreeMap param = new TreeMap(); + + String req = "GET\n" + host + ":" + prop.getProperty("port") + "\n/" + prop.getProperty("accesspoint") + "\n"; + String temp = ""; + param.put("AWSAccessKeyId", prop.getProperty("apikey")); + param.put("Expires",prop.getProperty("expires")); + param.put("SignatureMethod", "HmacSHA1"); + param.put("SignatureVersion", "2"); + param.put("Version", prop.getProperty("version")); + param.put("id", "1"); + + StringTokenizer str1 = new StringTokenizer (url, "&"); + while(str1.hasMoreTokens()) { + String newEl = str1.nextToken(); + StringTokenizer str2 = new StringTokenizer(newEl, "="); + String name = str2.nextToken(); + String value= str2.nextToken(); + param.put(name, value); + } + + //sort url hash map by key + Set c = param.entrySet(); + Iterator it = c.iterator(); + while (it.hasNext()) { + Map.Entry me = (Map.Entry)it.next(); + String key = (String) me.getKey(); + String value = (String) me.getValue(); + try { + temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&"; + } catch (Exception ex) { + s_logger.error("Unable to set parameter " + value + " for the command " + param.get("command")); + } + + } + temp = temp.substring(0, temp.length()-1 ); + String requestToSign = req + temp; + String signature = UtilsForTest.signRequest(requestToSign, secretkey); + String encodedSignature = ""; + try { + encodedSignature = URLEncoder.encode(signature, "UTF-8"); + } catch (Exception ex) { + s_logger.error(ex); + } + String url = "http://" + host + ":" + prop.getProperty("port") + "/" + prop.getProperty("accesspoint") + "?" + temp + "&Signature=" + encodedSignature; + s_logger.info("Url is " + url); + + } } diff --git a/test/src/com/cloud/test/utils/SignRequest.java b/test/src/com/cloud/test/utils/SignRequest.java index cebcbd1cd91..7f18d92c2e2 100644 --- a/test/src/com/cloud/test/utils/SignRequest.java +++ b/test/src/com/cloud/test/utils/SignRequest.java @@ -26,89 +26,89 @@ import java.util.StringTokenizer; import java.util.TreeMap; public class SignRequest { - public static String url; - public static String apikey; - public static String secretkey; - public static String command; - - - public static void main (String[] args) { - // Parameters - List argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - while (iter.hasNext()) { - String arg = iter.next(); - if (arg.equals("-a")) { - apikey = iter.next(); - - } - if (arg.equals("-u")) { - url = iter.next(); - } - - if (arg.equals("-s")) { - secretkey = iter.next(); - } - } - - - if (url == null) { - System.out.println("Please specify url with -u option. Example: -u \"command=listZones&id=1\""); - System.exit(1); - } - - if (apikey == null) { - System.out.println("Please specify apikey with -a option"); - System.exit(1); - } - - if (secretkey == null) { - System.out.println("Please specify secretkey with -s option"); - System.exit(1); - } - - TreeMap param = new TreeMap(); - - String temp = ""; - param.put("apikey", apikey); - - StringTokenizer str1 = new StringTokenizer (url, "&"); - while(str1.hasMoreTokens()) { - String newEl = str1.nextToken(); - StringTokenizer str2 = new StringTokenizer(newEl, "="); - String name = str2.nextToken(); - String value= str2.nextToken(); - param.put(name, value); - } - - //sort url hash map by key - Set c = param.entrySet(); - Iterator it = c.iterator(); - while (it.hasNext()) { - Map.Entry me = (Map.Entry)it.next(); - String key = (String) me.getKey(); - String value = (String) me.getValue(); - try { - temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&"; - } catch (Exception ex) { - System.out.println("Unable to set parameter " + value + " for the command " + param.get("command")); - } - - } - temp = temp.substring(0, temp.length()-1 ); - String requestToSign = temp.toLowerCase(); - System.out.println("After sorting: " + requestToSign); - String signature = UtilsForTest.signRequest(requestToSign, secretkey); - System.out.println("After Base64 encoding: " + signature); - String encodedSignature = ""; - try { - encodedSignature = URLEncoder.encode(signature, "UTF-8"); - } catch (Exception ex) { - System.out.println(ex); - } - System.out.println("After UTF8 encoding: " + encodedSignature); - String url = temp + "&signature=" + encodedSignature; - System.out.println("After sort and add signature: " + url); - - } + public static String url; + public static String apikey; + public static String secretkey; + public static String command; + + + public static void main (String[] args) { + // Parameters + List argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + while (iter.hasNext()) { + String arg = iter.next(); + if (arg.equals("-a")) { + apikey = iter.next(); + + } + if (arg.equals("-u")) { + url = iter.next(); + } + + if (arg.equals("-s")) { + secretkey = iter.next(); + } + } + + + if (url == null) { + System.out.println("Please specify url with -u option. Example: -u \"command=listZones&id=1\""); + System.exit(1); + } + + if (apikey == null) { + System.out.println("Please specify apikey with -a option"); + System.exit(1); + } + + if (secretkey == null) { + System.out.println("Please specify secretkey with -s option"); + System.exit(1); + } + + TreeMap param = new TreeMap(); + + String temp = ""; + param.put("apikey", apikey); + + StringTokenizer str1 = new StringTokenizer (url, "&"); + while(str1.hasMoreTokens()) { + String newEl = str1.nextToken(); + StringTokenizer str2 = new StringTokenizer(newEl, "="); + String name = str2.nextToken(); + String value= str2.nextToken(); + param.put(name, value); + } + + //sort url hash map by key + Set c = param.entrySet(); + Iterator it = c.iterator(); + while (it.hasNext()) { + Map.Entry me = (Map.Entry)it.next(); + String key = (String) me.getKey(); + String value = (String) me.getValue(); + try { + temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&"; + } catch (Exception ex) { + System.out.println("Unable to set parameter " + value + " for the command " + param.get("command")); + } + + } + temp = temp.substring(0, temp.length()-1 ); + String requestToSign = temp.toLowerCase(); + System.out.println("After sorting: " + requestToSign); + String signature = UtilsForTest.signRequest(requestToSign, secretkey); + System.out.println("After Base64 encoding: " + signature); + String encodedSignature = ""; + try { + encodedSignature = URLEncoder.encode(signature, "UTF-8"); + } catch (Exception ex) { + System.out.println(ex); + } + System.out.println("After UTF8 encoding: " + encodedSignature); + String url = temp + "&signature=" + encodedSignature; + System.out.println("After sort and add signature: " + url); + + } } diff --git a/test/src/com/cloud/test/utils/SqlDataGenerator.java b/test/src/com/cloud/test/utils/SqlDataGenerator.java index c2f31df282c..bd83eddd50f 100644 --- a/test/src/com/cloud/test/utils/SqlDataGenerator.java +++ b/test/src/com/cloud/test/utils/SqlDataGenerator.java @@ -22,27 +22,27 @@ import java.io.FileOutputStream; import java.util.Formatter; public class SqlDataGenerator { - public static void main (String[] args) { - try { - FileOutputStream fs = new FileOutputStream(new File("out.txt")); - - DataOutputStream out = new DataOutputStream(fs); - - for (int i = 20; i < 171; i++) { - out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('192.168.2."+i+"',1,1);\r\n"); - } - out.writeBytes("\r\n"); - for (int i = 1; i < 10000; i++) { - StringBuilder imagePath = new StringBuilder(); - Formatter formatter = new Formatter(imagePath); - formatter.format("%04x", i); - out.writeBytes("INSERT INTO `vmops`.`dc_vnet_alloc` (vnet, data_center_id) VALUES ('"+imagePath.toString()+"',1);\r\n"); - } - - out.flush(); - out.close(); - } catch (Exception e) { - - } - } + public static void main (String[] args) { + try { + FileOutputStream fs = new FileOutputStream(new File("out.txt")); + + DataOutputStream out = new DataOutputStream(fs); + + for (int i = 20; i < 171; i++) { + out.writeBytes("INSERT INTO `vmops`.`dc_ip_address_alloc` (ip_address, data_center_id, pod_id) VALUES ('192.168.2."+i+"',1,1);\r\n"); + } + out.writeBytes("\r\n"); + for (int i = 1; i < 10000; i++) { + StringBuilder imagePath = new StringBuilder(); + Formatter formatter = new Formatter(imagePath); + formatter.format("%04x", i); + out.writeBytes("INSERT INTO `vmops`.`dc_vnet_alloc` (vnet, data_center_id) VALUES ('"+imagePath.toString()+"',1);\r\n"); + } + + out.flush(); + out.close(); + } catch (Exception e) { + + } + } } diff --git a/test/src/com/cloud/test/utils/TestClient.java b/test/src/com/cloud/test/utils/TestClient.java index 59fd7e37e6b..dbd6d14f884 100644 --- a/test/src/com/cloud/test/utils/TestClient.java +++ b/test/src/com/cloud/test/utils/TestClient.java @@ -34,348 +34,348 @@ import com.trilead.ssh2.SCPClient; import com.trilead.ssh2.Session; public class TestClient { - private static long sleepTime = 180000L; // default 0 - private static boolean cleanUp = true; - public static final Logger s_logger = Logger.getLogger(TestClient.class.getName()); - private static boolean repeat = true; - private static int numOfUsers = 0; - private static String[] users = null; - private static boolean internet = true; - - private static final int MAX_RETRY_LINUX = 5; - private static final int MAX_RETRY_WIN = 10; - - public static void main (String[] args) { - String host = "http://localhost"; - String port = "8080"; - String testUrl = "/client/test"; - int numThreads = 1; - - try { - // Parameters - List argsList = Arrays.asList(args); - Iterator iter = argsList.iterator(); - while (iter.hasNext()) { - String arg = iter.next(); - // host - if (arg.equals("-h")) { - host = "http://" + iter.next(); - } - - if (arg.equals("-p")) { - port = iter.next(); - } - - if (arg.equals("-t")) { - numThreads = Integer.parseInt(iter.next()); - } - - if (arg.equals("-s")) { - sleepTime = Long.parseLong(iter.next()); - } - - if (arg.equals("-c")) { - cleanUp = Boolean.parseBoolean(iter.next()); - if (!cleanUp) sleepTime = 0L; // no need to wait if we don't ever cleanup - } - - if (arg.equals("-r")) { - repeat = Boolean.parseBoolean(iter.next()); - } - - if (arg.equals("-u")) { - numOfUsers = Integer.parseInt(iter.next()); - } - - if (arg.equals("-i")) { - internet = Boolean.parseBoolean(iter.next()); - } - } - - final String server = host+":"+port+testUrl; - s_logger.info("Starting test against server: " + server + " with " + numThreads + " thread(s)"); - if (cleanUp) s_logger.info("Clean up is enabled, each test will wait " + sleepTime + " ms before cleaning up"); - - if (numOfUsers > 0) { - s_logger.info("Pre-generating users for test of size : " + numOfUsers); - users = new String[numOfUsers]; - Random ran = new Random(); - for (int i = 0; i < numOfUsers; i++) { - users[i] = Math.abs(ran.nextInt()) + "-user"; - } - } - - for (int i = 0; i < numThreads; i++) { - new Thread(new Runnable() { - public void run() { - do { - String username = null; - try { - long now = System.currentTimeMillis(); - Random ran = new Random(); - if (users != null) { - username = users[Math.abs(ran.nextInt()) % numOfUsers]; - } else { - username = Math.abs(ran.nextInt())+"-user"; - } - NDC.push(username); + private static long sleepTime = 180000L; // default 0 + private static boolean cleanUp = true; + public static final Logger s_logger = Logger.getLogger(TestClient.class.getName()); + private static boolean repeat = true; + private static int numOfUsers = 0; + private static String[] users = null; + private static boolean internet = true; + + private static final int MAX_RETRY_LINUX = 5; + private static final int MAX_RETRY_WIN = 10; + + public static void main (String[] args) { + String host = "http://localhost"; + String port = "8080"; + String testUrl = "/client/test"; + int numThreads = 1; + + try { + // Parameters + List argsList = Arrays.asList(args); + Iterator iter = argsList.iterator(); + while (iter.hasNext()) { + String arg = iter.next(); + // host + if (arg.equals("-h")) { + host = "http://" + iter.next(); + } + + if (arg.equals("-p")) { + port = iter.next(); + } + + if (arg.equals("-t")) { + numThreads = Integer.parseInt(iter.next()); + } + + if (arg.equals("-s")) { + sleepTime = Long.parseLong(iter.next()); + } + + if (arg.equals("-c")) { + cleanUp = Boolean.parseBoolean(iter.next()); + if (!cleanUp) sleepTime = 0L; // no need to wait if we don't ever cleanup + } + + if (arg.equals("-r")) { + repeat = Boolean.parseBoolean(iter.next()); + } + + if (arg.equals("-u")) { + numOfUsers = Integer.parseInt(iter.next()); + } + + if (arg.equals("-i")) { + internet = Boolean.parseBoolean(iter.next()); + } + } + + final String server = host+":"+port+testUrl; + s_logger.info("Starting test against server: " + server + " with " + numThreads + " thread(s)"); + if (cleanUp) s_logger.info("Clean up is enabled, each test will wait " + sleepTime + " ms before cleaning up"); + + if (numOfUsers > 0) { + s_logger.info("Pre-generating users for test of size : " + numOfUsers); + users = new String[numOfUsers]; + Random ran = new Random(); + for (int i = 0; i < numOfUsers; i++) { + users[i] = Math.abs(ran.nextInt()) + "-user"; + } + } + + for (int i = 0; i < numThreads; i++) { + new Thread(new Runnable() { + public void run() { + do { + String username = null; + try { + long now = System.currentTimeMillis(); + Random ran = new Random(); + if (users != null) { + username = users[Math.abs(ran.nextInt()) % numOfUsers]; + } else { + username = Math.abs(ran.nextInt())+"-user"; + } + NDC.push(username); - String url = server+"?email="+username+"&password="+username+"&command=deploy"; - s_logger.info("Launching test for user: " + username + " with url: " + url); - HttpClient client = new HttpClient(); - HttpMethod method = new GetMethod(url); - int responseCode = client.executeMethod(method); - boolean success = false; - String reason = null; - if (responseCode == 200) { - if (internet) { - s_logger.info("Deploy successful...waiting 5 minute before SSH tests"); - Thread.sleep(300000L); // Wait 60 seconds so the linux VM can boot up. - - s_logger.info("Begin Linux SSH test"); - reason = sshTest(method.getResponseHeader("linuxIP").getValue()); - - if (reason == null) { - s_logger.info("Linux SSH test successful"); - s_logger.info("Begin Windows SSH test"); - reason = sshWinTest(method.getResponseHeader("windowsIP").getValue()); - } - } - if (reason == null) { - if (internet) { - s_logger.info("Windows SSH test successful"); - } else { - s_logger.info("deploy test successful....now cleaning up"); - if (cleanUp) { - s_logger.info("Waiting " + sleepTime + " ms before cleaning up vms"); - Thread.sleep(sleepTime); - } else { - success = true; - } - } - if (users == null) { - s_logger.info("Sending cleanup command"); - url = server+"?email="+username+"&password="+username+"&command=cleanup"; - } else { - s_logger.info("Sending stop DomR / destroy VM command"); - url = server+"?email="+username+"&password="+username+"&command=stopDomR"; - } - method = new GetMethod(url); - responseCode = client.executeMethod(method); - if (responseCode == 200) { - success = true; - } else { - reason = method.getStatusText(); - } - } else { - // Just stop but don't destroy the VMs/Routers - s_logger.info("SSH test failed with reason '" + reason + "', stopping VMs"); - url = server+"?email="+username+"&password="+username+"&command=stop"; - responseCode = client.executeMethod(new GetMethod(url)); - } - } else { - // Just stop but don't destroy the VMs/Routers - reason = method.getStatusText(); - s_logger.info("Deploy test failed with reason '" + reason + "', stopping VMs"); - url = server+"?email="+username+"&password="+username+"&command=stop"; - client.executeMethod(new GetMethod(url)); - } + String url = server+"?email="+username+"&password="+username+"&command=deploy"; + s_logger.info("Launching test for user: " + username + " with url: " + url); + HttpClient client = new HttpClient(); + HttpMethod method = new GetMethod(url); + int responseCode = client.executeMethod(method); + boolean success = false; + String reason = null; + if (responseCode == 200) { + if (internet) { + s_logger.info("Deploy successful...waiting 5 minute before SSH tests"); + Thread.sleep(300000L); // Wait 60 seconds so the linux VM can boot up. + + s_logger.info("Begin Linux SSH test"); + reason = sshTest(method.getResponseHeader("linuxIP").getValue()); + + if (reason == null) { + s_logger.info("Linux SSH test successful"); + s_logger.info("Begin Windows SSH test"); + reason = sshWinTest(method.getResponseHeader("windowsIP").getValue()); + } + } + if (reason == null) { + if (internet) { + s_logger.info("Windows SSH test successful"); + } else { + s_logger.info("deploy test successful....now cleaning up"); + if (cleanUp) { + s_logger.info("Waiting " + sleepTime + " ms before cleaning up vms"); + Thread.sleep(sleepTime); + } else { + success = true; + } + } + if (users == null) { + s_logger.info("Sending cleanup command"); + url = server+"?email="+username+"&password="+username+"&command=cleanup"; + } else { + s_logger.info("Sending stop DomR / destroy VM command"); + url = server+"?email="+username+"&password="+username+"&command=stopDomR"; + } + method = new GetMethod(url); + responseCode = client.executeMethod(method); + if (responseCode == 200) { + success = true; + } else { + reason = method.getStatusText(); + } + } else { + // Just stop but don't destroy the VMs/Routers + s_logger.info("SSH test failed with reason '" + reason + "', stopping VMs"); + url = server+"?email="+username+"&password="+username+"&command=stop"; + responseCode = client.executeMethod(new GetMethod(url)); + } + } else { + // Just stop but don't destroy the VMs/Routers + reason = method.getStatusText(); + s_logger.info("Deploy test failed with reason '" + reason + "', stopping VMs"); + url = server+"?email="+username+"&password="+username+"&command=stop"; + client.executeMethod(new GetMethod(url)); + } - if (success) { - s_logger.info("***** Completed test for user : " + username + " in " + ((System.currentTimeMillis() - now) / 1000L) + " seconds"); - } else { - s_logger.info("##### FAILED test for user : " + username + " in " + ((System.currentTimeMillis() - now) / 1000L) + " seconds with reason : " + reason); - } - } catch (Exception e) { - s_logger.warn("Error in thread", e); - try { - HttpClient client = new HttpClient(); - String url = server+"?email="+username+"&password="+username+"&command=stop"; - client.executeMethod(new GetMethod(url)); - } catch (Exception e1) { - } - } finally { - NDC.clear(); - } - } while (repeat); - } - }).start(); - } - } catch (Exception e) { - s_logger.error(e); - } - } - - private static String sshWinTest(String host) { - if (host == null) { - s_logger.info("Did not receive a host back from test, ignoring win ssh test"); - return null; - } - - // We will retry 5 times before quitting - int retry = 0; + if (success) { + s_logger.info("***** Completed test for user : " + username + " in " + ((System.currentTimeMillis() - now) / 1000L) + " seconds"); + } else { + s_logger.info("##### FAILED test for user : " + username + " in " + ((System.currentTimeMillis() - now) / 1000L) + " seconds with reason : " + reason); + } + } catch (Exception e) { + s_logger.warn("Error in thread", e); + try { + HttpClient client = new HttpClient(); + String url = server+"?email="+username+"&password="+username+"&command=stop"; + client.executeMethod(new GetMethod(url)); + } catch (Exception e1) { + } + } finally { + NDC.clear(); + } + } while (repeat); + } + }).start(); + } + } catch (Exception e) { + s_logger.error(e); + } + } + + private static String sshWinTest(String host) { + if (host == null) { + s_logger.info("Did not receive a host back from test, ignoring win ssh test"); + return null; + } + + // We will retry 5 times before quitting + int retry = 0; - while (true) { - try { - if (retry > 0) { - s_logger.info("Retry attempt : " + retry + " ...sleeping 300 seconds before next attempt"); - Thread.sleep(300000); - } - - s_logger.info("Attempting to SSH into windows host " + host + " with retry attempt: " + retry); - - Connection conn = new Connection(host); - conn.connect(null, 60000, 60000); - - s_logger.info("SSHed successfully into windows host " + host); - boolean success = false; - boolean isAuthenticated = conn.authenticateWithPassword("vmops", "vmops"); - if (isAuthenticated == false) { - return "Authentication failed"; - } - SCPClient scp = new SCPClient(conn); - - scp.put("wget.exe", ""); - - Session sess = conn.openSession(); - s_logger.info("Executing : wget http://172.16.0.220/dump.bin"); - sess.execCommand("wget http://172.16.0.220/dump.bin && dir dump.bin"); - - InputStream stdout = sess.getStdout(); - InputStream stderr = sess.getStderr(); - - byte[] buffer = new byte[8192]; - while (true) { - if ((stdout.available() == 0) && (stderr.available() == 0)) { - int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA - | ChannelCondition.EOF, 120000); - - if ((conditions & ChannelCondition.TIMEOUT) != 0) { - s_logger.info("Timeout while waiting for data from peer."); - return null; - } - - if ((conditions & ChannelCondition.EOF) != 0) { - if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) { - break; - } - } - } - - while (stdout.available() > 0) { - success = true; - int len = stdout.read(buffer); - if (len > 0) // this check is somewhat paranoid - s_logger.info(new String(buffer, 0, len)); - } - - while (stderr.available() > 0) { - int len = stderr.read(buffer); - } - } - sess.close(); - conn.close(); - - if (success) { - return null; - } else { - retry++; - if (retry == MAX_RETRY_WIN) { - return "SSH Windows Network test fail"; - } - } - } catch (Exception e) { - retry++; - if (retry == MAX_RETRY_WIN) { - return "SSH Windows Network test fail with error " + e.getMessage(); - } - } - } - } - - private static String sshTest(String host) { - if (host == null) { - s_logger.info("Did not receive a host back from test, ignoring ssh test"); - return null; - } - - // We will retry 5 times before quitting - int retry = 0; + while (true) { + try { + if (retry > 0) { + s_logger.info("Retry attempt : " + retry + " ...sleeping 300 seconds before next attempt"); + Thread.sleep(300000); + } + + s_logger.info("Attempting to SSH into windows host " + host + " with retry attempt: " + retry); + + Connection conn = new Connection(host); + conn.connect(null, 60000, 60000); + + s_logger.info("SSHed successfully into windows host " + host); + boolean success = false; + boolean isAuthenticated = conn.authenticateWithPassword("vmops", "vmops"); + if (isAuthenticated == false) { + return "Authentication failed"; + } + SCPClient scp = new SCPClient(conn); + + scp.put("wget.exe", ""); + + Session sess = conn.openSession(); + s_logger.info("Executing : wget http://172.16.0.220/dump.bin"); + sess.execCommand("wget http://172.16.0.220/dump.bin && dir dump.bin"); + + InputStream stdout = sess.getStdout(); + InputStream stderr = sess.getStderr(); + + byte[] buffer = new byte[8192]; + while (true) { + if ((stdout.available() == 0) && (stderr.available() == 0)) { + int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA + | ChannelCondition.EOF, 120000); + + if ((conditions & ChannelCondition.TIMEOUT) != 0) { + s_logger.info("Timeout while waiting for data from peer."); + return null; + } + + if ((conditions & ChannelCondition.EOF) != 0) { + if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) { + break; + } + } + } + + while (stdout.available() > 0) { + success = true; + int len = stdout.read(buffer); + if (len > 0) // this check is somewhat paranoid + s_logger.info(new String(buffer, 0, len)); + } + + while (stderr.available() > 0) { + int len = stderr.read(buffer); + } + } + sess.close(); + conn.close(); + + if (success) { + return null; + } else { + retry++; + if (retry == MAX_RETRY_WIN) { + return "SSH Windows Network test fail"; + } + } + } catch (Exception e) { + retry++; + if (retry == MAX_RETRY_WIN) { + return "SSH Windows Network test fail with error " + e.getMessage(); + } + } + } + } + + private static String sshTest(String host) { + if (host == null) { + s_logger.info("Did not receive a host back from test, ignoring ssh test"); + return null; + } + + // We will retry 5 times before quitting + int retry = 0; - while (true) { - try { - if (retry > 0) { - s_logger.info("Retry attempt : " + retry + " ...sleeping 120 seconds before next attempt"); - Thread.sleep(120000); - } - - s_logger.info("Attempting to SSH into linux host " + host + " with retry attempt: " + retry); - - Connection conn = new Connection(host); - conn.connect(null, 60000, 60000); - - s_logger.info("SSHed successfully into linux host " + host); - - boolean isAuthenticated = conn.authenticateWithPassword("root", "password"); - - if (isAuthenticated == false) { - return "Authentication failed"; - } - boolean success = false; - Session sess = conn.openSession(); - s_logger.info("Executing : wget http://172.16.0.220/dump.bin"); - sess.execCommand("wget http://172.16.0.220/dump.bin && ls -al dump.bin"); - - InputStream stdout = sess.getStdout(); - InputStream stderr = sess.getStderr(); - - byte[] buffer = new byte[8192]; - while (true) { - if ((stdout.available() == 0) && (stderr.available() == 0)) { - int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA - | ChannelCondition.EOF, 120000); - - if ((conditions & ChannelCondition.TIMEOUT) != 0) { - s_logger.info("Timeout while waiting for data from peer."); - return null; - } - - if ((conditions & ChannelCondition.EOF) != 0) { - if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) { - break; - } - } - } - - while (stdout.available() > 0) { - success = true; - int len = stdout.read(buffer); - if (len > 0) // this check is somewhat paranoid - s_logger.info(new String(buffer, 0, len)); - } - - while (stderr.available() > 0) { - int len = stderr.read(buffer); - } - } - - sess.close(); - conn.close(); - - if (success) { - return null; - } else { - retry++; - if (retry == MAX_RETRY_LINUX) { - return "SSH Linux Network test fail"; - } - } - } catch (Exception e) { - retry++; - if (retry == MAX_RETRY_LINUX) { - return "SSH Linux Network test fail with error " + e.getMessage(); - } - } - } - } + while (true) { + try { + if (retry > 0) { + s_logger.info("Retry attempt : " + retry + " ...sleeping 120 seconds before next attempt"); + Thread.sleep(120000); + } + + s_logger.info("Attempting to SSH into linux host " + host + " with retry attempt: " + retry); + + Connection conn = new Connection(host); + conn.connect(null, 60000, 60000); + + s_logger.info("SSHed successfully into linux host " + host); + + boolean isAuthenticated = conn.authenticateWithPassword("root", "password"); + + if (isAuthenticated == false) { + return "Authentication failed"; + } + boolean success = false; + Session sess = conn.openSession(); + s_logger.info("Executing : wget http://172.16.0.220/dump.bin"); + sess.execCommand("wget http://172.16.0.220/dump.bin && ls -al dump.bin"); + + InputStream stdout = sess.getStdout(); + InputStream stderr = sess.getStderr(); + + byte[] buffer = new byte[8192]; + while (true) { + if ((stdout.available() == 0) && (stderr.available() == 0)) { + int conditions = sess.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA + | ChannelCondition.EOF, 120000); + + if ((conditions & ChannelCondition.TIMEOUT) != 0) { + s_logger.info("Timeout while waiting for data from peer."); + return null; + } + + if ((conditions & ChannelCondition.EOF) != 0) { + if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0) { + break; + } + } + } + + while (stdout.available() > 0) { + success = true; + int len = stdout.read(buffer); + if (len > 0) // this check is somewhat paranoid + s_logger.info(new String(buffer, 0, len)); + } + + while (stderr.available() > 0) { + int len = stderr.read(buffer); + } + } + + sess.close(); + conn.close(); + + if (success) { + return null; + } else { + retry++; + if (retry == MAX_RETRY_LINUX) { + return "SSH Linux Network test fail"; + } + } + } catch (Exception e) { + retry++; + if (retry == MAX_RETRY_LINUX) { + return "SSH Linux Network test fail with error " + e.getMessage(); + } + } + } + } } diff --git a/tools/apidoc/XmlToHtmlConverter.java b/tools/apidoc/XmlToHtmlConverter.java index 8b7cfccb0f6..92f82474909 100644 --- a/tools/apidoc/XmlToHtmlConverter.java +++ b/tools/apidoc/XmlToHtmlConverter.java @@ -17,127 +17,127 @@ import javax.xml.transform.*; import java.io.*; public class XmlToHtmlConverter extends XmlToHtmlConverterData { - // To turn off generation of API docs for certain roles, comment out - public static void main(String[] args) { - XmlToHtmlConverter x = new XmlToHtmlConverter(); - x.populateForRootAdmin(); - x.populateForDomainAdmin(); - x.populateForUser(); - x.generateToc(); - x.generateIndividualCommandPages(); - } - public void generateToc() { - try { - TransformerFactory tFactory = TransformerFactory.newInstance(); - // Generate the TOC for the API reference for User role - Transformer transformer = - tFactory.newTransformer - (new javax.xml.transform.stream.StreamSource - ("generatetocforuser.xsl")); - // Modify this path to match your own setup. - transformer.transform - (new javax.xml.transform.stream.StreamSource - ("regular_user/regularUserSummary.xml"), - new javax.xml.transform.stream.StreamResult - ( new FileOutputStream("html/TOC_User.html"))); - // Generate the TOC for root administrator role - Transformer transformer1 = - tFactory.newTransformer - (new javax.xml.transform.stream.StreamSource - ("generatetocforadmin.xsl")); - // Modify this path to match your own setup. - transformer1.transform - (new javax.xml.transform.stream.StreamSource - ("root_admin/rootAdminSummary.xml"), - // Modify this path to your own desired output location. - new javax.xml.transform.stream.StreamResult - ( new FileOutputStream("html/TOC_Root_Admin.html"))); - // Generate the TOC for domain admin role - Transformer transformer2 = - tFactory.newTransformer - (new javax.xml.transform.stream.StreamSource - ("generatetocfordomainadmin.xsl")); - - // The XML to be transformed must be at the location below. - // Modify this path to match your own setup. - transformer2.transform - (new javax.xml.transform.stream.StreamSource - ("domain_admin/domainAdminSummary.xml"), - // Modify this path to your own desired output location. - new javax.xml.transform.stream.StreamResult - ( new FileOutputStream("html/TOC_Domain_Admin.html"))); - - } - catch (Exception e) { - e.printStackTrace( ); - } - } - - // Create man pages - public void generateIndividualCommandPages() { - for(String commandName : rootAdminCommandNames) { - - try { - - TransformerFactory tFactory = TransformerFactory.newInstance(); - Transformer transformer = - tFactory.newTransformer - (new javax.xml.transform.stream.StreamSource - ("generateadmincommands.xsl")); - - transformer.transform - // Modify this path to the location of the input files on your system. - (new javax.xml.transform.stream.StreamSource - ("root_admin/"+commandName+".xml"), - // Modify this path with the desired output location. - new javax.xml.transform.stream.StreamResult - ( new FileOutputStream("html/root_admin/"+commandName+".html"))); - } catch (Exception e) { - e.printStackTrace( ); - } - } - - for(String commandName : domainAdminCommandNames) { - - try { - - TransformerFactory tFactory = TransformerFactory.newInstance(); - Transformer transformer = - tFactory.newTransformer - (new javax.xml.transform.stream.StreamSource - ("generatedomainadmincommands.xsl")); - - transformer.transform - // Modify this path with the location of the input files on your system. - (new javax.xml.transform.stream.StreamSource - ("domain_admin/"+commandName+".xml"), - // Modify this path to the desired output location. - new javax.xml.transform.stream.StreamResult - ( new FileOutputStream("html/domain_admin/"+commandName+".html"))); - } catch (Exception e) { - e.printStackTrace( ); - } - } - - for(String commandName : userCommandNames) { - - try { - - TransformerFactory tFactory = TransformerFactory.newInstance(); - - Transformer transformer = - tFactory.newTransformer - (new javax.xml.transform.stream.StreamSource - ("generateusercommands.xsl")); - - transformer.transform - (new javax.xml.transform.stream.StreamSource - ("regular_user/"+commandName+".xml"), - new javax.xml.transform.stream.StreamResult - ( new FileOutputStream("html/user/"+commandName+".html"))); - } catch (Exception e) { - e.printStackTrace( ); - } - } - } + // To turn off generation of API docs for certain roles, comment out + public static void main(String[] args) { + XmlToHtmlConverter x = new XmlToHtmlConverter(); + x.populateForRootAdmin(); + x.populateForDomainAdmin(); + x.populateForUser(); + x.generateToc(); + x.generateIndividualCommandPages(); + } + public void generateToc() { + try { + TransformerFactory tFactory = TransformerFactory.newInstance(); + // Generate the TOC for the API reference for User role + Transformer transformer = + tFactory.newTransformer + (new javax.xml.transform.stream.StreamSource + ("generatetocforuser.xsl")); + // Modify this path to match your own setup. + transformer.transform + (new javax.xml.transform.stream.StreamSource + ("regular_user/regularUserSummary.xml"), + new javax.xml.transform.stream.StreamResult + ( new FileOutputStream("html/TOC_User.html"))); + // Generate the TOC for root administrator role + Transformer transformer1 = + tFactory.newTransformer + (new javax.xml.transform.stream.StreamSource + ("generatetocforadmin.xsl")); + // Modify this path to match your own setup. + transformer1.transform + (new javax.xml.transform.stream.StreamSource + ("root_admin/rootAdminSummary.xml"), + // Modify this path to your own desired output location. + new javax.xml.transform.stream.StreamResult + ( new FileOutputStream("html/TOC_Root_Admin.html"))); + // Generate the TOC for domain admin role + Transformer transformer2 = + tFactory.newTransformer + (new javax.xml.transform.stream.StreamSource + ("generatetocfordomainadmin.xsl")); + + // The XML to be transformed must be at the location below. + // Modify this path to match your own setup. + transformer2.transform + (new javax.xml.transform.stream.StreamSource + ("domain_admin/domainAdminSummary.xml"), + // Modify this path to your own desired output location. + new javax.xml.transform.stream.StreamResult + ( new FileOutputStream("html/TOC_Domain_Admin.html"))); + + } + catch (Exception e) { + e.printStackTrace( ); + } + } + + // Create man pages + public void generateIndividualCommandPages() { + for(String commandName : rootAdminCommandNames) { + + try { + + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = + tFactory.newTransformer + (new javax.xml.transform.stream.StreamSource + ("generateadmincommands.xsl")); + + transformer.transform + // Modify this path to the location of the input files on your system. + (new javax.xml.transform.stream.StreamSource + ("root_admin/"+commandName+".xml"), + // Modify this path with the desired output location. + new javax.xml.transform.stream.StreamResult + ( new FileOutputStream("html/root_admin/"+commandName+".html"))); + } catch (Exception e) { + e.printStackTrace( ); + } + } + + for(String commandName : domainAdminCommandNames) { + + try { + + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = + tFactory.newTransformer + (new javax.xml.transform.stream.StreamSource + ("generatedomainadmincommands.xsl")); + + transformer.transform + // Modify this path with the location of the input files on your system. + (new javax.xml.transform.stream.StreamSource + ("domain_admin/"+commandName+".xml"), + // Modify this path to the desired output location. + new javax.xml.transform.stream.StreamResult + ( new FileOutputStream("html/domain_admin/"+commandName+".html"))); + } catch (Exception e) { + e.printStackTrace( ); + } + } + + for(String commandName : userCommandNames) { + + try { + + TransformerFactory tFactory = TransformerFactory.newInstance(); + + Transformer transformer = + tFactory.newTransformer + (new javax.xml.transform.stream.StreamSource + ("generateusercommands.xsl")); + + transformer.transform + (new javax.xml.transform.stream.StreamSource + ("regular_user/"+commandName+".xml"), + new javax.xml.transform.stream.StreamResult + ( new FileOutputStream("html/user/"+commandName+".html"))); + } catch (Exception e) { + e.printStackTrace( ); + } + } + } } diff --git a/utils/src/com/cloud/utils/component/ComponentLifecycle.java b/utils/src/com/cloud/utils/component/ComponentLifecycle.java index 68db348a8cf..bb06feea817 100644 --- a/utils/src/com/cloud/utils/component/ComponentLifecycle.java +++ b/utils/src/com/cloud/utils/component/ComponentLifecycle.java @@ -21,12 +21,12 @@ import java.util.Map; import javax.naming.ConfigurationException; public interface ComponentLifecycle extends Named { - public static final int RUN_LEVEL_SYSTEM_BOOTSTRAP = 0; // for system level bootstrap components - public static final int RUN_LEVEL_SYSTEM = 1; // for system level service components (i.e., DAOs) - public static final int RUN_LEVEL_FRAMEWORK_BOOTSTRAP = 2; // for framework startup checkers (i.e., DB migration check) - public static final int RUN_LEVEL_FRAMEWORK = 3; // for framework bootstrap components(i.e., clustering management components) - public static final int RUN_LEVEL_COMPONENT_BOOTSTRAP = 4; // general manager components - public static final int RUN_LEVEL_COMPONENT = 5; // regular adapters, plugin components + public static final int RUN_LEVEL_SYSTEM_BOOTSTRAP = 0; // for system level bootstrap components + public static final int RUN_LEVEL_SYSTEM = 1; // for system level service components (i.e., DAOs) + public static final int RUN_LEVEL_FRAMEWORK_BOOTSTRAP = 2; // for framework startup checkers (i.e., DB migration check) + public static final int RUN_LEVEL_FRAMEWORK = 3; // for framework bootstrap components(i.e., clustering management components) + public static final int RUN_LEVEL_COMPONENT_BOOTSTRAP = 4; // general manager components + public static final int RUN_LEVEL_COMPONENT = 5; // regular adapters, plugin components public static final int RUN_LEVEL_APPLICATION_MAINLOOP = 6; public static final int MAX_RUN_LEVELS = 7; diff --git a/utils/src/com/cloud/utils/nio/Link.java b/utils/src/com/cloud/utils/nio/Link.java index 4e1fe1d943e..e3cbd5a03ba 100755 --- a/utils/src/com/cloud/utils/nio/Link.java +++ b/utils/src/com/cloud/utils/nio/Link.java @@ -99,36 +99,36 @@ public class Link { * @return bytes read * @throws IOException if not read to completion. public static byte[] read(SocketChannel ch, ByteBuffer buff) throws IOException { - synchronized(buff) { - buff.clear(); - buff.limit(4); + synchronized(buff) { + buff.clear(); + buff.limit(4); - while (buff.hasRemaining()) { - if (ch.read(buff) == -1) { - throw new IOException("Connection closed with -1 on reading size."); - } - } + while (buff.hasRemaining()) { + if (ch.read(buff) == -1) { + throw new IOException("Connection closed with -1 on reading size."); + } + } - buff.flip(); + buff.flip(); - int length = buff.getInt(); - ByteArrayOutputStream output = new ByteArrayOutputStream(length); - WritableByteChannel outCh = Channels.newChannel(output); + int length = buff.getInt(); + ByteArrayOutputStream output = new ByteArrayOutputStream(length); + WritableByteChannel outCh = Channels.newChannel(output); - int count = 0; - while (count < length) { - buff.clear(); - int read = ch.read(buff); - if (read < 0) { - throw new IOException("Connection closed with -1 on reading data."); - } - count += read; - buff.flip(); - outCh.write(buff); - } + int count = 0; + while (count < length) { + buff.clear(); + int read = ch.read(buff); + if (read < 0) { + throw new IOException("Connection closed with -1 on reading data."); + } + count += read; + buff.flip(); + outCh.write(buff); + } return output.toByteArray(); - } + } } */ diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java index 31f63735dd9..c73360587f5 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java @@ -112,13 +112,13 @@ public class DatacenterMO extends BaseMO { if (prop.getName().equalsIgnoreCase("name")) { if (prop.getVal().toString().equals(vmLabel)) { list.add(new VirtualMachineMO(_context, oc.getObj())); - break; // break out inner loop + break; // break out inner loop } } else if (prop.getVal() instanceof CustomFieldStringValue) { String val = ((CustomFieldStringValue)prop.getVal()).getValue(); if (val.equals(vmLabel)) { list.add(new VirtualMachineMO(_context, oc.getObj())); - break; // break out inner loop + break; // break out inner loop } } } diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java index 53cee2bc52f..20860e75a24 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java @@ -163,7 +163,7 @@ public class HttpNfcLeaseMO extends BaseMO { public void run() { while (!_done) { try { - Thread.sleep(1000); // update progess every 1 second + Thread.sleep(1000); // update progess every 1 second updateLeaseProgress(_percent); } catch (InterruptedException e) { if (s_logger.isInfoEnabled()) diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index 8ddae645b2c..640cdf2f208 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -795,9 +795,9 @@ public class VirtualMachineMO extends BaseMO { String vmxFilePath = fileInfo.getVmPathName(); String vmxPathTokens[] = vmxFilePath.split("\\[|\\]|/"); assert (vmxPathTokens.length == 4); - pathInfo[1] = vmxPathTokens[1].trim(); // vSphere vm name - pathInfo[2] = dcInfo.second(); // vSphere datacenter name - pathInfo[3] = vmxPathTokens[0].trim(); // vSphere datastore name + pathInfo[1] = vmxPathTokens[1].trim(); // vSphere vm name + pathInfo[2] = dcInfo.second(); // vSphere datacenter name + pathInfo[3] = vmxPathTokens[0].trim(); // vSphere datastore name return pathInfo; } @@ -1429,7 +1429,7 @@ public class VirtualMachineMO extends BaseMO { Script command = new Script(false, "tar", 0, s_logger); command.setWorkDir(exportDir); command.add("-cf", exportName + ".ova"); - command.add(exportName + ".ovf"); // OVF file should be the first file in OVA archive + command.add(exportName + ".ovf"); // OVF file should be the first file in OVA archive for (String name : fileNames) { command.add((new File(name).getName())); } diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java index 133e16b0309..ed6ad82e0b4 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java @@ -59,7 +59,7 @@ public class VmwareContext { private static int MAX_CONNECT_RETRY = 5; private static int CONNECT_RETRY_INTERVAL = 1000; - private int _CHUNKSIZE = 1 * 1024 * 1024; // 1M + private int _CHUNKSIZE = 1 * 1024 * 1024; // 1M private VmwareClient _vimClient; private String _serverAddress; @@ -495,7 +495,7 @@ public class VmwareContext { * Sample content returned by query a datastore directory * * Url for the query - * https://vsphere-1.lab.vmops.com/folder/Fedora-clone-test?dcPath=cupertino&dsName=NFS+datastore + * https://vsphere-1.lab.vmops.com/folder/Fedora-clone-test?dcPath=cupertino&dsName=NFS+datastore * * Returned conent from vSphere * @@ -507,25 +507,25 @@ public class VmwareContext {

Index of Fedora-clone-test on datastore NFS datastore in datacenter cupertino

- - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + +
NameLast modifiedSize

Parent Directory  -
Fedora-clone-test-a2013465.hlog15-Aug-2010 00:131
Fedora-clone-test-a2013465.vswp14-Aug-2010 23:01402653184
Fedora-clone-test-flat.vmdk26-Aug-2010 18:4317179869184
Fedora-clone-test.nvram15-Aug-2010 00:138684
Fedora-clone-test.vmdk15-Aug-2010 00:13479
Fedora-clone-test.vmsd14-Aug-2010 16:590
Fedora-clone-test.vmx15-Aug-2010 00:133500
Fedora-clone-test.vmxf15-Aug-2010 00:13272
test.txt24-Aug-2010 01:0312
vmware-2.log14-Aug-2010 16:5180782
vmware-3.log14-Aug-2010 19:0758573
vmware-4.log14-Aug-2010 23:0049751
vmware-5.log15-Aug-2010 00:0464024
vmware-6.log15-Aug-2010 00:1159742
vmware-7.log15-Aug-2010 00:1359859
vmware.log15-Aug-2010 00:2347157

NameLast modifiedSize

Parent Directory  -
Fedora-clone-test-a2013465.hlog15-Aug-2010 00:131
Fedora-clone-test-a2013465.vswp14-Aug-2010 23:01402653184
Fedora-clone-test-flat.vmdk26-Aug-2010 18:4317179869184
Fedora-clone-test.nvram15-Aug-2010 00:138684
Fedora-clone-test.vmdk15-Aug-2010 00:13479
Fedora-clone-test.vmsd14-Aug-2010 16:590
Fedora-clone-test.vmx15-Aug-2010 00:133500
Fedora-clone-test.vmxf15-Aug-2010 00:13272
test.txt24-Aug-2010 01:0312
vmware-2.log14-Aug-2010 16:5180782
vmware-3.log14-Aug-2010 19:0758573
vmware-4.log14-Aug-2010 23:0049751
vmware-5.log15-Aug-2010 00:0464024
vmware-6.log15-Aug-2010 00:1159742
vmware-7.log15-Aug-2010 00:1359859
vmware.log15-Aug-2010 00:2347157

diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java index b5ed3da3628..768e8507286 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java @@ -152,7 +152,7 @@ public class VmwareContextPool { private void doIdleCheck() { List l = new ArrayList(); - int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate + int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate getIdleCheckContexts(l, batchSize); for (VmwareContext context : l) { @@ -184,7 +184,7 @@ public class VmwareContextPool { private void doKeepAlive() { List l = new ArrayList(); - int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate + int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate getKeepAliveCheckContexts(l, batchSize); for (VmwareContext context : l) { diff --git a/vmware-base/test/com/cloud/hypervisor/vmware/mo/VmwareMOTest.java b/vmware-base/test/com/cloud/hypervisor/vmware/mo/VmwareMOTest.java index ecc1eaf3e92..9e8550f1e33 100644 --- a/vmware-base/test/com/cloud/hypervisor/vmware/mo/VmwareMOTest.java +++ b/vmware-base/test/com/cloud/hypervisor/vmware/mo/VmwareMOTest.java @@ -23,19 +23,19 @@ public class VmwareMOTest { public static void main(String args[]) { try { - /* - VmwareContext context = TestVmwareContextFactory.create("10.223.80.29", "Administrator", "Suite219"); - - DatacenterMO dcMo = new DatacenterMO(context, "vsphere5"); - HostMO hostMo = new HostMO(context, dcMo.findHost("10.223.80.27")); + /* + VmwareContext context = TestVmwareContextFactory.create("10.223.80.29", "Administrator", "Suite219"); + + DatacenterMO dcMo = new DatacenterMO(context, "vsphere5"); + HostMO hostMo = new HostMO(context, dcMo.findHost("10.223.80.27")); - DatastoreMO dsMo = new DatastoreMO(context, dcMo.findDatastore("Storage1")); - hostMo.importVmFromOVF("/tmp/ubuntu-12.04.1-desktop-i386-nest-13.02.04.ovf", "Test123", dsMo, "thin"); + DatastoreMO dsMo = new DatastoreMO(context, dcMo.findDatastore("Storage1")); + hostMo.importVmFromOVF("/tmp/ubuntu-12.04.1-desktop-i386-nest-13.02.04.ovf", "Test123", dsMo, "thin"); - - VirtualMachineMO vmMo = dcMo.findVm("i-2-3-VM"); - Thread.sleep(10*60000); - vmMo.removeAllSnapshots(); + + VirtualMachineMO vmMo = dcMo.findVm("i-2-3-VM"); + Thread.sleep(10*60000); + vmMo.removeAllSnapshots(); */ } catch (Exception e) { e.printStackTrace();