CLOUDSTACK-3861 and CLOUDSTACK-3862: Deprecate old S3/Swift classes.

This commit is contained in:
Min Chen 2013-08-02 16:05:16 -07:00
parent 6940d256c9
commit 13d44fd7a6
20 changed files with 30 additions and 1200 deletions

View File

@ -1,50 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage;
import java.util.Date;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.agent.api.to.S3TO;
public interface S3 extends InternalIdentity, Identity {
String getAccessKey();
String getSecretKey();
String getEndPoint();
String getBucketName();
Integer getHttpsFlag();
Integer getConnectionTimeout();
Integer getMaxErrorRetry();
Integer getSocketTimeout();
Date getCreated();
S3TO toS3TO();
}

View File

@ -1,37 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.storage;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.agent.api.to.SwiftTO;
public interface Swift extends InternalIdentity {
public long getId();
public String getUuid();
public String getUrl();
public String getAccount();
public String getUserName();
public String getKey();
public SwiftTO toSwiftTO();
}

View File

@ -73,10 +73,8 @@ import com.cloud.projects.ProjectInvitation;
import com.cloud.region.ha.GlobalLoadBalancerRule;
import com.cloud.server.ResourceTag;
import com.cloud.storage.GuestOS;
import com.cloud.storage.S3;
import com.cloud.storage.Snapshot;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Swift;
import com.cloud.storage.Volume;
import com.cloud.storage.snapshot.SnapshotPolicy;
import com.cloud.storage.snapshot.SnapshotSchedule;
@ -151,7 +149,6 @@ import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
import org.apache.cloudstack.api.response.ResourceCountResponse;
import org.apache.cloudstack.api.response.ResourceLimitResponse;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.api.response.S3Response;
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ServiceResponse;
@ -164,7 +161,6 @@ import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
import org.apache.cloudstack.api.response.StaticRouteResponse;
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
@ -349,10 +345,6 @@ public interface ResponseGenerator {
SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine systemVM);
SwiftResponse createSwiftResponse(Swift swift);
S3Response createS3Response(S3 result);
PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result);
ServiceResponse createNetworkServiceResponse(Service service);

View File

@ -1,218 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.api.response;
import static org.apache.cloudstack.api.ApiConstants.ID;
import static org.apache.cloudstack.api.ApiConstants.S3_ACCESS_KEY;
import static org.apache.cloudstack.api.ApiConstants.S3_BUCKET_NAME;
import static org.apache.cloudstack.api.ApiConstants.S3_CONNECTION_TIMEOUT;
import static org.apache.cloudstack.api.ApiConstants.S3_END_POINT;
import static org.apache.cloudstack.api.ApiConstants.S3_HTTPS_FLAG;
import static org.apache.cloudstack.api.ApiConstants.S3_MAX_ERROR_RETRY;
import static org.apache.cloudstack.api.ApiConstants.S3_SECRET_KEY;
import static org.apache.cloudstack.api.ApiConstants.S3_SOCKET_TIMEOUT;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class S3Response extends BaseResponse {
@SerializedName(ID)
@Param(description = "The ID of the S3 configuration")
private String id;
@SerializedName(S3_ACCESS_KEY)
@Param(description = "The S3 access key")
private String accessKey;
@SerializedName(S3_SECRET_KEY)
@Param(description = "The S3 secret key")
private String secretKey;
@SerializedName(S3_END_POINT)
@Param(description = "The S3 end point")
private String endPoint;
@SerializedName(S3_BUCKET_NAME)
@Param(description = "The name of the template storage bucket")
private String bucketName;
@SerializedName(S3_HTTPS_FLAG)
@Param(description = "Connect to S3 using HTTPS?")
private Integer httpsFlag;
@SerializedName(S3_CONNECTION_TIMEOUT)
@Param(description = "The connection timeout (milliseconds)")
private Integer connectionTimeout;
@SerializedName(S3_MAX_ERROR_RETRY)
@Param(description = "The maximum number of time to retry a connection on error.")
private Integer maxErrorRetry;
@SerializedName(S3_SOCKET_TIMEOUT)
@Param(description = "The connection socket (milliseconds)")
private Integer socketTimeout;
@Override
public boolean equals(final Object thatObject) {
if (this == thatObject) {
return true;
}
if (thatObject == null || this.getClass() != thatObject.getClass()) {
return false;
}
final S3Response thatS3Response = (S3Response) thatObject;
if (this.httpsFlag != null ? !this.httpsFlag.equals(thatS3Response.httpsFlag) : thatS3Response.httpsFlag != null) {
return false;
}
if (this.accessKey != null ? !this.accessKey.equals(thatS3Response.accessKey) : thatS3Response.accessKey != null) {
return false;
}
if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatS3Response.connectionTimeout) : thatS3Response.connectionTimeout != null) {
return false;
}
if (this.endPoint != null ? !this.endPoint.equals(thatS3Response.endPoint) : thatS3Response.endPoint != null) {
return false;
}
if (this.id != null ? !this.id.equals(thatS3Response.id) : thatS3Response.id != null) {
return false;
}
if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatS3Response.maxErrorRetry) : thatS3Response.maxErrorRetry != null) {
return false;
}
if (this.secretKey != null ? !this.secretKey.equals(thatS3Response.secretKey) : thatS3Response.secretKey != null) {
return false;
}
if (this.socketTimeout != null ? !this.socketTimeout.equals(thatS3Response.socketTimeout) : thatS3Response.socketTimeout != null) {
return false;
}
if (this.bucketName != null ? !this.bucketName.equals(thatS3Response.bucketName) : thatS3Response.bucketName != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = this.id != null ? this.id.hashCode() : 0;
result = 31 * result + (this.accessKey != null ? this.accessKey.hashCode() : 0);
result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0);
result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0);
result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0);
result = 31 * result + (this.httpsFlag != null ? this.httpsFlag : 0);
result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0);
result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0);
result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0);
return result;
}
@Override
public String getObjectId() {
return this.id;
}
public void setObjectId(String id) {
this.id = id;
}
public String getAccessKey() {
return this.accessKey;
}
public void setAccessKey(final String accessKey) {
this.accessKey = accessKey;
}
public String getSecretKey() {
return this.secretKey;
}
public void setSecretKey(final String secretKey) {
this.secretKey = secretKey;
}
public String getEndPoint() {
return this.endPoint;
}
public void setEndPoint(final String endPoint) {
this.endPoint = endPoint;
}
public String getTemplateBucketName() {
return this.bucketName;
}
public void setTemplateBucketName(final String templateBucketName) {
this.bucketName = templateBucketName;
}
public Integer getHttpsFlag() {
return this.httpsFlag;
}
public void setHttpsFlag(final Integer httpsFlag) {
this.httpsFlag = httpsFlag;
}
public Integer getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(final Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public Integer getMaxErrorRetry() {
return this.maxErrorRetry;
}
public void setMaxErrorRetry(final Integer maxErrorRetry) {
this.maxErrorRetry = maxErrorRetry;
}
public Integer getSocketTimeout() {
return this.socketTimeout;
}
public void setSocketTimeout(final Integer socketTimeout) {
this.socketTimeout = socketTimeout;
}
}

View File

@ -1,86 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.response;
import java.util.Date;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class SwiftResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the ID of swift")
private String id;
@SerializedName(ApiConstants.URL)
@Param(description = "url for swift")
private String url;
@SerializedName(ApiConstants.CREATED)
@Param(description = "the date and time the host was created")
private Date created;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account for swift")
private String account;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the username for swift")
private String username;
public void setId(String id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}

View File

