Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public List list(boolean detail) {
public class List extends OpenStackRequest<Extensions> {

public List(boolean detail) {
super(CLIENT, HttpMethod.GET, detail ? "extensions/detail" : "extensions", null, Extensions.class);
super(CLIENT, HttpMethod.GET, detail ? "/extensions/detail" : "/extensions", null, Extensions.class);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,33 @@ public ListVolumeAttachments listVolumeAttachments(String serverId) {
public ShowVolumeAttachment showVolumeAttachment(String serverId, String volumeAttachmentId) {
return new ShowVolumeAttachment(serverId, volumeAttachmentId);
}

public class AddSecurityGroup extends OpenStackRequest<Void> {

public AddSecurityGroup(String id, com.woorea.openstack.nova.model.ServerAction.AddSecurityGroup action) {
super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class);
}

}

public class RemoveSecurityGroup extends OpenStackRequest<Void> {

public RemoveSecurityGroup(String id, com.woorea.openstack.nova.model.ServerAction.RemoveSecurityGroup action) {
super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class);
}

}

public AddSecurityGroup addSecurityGroup(String serverId, String securityGroupName) {
com.woorea.openstack.nova.model.ServerAction.AddSecurityGroup securityGroupAddAction = new com.woorea.openstack.nova.model.ServerAction.AddSecurityGroup(securityGroupName);
return new AddSecurityGroup(serverId, securityGroupAddAction);
}

public RemoveSecurityGroup removeSecurityGroup(String serverId, String securityGroupName) {
com.woorea.openstack.nova.model.ServerAction.RemoveSecurityGroup securityGroupRemoveAction = new com.woorea.openstack.nova.model.ServerAction.RemoveSecurityGroup(securityGroupName);
return new RemoveSecurityGroup(serverId, securityGroupRemoveAction);
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public class NetworkForCreate {
private String id;
@JsonProperty("fixed_ip")
private String fixedIp;
@JsonProperty("port")
private String portId;


public String getId() {
return id;
Expand All @@ -26,4 +29,14 @@ public void setFixedIp(String fixedIp) {
this.fixedIp = fixedIp;
}

public String getPortId() {
return portId;
}

public void setPortId(String portId) {
this.portId = portId;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,69 @@ public void setMetadata(Map<String, String> metadata) {

}

@JsonRootName("addSecurityGroup")
public static final class AddSecurityGroup implements ServerAction {

private String name;

public AddSecurityGroup() {
super();
// TODO Auto-generated constructor stub
}

public AddSecurityGroup(String securityGroupName) {
super();
this.name = securityGroupName;
}



/**
* @return the security group name
*/
public String getName() {
return name;
}

/**
* @param name the security group name to set
*/
public void setName(String name) {
this.name = name;
}

}

@JsonRootName("removeSecurityGroup")
public static final class RemoveSecurityGroup implements ServerAction {

private String name;

public RemoveSecurityGroup() {
super();
}

public RemoveSecurityGroup(String securityGroupName) {
super();
this.name = securityGroupName;
}



/**
* @return the security group name
*/
public String getName() {
return name;
}

/**
* @param name the security group name to set
*/
public void setName(String name) {
this.name = name;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,49 @@ public void setName(String name) {
this.name = name;
}

}

public static final class BlockDeviceMapping implements Serializable {

@JsonProperty("device_name")
private String deviceName;

@JsonProperty("volume_id")
private String volumeId;

@JsonProperty("delete_on_termination")
private boolean deleteOnTermination;

public BlockDeviceMapping() {
}

public String getDeviceName() {
return deviceName;
}

public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}

public String getVolumeId() {
return volumeId;
}

public void setVolumeId(String volumeId) {
this.volumeId = volumeId;
}

public boolean isDeleteOnTermination() {
return deleteOnTermination;
}

public void setDeleteOnTermination(boolean deleteOnTermination) {
this.deleteOnTermination = deleteOnTermination;
}




}

private String name;
Expand All @@ -52,8 +95,10 @@ public void setName(String name) {

private String accessIPv6;

@JsonProperty("min_count")
private Integer min;

@JsonProperty("max_count")
private Integer max;

private String diskConfig;
Expand All @@ -79,6 +124,9 @@ public void setName(String name) {

@JsonProperty("networks")
private List<NetworkForCreate> networks = new ArrayList<NetworkForCreate>();

@JsonProperty("block_device_mapping")
private List<BlockDeviceMapping> blockDeviceMappings;

/**
* @return the name
Expand Down Expand Up @@ -316,11 +364,21 @@ public void setNetworks(List<NetworkForCreate> networks) {
this.networks = networks;
}


public void addNetworks(String id, String fixedIp) {
NetworkForCreate net = new NetworkForCreate();
net.setId(id);
net.setFixedIp(fixedIp);
this.networks.add(net);
}

public List<BlockDeviceMapping> getBlockDeviceMappings() {
return blockDeviceMappings;
}

public void setBlockDeviceMappings(List<BlockDeviceMapping> blockDeviceMappings) {
this.blockDeviceMappings = blockDeviceMappings;
}


}