Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Image execute() {
}

public class Upload extends OpenStackRequest<Image> {

l
public Upload(String id, ImageUpload imageUpload) {
super(CLIENT, HttpMethod.PUT, new StringBuilder("/images/").append(id).toString(),
Entity.stream(imageUpload.getInputStream()), Image.class);
Expand Down Expand Up @@ -206,6 +206,7 @@ public static Map<String, String> compose(Image image) {
headers.put("X-Image-Meta-Checksum", image.getChecksum());
headers.put("X-Image-Meta-Is_public", String.valueOf(image.isPublic()));
headers.put("X-Image-Meta-Owner", image.getOwner());
headers.put("X-Image-Meta-Location", image.getLocation());

for(String key : image.getProperties().keySet()) {
image.getProperties().put("x-image-meta-property-" + key, image.getProperties().get(key));
Expand Down Expand Up @@ -233,6 +234,8 @@ public static Image parse(Map<String, String> headers) {
image.setMinRam(asInteger(headers.get("X-Image-Meta-Min_ram")));
image.setMinDisk(asInteger(headers.get("X-Image-Meta-Min_disk")));
image.setOwner(headers.get("X-Image-Meta-Owner"));
//setting this location option will not copy the image to glance store
image.setLocation(headers.get("X-Image-Meta-Location"));
for(String key : headers.keySet()) {
if(key.startsWith("x-image-meta-property-")) {
image.getProperties().put(key.substring(22), headers.get(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Image implements Serializable {

private String name;


@JsonProperty("disk_format")
private String diskFormat;

Expand Down Expand Up @@ -55,6 +56,18 @@ public class Image implements Serializable {
@JsonProperty("protected")
private boolean isProtected;

@JsonProperty("location")
private String location;


public String getLocation() {
return location;
}

public void setLocation(String location) {
this.location = location;
}

private Map<String, Object> properties;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,51 @@ public ListVolumeAttachments listVolumeAttachments(String serverId) {
public ShowVolumeAttachment showVolumeAttachment(String serverId, String volumeAttachmentId) {
return new ShowVolumeAttachment(serverId, volumeAttachmentId);
}
public Diagnostics getServerDiagnostics(String id) {
return new Diagnostics(id);
}

public class Diagnostics extends OpenStackRequest<ServerDiagnostics> {

public Diagnostics(String id) {

super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/")
.append(id).append("/diagnostics"), null,
ServerDiagnostics.class);
}

}

public LiveMigration liveMigration(LiveMigrationSet liveMigrationSet) {
return new LiveMigration(liveMigrationSet);
}

public GetServerForMigration getServerForMigration(
LiveMigrationSet liveMigrationSet) {
return new GetServerForMigration(liveMigrationSet);
}

public class GetServerForMigration extends OpenStackRequest<Server> {

public GetServerForMigration(LiveMigrationSet liveMigrationSet) {

super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/")
.append(liveMigrationSet.getServerId()), null, Server.class);

}

}

public class LiveMigration extends OpenStackRequest<Void> {
LiveMigration(LiveMigrationSet liveMigrationSet) {
super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/")
.append(liveMigrationSet.getServerId()).append("/action"),
Entity.json(liveMigrationSet), Void.class);

}

}


}

Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,18 @@ public Delete(String id) {
}

}
public QuotaDefaults getquotaDefaults(String id) {
return new QuotaDefaults(id);
}
public class QuotaDefaults extends OpenStackRequest<VolumeQuotaDefaults> {

public QuotaDefaults(String id) {

super(CLIENT, HttpMethod.GET, new StringBuilder("/os-quota-sets/")
.append(id).append("/defaults"), null,
VolumeQuotaDefaults.class);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.woorea.openstack.nova.model;

import java.io.Serializable;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;

@JsonRootName("os-migrateLive")
public class LiveMigrationSet implements Serializable {
@JsonIgnore
String serverId;
@JsonProperty("host")
String hostName;
@JsonProperty("block_migration")
boolean blockMigration;
@JsonProperty("disk_over_commit")
boolean diskOverCommit;

public boolean isBlockMigration() {
return blockMigration;
}

public void setBlockMigration(boolean blockMigration) {
this.blockMigration = blockMigration;
}

public boolean isDiskOverCommit() {
return diskOverCommit;
}

public void setDiskOverCommit(boolean diskOverCommit) {
this.diskOverCommit = diskOverCommit;
}

public String getServerId() {
return serverId;
}

public void setServerId(String serverId) {
this.serverId = serverId;
}

public String getHostName() {
return hostName;
}

public void setHostName(String hostName) {
this.hostName = hostName;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.woorea.openstack.nova.model;

import java.io.Serializable;

import org.codehaus.jackson.annotate.JsonProperty;

public class ServerDiagnostics implements Serializable {
@JsonProperty("memory")
String memory;
@JsonProperty("cpu0_time")
String cpu0_time;
@JsonProperty("vda_read")
String vda_read;
@JsonProperty("vda_write")
String vda_write;
@JsonProperty("vda_write_req")
String vda_write_req;
@JsonProperty("tap7baaefe5-d7_rx_packets")
String t1;
@JsonProperty("tap7baaefe5-d7_rx")
String tap1;
@JsonProperty("tap7baaefe5-d7_rx_drop")
String drop1;
@JsonProperty("tap7baaefe5-d7_tx")
String d7_tx;
@JsonProperty("tap7baaefe5-d7_tx_drop")
String d7_tx_drop;
@JsonProperty("tap7baaefe5-d7_rx_errors")
String rx_errors;
@JsonProperty("memory-actual")
String actual;
@JsonProperty("memory-rss")
String rss;
@JsonProperty("tap7baaefe5-d7_tx_packets")
String d7_tx_packets;
@JsonProperty("vda_read_req")
String vda_read_req;
@JsonProperty("vda_errors")
String vda_errors;
@JsonProperty("tap7baaefe5-d7_tx_errors")
String d7_tx_errors;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.woorea.openstack.nova.model;

import java.io.Serializable;

import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;

@JsonRootName("quota_set")
public class VolumeQuotaDefaults implements Serializable {
@JsonProperty("gigabytes")
String gigabytes;
@JsonProperty("volumes")
String volumes;
@JsonProperty("id")
String id;
@JsonProperty("snapshots")
String snapshots;

public String getGigabytes() {
return gigabytes;
}

public void setGigabytes(String gigabytes) {
this.gigabytes = gigabytes;
}

public String getVolumes() {
return volumes;
}

public void setVolumes(String volumes) {
this.volumes = volumes;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getSnapshots() {
return snapshots;
}

public void setSnapshots(String snapshots) {
this.snapshots = snapshots;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ExamplesConfiguration {

public static final String CEILOMETER_ENDPOINT = "";

public static final String CINDER_ENDPOINT ="http://volume/v1";

public static void main(String[] args) {
Keystone client = new Keystone(KEYSTONE_ENDPOINT);
client.setTokenProvider(new OpenStackSimpleTokenProvider("secret0"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
public class LiveMigrationExample {

public Access authenticate(String tenantId) {
Keystone keystone = new Keystone(
ExamplesConfiguration.KEYSTONE_AUTH_URL);
// access with unscoped token
Access access = keystone
.tokens()
.authenticate(
new UsernamePassword(
ExamplesConfiguration.KEYSTONE_USERNAME,
ExamplesConfiguration.KEYSTONE_PASSWORD))
.withTenantId(tenantId).execute();
// authorization
access = keystone
.tokens()
.authenticate(
new TokenAuthentication(access.getToken().getId()))
.withTenantId(tenantId).execute();
System.out.println("token" + access.getToken());
return access;
}
public void liveMigration(Access access, String tenantId) {
System.out.println("in livemigration");
Nova nova = new Nova(
ExamplesConfiguration.NOVA_ENDPOINT.concat(tenantId));

nova.setTokenProvider(new OpenStackSimpleTokenProvider(access
.getToken().getId()));
LiveMigrationSet liveMigrationSet = new LiveMigrationSet();
//provide hostname of the compute node to wich you want to migrate
liveMigrationSet.setHostName("hostnname");
//server id of the server , wich you want to migrate
liveMigrationSet.setServerId("serverId");
nova.servers().getServerForMigration(liveMigrationSet).execute();
nova.servers().liveMigration(liveMigrationSet).execute();

}

public static void main(String[] args) {
// TODO Auto-generated method stub
LiveMigrationExample example = new LiveMigrationExample();
//provide tenant id to authenticate and server id to migrate
Access access = example
.authenticate("tenantId");
example.liveMigration(access, "serverId");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ public Detach(RouterForAddInterface interfaceToAdd) {
}

}
public SetExternalGateway setExternalGateway(ExternalGatewayForCreate externalGatewayForCreate) {
return new SetExternalGateway(externalGatewayForCreate);
}

public class SetExternalGateway extends OpenStackRequest<RouterExternalGateway> {

public SetExternalGateway(ExternalGatewayForCreate externalGatewayForCreate) {
super(CLIENT, HttpMethod.PUT, buildPath("routers/",
externalGatewayForCreate.getRouterId()),
Entity.json(externalGatewayForCreate), RouterExternalGateway.class);
}

}



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.woorea.openstack.quantum.model;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;

@JsonRootName("router")
public class ExternalGatewayForCreate implements Serializable {
@JsonProperty("external_gateway_info")
private Map<String, String> external_gateway_info;

@JsonIgnore
String routerId;

public Map<String, String> getExternal_gateway_info() {
return external_gateway_info;
}

public void setExternal_gateway_info(
Map<String, String> external_gateway_info) {
this.external_gateway_info = external_gateway_info;
}

public String getRouterId() {
return routerId;
}

public void setRouterId(String routerId) {
this.routerId = routerId;
}


}
Loading