@ -24,16 +24,12 @@ import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import static org.mockito.Matchers.anyInt;
import java.util.LinkedList;
import java.util.List;
@ -45,6 +41,7 @@ public class ScaleVMCmdTest extends TestCase{
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Override
@Before
public void setUp() {

View File

@ -293,7 +293,6 @@
<bean id="resourceTagJoinDaoImpl" class="com.cloud.api.query.dao.ResourceTagJoinDaoImpl" />
<bean id="resourceTagsDaoImpl" class="com.cloud.tags.dao.ResourceTagsDaoImpl" />
<bean id="routerNetworkDaoImpl" class="com.cloud.network.dao.RouterNetworkDaoImpl" />
<bean id="s3DaoImpl" class="com.cloud.storage.dao.S3DaoImpl" />
<bean id="sSHKeyPairDaoImpl" class="com.cloud.user.dao.SSHKeyPairDaoImpl" />
<bean id="secondaryStorageVmDaoImpl" class="com.cloud.vm.dao.SecondaryStorageVmDaoImpl" />
<bean id="securityGroupDaoImpl" class="com.cloud.network.security.dao.SecurityGroupDaoImpl" />
@ -354,7 +353,6 @@
<bean id="vMTemplateDetailsDaoImpl" class="com.cloud.storage.dao.VMTemplateDetailsDaoImpl" />
<bean id="vMTemplateHostDaoImpl" class="com.cloud.storage.dao.VMTemplateHostDaoImpl" />
<bean id="vMTemplatePoolDaoImpl" class="com.cloud.storage.dao.VMTemplatePoolDaoImpl" />
<bean id="vMTemplateS3DaoImpl" class="com.cloud.storage.dao.VMTemplateS3DaoImpl" />
<bean id="vMTemplateZoneDaoImpl" class="com.cloud.storage.dao.VMTemplateZoneDaoImpl" />
<bean id="versionDaoImpl" class="com.cloud.upgrade.dao.VersionDaoImpl" />
<bean id="virtualRouterProviderDaoImpl" class="com.cloud.network.dao.VirtualRouterProviderDaoImpl" />

View File

@ -1,205 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.agent.api.to.S3TO;
import com.cloud.utils.db.GenericDao;
//TODO: this will be removed after object_store merge.
@Entity
@Table(name = "s3")
public class S3VO implements S3 {
public static final String ID_COLUMN_NAME = "id";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = ID_COLUMN_NAME)
private long id;
@Column(name = "uuid")
private String uuid;
@Column(name = "access_key")
private String accessKey;
@Column(name = "secret_key")
private String secretKey;
@Column(name = "end_point")
private String endPoint;
@Column(name = "bucket")
private String bucketName;
@Column(name = "https")
private Integer httpsFlag;
@Column(name = "connection_timeout")
private Integer connectionTimeout;
@Column(name = "max_error_retry")
private Integer maxErrorRetry;
@Column(name = "socket_timeout")
private Integer socketTimeout;
@Column(name = GenericDao.CREATED_COLUMN)
private Date created;
public S3VO() {
super();
}
public S3VO(final String uuid, final String accessKey, final String secretKey, final String endPoint,
final String bucketName, final Boolean httpsFlag, final Integer connectionTimeout,
final Integer maxErrorRetry, final Integer socketTimeout, final Date created) {
super();
this.uuid = uuid;
this.accessKey = accessKey;
this.secretKey = secretKey;
this.endPoint = endPoint;
this.bucketName = bucketName;
Integer value = null;
if (httpsFlag != null) {
value = httpsFlag == false ? 0 : 1;
}
this.httpsFlag = value;
this.connectionTimeout = connectionTimeout;
this.maxErrorRetry = maxErrorRetry;
this.socketTimeout = socketTimeout;
this.created = created;
}
@Override
public S3TO toS3TO() {
Boolean httpsFlag = null;
if (this.httpsFlag != null) {
httpsFlag = this.httpsFlag == 0 ? false : true;
}
return new S3TO(this.id, this.uuid, this.accessKey, this.secretKey, this.endPoint, this.bucketName, httpsFlag,
this.connectionTimeout, this.maxErrorRetry, this.socketTimeout, this.created, false);
}
public long getId() {
return this.id;
}
public void setId(final long id) {
this.id = id;
}
public String getUuid() {
return this.uuid;
}
public void setUuid(final String uuid) {
this.uuid = uuid;
}
public String getAccessKey() {
return this.accessKey;
}
public void setAccessKey(final String accessKey) {
this.accessKey = accessKey;
}
public String getSecretKey() {
return this.secretKey;
}
public void setSecretKey(final String secretKey) {
this.secretKey = secretKey;
}
public String getEndPoint() {
return this.endPoint;
}
public void setEndPoint(final String endPoint) {
this.endPoint = endPoint;
}
public String getBucketName() {
return this.bucketName;
}
public void setBucketName(final String bucketName) {
this.bucketName = bucketName;
}
public Integer getHttpsFlag() {
return this.httpsFlag;
}
public void setHttpsFlag(final Integer httpsFlag) {
this.httpsFlag = httpsFlag;
}
public Integer getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(final int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public Integer getMaxErrorRetry() {
return this.maxErrorRetry;
}
public void setMaxErrorRetry(final int maxErrorRetry) {
this.maxErrorRetry = maxErrorRetry;
}
public Integer getSocketTimeout() {
return this.socketTimeout;
}
public void setSocketTimeout(final int socketTimeout) {
this.socketTimeout = socketTimeout;
}
public Date getCreated() {
return this.created;
}
public void setCreated(final Date created) {
this.created = created;
}
}

View File

@ -1,113 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.storage;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.agent.api.to.SwiftTO;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name = "swift")
public class SwiftVO implements Swift, InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "url")
String url;
@Column(name = "account")
String account;
@Column(name = "username")
String userName;
@Column(name = "key")
String key;
@Column(name = "uuid")
String uuid = UUID.randomUUID().toString();
@Column(name = GenericDao.CREATED_COLUMN)
private Date created;
public SwiftVO() {
}
public SwiftVO(String url, String account, String userName, String key) {
this.url = url;
this.account = account;
this.userName = userName;
this.key = key;
}
@Override
public long getId() {
return id;
}
@Override
public String getUrl() {
return url;
}
@Override
public String getAccount() {
return account;
}
@Override
public String getUserName() {
return userName;
}
@Override
public String getKey() {
return key;
}
public Date getCreated() {
return created;
}
@Override
public SwiftTO toSwiftTO() {
return null;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}

