Resource metadata support for S2SVpnConnection

Conflicts:
	server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
	server/src/com/cloud/tags/TaggedResourceManagerImpl.java
	setup/db/db/schema-421to430.sql
This commit is contained in:
Alena Prokharchyk 2013-12-12 14:57:44 -08:00
parent d5fcc6ef5a
commit 9df10718e4
9 changed files with 199 additions and 50 deletions

View File

@ -24,31 +24,12 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
// FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
public enum ResourceObjectType {
UserVm(true, true),
Template(true, true),
ISO(true, false),
Volume(true, true),
Snapshot(true, false),
Network(true, true),
Nic(false, true),
LoadBalancer(true, true),
PortForwardingRule(true, true),
FirewallRule(true, true),
SecurityGroup(true, false),
PublicIpAddress(true, true),
Project(true, false),
Vpc(true, true),
NetworkACL(true, true),
StaticRoute(true, false),
VMSnapshot(true, false),
RemoteAccessVpn(true, true),
Zone(false, true),
ServiceOffering(false, true),
Storage(false, true),
PrivateGateway(false, true),
NetworkACLList(false, true),
VpnGateway(false, true),
CustomerGateway(false, true);
UserVm(true, true), Template(true, true), ISO(true, false), Volume(true, true), Snapshot(true, false), Network(true, true), Nic(false, true), LoadBalancer(true, true), PortForwardingRule(
true, true), FirewallRule(true, true),
SecurityGroup(true, false), PublicIpAddress(true, true), Project(true, false), Vpc(true, true), NetworkACL(true, true), StaticRoute(true, false), VMSnapshot(true, false), RemoteAccessVpn(
true, true), Zone(false, true), ServiceOffering(false, true), Storage(false, true), PrivateGateway(false, true), NetworkACLList(false, true), VpnGateway(false,
true), CustomerGateway(false, true), VpnConnection(false, true);
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
this.resourceTagsSupport = resourceTagsSupport;

View File

@ -329,6 +329,7 @@
<bean id="NetworkACLItemDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.NetworkACLItemDetailsDaoImpl" />
<bean id="Site2SiteVpnGatewayDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.Site2SiteVpnGatewayDetailsDaoImpl" />
<bean id="Site2SiteCustomerGatewayDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.Site2SiteCustomerGatewayDetailsDaoImpl" />
<bean id="Site2SiteVpnConnectionDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.Site2SiteVpnConnectionDetailsDaoImpl" />
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
</beans>

View File

@ -0,0 +1,81 @@
// 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.resourcedetail;
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.ResourceDetail;
@Entity
@Table(name = "s2s_vpn_connection_details")
public class Site2SiteVpnConnectionDetailVO implements ResourceDetail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "s2s_vpn_connection_id")
private long resourceId;
@Column(name = "name")
private String name;
@Column(name = "value", length = 1024)
private String value;
@Column(name = "display")
private boolean display;
public Site2SiteVpnConnectionDetailVO() {
}
public Site2SiteVpnConnectionDetailVO(long id, String name, String value) {
this.resourceId = id;
this.name = name;
this.value = value;
}
@Override
public long getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public String getValue() {
return value;
}
@Override
public long getResourceId() {
return resourceId;
}
@Override
public boolean isDisplay() {
return display;
}
}

View File

@ -0,0 +1,26 @@
// 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.resourcedetail.dao;
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
import org.apache.cloudstack.resourcedetail.Site2SiteVpnConnectionDetailVO;
import com.cloud.utils.db.GenericDao;
public interface Site2SiteVpnConnectionDetailsDao extends GenericDao<Site2SiteVpnConnectionDetailVO, Long>, ResourceDetailsDao<Site2SiteVpnConnectionDetailVO> {
}

View File

@ -0,0 +1,32 @@
// 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.resourcedetail.dao;
import javax.ejb.Local;
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
import org.apache.cloudstack.resourcedetail.Site2SiteVpnConnectionDetailVO;
import org.springframework.stereotype.Component;
@Component
@Local(value = {Site2SiteVpnConnectionDetailsDao.class})
public class Site2SiteVpnConnectionDetailsDaoImpl extends ResourceDetailsDaoBase<Site2SiteVpnConnectionDetailVO> implements Site2SiteVpnConnectionDetailsDao {
@Override
public void addDetail(long resourceId, String key, String value) {
super.addDetail(new Site2SiteVpnConnectionDetailVO(resourceId, key, value));
}
}

View File

