mirror of https://github.com/apache/jclouds.git
parent
d210baa962
commit
1137e552ae
|
@ -31,14 +31,11 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.openstack.nova.binders.BindBackupScheduleToJsonPayload;
|
||||
import org.jclouds.openstack.nova.domain.Addresses;
|
||||
import org.jclouds.openstack.nova.domain.BackupSchedule;
|
||||
import org.jclouds.openstack.nova.domain.Flavor;
|
||||
import org.jclouds.openstack.nova.domain.Image;
|
||||
import org.jclouds.openstack.nova.domain.RebootType;
|
||||
import org.jclouds.openstack.nova.domain.Server;
|
||||
import org.jclouds.openstack.nova.domain.SharedIpGroup;
|
||||
import org.jclouds.openstack.nova.options.CreateServerOptions;
|
||||
import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions;
|
||||
import org.jclouds.openstack.nova.options.ListOptions;
|
||||
|
@ -170,25 +167,6 @@ public interface NovaAsyncClient {
|
|||
@MapBinder(RebuildServerOptions.class)
|
||||
ListenableFuture<Void> rebuildServer(@PathParam("id") int id, RebuildServerOptions... options);
|
||||
|
||||
/**
|
||||
* @see NovaClient#shareIp
|
||||
*/
|
||||
@PUT
|
||||
@Path("/servers/{id}/ips/public/{address}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"shareIp\":%7B\"sharedIpGroupId\":{sharedIpGroupId},\"configureServer\":{configureServer}%7D%7D")
|
||||
ListenableFuture<Void> shareIp(@PathParam("address") String addressToShare,
|
||||
@PathParam("id") int serverToTosignBindressTo, @PayloadParam("sharedIpGroupId") int sharedIpGroup,
|
||||
@PayloadParam("configureServer") boolean configureServer);
|
||||
|
||||
/**
|
||||
* @see NovaClient#unshareIp
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/servers/{id}/ips/public/{address}")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> unshareIp(@PathParam("address") String addressToShare,
|
||||
@PathParam("id") int serverToTosignBindressTo);
|
||||
|
||||
/**
|
||||
* @see NovaClient#changeAdminPass
|
||||
|
@ -273,75 +251,6 @@ public interface NovaAsyncClient {
|
|||
ListenableFuture<Image> createImageFromServer(@PayloadParam("name") String imageName,
|
||||
@PayloadParam("serverId") int serverId);
|
||||
|
||||
/**
|
||||
* @see NovaClient#listSharedIpGroups
|
||||
*/
|
||||
@GET
|
||||
@Unwrap
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@QueryParams(keys = "format", values = "json")
|
||||
@Path("/shared_ip_groups")
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends Set<SharedIpGroup>> listSharedIpGroups(ListOptions... options);
|
||||
|
||||
/**
|
||||
* @see NovaClient#getSharedIpGroup
|
||||
*/
|
||||
@GET
|
||||
@Unwrap
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@QueryParams(keys = "format", values = "json")
|
||||
@Path("/shared_ip_groups/{id}")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<SharedIpGroup> getSharedIpGroup(@PathParam("id") int id);
|
||||
|
||||
/**
|
||||
* @see NovaClient#createSharedIpGroup
|
||||
*/
|
||||
@POST
|
||||
@Unwrap
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@QueryParams(keys = "format", values = "json")
|
||||
@Path("/shared_ip_groups")
|
||||
@MapBinder(CreateSharedIpGroupOptions.class)
|
||||
ListenableFuture<SharedIpGroup> createSharedIpGroup(@PayloadParam("name") String name,
|
||||
CreateSharedIpGroupOptions... options);
|
||||
|
||||
/**
|
||||
* @see NovaClient#deleteSharedIpGroup
|
||||
*/
|
||||
@DELETE
|
||||
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
|
||||
@Path("/shared_ip_groups/{id}")
|
||||
ListenableFuture<Boolean> deleteSharedIpGroup(@PathParam("id") int id);
|
||||
|
||||
/**
|
||||
* @see NovaClient#listBackupSchedule
|
||||
*/
|
||||
@GET
|
||||
@Unwrap
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@QueryParams(keys = "format", values = "json")
|
||||
@Path("/servers/{id}/backup_schedule")
|
||||
ListenableFuture<BackupSchedule> getBackupSchedule(@PathParam("id") int serverId);
|
||||
|
||||
/**
|
||||
* @see NovaClient#deleteBackupSchedule
|
||||
*/
|
||||
@DELETE
|
||||
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
|
||||
@Path("/servers/{id}/backup_schedule")
|
||||
ListenableFuture<Boolean> deleteBackupSchedule(@PathParam("id") int serverId);
|
||||
|
||||
/**
|
||||
* @see NovaClient#replaceBackupSchedule
|
||||
*/
|
||||
@POST
|
||||
@ExceptionParser(ReturnFalseOn404.class)
|
||||
@Path("/servers/{id}/backup_schedule")
|
||||
ListenableFuture<Void> replaceBackupSchedule(@PathParam("id") int id,
|
||||
@BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule);
|
||||
|
||||
/**
|
||||
* @see NovaClient#listAddresses
|
||||
*/
|
||||
|
|
|
@ -26,12 +26,10 @@ import javax.ws.rs.PathParam;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.openstack.nova.domain.Addresses;
|
||||
import org.jclouds.openstack.nova.domain.BackupSchedule;
|
||||
import org.jclouds.openstack.nova.domain.Flavor;
|
||||
import org.jclouds.openstack.nova.domain.Image;
|
||||
import org.jclouds.openstack.nova.domain.RebootType;
|
||||
import org.jclouds.openstack.nova.domain.Server;
|
||||
import org.jclouds.openstack.nova.domain.SharedIpGroup;
|
||||
import org.jclouds.openstack.nova.options.CreateServerOptions;
|
||||
import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions;
|
||||
import org.jclouds.openstack.nova.options.ListOptions;
|
||||
|
@ -173,40 +171,6 @@ public interface NovaClient {
|
|||
*/
|
||||
void rebuildServer(int id, RebuildServerOptions... options);
|
||||
|
||||
/**
|
||||
* /** This operation allows you share an IP address to the specified server
|
||||
* <p/>
|
||||
* This operation shares an IP from an existing server in the specified shared IP group to
|
||||
* another specified server in the same group. The operation modifies cloud network restrictions
|
||||
* to allow IP traffic for the given IP to/from the server specified.
|
||||
*
|
||||
* <p/>
|
||||
* Status Transition: ACTIVE - SHARE_IP - ACTIVE (if configureServer is true) ACTIVE -
|
||||
* SHARE_IP_NO_CONFIG - ACTIVE
|
||||
*
|
||||
* @param configureServer
|
||||
* <p/>
|
||||
* if set to true, the server is configured with the new address, though the address is
|
||||
* not enabled. Note that configuring the server does require a reboot.
|
||||
* <p/>
|
||||
* If set to false, does not bind the IP to the server itself. A heartbeat facility
|
||||
* (e.g. keepalived) can then be used within the servers to perform health checks and
|
||||
* manage IP failover.
|
||||
*/
|
||||
void shareIp(String addressToShare, int serverToTosignBindressTo, int sharedIpGroup,
|
||||
boolean configureServer);
|
||||
|
||||
/**
|
||||
* This operation removes a shared IP address from the specified server.
|
||||
* <p/>
|
||||
* Status Transition: ACTIVE - DELETE_IP - ACTIVE
|
||||
*
|
||||
* @param addressToShare
|
||||
* @param serverToTosignBindressTo
|
||||
* @return
|
||||
*/
|
||||
void unshareIp(String addressToShare, int serverToTosignBindressTo);
|
||||
|
||||
/**
|
||||
* This operation allows you to change the administrative password.
|
||||
* <p/>
|
||||
|
@ -295,66 +259,6 @@ public interface NovaClient {
|
|||
*/
|
||||
Image createImageFromServer(String imageName, int serverId);
|
||||
|
||||
/**
|
||||
*
|
||||
* List shared IP groups (IDs and names only)
|
||||
*
|
||||
* in order to retrieve all details, pass the option {@link ListOptions#withDetails()
|
||||
* withDetails()}
|
||||
*/
|
||||
Set<SharedIpGroup> listSharedIpGroups(ListOptions... options);
|
||||
|
||||
/**
|
||||
*
|
||||
* This operation returns details of the specified shared IP group.
|
||||
*
|
||||
* @return null, if the shared ip group is not found
|
||||
*
|
||||
* @see SharedIpGroup
|
||||
*/
|
||||
SharedIpGroup getSharedIpGroup(int id);
|
||||
|
||||
/**
|
||||
* This operation creates a new shared IP group. Please note, all responses to requests for
|
||||
* shared_ip_groups return an array of servers. However, on a create request, the shared IP group
|
||||
* can be created empty or can be initially populated with a single server. Use
|
||||
* {@link CreateSharedIpGroupOptions} to specify an server.
|
||||
*/
|
||||
SharedIpGroup createSharedIpGroup(String name, CreateSharedIpGroupOptions... options);
|
||||
|
||||
/**
|
||||
* This operation deletes the specified shared IP group. This operation will ONLY succeed if 1)
|
||||
* there are no active servers in the group (i.e. they have all been terminated) or 2) no servers
|
||||
* in the group are actively sharing IPs.
|
||||
*
|
||||
* @return false if the shared ip group is not found
|
||||
* @see SharedIpGroup
|
||||
*/
|
||||
boolean deleteSharedIpGroup(int id);
|
||||
|
||||
/**
|
||||
* List the backup schedule for the specified server
|
||||
*
|
||||
* @throws ResourceNotFoundException
|
||||
* , if the server doesn't exist
|
||||
*/
|
||||
BackupSchedule getBackupSchedule(int serverId);
|
||||
|
||||
/**
|
||||
* Delete backup schedule for the specified server.
|
||||
* <p/>
|
||||
* Web Hosting #119571 currently disables the schedule, not deletes it.
|
||||
*
|
||||
* @return false if the schedule is not found
|
||||
*/
|
||||
boolean deleteBackupSchedule(int serverId);
|
||||
|
||||
/**
|
||||
* Enable/update the backup schedule for the specified server
|
||||
*
|
||||
*/
|
||||
void replaceBackupSchedule(int id, BackupSchedule backupSchedule);
|
||||
|
||||
/**
|
||||
* List all server addresses
|
||||
*
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.openstack.nova.domain.BackupSchedule;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class BindBackupScheduleToJsonPayload extends BindToJsonPayload {
|
||||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
|
||||
throw new IllegalStateException(
|
||||
"Replace Backup Schedule needs an BackupSchedule object, not a Map");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
|
||||
checkArgument(toBind instanceof BackupSchedule,
|
||||
"this binder is only valid for BackupSchedules!");
|
||||
return super.bindToRequest(request, ImmutableMap.of("backupSchedule", toBind));
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
/**
|
||||
* A backup schedule can be defined to create server images at regular intervals (daily and weekly).
|
||||
* Backup schedules are configurable per server.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BackupSchedule {
|
||||
protected DailyBackup daily = DailyBackup.DISABLED;
|
||||
protected boolean enabled;
|
||||
protected WeeklyBackup weekly = WeeklyBackup.DISABLED;
|
||||
|
||||
public BackupSchedule() {
|
||||
}
|
||||
|
||||
public BackupSchedule(WeeklyBackup weekly, DailyBackup daily, boolean enabled) {
|
||||
this.weekly = weekly;
|
||||
this.daily = daily;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public DailyBackup getDaily() {
|
||||
return daily;
|
||||
}
|
||||
|
||||
public void setDaily(DailyBackup value) {
|
||||
this.daily = value;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean value) {
|
||||
this.enabled = value;
|
||||
}
|
||||
|
||||
public WeeklyBackup getWeekly() {
|
||||
return weekly;
|
||||
}
|
||||
|
||||
public void setWeekly(WeeklyBackup value) {
|
||||
this.weekly = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[daily=" + daily + ", enabled=" + enabled + ", weekly=" + weekly + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((daily == null) ? 0 : daily.hashCode());
|
||||
result = prime * result + (enabled ? 1231 : 1237);
|
||||
result = prime * result + ((weekly == null) ? 0 : weekly.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BackupSchedule other = (BackupSchedule) obj;
|
||||
if (daily == null) {
|
||||
if (other.daily != null)
|
||||
return false;
|
||||
} else if (!daily.equals(other.daily))
|
||||
return false;
|
||||
if (enabled != other.enabled)
|
||||
return false;
|
||||
if (weekly == null) {
|
||||
if (other.weekly != null)
|
||||
return false;
|
||||
} else if (!weekly.equals(other.weekly))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
public enum DailyBackup {
|
||||
|
||||
DISABLED, H_0000_0200, H_0200_0400, H_0400_0600, H_0600_0800, H_0800_1000, H_1000_1200, H_1200_1400, H_1400_1600, H_1600_1800, H_1800_2000, H_2000_2200, H_2200_0000, UNRECOGNIZED;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static DailyBackup fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
public class ShareIp {
|
||||
|
||||
private boolean configureServer;
|
||||
private int sharedIpGroupId;
|
||||
|
||||
public void setConfigureServer(boolean configureServer) {
|
||||
this.configureServer = configureServer;
|
||||
}
|
||||
|
||||
public boolean isConfigureServer() {
|
||||
return configureServer;
|
||||
}
|
||||
|
||||
public void setSharedIpGroupId(int sharedIpGroupId) {
|
||||
this.sharedIpGroupId = sharedIpGroupId;
|
||||
}
|
||||
|
||||
public int getSharedIpGroupId() {
|
||||
return sharedIpGroupId;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* A shared IP group is a collection of servers that can share IPs with other members of the group.
|
||||
* Any server in a group can share one or more public IPs with any other server in the group. With
|
||||
* the exception of the first server in a shared IP group, servers must be launched into shared IP
|
||||
* groups. A server may only be a member of one shared IP group.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SharedIpGroup {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
private List<Integer> servers = Lists.newArrayList();
|
||||
|
||||
public SharedIpGroup() {
|
||||
}
|
||||
|
||||
public SharedIpGroup(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setServers(List<Integer> servers) {
|
||||
this.servers = servers;
|
||||
}
|
||||
|
||||
public List<Integer> getServers() {
|
||||
return servers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + id;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((servers == null) ? 0 : servers.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SharedIpGroup other = (SharedIpGroup) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (servers == null) {
|
||||
if (other.servers != null)
|
||||
return false;
|
||||
} else if (!servers.equals(other.servers))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SharedIpGroup [id=" + id + ", name=" + name + ", servers=" + servers + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
public class Version {
|
||||
|
||||
private String docURL;
|
||||
private String id = "v1.0";
|
||||
private VersionStatus status;
|
||||
private String wadl;
|
||||
|
||||
public void setDocURL(String docURL) {
|
||||
this.docURL = docURL;
|
||||
}
|
||||
|
||||
public String getDocURL() {
|
||||
return docURL;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setStatus(VersionStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public VersionStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setWadl(String wadl) {
|
||||
this.wadl = wadl;
|
||||
}
|
||||
|
||||
public String getWadl() {
|
||||
return wadl;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
public enum VersionStatus {
|
||||
|
||||
BETA, CURRENT, DEPRECATED, UNRECOGNIZED;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static VersionStatus fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.domain;
|
||||
|
||||
public enum WeeklyBackup {
|
||||
|
||||
DISABLED, SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, UNRECOGNIZED;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static WeeklyBackup fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -32,10 +32,7 @@ import org.jclouds.openstack.TestOpenStackAuthenticationModule;
|
|||
import org.jclouds.openstack.filters.AddTimestampQuery;
|
||||
import org.jclouds.openstack.filters.AuthenticateRequest;
|
||||
import org.jclouds.openstack.nova.config.NovaRestClientModule;
|
||||
import org.jclouds.openstack.nova.domain.BackupSchedule;
|
||||
import org.jclouds.openstack.nova.domain.DailyBackup;
|
||||
import org.jclouds.openstack.nova.domain.RebootType;
|
||||
import org.jclouds.openstack.nova.domain.WeeklyBackup;
|
||||
import org.jclouds.openstack.nova.options.CreateServerOptions;
|
||||
import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions;
|
||||
import org.jclouds.openstack.nova.options.ListOptions;
|
||||
|
@ -96,25 +93,6 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, withSharedIpGroup(2));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request,
|
||||
"{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2}}",
|
||||
"application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
|
@ -158,27 +136,6 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
public void testCreateServerWithIpGroupAndSharedIp() throws IOException, SecurityException, NoSuchMethodException,
|
||||
UnknownHostException {
|
||||
Method method = NovaAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1,
|
||||
withSharedIpGroup(2).withSharedIp("127.0.0.1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2,\"addresses\":{\"public\":[\"127.0.0.1\"]}}}",
|
||||
"application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("deleteImage", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
|
@ -426,94 +383,6 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
|
||||
Method method = NovaAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class,
|
||||
boolean.class);
|
||||
HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false);
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2/ips/public/127.0.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":false}}",
|
||||
MediaType.APPLICATION_JSON, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
|
||||
}
|
||||
|
||||
public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
|
||||
Method method = NovaAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class,
|
||||
boolean.class);
|
||||
HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, true);
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2/ips/public/127.0.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":true}}",
|
||||
MediaType.APPLICATION_JSON, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
|
||||
}
|
||||
|
||||
public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException,
|
||||
UnknownHostException {
|
||||
Method method = NovaAsyncClient.class.getMethod("unshareIp", String.class, int.class);
|
||||
HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false);
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2/ips/public/127.0.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
||||
}
|
||||
|
||||
public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, new BackupSchedule(WeeklyBackup.MONDAY,
|
||||
DailyBackup.H_0800_1000, true));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/backup_schedule HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request,
|
||||
"{\"backupSchedule\":{\"daily\":\"H_0800_1000\",\"enabled\":true,\"weekly\":\"MONDAY\"}}",
|
||||
MediaType.APPLICATION_JSON, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnFalseOn404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
||||
}
|
||||
|
||||
public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("deleteBackupSchedule", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/servers/2/backup_schedule HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, null, MediaType.APPLICATION_JSON, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
||||
}
|
||||
|
||||
public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("changeAdminPass", int.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, "foo");
|
||||
|
@ -546,135 +415,6 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/shared_ip_groups?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://endpoint/vapiversion/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/shared_ip_groups/detail?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://endpoint/vapiversion/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("getSharedIpGroup", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
|
||||
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/shared_ip_groups/2?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
private static final Class<? extends CreateSharedIpGroupOptions[]> createSharedIpGroupOptionsVarargsClass = new CreateSharedIpGroupOptions[]{}
|
||||
.getClass();
|
||||
|
||||
public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("createSharedIpGroup", String.class,
|
||||
createSharedIpGroupOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie");
|
||||
|
||||
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/shared_ip_groups?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
|
||||
}
|
||||
|
||||
public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("createSharedIpGroup", String.class,
|
||||
createSharedIpGroupOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", withServer(2));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://endpoint/vapiversion/shared_ip_groups?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\",\"server\":2}}",
|
||||
MediaType.APPLICATION_JSON, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("deleteSharedIpGroup", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/shared_ip_groups/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("getAddresses", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
|
@ -721,22 +461,6 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("getBackupSchedule", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
|
||||
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/2/backup_schedule?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = NovaAsyncClient.class.getMethod("createImageFromServer", String.class, int.class);
|
||||
|
|
|
@ -260,68 +260,6 @@ public class NovaClientLiveTest {
|
|||
assert client.getFlavor(12312987) == null;
|
||||
}
|
||||
|
||||
public void testListSharedIpGroups() throws Exception {
|
||||
Set<SharedIpGroup> response = client.listSharedIpGroups();
|
||||
assert null != response;
|
||||
long sharedIpGroupCount = response.size();
|
||||
assertTrue(sharedIpGroupCount >= 0);
|
||||
for (SharedIpGroup sharedIpGroup : response) {
|
||||
assertTrue(sharedIpGroup.getId() >= 0);
|
||||
assert null != sharedIpGroup.getName() : sharedIpGroup;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testListSharedIpGroupsDetail() throws Exception {
|
||||
Set<SharedIpGroup> response = client.listSharedIpGroups(withDetails());
|
||||
assert null != response;
|
||||
long sharedIpGroupCount = response.size();
|
||||
assertTrue(sharedIpGroupCount >= 0);
|
||||
for (SharedIpGroup sharedIpGroup : response) {
|
||||
assertTrue(sharedIpGroup.getId() >= 1);
|
||||
assert null != sharedIpGroup.getName() : sharedIpGroup;
|
||||
assert null != sharedIpGroup.getServers() : sharedIpGroup;
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetSharedIpGroupsDetail() throws Exception {
|
||||
Set<SharedIpGroup> response = client.listSharedIpGroups(withDetails());
|
||||
assert null != response;
|
||||
long sharedIpGroupCount = response.size();
|
||||
assertTrue(sharedIpGroupCount >= 0);
|
||||
for (SharedIpGroup sharedIpGroup : response) {
|
||||
SharedIpGroup newDetails = client.getSharedIpGroup(sharedIpGroup.getId());
|
||||
assertEquals(sharedIpGroup, newDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSharedIpGroupDetailsNotFound() throws Exception {
|
||||
assert client.getSharedIpGroup(12312987) == null;
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
|
||||
public void testCreateSharedIpGroup() throws Exception {
|
||||
SharedIpGroup sharedIpGroup = null;
|
||||
while (sharedIpGroup == null) {
|
||||
String sharedIpGroupName = serverPrefix + "createSharedIpGroup" + new SecureRandom().nextInt();
|
||||
try {
|
||||
sharedIpGroup = client.createSharedIpGroup(sharedIpGroupName, withServer(serverId));
|
||||
} catch (UndeclaredThrowableException e) {
|
||||
HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
|
||||
if (htpe.getResponse().getStatusCode() == 400)
|
||||
continue;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
assertNotNull(sharedIpGroup.getName());
|
||||
sharedIpGroupId = sharedIpGroup.getId();
|
||||
// Response doesn't include the server id Web Hosting #119311
|
||||
// assertEquals(sharedIpGroup.getServers(), ImmutableList.of(serverId));
|
||||
}
|
||||
|
||||
private int sharedIpGroupId;
|
||||
|
||||
private String serverPrefix = System.getProperty("user.name") + ".cs";
|
||||
private int serverId;
|
||||
private String adminPass;
|
||||
|
@ -468,33 +406,6 @@ public class NovaClientLiveTest {
|
|||
this.adminPass = "elmo";
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateSharedIpGroup")
|
||||
public void testCreateServerIp() throws Exception {
|
||||
int imageId = 14362;
|
||||
int flavorId = 1;
|
||||
Server server = null;
|
||||
while (server == null) {
|
||||
String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
|
||||
try {
|
||||
server = client
|
||||
.createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt", "rackspace".getBytes())
|
||||
.withMetadata(metadata).withSharedIpGroup(sharedIpGroupId).withSharedIp(ip));
|
||||
} catch (UndeclaredThrowableException e) {
|
||||
HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
|
||||
if (htpe.getResponse().getStatusCode() == 400)
|
||||
continue;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
assertNotNull(server.getAdminPass());
|
||||
serverId2 = server.getId();
|
||||
adminPass2 = server.getAdminPass();
|
||||
blockUntilServerActive(serverId2);
|
||||
assertIpConfigured(server, adminPass2);
|
||||
assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses() + " doesn't contain " + ip;
|
||||
assertEquals(server.getSharedIpGroupId(), new Integer(sharedIpGroupId));
|
||||
}
|
||||
|
||||
private void assertIpConfigured(Server server, String password) {
|
||||
try {
|
||||
ExecResponse response = exec(server, password, "ifconfig -a");
|
||||
|
@ -507,15 +418,6 @@ public class NovaClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateServerIp")
|
||||
public void testUnshare() throws Exception {
|
||||
client.unshareIp(ip, serverId2);
|
||||
blockUntilServerActive(serverId2);
|
||||
Server server = client.getServer(serverId2);
|
||||
assert !server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
|
||||
assertIpNotConfigured(server, adminPass2);
|
||||
}
|
||||
|
||||
private void assertIpNotConfigured(Server server, String password) {
|
||||
try {
|
||||
ExecResponse response = exec(server, password, "ifconfig -a");
|
||||
|
@ -528,39 +430,6 @@ public class NovaClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testUnshare")
|
||||
public void testShareConfig() throws Exception {
|
||||
client.shareIp(ip, serverId2, sharedIpGroupId, true);
|
||||
blockUntilServerActive(serverId2);
|
||||
Server server = client.getServer(serverId2);
|
||||
assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
|
||||
assertIpConfigured(server, adminPass2);
|
||||
testUnshare();
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testShareConfig")
|
||||
public void testShareNoConfig() throws Exception {
|
||||
client.shareIp(ip, serverId2, sharedIpGroupId, false);
|
||||
blockUntilServerActive(serverId2);
|
||||
Server server = client.getServer(serverId2);
|
||||
assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
|
||||
assertIpNotConfigured(server, adminPass2);
|
||||
testUnshare();
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testShareNoConfig")
|
||||
public void testBackup() throws Exception {
|
||||
assertEquals(new BackupSchedule(), client.getBackupSchedule(serverId));
|
||||
BackupSchedule dailyWeekly = new BackupSchedule();
|
||||
dailyWeekly.setEnabled(true);
|
||||
dailyWeekly.setWeekly(WeeklyBackup.FRIDAY);
|
||||
dailyWeekly.setDaily(DailyBackup.H_0400_0600);
|
||||
client.replaceBackupSchedule(serverId, dailyWeekly);
|
||||
client.deleteBackupSchedule(serverId);
|
||||
// disables, doesn't delete: Web Hosting #119571
|
||||
assertEquals(client.getBackupSchedule(serverId).isEnabled(), false);
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = "testBackup")
|
||||
public void testCreateImage() throws Exception {
|
||||
Image image = client.createImageFromServer("hoofie", serverId);
|
||||
|
@ -633,14 +502,6 @@ public class NovaClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(enabled = false, timeOut = 10 * 60 * 1000, dependsOnMethods = {"deleteServer1"})
|
||||
void testDeleteSharedIpGroup() {
|
||||
if (sharedIpGroupId > 0) {
|
||||
client.deleteSharedIpGroup(sharedIpGroupId);
|
||||
assert client.getSharedIpGroup(sharedIpGroupId) == null;
|
||||
}
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
void deleteServersOnEnd() {
|
||||
if (serverId > 0) {
|
||||
|
@ -649,8 +510,5 @@ public class NovaClientLiveTest {
|
|||
if (serverId2 > 0) {
|
||||
client.deleteServer(serverId2);
|
||||
}
|
||||
if (sharedIpGroupId > 0) {
|
||||
client.deleteSharedIpGroup(sharedIpGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.openstack.nova.domain.BackupSchedule;
|
||||
import org.jclouds.openstack.nova.domain.DailyBackup;
|
||||
import org.jclouds.openstack.nova.domain.WeeklyBackup;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ParseBackupScheduleFromJsonResponse}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ParseBackupScheduleFromJsonResponseTest {
|
||||
Injector i = Guice.createInjector(new GsonModule());
|
||||
|
||||
public void testApplyInputStreamDetails() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/test_list_backupschedule.json");
|
||||
|
||||
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
|
||||
}));
|
||||
BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
assertEquals(new BackupSchedule(WeeklyBackup.THURSDAY, DailyBackup.H_0400_0600, true), response);
|
||||
}
|
||||
|
||||
public void testNoSchedule() throws UnknownHostException {
|
||||
|
||||
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
|
||||
}));
|
||||
BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads
|
||||
.newStringPayload("{\"backupSchedule\":{\"enabled\" : false}}")));
|
||||
assertEquals(new BackupSchedule(), response);
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.openstack.nova.domain.SharedIpGroup;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ParseSharedIpGroupFromJsonResponse}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ParseSharedIpGroupFromJsonResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule());
|
||||
|
||||
public void testApplyInputStreamDetails() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/test_get_sharedipgroup_details.json");
|
||||
|
||||
UnwrapOnlyJsonValue<SharedIpGroup> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<SharedIpGroup>>() {
|
||||
}));
|
||||
SharedIpGroup response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(response.getId(), 1234);
|
||||
assertEquals(response.getName(), "Shared IP Group 1");
|
||||
assertEquals(response.getServers(), ImmutableList.of(422));
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.openstack.nova.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.openstack.nova.domain.SharedIpGroup;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ParseSharedIpGroupListFromJsonResponse}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ParseSharedIpGroupListFromJsonResponseTest {
|
||||
|
||||
Injector i = Guice.createInjector(new GsonModule());
|
||||
|
||||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/test_list_sharedipgroups.json");
|
||||
|
||||
List<SharedIpGroup> expects = ImmutableList.of(new SharedIpGroup(1234, "Shared IP Group 1"), new SharedIpGroup(
|
||||
5678, "Shared IP Group 2"));
|
||||
|
||||
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
|
||||
}));
|
||||
List<SharedIpGroup> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(response, expects);
|
||||
|
||||
}
|
||||
|
||||
public void testApplyInputStreamDetails() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/test_list_sharedipgroups_detail.json");
|
||||
|
||||
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
|
||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
|
||||
}));
|
||||
List<SharedIpGroup> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||
|
||||
assertEquals(response.get(0).getId(), 1234);
|
||||
assertEquals(response.get(0).getName(), "Shared IP Group 1");
|
||||
assertEquals(response.get(0).getServers(), ImmutableList.of(422, 3445));
|
||||
|
||||
assertEquals(response.get(1).getId(), 5678);
|
||||
assertEquals(response.get(1).getName(), "Shared IP Group 2");
|
||||
assertEquals(response.get(1).getServers(), ImmutableList.of(23203, 2456, 9891));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"sharedIpGroup" : {
|
||||
"id" : 1234,
|
||||
"name" : "Shared IP Group 1",
|
||||
"servers" : [422]
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"backupSchedule" : {
|
||||
"enabled" : true,
|
||||
"weekly" : "THURSDAY",
|
||||
"daily" : "H_0400_0600"
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"sharedIpGroups" : [
|
||||
{
|
||||
"id" : 1234,
|
||||
"name" : "Shared IP Group 1"
|
||||
},
|
||||
{
|
||||
"id" : 5678,
|
||||
"name" : "Shared IP Group 2"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"sharedIpGroups" : [
|
||||
{
|
||||
"id" : 1234,
|
||||
"name" : "Shared IP Group 1",
|
||||
"servers" : [422, 3445]
|
||||
},
|
||||
{
|
||||
"id" : 5678,
|
||||
"name" : "Shared IP Group 2",
|
||||
"servers" : [23203, 2456, 9891]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue