Skip to content

Commit da2b224

Browse files
committed
add/remove security group options to compute servers API
1 parent 0ed2eed commit da2b224

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/main/java/org/openstack4j/api/compute/ServerService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ public interface ServerService {
111111
*/
112112
String createSnapshot(String serverId, String snapshotName);
113113

114+
/**
115+
* Associates the specified Server Group by name to the Server by it's identifier
116+
*
117+
* @param serverId the server identifier
118+
* @param secGroupName the security group name
119+
* @return the action response
120+
*/
121+
ActionResponse addSecurityGroup(String serverId, String secGroupName);
122+
123+
/**
124+
* Removes the specified Server Group by name from the Server by it's identifier
125+
*
126+
* @param serverId the server identifier
127+
* @param secGroupName the security group name
128+
* @return the action response
129+
*/
130+
ActionResponse removeSecurityGroup(String serverId, String secGroupName);
131+
114132
/**
115133
* Gets usage information about the server. Usage includes CPU, Memory, IO. Information
116134
* is dependent on the hypervisor used by the OpenStack installation and whether that hypervisor

src/main/java/org/openstack4j/openstack/compute/internal/ServerServiceImpl.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ public ActionResponse resize(String serverId, String flavorId) {
139139
checkNotNull(flavorId);
140140
return invokeAction(serverId, "resize", String.format("{ \"flavorRef\": \"%s\" }", flavorId));
141141
}
142+
143+
/**
144+
* {@inheritDoc}
145+
*/
146+
@Override
147+
public ActionResponse addSecurityGroup(String serverId, String secGroupName) {
148+
checkNotNull(serverId);
149+
checkNotNull(secGroupName);
150+
return invokeAction(serverId, "addSecurityGroup", String.format("{ \"name\": \"%s\" }", secGroupName));
151+
}
152+
153+
/**
154+
* {@inheritDoc}
155+
*/
156+
@Override
157+
public ActionResponse removeSecurityGroup(String serverId, String secGroupName) {
158+
checkNotNull(serverId);
159+
checkNotNull(secGroupName);
160+
return invokeAction(serverId, "removeSecurityGroup", String.format("{ \"name\": \"%s\" }", secGroupName));
161+
}
142162

143163
/**
144164
* {@inheritDoc}

0 commit comments

Comments
 (0)