Skip to content

Commit 1fe8efc

Browse files
author
Alena Prokharchyk
committed
Resource metadata support for VPC Private Gateway
1 parent e52b457 commit 1fe8efc

8 files changed

Lines changed: 163 additions & 1 deletion

File tree

‎api/src/com/cloud/server/ResourceTag.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public enum ResourceObjectType {
4545
RemoteAccessVpn(true, true),
4646
Zone(false, true),
4747
ServiceOffering(false, true),
48-
Storage(false, true);
48+
Storage(false, true),
49+
PrivateGateway(false, true);
4950

5051
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
5152
this.resourceTagsSupport = resourceTagsSupport;

‎engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@
324324
<bean id="UserIpAddressDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDaoImpl" />
325325
<bean id="RemoteAccessVpnDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDaoImpl" />
326326
<bean id="VpcDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.VpcDetailsDaoImpl" />
327+
<bean id="VpcGatewayDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.VpcGatewayDetailsDaoImpl" />
327328
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
328329

329330
</beans>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.resourcedetail;
18+
19+
import javax.persistence.Column;
20+
import javax.persistence.Entity;
21+
import javax.persistence.GeneratedValue;
22+
import javax.persistence.GenerationType;
23+
import javax.persistence.Id;
24+
import javax.persistence.Table;
25+
26+
import org.apache.cloudstack.api.ResourceDetail;
27+
28+
@Entity
29+
@Table(name = "vpc_gateway_details")
30+
public class VpcGatewayDetailVO implements ResourceDetail {
31+
@Id
32+
@GeneratedValue(strategy = GenerationType.IDENTITY)
33+
@Column(name = "id")
34+
private long id;
35+
36+
@Column(name = "vpc_gateway_id")
37+
private long resourceId;
38+
39+
@Column(name = "name")
40+
private String name;
41+
42+
@Column(name = "value", length = 1024)
43+
private String value;
44+
45+
@Column(name = "display")
46+
private boolean display;
47+
48+
public VpcGatewayDetailVO() {
49+
}
50+
51+
public VpcGatewayDetailVO(long id, String name, String value) {
52+
this.resourceId = id;
53+
this.name = name;
54+
this.value = value;
55+
}
56+
57+
@Override
58+
public long getId() {
59+
return id;
60+
}
61+
62+
@Override
63+
public String getName() {
64+
return name;
65+
}
66+
67+
@Override
68+
public String getValue() {
69+
return value;
70+
}
71+
72+
@Override
73+
public long getResourceId() {
74+
return resourceId;
75+
}
76+
77+
@Override
78+
public boolean isDisplay() {
79+
return display;
80+
}
81+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.resourcedetail.dao;
18+
19+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
20+
import org.apache.cloudstack.resourcedetail.VpcGatewayDetailVO;
21+
22+
import com.cloud.utils.db.GenericDao;
23+
24+
public interface VpcGatewayDetailsDao extends GenericDao<VpcGatewayDetailVO, Long>, ResourceDetailsDao<VpcGatewayDetailVO> {
25+
26+
}
27+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.resourcedetail.dao;
18+
19+
import javax.ejb.Local;
20+
21+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
22+
import org.apache.cloudstack.resourcedetail.VpcGatewayDetailVO;
23+
import org.springframework.stereotype.Component;
24+
25+
@Component
26+
@Local(value = { VpcGatewayDetailsDao.class })
27+
public class VpcGatewayDetailsDaoImpl extends ResourceDetailsDaoBase<VpcGatewayDetailVO> implements VpcGatewayDetailsDao {
28+
29+
@Override
30+
public void addDetail(long resourceId, String key, String value) {
31+
super.addDetail(new VpcGatewayDetailVO(resourceId, key, value));
32+
}
33+
}

‎server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
3131
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
3232
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
33+
import org.apache.cloudstack.resourcedetail.dao.VpcGatewayDetailsDao;
3334
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3435
import org.apache.log4j.Logger;
3536
import org.springframework.stereotype.Component;
@@ -84,6 +85,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
8485
RemoteAccessVpnDetailsDao _vpnDetailsDao;
8586
@Inject
8687
VpcDetailsDao _vpcDetailsDao;
88+
@Inject
89+
VpcGatewayDetailsDao _vpcGatewayDetailsDao;
8790

8891
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap =
8992
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
@@ -104,6 +107,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
104107
_daoMap.put(ResourceObjectType.LoadBalancer, _firewallRuleDetailsDao);
105108
_daoMap.put(ResourceObjectType.RemoteAccessVpn, _vpnDetailsDao);
106109
_daoMap.put(ResourceObjectType.Vpc, _vpcDetailsDao);
110+
_daoMap.put(ResourceObjectType.PrivateGateway, _vpcGatewayDetailsDao);
107111

108112
return true;
109113
}

‎server/src/com/cloud/tags/TaggedResourceManagerImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.cloud.network.vpc.NetworkACLItemDao;
4848
import com.cloud.network.vpc.dao.StaticRouteDao;
4949
import com.cloud.network.vpc.dao.VpcDao;
50+
import com.cloud.network.vpc.dao.VpcGatewayDao;
5051
import com.cloud.projects.dao.ProjectDao;
5152
import com.cloud.server.ResourceTag;
5253
import com.cloud.server.ResourceTag.ResourceObjectType;
@@ -134,6 +135,8 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
134135
ServiceOfferingDao _serviceOffDao;
135136
@Inject
136137
PrimaryDataStoreDao _storagePoolDao;
138+
@Inject
139+
VpcGatewayDao _vpcGatewayDao;
137140

138141

139142
@Override
@@ -159,6 +162,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
159162
_daoMap.put(ResourceObjectType.Zone, _dataCenterDao);
160163
_daoMap.put(ResourceObjectType.ServiceOffering, _serviceOffDao);
161164
_daoMap.put(ResourceObjectType.Storage, _storagePoolDao);
165+
_daoMap.put(ResourceObjectType.PrivateGateway, _vpcGatewayDao);
162166

163167

164168
return true;

‎setup/db/db/schema-421to430.sql‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,3 +768,14 @@ CREATE TABLE `cloud`.`vpc_details` (
768768
PRIMARY KEY (`id`),
769769
CONSTRAINT `fk_vpc_details__vpc_id` FOREIGN KEY `fk_vpc_details__vpc_id`(`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE
770770
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
771+
772+
773+
CREATE TABLE `cloud`.`vpc_gateway_details` (
774+
`id` bigint unsigned NOT NULL auto_increment,
775+
`vpc_gateway_id` bigint unsigned NOT NULL COMMENT 'VPC gateway id',
776+
`name` varchar(255) NOT NULL,
777+
`value` varchar(1024) NOT NULL,
778+
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
779+
PRIMARY KEY (`id`),
780+
CONSTRAINT `fk_vpc_gateway_details__vpc_gateway_id` FOREIGN KEY `fk_vpc_gateway_details__vpc_gateway_id`(`vpc_gateway_id`) REFERENCES `vpc_gateways`(`id`) ON DELETE CASCADE
781+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

0 commit comments

Comments
 (0)