View File

@ -1,194 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage;
import com.cloud.utils.db.GenericDaoBase;
import org.apache.cloudstack.api.InternalIdentity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.text.DateFormat;
import java.util.Date;
@Entity
@Table(name = "template_s3_ref")
public class VMTemplateS3VO implements InternalIdentity {
public static final String S3_ID_COLUMN_NAME = "s3_id";
public static final String TEMPLATE_ID_COLUMN_NAME = "template_id";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = S3_ID_COLUMN_NAME)
private long s3Id;
@Column(name = TEMPLATE_ID_COLUMN_NAME)
private long templateId;
@Column(name = GenericDaoBase.CREATED_COLUMN)
private Date created;
@Column(name = "size")
private Long size;
@Column(name = "physical_size")
private Long physicalSize;
public VMTemplateS3VO() {
super();
}
public VMTemplateS3VO(final long s3Id, final long templateId, final Date created, final Long size,
final Long physicalSize) {
super();
this.s3Id = s3Id;
this.templateId = templateId;
this.created = created;
this.size = size;
this.physicalSize = physicalSize;
}
@Override
public boolean equals(final Object thatObject) {
if (this == thatObject) {
return true;
}
if (thatObject == null || getClass() != thatObject.getClass()) {
return false;
}
final VMTemplateS3VO thatVMTemplateS3VO = (VMTemplateS3VO) thatObject;
if (this.id != thatVMTemplateS3VO.id) {
return false;
}
if (this.s3Id != thatVMTemplateS3VO.s3Id) {
return false;
}
if (this.templateId != thatVMTemplateS3VO.templateId) {
return false;
}
if (this.created != null ? !created.equals(thatVMTemplateS3VO.created) : thatVMTemplateS3VO.created != null) {
return false;
}
if (this.physicalSize != null ? !physicalSize.equals(thatVMTemplateS3VO.physicalSize)
: thatVMTemplateS3VO.physicalSize != null) {
return false;
}
if (this.size != null ? !size.equals(thatVMTemplateS3VO.size) : thatVMTemplateS3VO.size != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = (int) (this.id ^ (this.id >>> 32));
result = 31 * result + (int) (this.s3Id ^ (this.s3Id >>> 32));
result = 31 * result + (int) (this.templateId ^ (this.templateId >>> 32));
result = 31 * result + (this.created != null ? this.created.hashCode() : 0);
result = 31 * result + (this.size != null ? this.size.hashCode() : 0);
result = 31 * result + (this.physicalSize != null ? this.physicalSize.hashCode() : 0);
return result;
}
public long getId() {
return this.id;
}
public void setId(final long id) {
this.id = id;
}
public long getS3Id() {
return this.s3Id;
}
public void setS3Id(final long s3Id) {
this.s3Id = s3Id;
}
public long getTemplateId() {
return this.templateId;
}
public void setTemplateId(final long templateId) {
this.templateId = templateId;
}
public Date getCreated() {
return this.created;
}
public void setCreated(final Date created) {
this.created = created;
}
public Long getSize() {
return this.size;
}
public void setSize(final Long size) {
this.size = size;
}
public Long getPhysicalSize() {
return this.physicalSize;
}
public void setPhysicalSize(final Long physicalSize) {
this.physicalSize = physicalSize;
}
@Override
public String toString() {
final StringBuilder stringBuilder = new StringBuilder("VMTemplateS3VO [ id: ").append(id).append(", created: ")
.append(DateFormat.getDateTimeInstance().format(created)).append(", physicalSize: ")
.append(physicalSize).append(", size: ").append(size).append(", templateId: ").append(templateId)
.append(", s3Id: ").append(s3Id).append(" ]");
return stringBuilder.toString();
}
}

