Skip to content

Commit 8bd1eaa

Browse files
author
Alena Prokharchyk
committed
ResourceMetaData: added support for userIpAddress (publicIp) metadata
1 parent 31b439e commit 8bd1eaa

8 files changed

Lines changed: 198 additions & 41 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum ResourceObjectType {
3535
PortForwardingRule (true, false),
3636
FirewallRule (true, true),
3737
SecurityGroup (true, false),
38-
PublicIpAddress (true, false),
38+
PublicIpAddress (true, true),
3939
Project (true, false),
4040
Vpc (true, false),
4141
NetworkACL (true, false),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@
321321
<bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl" />
322322
<bean id="AffinityGroupDomainMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDaoImpl" />
323323
<bean id="FirewallRuleDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDaoImpl" />
324+
<bean id="UserIpAddressDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDaoImpl" />
325+
324326

325327
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
326328

‎engine/schema/src/org/apache/cloudstack/resourcedetail/FirewallRuleDetailVO.java‎

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,53 @@
2828
@Entity
2929
@Table(name="firewall_rule_details")
3030
public class FirewallRuleDetailVO implements ResourceDetail{
31-
@Id
32-
@GeneratedValue(strategy= GenerationType.IDENTITY)
33-
@Column(name="id")
34-
private long id;
31+
@Id
32+
@GeneratedValue(strategy= GenerationType.IDENTITY)
33+
@Column(name="id")
34+
private long id;
3535

36-
@Column(name="firewall_rule_id")
37-
private long resourceId;
36+
@Column(name="firewall_rule_id")
37+
private long resourceId;
3838

39-
@Column(name="name")
40-
private String name;
39+
@Column(name="name")
40+
private String name;
4141

42-
@Column(name="value", length=1024)
43-
private String value;
44-
45-
@Column(name="display")
46-
private boolean display;
42+
@Column(name="value", length=1024)
43+
private String value;
44+
45+
@Column(name="display")
46+
private boolean display;
4747

48-
public FirewallRuleDetailVO() {}
48+
public FirewallRuleDetailVO() {}
4949

50-
public FirewallRuleDetailVO(long networkId, String name, String value) {
51-
this.resourceId = networkId;
52-
this.name = name;
53-
this.value = value;
54-
}
50+
public FirewallRuleDetailVO(long networkId, String name, String value) {
51+
this.resourceId = networkId;
52+
this.name = name;
53+
this.value = value;
54+
}
5555

56-
@Override
57-
public long getId() {
58-
return id;
59-
}
56+
@Override
57+
public long getId() {
58+
return id;
59+
}
6060

61-
@Override
62-
public String getName() {
63-
return name;
64-
}
61+
@Override
62+
public String getName() {
63+
return name;
64+
}
6565

66-
@Override
67-
public String getValue() {
68-
return value;
69-
}
66+
@Override
67+
public String getValue() {
68+
return value;
69+
}
7070

71-
@Override
72-
public long getResourceId() {
73-
return resourceId;
74-
}
71+
@Override
72+
public long getResourceId() {
73+
return resourceId;
74+
}
7575

76-
@Override
77-
public boolean isDisplay() {
78-
return display;
79-
}
76+
@Override
77+
public boolean isDisplay() {
78+
return display;
79+
}
8080
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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="user_ip_address_details")
30+
public class UserIpAddressDetailVO implements ResourceDetail{
31+
@Id
32+
@GeneratedValue(strategy= GenerationType.IDENTITY)
33+
@Column(name="id")
34+
private long id;
35+
36+
@Column(name="user_ip_address_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 UserIpAddressDetailVO() {}
49+
50+
public UserIpAddressDetailVO(long networkId, String name, String value) {
51+
this.resourceId = networkId;
52+
this.name = name;
53+
this.value = value;
54+
}
55+
56+
@Override
57+
public long getId() {
58+
return id;
59+
}
60+
61+
@Override
62+
public String getName() {
63+
return name;
64+
}
65+
66+
@Override
67+
public String getValue() {
68+
return value;
69+
}
70+
71+
@Override
72+
public long getResourceId() {
73+
return resourceId;
74+
}
75+
76+
@Override
77+
public boolean isDisplay() {
78+
return display;
79+
}
80+
}
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.UserIpAddressDetailVO;
21+
22+
import com.cloud.utils.db.GenericDao;
23+
24+
public interface UserIpAddressDetailsDao extends GenericDao<UserIpAddressDetailVO, Long>, ResourceDetailsDao<UserIpAddressDetailVO>{
25+
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.UserIpAddressDetailVO;
23+
import org.springframework.stereotype.Component;
24+
25+
26+
@Component
27+
@Local (value={UserIpAddressDetailsDao.class})
28+
public class UserIpAddressDetailsDaoImpl extends ResourceDetailsDaoBase<UserIpAddressDetailVO> implements UserIpAddressDetailsDao {
29+
30+
@Override
31+
public void addDetail(long resourceId, String key, String value) {
32+
super.addDetail(new UserIpAddressDetailVO(resourceId, key, value));
33+
}
34+
}
35+

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

Lines changed: 5 additions & 1 deletion
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.UserIpAddressDetailsDao;
3031
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3132
import org.apache.log4j.Logger;
3233
import org.springframework.stereotype.Component;
@@ -75,6 +76,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
7576
StoragePoolDetailsDao _storageDetailsDao;
7677
@Inject
7778
FirewallRuleDetailsDao _firewallRuleDetailsDao;
79+
@Inject
80+
UserIpAddressDetailsDao _userIpAddressDetailsDao;
7881

7982
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap=
8083
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
@@ -91,7 +94,8 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
9194
_daoMap.put(ResourceObjectType.Zone, _dcDetailsDao);
9295
_daoMap.put(ResourceObjectType.Storage, _storageDetailsDao);
9396
_daoMap.put(ResourceObjectType.FirewallRule, _firewallRuleDetailsDao);
94-
97+
_daoMap.put(ResourceObjectType.PublicIpAddress, _userIpAddressDetailsDao);
98+
9599
return true;
96100
}
97101

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,13 @@ CREATE TABLE `cloud`.`usage_event_details` (
619619
PRIMARY KEY (`id`),
620620
CONSTRAINT `fk_usage_event_details__usage_event_id` FOREIGN KEY `fk_usage_event_details__usage_event_id`(`usage_event_id`) REFERENCES `usage_event`(`id`) ON DELETE CASCADE
621621
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
622+
623+
CREATE TABLE `cloud`.`user_ip_address_details` (
624+
`id` bigint unsigned NOT NULL auto_increment,
625+
`user_ip_address_id` bigint unsigned NOT NULL COMMENT 'User ip address id',
626+
`name` varchar(255) NOT NULL,
627+
`value` varchar(1024) NOT NULL,
628+
`display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
629+
PRIMARY KEY (`id`),
630+
CONSTRAINT `fk_user_ip_address_details__user_ip_address_id` FOREIGN KEY `fk_user_ip_address_details__user_ip_address_id`(`user_ip_address_id`) REFERENCES `user_ip_address`(`id`) ON DELETE CASCADE
631+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

0 commit comments

Comments
 (0)