@ -31,8 +31,6 @@ import java.util.TimeZone;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroup;
@ -149,6 +147,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.usage.Usage;
import org.apache.cloudstack.usage.UsageService;
import org.apache.cloudstack.usage.UsageTypes;
import org.apache.log4j.Logger;
import com.cloud.api.query.ViewResponseHelper;
import com.cloud.api.query.vo.AccountJoinVO;
@ -288,7 +287,6 @@ import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
import com.cloud.utils.StringUtils;
import com.cloud.utils.db.EntityManager;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.Ip;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.ConsoleProxyVO;
@ -465,9 +463,9 @@ public class ApiResponseHelper implements ResponseGenerator {
}
if (snapshotInfo == null) {
s_logger.debug("Unable to find info for image store snapshot with uuid "+snapshot.getUuid());
s_logger.debug("Unable to find info for image store snapshot with uuid " + snapshot.getUuid());
snapshotResponse.setRevertable(false);
}else{
} else {
snapshotResponse.setRevertable(snapshotInfo.isRevertable());
}
@ -1704,8 +1702,8 @@ public class ApiResponseHelper implements ResponseGenerator {
short capacityType = capacity.getCapacityType();
// If local storage then ignore
if ((capacityType == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED || capacityType == Capacity.CAPACITY_TYPE_STORAGE) &&
poolIdsToIgnore.contains(capacity.getHostOrPoolId())) {
if ((capacityType == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED || capacityType == Capacity.CAPACITY_TYPE_STORAGE)
&& poolIdsToIgnore.contains(capacity.getHostOrPoolId())) {
continue;
}
@ -2198,8 +2196,7 @@ public class ApiResponseHelper implements ResponseGenerator {
reservation = (NetUtils.long2Ip(startGuestIp) + "-" + NetUtils.long2Ip(startVmIp - 1));
}
if (startVmIp > startGuestIp + 1 && endVmIp < endGuestIp - 1) {
reservation =
(NetUtils.long2Ip(startGuestIp) + "-" + NetUtils.long2Ip(startVmIp - 1) + " , " + NetUtils.long2Ip(endVmIp + 1) + "-" + NetUtils.long2Ip(endGuestIp));
reservation = (NetUtils.long2Ip(startGuestIp) + "-" + NetUtils.long2Ip(startVmIp - 1) + " , " + NetUtils.long2Ip(endVmIp + 1) + "-" + NetUtils.long2Ip(endGuestIp));
}
}
response.setReservedIpRange(reservation);
@ -2210,10 +2207,10 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setBroadcastUri(broadcastUri);
String vlan = "N/A";
switch (BroadcastDomainType.getSchemeValue(network.getBroadcastUri())) {
case Vlan:
case Vxlan:
vlan = BroadcastDomainType.getValue(network.getBroadcastUri());
break;
case Vlan:
case Vxlan:
vlan = BroadcastDomainType.getValue(network.getBroadcastUri());
break;
}
// return vlan information only to Root admin
response.setVlan(vlan);
@ -2626,8 +2623,8 @@ public class ApiResponseHelper implements ResponseGenerator {
CapabilityResponse capabilityResponse = new CapabilityResponse();
capabilityResponse.setName(cap.getName());
capabilityResponse.setObjectName("capability");
if (cap.getName().equals(Capability.SupportedLBIsolation.getName()) || cap.getName().equals(Capability.SupportedSourceNatTypes.getName()) ||
cap.getName().equals(Capability.RedundantRouter.getName())) {
if (cap.getName().equals(Capability.SupportedLBIsolation.getName()) || cap.getName().equals(Capability.SupportedSourceNatTypes.getName())
|| cap.getName().equals(Capability.RedundantRouter.getName())) {
capabilityResponse.setCanChoose(true);
} else {
capabilityResponse.setCanChoose(false);
@ -2641,8 +2638,8 @@ public class ApiResponseHelper implements ResponseGenerator {
List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
for (Network.Provider serviceProvider : serviceProviders) {
// return only Virtual Router/JuniperSRX/CiscoVnmc as a provider for the firewall
if (service == Service.Firewall &&
!(serviceProvider == Provider.VirtualRouter || serviceProvider == Provider.JuniperSRX || serviceProvider == Provider.CiscoVnmc || serviceProvider == Provider.PaloAlto)) {
if (service == Service.Firewall
&& !(serviceProvider == Provider.VirtualRouter || serviceProvider == Provider.JuniperSRX || serviceProvider == Provider.CiscoVnmc || serviceProvider == Provider.PaloAlto)) {
continue;
}
@ -2734,8 +2731,7 @@ public class ApiResponseHelper implements ResponseGenerator {
OvsProviderResponse response = new OvsProviderResponse();
response.setId(result.getUuid());
PhysicalNetworkServiceProvider nsp = ApiDBUtils
.findPhysicalNetworkServiceProviderById(result.getNspId());
PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
if (nsp != null) {
response.setNspId(nsp.getUuid());
}
@ -3373,8 +3369,8 @@ public class ApiResponseHelper implements ResponseGenerator {
NetworkVO network = _entityMgr.findById(NetworkVO.class, usageRecord.getNetworkId().toString());
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) {
} 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) {
//Device Type
usageRecResponse.setType(usageRecord.getType());
//VM Instance Id

View File

@ -30,6 +30,9 @@ import org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.NetworkACLItemDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.NetworkACLListDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.Site2SiteCustomerGatewayDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.Site2SiteVpnConnectionDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.Site2SiteVpnGatewayDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import org.apache.cloudstack.resourcedetail.dao.VpcGatewayDetailsDao;
@ -92,9 +95,14 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
NetworkACLListDetailsDao _networkACLListDetailsDao;
@Inject
NetworkACLItemDetailsDao _networkACLDetailsDao;
@Inject
Site2SiteVpnGatewayDetailsDao _vpnGatewayDetailsDao;
@Inject
Site2SiteCustomerGatewayDetailsDao _customerGatewayDetailsDao;
@Inject
Site2SiteVpnConnectionDetailsDao _vpnConnectionDetailsDao;
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> s_daoMap =
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> s_daoMap = new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@ -115,6 +123,9 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
s_daoMap.put(ResourceObjectType.PrivateGateway, _vpcGatewayDetailsDao);
s_daoMap.put(ResourceObjectType.NetworkACLList, _networkACLListDetailsDao);
s_daoMap.put(ResourceObjectType.NetworkACL, _networkACLDetailsDao);
s_daoMap.put(ResourceObjectType.VpnGateway, _vpnGatewayDetailsDao);
s_daoMap.put(ResourceObjectType.CustomerGateway, _customerGatewayDetailsDao);
s_daoMap.put(ResourceObjectType.VpnConnection, _vpnConnectionDetailsDao);
return true;
}

View File

@ -42,6 +42,9 @@ import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
import com.cloud.network.dao.Site2SiteVpnConnectionDao;
import com.cloud.network.dao.Site2SiteVpnGatewayDao;
import com.cloud.network.rules.dao.PortForwardingRulesDao;
import com.cloud.network.security.dao.SecurityGroupDao;
import com.cloud.network.vpc.NetworkACLItemDao;
@ -138,6 +141,12 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
VpcGatewayDao _vpcGatewayDao;
@Inject
NetworkACLDao _networkACLListDao;
@Inject
Site2SiteVpnGatewayDao _vpnGatewayDao;
@Inject
Site2SiteCustomerGatewayDao _customerGatewayDao;
@Inject
Site2SiteVpnConnectionDao _vpnConnectionDao;
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@ -164,6 +173,9 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
s_daoMap.put(ResourceObjectType.Storage, _storagePoolDao);
s_daoMap.put(ResourceObjectType.PrivateGateway, _vpcGatewayDao);
s_daoMap.put(ResourceObjectType.NetworkACLList, _networkACLListDao);
s_daoMap.put(ResourceObjectType.VpnGateway, _vpnGatewayDao);
s_daoMap.put(ResourceObjectType.CustomerGateway, _customerGatewayDao);
s_daoMap.put(ResourceObjectType.VpnConnection, _vpnConnectionDao);
return true;
}
@ -294,8 +306,7 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
throw new InvalidParameterValueException("Value for the key " + key + " is either null or empty");
}
ResourceTagVO resourceTag =
new ResourceTagVO(key, value, accountDomainPair.first(), accountDomainPair.second(), id, resourceType, customer, resourceUuid);
ResourceTagVO resourceTag = new ResourceTagVO(key, value, accountDomainPair.first(), accountDomainPair.second(), id, resourceType, customer, resourceUuid);
resourceTag = _resourceTagDao.persist(resourceTag);
resourceTags.add(resourceTag);
}

View File

@ -859,3 +859,13 @@ CREATE TABLE `cloud`.`s2s_customer_gateway_details` (
CONSTRAINT `fk_s2s_customer_gateway_details__s2s_customer_gateway_id` FOREIGN KEY `fk_s2s_customer_gateway_details__s2s_customer_gateway_id`(`s2s_customer_gateway_id`) REFERENCES `s2s_customer_gateway`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`s2s_vpn_connection_details` (
`id` bigint unsigned NOT NULL auto_increment,
`s2s_vpn_connection_id` bigint unsigned NOT NULL COMMENT 'VPC gateway id',
`name` varchar(255) NOT NULL,
`value` varchar(1024) NOT NULL,
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
PRIMARY KEY (`id`),
CONSTRAINT `fk_s2s_vpn_connection_details__s2s_vpn_connection_id` FOREIGN KEY `fk_s2s_vpn_connection_details__s2s_vpn_connection_id`(`s2s_vpn_connection_id`) REFERENCES `s2s_vpn_connection`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;