View File

@ -1,29 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage.dao;
import com.cloud.agent.api.to.S3TO;
import com.cloud.storage.S3VO;
import com.cloud.utils.db.GenericDao;
public interface S3Dao extends GenericDao<S3VO, Long> {
S3TO getS3TO(final Long id);
}

View File

@ -1,51 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage.dao;
import com.cloud.agent.api.to.S3TO;
import com.cloud.storage.S3VO;
import com.cloud.utils.db.GenericDaoBase;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
@Component
@Local(S3Dao.class)
public class S3DaoImpl extends GenericDaoBase<S3VO, Long> implements S3Dao {
@Override
public S3TO getS3TO(final Long id) {
if (id != null) {
final S3VO s3VO = findById(id);
if (s3VO != null) {
return s3VO.toS3TO();
}
}
// NOTE: Excluded listAll / shuffle operation implemented in
// SwiftDaoImpl ...
return null;
}
}

View File

@ -1,36 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage.dao;
import com.cloud.storage.VMTemplateS3VO;
import com.cloud.utils.db.GenericDao;
import java.util.List;
public interface VMTemplateS3Dao extends GenericDao<VMTemplateS3VO, Long> {
List<VMTemplateS3VO> listByS3Id(long id);
VMTemplateS3VO findOneByTemplateId(long id);
VMTemplateS3VO findOneByS3Template(long s3Id, long templateId);
void expungeAllByTemplateId(long templateId);
}

View File

@ -1,96 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.cloud.storage.dao;
import static com.cloud.utils.db.SearchCriteria.Op.*;
import static com.cloud.storage.VMTemplateS3VO.*;
import com.cloud.storage.VMTemplateS3VO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Local(VMTemplateS3Dao.class)
public class VMTemplateS3DaoImpl extends GenericDaoBase<VMTemplateS3VO, Long> implements VMTemplateS3Dao {
private final SearchBuilder<VMTemplateS3VO> searchBuilder;
public VMTemplateS3DaoImpl() {
super();
this.searchBuilder = createSearchBuilder();
this.searchBuilder.and(S3_ID_COLUMN_NAME, this.searchBuilder.entity().getS3Id(), EQ)
.and(TEMPLATE_ID_COLUMN_NAME, this.searchBuilder.entity().getTemplateId(), EQ).done();
}
@Override
public List<VMTemplateS3VO> listByS3Id(final long s3id) {
final SearchCriteria<VMTemplateS3VO> criteria = this.searchBuilder.create();
criteria.setParameters(S3_ID_COLUMN_NAME, s3id);
return this.listBy(criteria);
}
@Override
public VMTemplateS3VO findOneByTemplateId(final long templateId) {
final SearchCriteria<VMTemplateS3VO> criteria = this.searchBuilder.create();
criteria.setParameters(TEMPLATE_ID_COLUMN_NAME, templateId);
return this.findOneBy(criteria);
}
@Override
public VMTemplateS3VO findOneByS3Template(final long s3Id, final long templateId) {
final SearchCriteria<VMTemplateS3VO> criteria = this.searchBuilder.create();
criteria.setParameters(S3_ID_COLUMN_NAME, s3Id);
criteria.setParameters(TEMPLATE_ID_COLUMN_NAME, templateId);
return this.findOneBy(criteria);
}
@Override
public void expungeAllByTemplateId(long templateId) {
final SearchCriteria<VMTemplateS3VO> criteria = this.searchBuilder.create();
criteria.setParameters(TEMPLATE_ID_COLUMN_NAME, templateId);
this.expunge(criteria);
}
}

