Skip to content

Commit 602d4ef

Browse files
author
Alena Prokharchyk
committed
Resource metadata - support for VPC
1 parent b4282c2 commit 602d4ef

7 files changed

Lines changed: 180 additions & 11 deletions

File tree

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,29 @@
2222

2323
public interface ResourceTag extends ControlledEntity, Identity, InternalIdentity {
2424

25-
//FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
25+
// FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
2626
public enum ResourceObjectType {
27-
UserVm(true, true), Template(true, true), ISO(true, false), Volume(true, true), Snapshot(true, false), Network(true, true), Nic(false, true), LoadBalancer(
28-
true,
29-
true), PortForwardingRule(true, true), FirewallRule(true, true), SecurityGroup(true, false), PublicIpAddress(true, true), Project(true, false), Vpc(
30-
true,
31-
false), NetworkACL(true, false), StaticRoute(true, false), VMSnapshot(true, false), RemoteAccessVpn(true, true), Zone(false, true), ServiceOffering(
32-
false,
33-
true), Storage(false, true);
27+
UserVm(true, true),
28+
Template(true, true),
29+
ISO(true, false),
30+
Volume(true, true),
31+
Snapshot(true, false),
32+
Network(true, true),
33+
Nic(false, true),
34+
LoadBalancer(true, true),
35+
PortForwardingRule(true, true),
36+
FirewallRule(true, true),
37+
SecurityGroup(true, false),
38+
PublicIpAddress(true, true),
39+
Project(true, false),
40+
Vpc(true, true),
41+
NetworkACL(true, false),
42+
StaticRoute(true, false),
43+
VMSnapshot(true, false),
44+
RemoteAccessVpn(true, true),
45+
Zone(false, true),
46+
ServiceOffering(false, true),
47+
Storage(false, true);
3448

3549
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
3650
this.resourceTagsSupport = resourceTagsSupport;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323
<bean id="FirewallRuleDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDaoImpl" />
324324
<bean id="UserIpAddressDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDaoImpl" />
325325
<bean id="RemoteAccessVpnDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDaoImpl" />
326-
326+
<bean id="VpcDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.VpcDetailsDaoImpl" />
327327
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
328328

329329
</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_details")
30+
public class VpcDetailVO implements ResourceDetail {
31+
@Id
32+
@GeneratedValue(strategy = GenerationType.IDENTITY)
33+
@Column(name = "id")
34+
private long id;
35+
36+
@Column(name = "vpc_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 VpcDetailVO() {
49+
}
50+
51+
public VpcDetailVO(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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.VpcDetailVO;
21+
22+
import com.cloud.utils.db.GenericDao;
23+
24+
public interface VpcDetailsDao extends GenericDao<VpcDetailVO, Long>, ResourceDetailsDao<VpcDetailVO> {
25+
26+
}
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.VpcDetailVO;
23+
import org.springframework.stereotype.Component;
24+
25+
@Component
26+
@Local(value = { VpcDetailsDao.class })
27+
public class VpcDetailsDaoImpl extends ResourceDetailsDaoBase<VpcDetailVO> implements VpcDetailsDao {
28+
29+
@Override
30+
public void addDetail(long resourceId, String key, String value) {
31+
super.addDetail(new VpcDetailVO(resourceId, key, value));
32+
}
33+
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDao;
3333
import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
3434
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
35+
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
3536
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3637

3738
import com.cloud.dc.dao.DataCenterDetailsDao;
@@ -81,9 +82,11 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
8182
UserIpAddressDetailsDao _userIpAddressDetailsDao;
8283
@Inject
8384
RemoteAccessVpnDetailsDao _vpnDetailsDao;
85+
@Inject
86+
VpcDetailsDao _vpcDetailsDao;
8487

8588
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap =
86-
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
89+
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
8790

8891
@Override
8992
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -100,6 +103,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
100103
_daoMap.put(ResourceObjectType.PortForwardingRule, _firewallRuleDetailsDao);
101104
_daoMap.put(ResourceObjectType.LoadBalancer, _firewallRuleDetailsDao);
102105
_daoMap.put(ResourceObjectType.RemoteAccessVpn, _vpnDetailsDao);
106+
_daoMap.put(ResourceObjectType.Vpc, _vpcDetailsDao);
103107

104108
return true;
105109
}
@@ -162,7 +166,7 @@ private DetailDaoHelper(ResourceObjectType resourceType) {
162166
if (dao == null) {
163167
throw new UnsupportedOperationException("ResourceType " + resourceType + " doesn't support metadata");
164168
}
165-
this.dao = (ResourceDetailsDao)_daoMap.get(resourceType);
169+
this.dao = (ResourceDetailsDao) _daoMap.get(resourceType);
166170
}
167171

168172
private void removeDetail(long resourceId, String key) {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,17 @@ CREATE VIEW `cloud`.`domain_router_view` AS
751751
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
752752
and async_job.instance_type = 'DomainRouter'
753753
and async_job.job_status = 0;
754+
754755
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", "1200", NULL,NULL,0);
755756
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "mgt.server.vendor", "ACS", "the vendor of management server", "ACS", NULL,NULL,0);
756757

758+
759+
CREATE TABLE `cloud`.`vpc_details` (
760+
`id` bigint unsigned NOT NULL auto_increment,
761+
`vpc_id` bigint unsigned NOT NULL COMMENT 'VPC id',
762+
`name` varchar(255) NOT NULL,
763+
`value` varchar(1024) NOT NULL,
764+
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
765+
PRIMARY KEY (`id`),
766+
CONSTRAINT `fk_vpc_details__vpc_id` FOREIGN KEY `fk_vpc_details__vpc_id`(`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE
767+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

0 commit comments

Comments
 (0)