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

This commit is contained in:
Min Chen 2013-08-02 18:16:46 -07:00
parent b96fea2e06
commit 151a7ee497
20 changed files with 199 additions and 1367 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

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api;
import java.text.DecimalFormat;
import java.util.EnumSet;
import java.util.List;
@ -81,7 +82,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;
@ -94,7 +94,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;
@ -175,10 +174,8 @@ import com.cloud.region.ha.GlobalLoadBalancerRule;
import com.cloud.server.ResourceTag;
import com.cloud.storage.GuestOS;
import com.cloud.storage.ImageStore;
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;
@ -330,7 +327,7 @@ public interface ResponseGenerator {
List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, Long zoneId, boolean readyOnly);
// List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly);
// List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly);
//List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, long zoneId, boolean readyOnly);
ProjectResponse createProjectResponse(Project project);
@ -347,10 +344,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

@ -292,7 +292,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" />
@ -351,7 +350,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

@ -232,7 +232,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;
@ -246,7 +245,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;
@ -329,7 +327,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;
@ -401,7 +398,7 @@ public class ApiDBUtils {
static NetworkACLDao _networkACLDao;
static ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
static AccountService _accountService;
@Inject
private ManagementServer ms;
@ -442,7 +439,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;
@ -552,7 +548,6 @@ public class ApiDBUtils {
_storagePoolDao = storagePoolDao;
_templateDao = templateDao;
_templateDetailsDao = templateDetailsDao;
_templateS3Dao = templateS3Dao;
_uploadDao = uploadDao;
_userDao = userDao;
_userStatsDao = userStatsDao;
@ -888,15 +883,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);
@ -1184,10 +1177,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) {
@ -1208,10 +1202,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);
}
}
}
@ -1276,8 +1271,9 @@ public class ApiDBUtils {
}
public static String findJobInstanceUuid(AsyncJob job){
if ( job == null )
if ( job == null ) {
return null;
}
String jobInstanceId = null;
ApiCommandJobType jobInstanceType = EnumUtils.fromString(ApiCommandJobType.class, job.getInstanceType(), ApiCommandJobType.None);
@ -1604,64 +1600,64 @@ public class ApiDBUtils {
return _jobJoinDao.newAsyncJobView(e);
}
public static DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
return _diskOfferingJoinDao.newDiskOfferingResponse(offering);
}
public static DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
return _diskOfferingJoinDao.newDiskOfferingResponse(offering);
}
public static DiskOfferingJoinVO newDiskOfferingView(DiskOffering offering){
return _diskOfferingJoinDao.newDiskOfferingView(offering);
}
public static DiskOfferingJoinVO newDiskOfferingView(DiskOffering offering){
return _diskOfferingJoinDao.newDiskOfferingView(offering);
}
public static ServiceOfferingResponse newServiceOfferingResponse(ServiceOfferingJoinVO offering) {
return _serviceOfferingJoinDao.newServiceOfferingResponse(offering);
}
public static ServiceOfferingResponse newServiceOfferingResponse(ServiceOfferingJoinVO offering) {
return _serviceOfferingJoinDao.newServiceOfferingResponse(offering);
}
public static ServiceOfferingJoinVO newServiceOfferingView(ServiceOffering offering){
return _serviceOfferingJoinDao.newServiceOfferingView(offering);
}
public static ServiceOfferingJoinVO newServiceOfferingView(ServiceOffering offering){
return _serviceOfferingJoinDao.newServiceOfferingView(offering);
}
public static ZoneResponse newDataCenterResponse(DataCenterJoinVO dc, Boolean showCapacities) {
return _dcJoinDao.newDataCenterResponse(dc, showCapacities);
}
public static ZoneResponse newDataCenterResponse(DataCenterJoinVO dc, Boolean showCapacities) {
return _dcJoinDao.newDataCenterResponse(dc, showCapacities);
}
public static DataCenterJoinVO newDataCenterView(DataCenter dc){
return _dcJoinDao.newDataCenterView(dc);
}
public static DataCenterJoinVO newDataCenterView(DataCenter dc){
return _dcJoinDao.newDataCenterView(dc);
}
public static Map<String, String> findHostDetailsById(long hostId){
return _hostDetailsDao.findDetails(hostId);
}
public static Map<String, String> findHostDetailsById(long hostId){
return _hostDetailsDao.findDetails(hostId);
}
public static List<NicSecondaryIpVO> findNicSecondaryIps(long nicId) {
return _nicSecondaryIpDao.listByNicId(nicId);
}
public static List<NicSecondaryIpVO> findNicSecondaryIps(long nicId) {
return _nicSecondaryIpDao.listByNicId(nicId);
}
public static TemplateResponse newTemplateUpdateResponse(TemplateJoinVO vr) {
return _templateJoinDao.newUpdateResponse(vr);
}
public static TemplateResponse newTemplateUpdateResponse(TemplateJoinVO vr) {
return _templateJoinDao.newUpdateResponse(vr);
}
public static TemplateResponse newTemplateResponse(TemplateJoinVO vr) {
return _templateJoinDao.newTemplateResponse(vr);
}
public static TemplateResponse newTemplateResponse(TemplateJoinVO vr) {
return _templateJoinDao.newTemplateResponse(vr);
}
public static TemplateResponse newIsoResponse(TemplateJoinVO vr) {
return _templateJoinDao.newIsoResponse(vr);
}
public static TemplateResponse newIsoResponse(TemplateJoinVO vr) {
return _templateJoinDao.newIsoResponse(vr);
}
public static TemplateResponse fillTemplateDetails(TemplateResponse vrData, TemplateJoinVO vr){
return _templateJoinDao.setTemplateResponse(vrData, vr);
}
public static TemplateResponse fillTemplateDetails(TemplateResponse vrData, TemplateJoinVO vr){
return _templateJoinDao.setTemplateResponse(vrData, vr);
}
public static List<TemplateJoinVO> newTemplateView(VirtualMachineTemplate vr){
return _templateJoinDao.newTemplateView(vr);
}
public static List<TemplateJoinVO> newTemplateView(VirtualMachineTemplate vr){
return _templateJoinDao.newTemplateView(vr);
}
public static List<TemplateJoinVO> newTemplateView(VirtualMachineTemplate vr, long zoneId, boolean readyOnly){
return _templateJoinDao.newTemplateView(vr, zoneId, readyOnly);
}
public static List<TemplateJoinVO> newTemplateView(VirtualMachineTemplate vr, long zoneId, boolean readyOnly){
return _templateJoinDao.newTemplateView(vr, zoneId, readyOnly);
}
public static AffinityGroup getAffinityGroup(String groupName, long accountId) {
return _affinityGroupDao.findByAccountAndName(accountId, groupName);
@ -1683,12 +1679,12 @@ public class ApiDBUtils {
String providerDnsName = _configDao.getValue(Config.CloudDnsName.key());
return providerDnsName;
}
public static Map<String, String> getServiceOfferingDetails(long serviceOfferingId) {
Map<String, String> details = _serviceOfferingDetailsDao.findDetails(serviceOfferingId);
return details.isEmpty() ? null : details;
}
public static boolean isAdmin(Account account) {
return _accountService.isAdmin(account.getType());
}

View File

@ -103,7 +103,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;
@ -117,7 +116,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;
@ -262,12 +260,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;
@ -298,6 +294,7 @@ import com.cloud.vm.VirtualMachine.Type;
import com.cloud.vm.dao.NicSecondaryIpVO;
import com.cloud.vm.snapshot.VMSnapshot;
public class ApiResponseHelper implements ResponseGenerator {
private static final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
@ -470,10 +467,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");
@ -524,35 +523,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) {
@ -1573,7 +1543,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponses.add(isoResponse);
return isoResponses;
}
*/
*/
@Override
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
@ -1680,8 +1650,8 @@ public class ApiResponseHelper implements ResponseGenerator {
for (StoragePoolVO pool : allStoragePools) {
StoragePoolType poolType = pool.getPoolType();
if (!(poolType.isShared())) {// All the non shared storages
// shouldn't show up in the capacity
// calculation
// shouldn't show up in the capacity
// calculation
poolIdsToIgnore.add(pool.getId());
}
}
@ -1900,10 +1870,11 @@ public class ApiResponseHelper implements ResponseGenerator {
// convert account to projectIds
Project project = ApiDBUtils.findProjectByProjectAccountId(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()));
}
}
}
@ -2038,8 +2009,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) {
@ -2751,8 +2723,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) {
@ -2779,8 +2752,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) {
@ -3283,84 +3257,84 @@ public class ApiResponseHelper implements ResponseGenerator {
return response;
}
@Override
public UsageRecordResponse createUsageResponse(Usage usageRecord) {
UsageRecordResponse usageRecResponse = new UsageRecordResponse();
@Override
public UsageRecordResponse createUsageResponse(Usage usageRecord) {
UsageRecordResponse usageRecResponse = new UsageRecordResponse();
Account account = ApiDBUtils.findAccountById(usageRecord.getAccountId());
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
//find the project
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
//find the project
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
usageRecResponse.setProjectId(project.getUuid());
usageRecResponse.setProjectName(project.getName());
} else {
usageRecResponse.setAccountId(account.getUuid());
usageRecResponse.setAccountName(account.getAccountName());
}
usageRecResponse.setProjectId(project.getUuid());
usageRecResponse.setProjectName(project.getName());
} else {
usageRecResponse.setAccountId(account.getUuid());
usageRecResponse.setAccountName(account.getAccountName());
}
Domain domain = ApiDBUtils.findDomainById(usageRecord.getDomainId());
if (domain != null) {
usageRecResponse.setDomainId(domain.getUuid());
}
Domain domain = ApiDBUtils.findDomainById(usageRecord.getDomainId());
if (domain != null) {
usageRecResponse.setDomainId(domain.getUuid());
}
if (usageRecord.getZoneId() != null) {
DataCenter zone = ApiDBUtils.findZoneById(usageRecord.getZoneId());
if (zone != null) {
usageRecResponse.setZoneId(zone.getUuid());
}
}
usageRecResponse.setDescription(usageRecord.getDescription());
usageRecResponse.setUsage(usageRecord.getUsageDisplay());
usageRecResponse.setUsageType(usageRecord.getUsageType());
if (usageRecord.getVmInstanceId() != null) {
if (usageRecord.getZoneId() != null) {
DataCenter zone = ApiDBUtils.findZoneById(usageRecord.getZoneId());
if (zone != null) {
usageRecResponse.setZoneId(zone.getUuid());
}
}
usageRecResponse.setDescription(usageRecord.getDescription());
usageRecResponse.setUsage(usageRecord.getUsageDisplay());
usageRecResponse.setUsageType(usageRecord.getUsageType());
if (usageRecord.getVmInstanceId() != null) {
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId());
usageRecResponse.setVirtualMachineId(vm.getUuid());
}
usageRecResponse.setVmName(usageRecord.getVmName());
if (usageRecord.getTemplateId() != null) {
VMTemplateVO template = ApiDBUtils.findTemplateById(usageRecord.getTemplateId());
if (template != null) {
usageRecResponse.setTemplateId(template.getUuid());
}
}
usageRecResponse.setVirtualMachineId(vm.getUuid());
}
usageRecResponse.setVmName(usageRecord.getVmName());
if (usageRecord.getTemplateId() != null) {
VMTemplateVO template = ApiDBUtils.findTemplateById(usageRecord.getTemplateId());
if (template != null) {
usageRecResponse.setTemplateId(template.getUuid());
}
}
if(usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM){
if(usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM){
ServiceOfferingVO svcOffering = _entityMgr.findById(ServiceOfferingVO.class, usageRecord.getOfferingId().toString());
//Service Offering Id
usageRecResponse.setOfferingId(svcOffering.getUuid());
//VM Instance ID
//Service Offering Id
usageRecResponse.setOfferingId(svcOffering.getUuid());
//VM Instance ID
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vm.getUuid());
//Hypervisor Type
usageRecResponse.setType(usageRecord.getType());
usageRecResponse.setUsageId(vm.getUuid());
//Hypervisor Type
usageRecResponse.setType(usageRecord.getType());
} else if(usageRecord.getUsageType() == UsageTypes.IP_ADDRESS){
//isSourceNAT
usageRecResponse.setSourceNat((usageRecord.getType().equals("SourceNat"))?true:false);
//isSystem
usageRecResponse.setSystem((usageRecord.getSize() == 1)?true:false);
//IP Address ID
} else if(usageRecord.getUsageType() == UsageTypes.IP_ADDRESS){
//isSourceNAT
usageRecResponse.setSourceNat((usageRecord.getType().equals("SourceNat"))?true:false);
//isSystem
usageRecResponse.setSystem((usageRecord.getSize() == 1)?true:false);
//IP Address ID
IPAddressVO ip = _entityMgr.findById(IPAddressVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(ip.getUuid());
usageRecResponse.setUsageId(ip.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED){
//Device Type
usageRecResponse.setType(usageRecord.getType());
if(usageRecord.getType().equals("DomainRouter")){
//Domain Router Id
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED){
//Device Type
usageRecResponse.setType(usageRecord.getType());
if(usageRecord.getType().equals("DomainRouter")){
//Domain Router Id
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vm.getUuid());
} else {
//External Device Host Id
usageRecResponse.setUsageId(vm.getUuid());
} else {
//External Device Host Id
HostVO host = _entityMgr.findById(HostVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(host.getUuid());
}
//Network ID
usageRecResponse.setUsageId(host.getUuid());
}
//Network ID
NetworkVO network = _entityMgr.findById(NetworkVO.class, usageRecord.getNetworkId().toString());
usageRecResponse.setNetworkId(network.getUuid());
usageRecResponse.setNetworkId(network.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_WRITE ||
usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_WRITE){
usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_WRITE){
//Device Type
usageRecResponse.setType(usageRecord.getType());
//VM Instance Id
@ -3370,89 +3344,91 @@ public class ApiResponseHelper implements ResponseGenerator {
VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(volume.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.VOLUME){
//Volume ID
} else if(usageRecord.getUsageType() == UsageTypes.VOLUME){
//Volume ID
VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(volume.getUuid());
//Volume Size
usageRecResponse.setSize(usageRecord.getSize());
//Disk Offering Id
if(usageRecord.getOfferingId() != null){
usageRecResponse.setUsageId(volume.getUuid());
//Volume Size
usageRecResponse.setSize(usageRecord.getSize());
//Disk Offering Id
if(usageRecord.getOfferingId() != null){
DiskOfferingVO diskOff = _entityMgr.findById(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
usageRecResponse.setOfferingId(diskOff.getUuid());
}
usageRecResponse.setOfferingId(diskOff.getUuid());
}
} else if(usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO){
//Template/ISO ID
} else if(usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO){
//Template/ISO ID
VMTemplateVO tmpl = _entityMgr.findById(VMTemplateVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(tmpl.getUuid());
//Template/ISO Size
usageRecResponse.setSize(usageRecord.getSize());
if(usageRecord.getUsageType() == UsageTypes.ISO) {
usageRecResponse.setVirtualSize(usageRecord.getSize());
} else {
usageRecResponse.setVirtualSize(usageRecord.getVirtualSize());
}
usageRecResponse.setUsageId(tmpl.getUuid());
//Template/ISO Size
usageRecResponse.setSize(usageRecord.getSize());
if(usageRecord.getUsageType() == UsageTypes.ISO) {
usageRecResponse.setVirtualSize(usageRecord.getSize());
} else {
usageRecResponse.setVirtualSize(usageRecord.getVirtualSize());
}
} else if(usageRecord.getUsageType() == UsageTypes.SNAPSHOT){
//Snapshot ID
} else if(usageRecord.getUsageType() == UsageTypes.SNAPSHOT){
//Snapshot ID
SnapshotVO snap = _entityMgr.findById(SnapshotVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(snap.getUuid());
//Snapshot Size
usageRecResponse.setSize(usageRecord.getSize());
usageRecResponse.setUsageId(snap.getUuid());
//Snapshot Size
usageRecResponse.setSize(usageRecord.getSize());
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
//Load Balancer Policy ID
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
//Load Balancer Policy ID
LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(lb.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
//Port Forwarding Rule ID
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
//Port Forwarding Rule ID
PortForwardingRuleVO pf = _entityMgr.findById(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(pf.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
//Network Offering Id
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
//Network Offering Id
NetworkOfferingVO netOff = _entityMgr.findById(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
usageRecResponse.setOfferingId(netOff.getUuid());
//is Default
usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
usageRecResponse.setOfferingId(netOff.getUuid());
//is Default
usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
//VPN User ID
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
//VPN User ID
VpnUserVO vpnUser = _entityMgr.findById(VpnUserVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vpnUser.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
//Security Group Id
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
//Security Group Id
SecurityGroupVO sg = _entityMgr.findById(SecurityGroupVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(sg.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.VM_SNAPSHOT){
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
usageRecResponse.setVmName(vm.getInstanceName());
usageRecResponse.setUsageId(vm.getUuid());
usageRecResponse.setSize(usageRecord.getSize());
if(usageRecord.getOfferingId() != null)
usageRecResponse.setOfferingId(usageRecord.getOfferingId().toString());
}
usageRecResponse.setUsageId(sg.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.VM_SNAPSHOT){
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
usageRecResponse.setVmName(vm.getInstanceName());
usageRecResponse.setUsageId(vm.getUuid());
usageRecResponse.setSize(usageRecord.getSize());
if(usageRecord.getOfferingId() != null) {
usageRecResponse.setOfferingId(usageRecord.getOfferingId().toString());
}
}
if (usageRecord.getRawUsage() != null) {
DecimalFormat decimalFormat = new DecimalFormat("###########.######");
usageRecResponse.setRawUsage(decimalFormat.format(usageRecord.getRawUsage()));
}
if (usageRecord.getRawUsage() != null) {
DecimalFormat decimalFormat = new DecimalFormat("###########.######");
usageRecResponse.setRawUsage(decimalFormat.format(usageRecord.getRawUsage()));
}
if (usageRecord.getStartDate() != null) {
usageRecResponse.setStartDate(getDateStringInternal(usageRecord.getStartDate()));
}
if (usageRecord.getEndDate() != null) {
usageRecResponse.setEndDate(getDateStringInternal(usageRecord.getEndDate()));
}
if (usageRecord.getStartDate() != null) {
usageRecResponse.setStartDate(getDateStringInternal(usageRecord.getStartDate()));
}
if (usageRecord.getEndDate() != null) {
usageRecResponse.setEndDate(getDateStringInternal(usageRecord.getEndDate()));
}
return usageRecResponse;
}
return usageRecResponse;
}
public String getDateStringInternal(Date inputDate) {
if (inputDate == null)
if (inputDate == null) {
return null;
}
TimeZone tz = _usageSvc.getUsageTimezone();
Calendar cal = Calendar.getInstance(tz);
@ -3501,8 +3477,8 @@ public class ApiResponseHelper implements ResponseGenerator {
double offset = cal.get(Calendar.ZONE_OFFSET);
if (tz.inDaylightTime(inputDate)) {
offset += (1.0 * tz.getDSTSavings()); // add the timezone's DST
// value (typically 1 hour
// expressed in milliseconds)
// value (typically 1 hour
// expressed in milliseconds)
}
offset = offset / (1000d * 60d * 60d);

View File

@ -176,7 +176,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;
@ -228,8 +227,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;
@ -143,7 +141,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;
@ -239,8 +236,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

@ -151,7 +151,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;
@ -231,8 +230,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
@Inject
SnapshotDao _snapshotDao;
@Inject
VMTemplateS3Dao _vmS3TemplateDao;
@Inject
ConfigurationDao _configDao;
@Inject
ClusterDao _clusterDao;

View File

@ -99,7 +99,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 com.cloud.vm.dao.VMInstanceDaoImpl;
DcDetailsDaoImpl.class,
NicSecondaryIpDaoImpl.class,
UserIpv6AddressDaoImpl.class,
S3DaoImpl.class,
UserDaoImpl.class,
NicDaoImpl.class,
NetworkDomainDaoImpl.class,