mirror of https://github.com/apache/jclouds.git
Merge pull request #135 from jsonking/master
Issue 695: Added VirtualMachine + various other tidy-up
This commit is contained in:
commit
77709f5be4
|
@ -79,7 +79,7 @@ public class TerremarkEnterpriseCloudProviderMetadata extends BaseProviderMetada
|
|||
*/
|
||||
@Override
|
||||
public URI getHomepage() {
|
||||
return URI.create("TODO");
|
||||
return URI.create("http://www.terremark.com/services/cloudcomputing/theenterprisecloud.aspx");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +87,7 @@ public class TerremarkEnterpriseCloudProviderMetadata extends BaseProviderMetada
|
|||
*/
|
||||
@Override
|
||||
public URI getConsole() {
|
||||
return URI.create("TODO");
|
||||
return URI.create("https://my-beta.enterprisecloud.terremark.com/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain;
|
||||
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
|
@ -9,6 +27,7 @@ import java.util.Map;
|
|||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -90,6 +109,14 @@ public class Action extends BaseNamedResource<Action> {
|
|||
return fromNamedResource(in).actionDisabled(in.getActionDisabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Action> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -98,6 +125,30 @@ public class Action extends BaseNamedResource<Action> {
|
|||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -129,4 +180,28 @@ public class Action extends BaseNamedResource<Action> {
|
|||
return actionDisabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
Action action = (Action) o;
|
||||
|
||||
if (actionDisabled != action.actionDisabled) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (actionDisabled != null ? actionDisabled.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", actionDisabled="+actionDisabled;
|
||||
}
|
||||
}
|
|
@ -1,3 +1,21 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
@ -6,6 +24,7 @@ import java.net.URI;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -100,6 +119,14 @@ public class Link extends BaseNamedResource<Link> {
|
|||
return fromNamedResource(in).rel(in.getRelationship());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<Link> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -108,6 +135,30 @@ public class Link extends BaseNamedResource<Link> {
|
|||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -135,4 +186,28 @@ public class Link extends BaseNamedResource<Link> {
|
|||
return rel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
Link link = (Link) o;
|
||||
|
||||
if (rel != link.rel) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + rel.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", rel="+rel;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,28 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,22 +58,30 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
public Builder fromResource(BaseResource<NamedResource> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
public Builder fromNamedResource(BaseNamedResource<NamedResource> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
@ -63,8 +90,8 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<NamedResource> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain;
|
||||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
|
@ -281,11 +299,48 @@ public class Task extends BaseResource<Task> {
|
|||
return initiatedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[type=" + type + ", href=" + href + ", operation=" + operation + ", status=" + status + ", impactedItem="
|
||||
+ impactedItem + ", startTime=" + startTime + ", completedTime=" + completedTime + ", notes=" + notes
|
||||
+ ", errorMessage=" + errorMessage + ", initiatedBy=" + initiatedBy + "]";
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
Task task = (Task) o;
|
||||
|
||||
if (completedTime != null ? !completedTime.equals(task.completedTime) : task.completedTime != null)
|
||||
return false;
|
||||
if (errorMessage != null ? !errorMessage.equals(task.errorMessage) : task.errorMessage != null)
|
||||
return false;
|
||||
if (!impactedItem.equals(task.impactedItem)) return false;
|
||||
if (!initiatedBy.equals(task.initiatedBy)) return false;
|
||||
if (notes != null ? !notes.equals(task.notes) : task.notes != null)
|
||||
return false;
|
||||
if (!operation.equals(task.operation)) return false;
|
||||
if (!startTime.equals(task.startTime)) return false;
|
||||
if (status != task.status) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + operation.hashCode();
|
||||
result = 31 * result + status.hashCode();
|
||||
result = 31 * result + impactedItem.hashCode();
|
||||
result = 31 * result + startTime.hashCode();
|
||||
result = 31 * result + (completedTime != null ? completedTime.hashCode() : 0);
|
||||
result = 31 * result + (notes != null ? notes.hashCode() : 0);
|
||||
result = 31 * result + (errorMessage != null ? errorMessage.hashCode() : 0);
|
||||
result = 31 * result + initiatedBy.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", operation="+operation+", status="+status+
|
||||
", impactedItem="+impactedItem+", startTime="+startTime+", completedTime="+completedTime+
|
||||
", notes="+notes+", errorMessage="+errorMessage+", initiatedBy="+initiatedBy;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain;
|
||||
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.trmk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromVirtualMachine(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<VirtualMachine> {
|
||||
private List<Link> links;
|
||||
private List<Action> actions;
|
||||
private List<Task> tasks;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.trmk.enterprisecloud.domain.VirtualMachine#getLinks
|
||||
*/
|
||||
public Builder links(List<Link> links) {
|
||||
this.links = links;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.trmk.enterprisecloud.domain.VirtualMachine#getActions
|
||||
*/
|
||||
public Builder actions(List<Action> actions) {
|
||||
this.actions = actions;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.trmk.enterprisecloud.domain.VirtualMachine#getTasks
|
||||
*/
|
||||
public Builder tasks(List<Task> tasks) {
|
||||
this.tasks = tasks;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.jclouds.trmk.enterprisecloud.domain.VirtualMachine#getDescription
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachine build() {
|
||||
return new VirtualMachine(href, type, name, tasks, actions, links, description);
|
||||
}
|
||||
|
||||
public Builder fromVirtualMachine(VirtualMachine in) {
|
||||
return fromNamedResource(in)
|
||||
.links(in.getLinks())
|
||||
.tasks(in.getTasks())
|
||||
.actions(in.getActions())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(BaseResource<VirtualMachine> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<VirtualMachine> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
// TODO Other fields?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final List<Link> links;
|
||||
private final List<Task> tasks;
|
||||
private final List<Action> actions;
|
||||
private final String description;
|
||||
|
||||
public VirtualMachine(URI href, String type, String name, List<Task> tasks, List<Action> actions, List<Link> links, String description) {
|
||||
super(href, type, name);
|
||||
this.description = checkNotNull(description, "description");
|
||||
this.links = checkNotNull(links, "links");
|
||||
this.tasks = checkNotNull(tasks, "tasks");
|
||||
this.actions = checkNotNull(actions, "actions");
|
||||
}
|
||||
|
||||
public List<Link> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* refers to tasks regarding the virtual machine.
|
||||
* Only the most recent tasks, up to twenty, are returned.
|
||||
* Use the href to retrieve the complete list of tasks.
|
||||
* @return most recent tasks
|
||||
*/
|
||||
public List<Task> getTasks() {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public List<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
VirtualMachine that = (VirtualMachine) o;
|
||||
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (!description.equals(that.description)) return false;
|
||||
if (!links.equals(that.links)) return false;
|
||||
if (!tasks.equals(that.tasks)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + links.hashCode();
|
||||
result = 31 * result + tasks.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + description.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+links+", tasks="+tasks+", actions="+actions+", description="+description;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,21 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
@ -37,6 +55,15 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
return new BaseNamedResource<T>(href, type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Builder<T> fromResource(BaseResource<T> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
public Builder<T> fromNamedResource(BaseNamedResource<T> in) {
|
||||
return fromResource(in).name(in.getName());
|
||||
}
|
||||
|
@ -48,15 +75,6 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
public Builder<T> fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes)).name(attributes.get("name"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Builder<T> fromResource(BaseResource<T> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
|
@ -70,45 +88,28 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BaseNamedResource<?> other = (BaseNamedResource<?>) obj;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
||||
} else if (!href.equals(other.href))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
BaseNamedResource that = (BaseNamedResource) o;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[href=" + href + ", name=" + name + ", type=" + type + "]";
|
||||
}
|
||||
if (!name.equals(that.name)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + name.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", name="+name;
|
||||
}
|
||||
}
|
|
@ -1,3 +1,21 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.trmk.enterprisecloud.domain.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
@ -113,6 +131,10 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[href=" + href + ", type=" + type + "]";
|
||||
return String.format("[%s]",string());
|
||||
}
|
||||
|
||||
protected String string() {
|
||||
return "href="+href+", type="+type;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ import org.xml.sax.Attributes;
|
|||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -46,7 +45,7 @@ public class TasksHandler extends ParseSax.HandlerWithResult<Set<Task>> {
|
|||
|
||||
protected final TaskHandler taskHandler;
|
||||
|
||||
protected Builder<Task> builder = ImmutableSet.<Task> builder();
|
||||
protected ImmutableSet.Builder<Task> builder = ImmutableSet.<Task> builder();
|
||||
|
||||
@Inject
|
||||
public TasksHandler(TaskHandler taskHandler) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TaskAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClient
|
|||
Method method = TaskAsyncClient.class.getMethod("getTasksInEnvironment", long.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1l);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://209.251.187.125/livespec/tasks/environments/1 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/tasks/environments/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.task; type=collection\nx-trmk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -60,9 +60,9 @@ public class TaskAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClient
|
|||
|
||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TaskAsyncClient.class.getMethod("getTask", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("http://209.251.187.125/livespec/tasks/1"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("https://services-beta.enterprisecloud.terremark.com/cloudapi/tasks/1"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://209.251.187.125/livespec/tasks/1 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/tasks/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/vnd.tmrk.cloud.task\nx-trmk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
<VirtualMachine href="/cloudapi/ecloud/virtualmachines/5504" name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.virtualMachine"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/computepools/89"
|
||||
name="Default Compute Pool"
|
||||
type="application/vnd.tmrk.cloud.computePool" rel="up"/>
|
||||
<Link href="/cloudapi/ecloud/environments/77" name="Beta Environment 01"
|
||||
type="application/vnd.tmrk.cloud.environment" rel="up"/>
|
||||
<Link href="/cloudapi/ecloud/tasks/virtualmachines/5504"
|
||||
type="application/vnd.tmrk.cloud.task; type=collection"
|
||||
rel="down"/>
|
||||
<Link href="/cloudapi/ecloud/virtualmachines/5504/guest/processes"
|
||||
name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.guest.process; type=collection"
|
||||
rel="down"/>
|
||||
<Link href="/cloudapi/ecloud/virtualmachines/5504/configurationoptions"
|
||||
name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.virtualMachineConfigurationOptions"
|
||||
rel="down"/>
|
||||
<Link href="/cloudapi/ecloud/virtualmachines-streaming/5504/guest/action/files"
|
||||
name="helloworld" type="application/octet-stream" rel="down"/>
|
||||
</Links>
|
||||
<Actions>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504" name="edit"
|
||||
type="application/vnd.tmrk.cloud.virtualMachine"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/action/move"
|
||||
name="move"
|
||||
type="application/vnd.tmrk.cloud.moveLayoutRequest"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504" name="remove"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/action/poweroff"
|
||||
name="power:powerOff" actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/action/reboot"
|
||||
name="power:reboot" actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/action/shutdown"
|
||||
name="power:shutdown" actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/action/poweron"
|
||||
name="power:powerOn"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/tools/action/mount"
|
||||
name="tools:mount" actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/tools/action/unmount"
|
||||
name="tools:unmount" actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/guest/action/createprocess"
|
||||
name="createGuestProcess"
|
||||
type="application/vnd.tmrk.cloud.guest.process"
|
||||
actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines-streaming/5504/guest/action/files"
|
||||
name="createFile" type="application/octet-stream"
|
||||
actionDisabled="disabled"/>
|
||||
</Actions>
|
||||
<Tasks type="application/vnd.tmrk.cloud.task; type=collection">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/virtualmachines/5504" name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.virtualMachine" rel="up"/>
|
||||
</Links>
|
||||
<Task href="/cloudapi/ecloud/tasks/12345"
|
||||
type="application/vnd.tmrk.cloud.task">
|
||||
<Operation>Create Server</Operation>
|
||||
<Status>Complete</Status>
|
||||
<ImpactedItem href="/cloudapi/ecloud/virtualmachines/5504"
|
||||
name="helloworld"
|
||||
type="application/vnd.tmrk.cloud.virtualMachine"/>
|
||||
<StartTime>2011-11-09T21:46:11.787Z</StartTime>
|
||||
<CompletedTime>2011-11-09T21:50:32.933Z</CompletedTime>
|
||||
<InitiatedBy href="/cloudapi/ecloud/admin/users/1804"
|
||||
name="Jason King"
|
||||
type="application/vnd.tmrk.cloud.admin.user"/>
|
||||
</Task>
|
||||
<TotalCount>1</TotalCount>
|
||||
</Tasks>
|
||||
<Description>My first terremark server</Description>
|
||||
<Layout>
|
||||
<Row href="/cloudapi/ecloud/layoutrows/285" name="test row"
|
||||
type="application/vnd.tmrk.cloud.layoutRow"/>
|
||||
<Group href="/cloudapi/ecloud/layoutgroups/308" name="test group"
|
||||
type="application/vnd.tmrk.cloud.layoutGroup"/>
|
||||
</Layout>
|
||||
<Status>Deployed</Status>
|
||||
<PoweredOn>false</PoweredOn>
|
||||
<HardwareConfiguration
|
||||
href="/cloudapi/ecloud/virtualmachines/5504/hardwareconfiguration"
|
||||
type="application/vnd.tmrk.cloud.virtualMachineHardware">
|
||||
<Actions>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/hardwareconfiguration"
|
||||
name="edit"
|
||||
type="application/vnd.tmrk.cloud.virtualMachineHardware"/>
|
||||
</Actions>
|
||||
<ProcessorCount>1</ProcessorCount>
|
||||
<Memory>
|
||||
<Unit>MB</Unit>
|
||||
<Value>384</Value>
|
||||
</Memory>
|
||||
<Disks>
|
||||
<Disk>
|
||||
<Index>0</Index>
|
||||
<Size>
|
||||
<Unit>GB</Unit>
|
||||
<Value>10</Value>
|
||||
</Size>
|
||||
<Name>Hard Disk 1</Name>
|
||||
</Disk>
|
||||
</Disks>
|
||||
<Nics>
|
||||
<Nic>
|
||||
<UnitNumber>7</UnitNumber>
|
||||
<Name>Network adapter 1</Name>
|
||||
<MacAddress>00:50:56:b8:00:58</MacAddress>
|
||||
<Network href="/cloudapi/ecloud/networks/3936"
|
||||
name="10.146.204.64/28"
|
||||
type="application/vnd.tmrk.cloud.network">
|
||||
<NetworkType>Internal</NetworkType>
|
||||
</Network>
|
||||
</Nic>
|
||||
</Nics>
|
||||
</HardwareConfiguration>
|
||||
<IpAddresses>
|
||||
<AssignedIpAddresses
|
||||
href="/cloudapi/ecloud/virtualmachines/5504/assignedips"
|
||||
type="application/vnd.tmrk.cloud.virtualMachineAssignedIps">
|
||||
<Actions>
|
||||
<Action href="/cloudapi/ecloud/virtualmachines/5504/assignedips"
|
||||
name="edit"
|
||||
type="application/vnd.tmrk.cloud.virtualMachineAssignedIps"/>
|
||||
</Actions>
|
||||
<Networks>
|
||||
<Network href="/cloudapi/ecloud/networks/3936"
|
||||
name="10.146.204.64/28 (INT_202)"
|
||||
type="application/vnd.tmrk.cloud.network">
|
||||
<IpAddresses>
|
||||
<IpAddress>10.146.204.67</IpAddress>
|
||||
</IpAddresses>
|
||||
</Network>
|
||||
</Networks>
|
||||
</AssignedIpAddresses>
|
||||
</IpAddresses>
|
||||
<OperatingSystem
|
||||
href="/cloudapi/ecloud/operatingsystems/rhel5_64guest/computepools/89"
|
||||
name="Red Hat Enterprise Linux 5 (64-bit)"
|
||||
type="application/vnd.tmrk.cloud.operatingSystem"/>
|
||||
<ToolsStatus>NotRunning</ToolsStatus>
|
||||
<MediaStatus>Unmounted</MediaStatus>
|
||||
<CustomizationPending>false</CustomizationPending>
|
||||
</VirtualMachine>
|
Loading…
Reference in New Issue