View File

@ -233,7 +233,6 @@ import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StorageStats;
import com.cloud.storage.UploadVO;
import com.cloud.storage.VMTemplateS3VO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.Volume.Type;
@ -247,7 +246,6 @@ import com.cloud.storage.dao.SnapshotPolicyDao;
import com.cloud.storage.dao.UploadDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateDetailsDao;
import com.cloud.storage.dao.VMTemplateS3Dao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.snapshot.SnapshotPolicy;
import com.cloud.template.TemplateManager;
@ -330,7 +328,6 @@ public class ApiDBUtils {
static PrimaryDataStoreDao _storagePoolDao;
static VMTemplateDao _templateDao;
static VMTemplateDetailsDao _templateDetailsDao;
static VMTemplateS3Dao _templateS3Dao;
static UploadDao _uploadDao;
static UserDao _userDao;
static UserStatisticsDao _userStatsDao;
@ -441,7 +438,6 @@ public class ApiDBUtils {
@Inject private PrimaryDataStoreDao storagePoolDao;
@Inject private VMTemplateDao templateDao;
@Inject private VMTemplateDetailsDao templateDetailsDao;
@Inject private VMTemplateS3Dao templateS3Dao;
@Inject private UploadDao uploadDao;
@Inject private UserDao userDao;
@Inject private UserStatisticsDao userStatsDao;
@ -551,7 +547,6 @@ public class ApiDBUtils {
_storagePoolDao = storagePoolDao;
_templateDao = templateDao;
_templateDetailsDao = templateDetailsDao;
_templateS3Dao = templateS3Dao;
_uploadDao = uploadDao;
_userDao = userDao;
_userStatsDao = userStatsDao;
@ -891,15 +886,13 @@ public class ApiDBUtils {
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(templateId);
if(template != null) {
Map details = _templateDetailsDao.findDetails(templateId);
if(details != null && !details.isEmpty())
if(details != null && !details.isEmpty()) {
template.setDetails(details);
}
}
return template;
}
public static VMTemplateS3VO findTemplateS3Ref(long templateId) {
return _templateS3Dao.findOneByTemplateId(templateId);
}
public static UploadVO findUploadById(Long id) {
return _uploadDao.findById(id);
@ -1187,10 +1180,11 @@ public class ApiDBUtils {
List<AutoScaleVmGroupPolicyMapVO> vos = _asVmGroupPolicyMapDao.listByVmGroupId(vmGroupId);
for (AutoScaleVmGroupPolicyMapVO vo : vos) {
AutoScalePolicy autoScalePolicy = _asPolicyDao.findById(vo.getPolicyId());
if(autoScalePolicy.getAction().equals("scaleup"))
if(autoScalePolicy.getAction().equals("scaleup")) {
scaleUpPolicyIds.add(autoScalePolicy.getId());
else
} else {
scaleDownPolicyIds.add(autoScalePolicy.getId());
}
}
}
public static String getKeyPairName(String sshPublicKey) {
@ -1211,10 +1205,11 @@ public class ApiDBUtils {
List<AutoScaleVmGroupPolicyMapVO> vos = _asVmGroupPolicyMapDao.listByVmGroupId(vmGroupId);
for (AutoScaleVmGroupPolicyMapVO vo : vos) {
AutoScalePolicy autoScalePolicy = _asPolicyDao.findById(vo.getPolicyId());
if(autoScalePolicy.getAction().equals("scaleup"))
if(autoScalePolicy.getAction().equals("scaleup")) {
scaleUpPolicies.add(autoScalePolicy);
else
} else {
scaleDownPolicies.add(autoScalePolicy);
}
}
}
@ -1279,8 +1274,9 @@ public class ApiDBUtils {
}
public static String findJobInstanceUuid(AsyncJob job){
if ( job == null || job.getInstanceId() == null)
if ( job == null || job.getInstanceId() == null) {
return null;
}
String jobInstanceId = null;

View File

@ -131,12 +131,10 @@ import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.ImageStore;
import com.cloud.storage.S3;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Swift;
import com.cloud.storage.Upload;
import com.cloud.storage.UploadVO;
import com.cloud.storage.VMTemplateVO;
@ -235,7 +233,6 @@ import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
import org.apache.cloudstack.api.response.ResourceCountResponse;
import org.apache.cloudstack.api.response.ResourceLimitResponse;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.api.response.S3Response;
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
@ -249,7 +246,6 @@ import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
import org.apache.cloudstack.api.response.StaticRouteResponse;
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.SwiftResponse;
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
import org.apache.cloudstack.api.response.SystemVmResponse;
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
@ -460,10 +456,12 @@ public class ApiResponseHelper implements ResponseGenerator {
vmSnapshotResponse.setDescription(vmSnapshot.getDescription());
vmSnapshotResponse.setDisplayName(vmSnapshot.getDisplayName());
UserVm vm = ApiDBUtils.findUserVmById(vmSnapshot.getVmId());
if (vm != null)
if (vm != null) {
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
if (vmSnapshot.getParent() != null)
}
if (vmSnapshot.getParent() != null) {
vmSnapshotResponse.setParentName(ApiDBUtils.getVMSnapshotById(vmSnapshot.getParent()).getDisplayName());
}
vmSnapshotResponse.setCurrent(vmSnapshot.getCurrent());
vmSnapshotResponse.setType(vmSnapshot.getType().toString());
vmSnapshotResponse.setObjectName("vmsnapshot");
@ -514,35 +512,6 @@ public class ApiResponseHelper implements ResponseGenerator {
return listHosts.get(0);
}
@Override
public SwiftResponse createSwiftResponse(Swift swift) {
SwiftResponse swiftResponse = new SwiftResponse();
swiftResponse.setId(swift.getUuid());
swiftResponse.setUrl(swift.getUrl());
swiftResponse.setAccount(swift.getAccount());
swiftResponse.setUsername(swift.getUserName());
swiftResponse.setObjectName("swift");
return swiftResponse;
}
@Override
public S3Response createS3Response(final S3 result) {
final S3Response response = new S3Response();
response.setAccessKey(result.getAccessKey());
response.setConnectionTimeout(result.getConnectionTimeout());
response.setEndPoint(result.getEndPoint());
response.setHttpsFlag(result.getHttpsFlag());
response.setMaxErrorRetry(result.getMaxErrorRetry());
response.setObjectId(result.getUuid());
response.setSecretKey(result.getSecretKey());
response.setSocketTimeout(result.getSocketTimeout());
response.setTemplateBucketName(result.getBucketName());
return response;
}
@Override
public VlanIpRangeResponse createVlanIpRangeResponse(Vlan vlan) {
@ -1896,10 +1865,11 @@ public class ApiResponseHelper implements ResponseGenerator {
// convert account to projectIds
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
if (project.getUuid() != null && !project.getUuid().isEmpty())
if (project.getUuid() != null && !project.getUuid().isEmpty()) {
projectIds.add(project.getUuid());
else
} else {
projectIds.add(String.valueOf(project.getId()));
}
}
}
@ -2010,8 +1980,9 @@ public class ApiResponseHelper implements ResponseGenerator {
}
if (so != null) {
ServiceOffering soffering = ApiDBUtils.findServiceOfferingById(so);
if (soffering != null)
if (soffering != null) {
response.setServiceOfferingId(soffering.getUuid());
}
}
if (offering.getGuestType() != null) {
@ -2197,7 +2168,7 @@ public class ApiResponseHelper implements ResponseGenerator {
}
// populate network offering information
NetworkOffering networkOffering = (NetworkOffering) ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
if (networkOffering != null) {
response.setNetworkOfferingId(networkOffering.getUuid());
response.setNetworkOfferingName(networkOffering.getName());
@ -2723,8 +2694,9 @@ public class ApiResponseHelper implements ResponseGenerator {
public LBStickinessResponse createLBStickinessPolicyResponse(List<? extends StickinessPolicy> stickinessPolicies, LoadBalancer lb) {
LBStickinessResponse spResponse = new LBStickinessResponse();
if (lb == null)
if (lb == null) {
return spResponse;
}
spResponse.setlbRuleId(lb.getUuid());
Account account = ApiDBUtils.findAccountById(lb.getAccountId());
if (account != null) {
@ -2751,8 +2723,9 @@ public class ApiResponseHelper implements ResponseGenerator {
public LBHealthCheckResponse createLBHealthCheckPolicyResponse(List<? extends HealthCheckPolicy> healthcheckPolicies, LoadBalancer lb) {
LBHealthCheckResponse hcResponse = new LBHealthCheckResponse();
if (lb == null)
if (lb == null) {
return hcResponse;
}
hcResponse.setlbRuleId(lb.getUuid());
Account account = ApiDBUtils.findAccountById(lb.getAccountId());
if (account != null) {
@ -3403,8 +3376,9 @@ public class ApiResponseHelper implements ResponseGenerator {
usageRecResponse.setVmName(vm.getInstanceName());
usageRecResponse.setUsageId(vm.getUuid());
usageRecResponse.setSize(usageRecord.getSize());
if(usageRecord.getOfferingId() != null)
usageRecResponse.setOfferingId(usageRecord.getOfferingId().toString());
if(usageRecord.getOfferingId() != null) {
usageRecResponse.setOfferingId(usageRecord.getOfferingId().toString());
}
}
if (usageRecord.getRawUsage() != null) {
@ -3423,8 +3397,9 @@ public class ApiResponseHelper implements ResponseGenerator {
}
public String getDateStringInternal(Date inputDate) {
if (inputDate == null)
if (inputDate == null) {
return null;
}
TimeZone tz = _usageSvc.getUsageTimezone();
Calendar cal = Calendar.getInstance(tz);

View File

@ -170,7 +170,6 @@ import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.service.dao.ServiceOfferingDetailsDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.S3Dao;
import com.cloud.test.IPRangeConfig;
import com.cloud.user.Account;
import com.cloud.user.AccountDetailVO;
@ -220,8 +219,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject
DomainDao _domainDao;
@Inject
S3Dao _s3Dao;
@Inject
ServiceOfferingDao _serviceOfferingDao;
@Inject
ServiceOfferingDetailsDao _serviceOfferingDetailsDao;

View File

@ -36,8 +36,6 @@ import com.cloud.utils.EnumUtils;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.UriUtils;
import com.cloud.utils.db.SearchCriteria;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@ -141,7 +139,6 @@ import com.cloud.storage.dao.StoragePoolWorkDao;
import com.cloud.storage.dao.UploadDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.storage.dao.VMTemplateS3Dao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.dao.VolumeDetailsDao;
import com.cloud.storage.download.DownloadMonitor;
@ -234,8 +231,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
@Inject
protected VMTemplatePoolDao _vmTemplatePoolDao = null;
@Inject
protected VMTemplateS3Dao _vmTemplateS3Dao;
@Inject
protected VMTemplateDao _vmTemplateDao = null;
@Inject
protected StoragePoolHostDao _poolHostDao = null;

View File

@ -139,7 +139,6 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateDetailsDao;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.storage.dao.VMTemplateS3Dao;
import com.cloud.storage.dao.VMTemplateZoneDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.download.DownloadMonitor;
@ -220,8 +219,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
@Inject
SnapshotDao _snapshotDao;
@Inject
VMTemplateS3Dao _vmS3TemplateDao;
@Inject
ConfigurationDao _configDao;
@Inject
ClusterDao _clusterDao;

View File

@ -97,7 +97,6 @@ import com.cloud.server.ManagementService;
import com.cloud.service.dao.ServiceOfferingDaoImpl;
import com.cloud.service.dao.ServiceOfferingDetailsDaoImpl;
import com.cloud.storage.dao.DiskOfferingDaoImpl;
import com.cloud.storage.dao.S3DaoImpl;
import com.cloud.storage.dao.SnapshotDaoImpl;
import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
import com.cloud.storage.dao.VolumeDaoImpl;
@ -148,7 +147,6 @@ import org.apache.cloudstack.region.PortableIpRangeDaoImpl;
DcDetailsDaoImpl.class,
NicSecondaryIpDaoImpl.class,
UserIpv6AddressDaoImpl.class,
S3DaoImpl.class,
UserDaoImpl.class,
NicDaoImpl.class,
NetworkDomainDaoImpl.class,