Skip to content

Commit cb14dad

Browse files
author
Alena Prokharchyk
committed
Resource metadata - support for VPC
Conflicts: api/src/com/cloud/server/ResourceTag.java server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
1 parent 98ed8b7 commit cb14dad

7 files changed

Lines changed: 183 additions & 28 deletions

File tree

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

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,31 @@
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
26-
public enum ResourceObjectType {
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, false),
41-
NetworkACL (true, false),
42-
StaticRoute (true, false),
43-
VMSnapshot (true, false),
44-
RemoteAccessVpn (true, true),
45-
Zone (false, true),
46-
ServiceOffering (false, true),
25+
26+
// FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
27+
public enum ResourceObjectType {
28+
UserVm(true, true),
29+
Template(true, true),
30+
ISO(true, false),
31+
Volume(true, true),
32+
Snapshot(true, false),
33+
Network(true, true),
34+
Nic(false, true),
35+
LoadBalancer(true, true),
36+
PortForwardingRule(true, true),
37+
FirewallRule(true, true),
38+
SecurityGroup(true, false),
39+
PublicIpAddress(true, true),
40+
Project(true, false),
41+
Vpc(true, true),
42+
NetworkACL(true, false),
43+
StaticRoute(true, false),
44+
VMSnapshot(true, false),
45+
RemoteAccessVpn(true, true),
46+
Zone(false, true),
47+
ServiceOffering(false, true),
4748
Storage(false, true);
48-
49+
4950
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
5051
this.resourceTagsSupport = resourceTagsSupport;
5152
this.metadataSupport = resourceMetadataSupport;

‎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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDao;
3030
import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
3131
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
32+
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
3233
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3334
import org.apache.log4j.Logger;
3435
import org.springframework.stereotype.Component;
@@ -81,10 +82,11 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
8182
UserIpAddressDetailsDao _userIpAddressDetailsDao;
8283
@Inject
8384
RemoteAccessVpnDetailsDao _vpnDetailsDao;
84-
85-
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap=
85+
@Inject
86+
VpcDetailsDao _vpcDetailsDao;
87+
88+
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap =
8689
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
87-
8890

8991
@Override
9092
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -101,6 +103,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
101103
_daoMap.put(ResourceObjectType.PortForwardingRule, _firewallRuleDetailsDao);
102104
_daoMap.put(ResourceObjectType.LoadBalancer, _firewallRuleDetailsDao);
103105
_daoMap.put(ResourceObjectType.RemoteAccessVpn, _vpnDetailsDao);
106+
_daoMap.put(ResourceObjectType.Vpc, _vpcDetailsDao);
104107

105108
return true;
106109
}
@@ -165,7 +168,7 @@ private DetailDaoHelper(ResourceObjectType resourceType) {
165168
if (dao == null) {
166169
throw new UnsupportedOperationException("ResourceType " + resourceType + " doesn't support metadata");
167170
}
168-
this.dao = (ResourceDetailsDao)_daoMap.get(resourceType);
171+
this.dao = (ResourceDetailsDao) _daoMap.get(resourceType);
169172
}
170173

171174
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
@@ -742,6 +742,17 @@ CREATE VIEW `cloud`.`domain_router_view` AS
742742
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
743743
and async_job.instance_type = 'DomainRouter'
744744
and async_job.job_status = 0;
745+
745746
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", "1200", NULL,NULL,0);
746747
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "mgt.server.vendor", "ACS", "the vendor of management server", "ACS", NULL,NULL,0);
747748

749+
750+
CREATE TABLE `cloud`.`vpc_details` (
751+
`id` bigint unsigned NOT NULL auto_increment,
752+
`vpc_id` bigint unsigned NOT NULL COMMENT 'VPC id',
753+
`name` varchar(255) NOT NULL,
754+
`value` varchar(1024) NOT NULL,
755+
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
756+
PRIMARY KEY (`id`),
757+
CONSTRAINT `fk_vpc_details__vpc_id` FOREIGN KEY `fk_vpc_details__vpc_id`(`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE
758+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

0 commit comments

Comments
 (0)