Skip to content

Commit 4edc398

Browse files
author
Alena Prokharchyk
committed
Resource metadata support for NetworkACLItem
1 parent 8249974 commit 4edc398

8 files changed

Lines changed: 159 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public enum ResourceObjectType {
3939
PublicIpAddress(true, true),
4040
Project(true, false),
4141
Vpc(true, true),
42-
NetworkACL(true, false),
42+
NetworkACL(true, true),
4343
StaticRoute(true, false),
4444
VMSnapshot(true, false),
4545
RemoteAccessVpn(true, true),

‎api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd {
3939
/////////////////////////////////////////////////////
4040
//////////////// API parameters /////////////////////
4141
/////////////////////////////////////////////////////
42-
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
42+
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkACLItemResponse.class,
4343
description="Lists network ACL Item with the specified ID")
4444
private Long id;
4545

‎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
@@ -326,6 +326,7 @@
326326
<bean id="VpcDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.VpcDetailsDaoImpl" />
327327
<bean id="VpcGatewayDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.VpcGatewayDetailsDaoImpl" />
328328
<bean id="NetworkACLListDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.NetworkACLListDetailsDaoImpl" />
329+
<bean id="NetworkACLItemDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.NetworkACLItemDetailsDaoImpl" />
329330

330331
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
331332

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.cloudstack.api.ResourceDetail;
2828
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
2929
import org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDao;
30+
import org.apache.cloudstack.resourcedetail.dao.NetworkACLItemDetailsDao;
3031
import org.apache.cloudstack.resourcedetail.dao.NetworkACLListDetailsDao;
3132
import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
3233
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
@@ -90,6 +91,9 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
9091
VpcGatewayDetailsDao _vpcGatewayDetailsDao;
9192
@Inject
9293
NetworkACLListDetailsDao _networkACLListDetailsDao;
94+
@Inject
95+
NetworkACLItemDetailsDao _networkACLDetailsDao;
96+
9397

9498
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap =
9599
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
@@ -112,6 +116,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
112116
_daoMap.put(ResourceObjectType.Vpc, _vpcDetailsDao);
113117
_daoMap.put(ResourceObjectType.PrivateGateway, _vpcGatewayDetailsDao);
114118
_daoMap.put(ResourceObjectType.NetworkACLList, _networkACLListDetailsDao);
119+
_daoMap.put(ResourceObjectType.NetworkACL, _networkACLDetailsDao);
115120

116121
return true;
117122
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,3 +789,13 @@ CREATE TABLE `cloud`.`network_acl_details` (
789789
PRIMARY KEY (`id`),
790790
CONSTRAINT `fk_network_acl_details__network_acl_id` FOREIGN KEY `fk_network_acl_details__network_acl_id`(`network_acl_id`) REFERENCES `network_acl`(`id`) ON DELETE CASCADE
791791
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
792+
793+
CREATE TABLE `cloud`.`network_acl_item_details` (
794+
`id` bigint unsigned NOT NULL auto_increment,
795+
`network_acl_item_id` bigint unsigned NOT NULL COMMENT 'VPC gateway id',
796+
`name` varchar(255) NOT NULL,
797+
`value` varchar(1024) NOT NULL,
798+
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
799+
PRIMARY KEY (`id`),
800+
CONSTRAINT `fk_network_acl_item_details__network_acl_item_id` FOREIGN KEY `fk_network_acl_item_details__network_acl_item_id`(`network_acl_item_id`) REFERENCES `network_acl_item`(`id`) ON DELETE CASCADE
801+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

0 commit comments

Comments
 (0)