http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndId.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndId.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndId.java new file mode 100644 index 0000000..b8602e2 --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndId.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.v2_0.domain.regionscoped; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Objects; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; + +public class RegionAndId { + public static RegionAndId fromSlashEncoded(String id) { + Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id")); + checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id"); + return new RegionAndId(Iterables.get(parts, 0), Iterables.get(parts, 1)); + } + + public static RegionAndId fromRegionAndId(String regionId, String id) { + return new RegionAndId(regionId, id); + } + + private static String slashEncodeRegionAndId(String regionId, String id) { + return checkNotNull(regionId, "regionId") + "/" + checkNotNull(id, "id"); + } + + public String slashEncode() { + return slashEncodeRegionAndId(regionId, id); + } + + protected final String regionId; + protected final String id; + + protected RegionAndId(String regionId, String id) { + this.regionId = checkNotNull(regionId, "regionId"); + this.id = checkNotNull(id, "id"); + } + + @Override + public int hashCode() { + return Objects.hashCode(regionId, id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RegionAndId other = (RegionAndId) obj; + return Objects.equal(regionId, other.regionId) && Objects.equal(id, other.id); + } + + public String getRegion() { + return regionId; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + return "[regionId=" + regionId + ", id=" + id + "]"; + } + +}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndName.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndName.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndName.java new file mode 100644 index 0000000..e91d1fa --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionAndName.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.v2_0.domain.regionscoped; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Function; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; + +/** + * Helpful when looking for resources by region and name + */ +public class RegionAndName { + + public static final Function<RegionAndName, String> NAME_FUNCTION = new Function<RegionAndName, String>() { + + @Override + public String apply(RegionAndName input) { + return input.getName(); + } + + }; + + public static final Function<RegionAndName, String> REGION_FUNCTION = new Function<RegionAndName, String>() { + + @Override + public String apply(RegionAndName input) { + return input.getRegion(); + } + + }; + + public static RegionAndName fromSlashEncoded(String name) { + Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); + checkArgument(Iterables.size(parts) == 2, "name must be in format regionId/name"); + return new RegionAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); + } + + public static RegionAndName fromRegionAndName(String regionId, String name) { + return new RegionAndName(regionId, name); + } + + private static String slashEncodeRegionAndName(String regionId, String name) { + return checkNotNull(regionId, "regionId") + "/" + checkNotNull(name, "name"); + } + + public String slashEncode() { + return slashEncodeRegionAndName(regionId, name); + } + + protected final String regionId; + protected final String name; + + protected RegionAndName(String regionId, String name) { + this.regionId = checkNotNull(regionId, "regionId"); + this.name = checkNotNull(name, "name"); + } + + public String getRegion() { + return regionId; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RegionAndName that = RegionAndName.class.cast(o); + return equal(this.regionId, that.regionId) && equal(this.name, that.name); + } + + @Override + public int hashCode() { + return Objects.hashCode(regionId, name); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return MoreObjects.toStringHelper("").add("regionId", regionId).add("name", name); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionSecurityGroupNameAndPorts.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionSecurityGroupNameAndPorts.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionSecurityGroupNameAndPorts.java new file mode 100644 index 0000000..f7866e0 --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/RegionSecurityGroupNameAndPorts.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.v2_0.domain.regionscoped; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; + +import com.google.common.base.Objects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.collect.ImmutableSet; + +public class RegionSecurityGroupNameAndPorts extends RegionAndName { + protected final Set<Integer> ports; + + public RegionSecurityGroupNameAndPorts(String regionId, String name, Iterable<Integer> ports) { + super(regionId, name); + this.ports = ImmutableSet.<Integer> copyOf(checkNotNull(ports, "ports")); + } + + public Set<Integer> getPorts() { + return ports; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RegionSecurityGroupNameAndPorts that = RegionSecurityGroupNameAndPorts.class.cast(o); + return super.equals(that) && equal(this.ports, that.ports); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), ports); + } + + @Override + public ToStringHelper string() { + return super.string().add("ports", ports); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/SecurityGroupInRegion.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/SecurityGroupInRegion.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/SecurityGroupInRegion.java new file mode 100644 index 0000000..a3898af --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/SecurityGroupInRegion.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.v2_0.domain.regionscoped; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup; + +public class SecurityGroupInRegion extends RegionAndName { + protected final SecurityGroup securityGroup; + + public SecurityGroupInRegion(SecurityGroup securityGroup, String regionId) { + super(regionId, checkNotNull(securityGroup, "securityGroup").getName()); + this.securityGroup = securityGroup; + } + + public SecurityGroup getSecurityGroup() { + return securityGroup; + } + + // superclass hashCode/equals are good enough, and help us use RegionAndName and ServerInRegion + // interchangeably as Map keys + + @Override + public String toString() { + return "[securityGroup=" + securityGroup + ", regionId=" + regionId + "]"; + } + +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ServerInRegion.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ServerInRegion.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ServerInRegion.java new file mode 100644 index 0000000..a5c1803 --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ServerInRegion.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.v2_0.domain.regionscoped; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.openstack.nova.v2_0.domain.Server; + +public class ServerInRegion extends RegionAndId { + protected final Server server; + + public ServerInRegion(Server server, String regionId) { + super(regionId, checkNotNull(server, "server").getId()); + this.server = server; + } + + public Server getServer() { + return server; + } + + // superclass hashCode/equals are good enough, and help us use RegionAndId and ServerInRegion + // interchangeably as Map keys + + @Override + public String toString() { + return "[server=" + server + ", regionId=" + regionId + "]"; + } + +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ZoneState.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ZoneState.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ZoneState.java new file mode 100644 index 0000000..814800a --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/regionscoped/ZoneState.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.v2_0.domain.regionscoped; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; + +public class ZoneState { + + private final boolean available; + + protected ZoneState(boolean available) { + this.available = available; + } + + public boolean available() { + return this.available; + } + + @Override + public int hashCode() { + return Objects.hashCode(available); + } + + @Override + public boolean equals(Object obj) { + if (this != obj) return false; + if (obj == null || getClass() != obj.getClass()) return false; + ZoneState that = ZoneState.class.cast(obj); + return Objects.equal(this.available, that.available); + } + + protected MoreObjects.ToStringHelper string() { + return MoreObjects.toStringHelper(this) + .add("available", available); + } + + @Override + public String toString() { + return string().toString(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java deleted file mode 100644 index a963dcd..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.gson.annotations.SerializedName; - -import java.beans.ConstructorProperties; - -public class AvailabilityZone { - - @SerializedName("zoneName") - private final String name; - private final ZoneState state; - - @ConstructorProperties({"zoneName" , "zoneState"}) - protected AvailabilityZone(String name, ZoneState state) { - this.name = name; - this.state = state; - } - - public String getName() { - return name; - } - - public ZoneState getState() { - return state; - } - - @Override - public int hashCode() { - return Objects.hashCode(name, state); - } - - @Override - public boolean equals(Object obj) { - if (this != obj) return false; - if (obj == null || getClass() != obj.getClass()) return false; - AvailabilityZone that = AvailabilityZone.class.cast(obj); - return Objects.equal(this.name, that.name) && Objects.equal(this.state, that.state); - } - - protected MoreObjects.ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("name", name) - .add("state", state); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java deleted file mode 100644 index 3f412d4..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.openstack.nova.v2_0.domain.Flavor; - -public class FlavorInZone extends ZoneAndId { - protected final Flavor image; - - public FlavorInZone(Flavor image, String zoneId) { - super(zoneId, checkNotNull(image, "image").getId()); - this.image = image; - } - - public Flavor getFlavor() { - return image; - } - - // superclass hashCode/equals are good enough, and help us use ZoneAndId and FlavorInZone - // interchangeably as Map keys - - @Override - public String toString() { - return "[image=" + image + ", zoneId=" + zoneId + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java deleted file mode 100644 index 86581ba..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.openstack.nova.v2_0.domain.Image; - -public class ImageInZone extends ZoneAndId { - protected final Image image; - - public ImageInZone(Image image, String zoneId) { - super(zoneId, checkNotNull(image, "image").getId()); - this.image = image; - } - - public Image getImage() { - return image; - } - - // superclass hashCode/equals are good enough, and help us use ZoneAndId and ImageInZone - // interchangeably as Map keys - - @Override - public String toString() { - return "[image=" + image + ", zoneId=" + zoneId + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java deleted file mode 100644 index 17535cd..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup; - -public class SecurityGroupInZone extends ZoneAndName { - protected final SecurityGroup securityGroup; - - public SecurityGroupInZone(SecurityGroup securityGroup, String zoneId) { - super(zoneId, checkNotNull(securityGroup, "securityGroup").getName()); - this.securityGroup = securityGroup; - } - - public SecurityGroup getSecurityGroup() { - return securityGroup; - } - - // superclass hashCode/equals are good enough, and help us use ZoneAndName and ServerInZone - // interchangeably as Map keys - - @Override - public String toString() { - return "[securityGroup=" + securityGroup + ", zoneId=" + zoneId + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java deleted file mode 100644 index 158f052..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.openstack.nova.v2_0.domain.Server; - -public class ServerInZone extends ZoneAndId { - protected final Server server; - - public ServerInZone(Server server, String zoneId) { - super(zoneId, checkNotNull(server, "server").getId()); - this.server = server; - } - - public Server getServer() { - return server; - } - - // superclass hashCode/equals are good enough, and help us use ZoneAndId and ServerInZone - // interchangeably as Map keys - - @Override - public String toString() { - return "[server=" + server + ", zoneId=" + zoneId + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java deleted file mode 100644 index e77286e..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; - -public class ZoneAndId { - public static ZoneAndId fromSlashEncoded(String id) { - Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id")); - checkArgument(Iterables.size(parts) == 2, "id must be in format zoneId/id"); - return new ZoneAndId(Iterables.get(parts, 0), Iterables.get(parts, 1)); - } - - public static ZoneAndId fromZoneAndId(String zoneId, String id) { - return new ZoneAndId(zoneId, id); - } - - private static String slashEncodeZoneAndId(String zoneId, String id) { - return checkNotNull(zoneId, "zoneId") + "/" + checkNotNull(id, "id"); - } - - public String slashEncode() { - return slashEncodeZoneAndId(zoneId, id); - } - - protected final String zoneId; - protected final String id; - - protected ZoneAndId(String zoneId, String id) { - this.zoneId = checkNotNull(zoneId, "zoneId"); - this.id = checkNotNull(id, "id"); - } - - @Override - public int hashCode() { - return Objects.hashCode(zoneId, id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ZoneAndId other = (ZoneAndId) obj; - return Objects.equal(zoneId, other.zoneId) && Objects.equal(id, other.id); - } - - public String getZone() { - return zoneId; - } - - public String getId() { - return id; - } - - @Override - public String toString() { - return "[zoneId=" + zoneId + ", id=" + id + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java deleted file mode 100644 index cebf999..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Splitter; -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.collect.Iterables; - -/** - * Helpful when looking for resources by zone and name - */ -public class ZoneAndName { - - public static final Function<ZoneAndName, String> NAME_FUNCTION = new Function<ZoneAndName, String>() { - - @Override - public String apply(ZoneAndName input) { - return input.getName(); - } - - }; - - public static final Function<ZoneAndName, String> ZONE_FUNCTION = new Function<ZoneAndName, String>() { - - @Override - public String apply(ZoneAndName input) { - return input.getZone(); - } - - }; - - public static ZoneAndName fromSlashEncoded(String name) { - Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); - checkArgument(Iterables.size(parts) == 2, "name must be in format zoneId/name"); - return new ZoneAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); - } - - public static ZoneAndName fromZoneAndName(String zoneId, String name) { - return new ZoneAndName(zoneId, name); - } - - private static String slashEncodeZoneAndName(String zoneId, String name) { - return checkNotNull(zoneId, "zoneId") + "/" + checkNotNull(name, "name"); - } - - public String slashEncode() { - return slashEncodeZoneAndName(zoneId, name); - } - - protected final String zoneId; - protected final String name; - - protected ZoneAndName(String zoneId, String name) { - this.zoneId = checkNotNull(zoneId, "zoneId"); - this.name = checkNotNull(name, "name"); - } - - public String getZone() { - return zoneId; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ZoneAndName that = ZoneAndName.class.cast(o); - return equal(this.zoneId, that.zoneId) && equal(this.name, that.name); - } - - @Override - public int hashCode() { - return Objects.hashCode(zoneId, name); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper("").add("zoneId", zoneId).add("name", name); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java deleted file mode 100644 index deaad97..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.collect.ImmutableSet; - -public class ZoneSecurityGroupNameAndPorts extends ZoneAndName { - protected final Set<Integer> ports; - - public ZoneSecurityGroupNameAndPorts(String zoneId, String name, Iterable<Integer> ports) { - super(zoneId, name); - this.ports = ImmutableSet.<Integer> copyOf(checkNotNull(ports, "ports")); - } - - public Set<Integer> getPorts() { - return ports; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ZoneSecurityGroupNameAndPorts that = ZoneSecurityGroupNameAndPorts.class.cast(o); - return super.equals(that) && equal(this.ports, that.ports); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), ports); - } - - @Override - public ToStringHelper string() { - return super.string().add("ports", ports); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java deleted file mode 100644 index 6beea92..0000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.v2_0.domain.zonescoped; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; - -public class ZoneState { - - private final boolean available; - - protected ZoneState(boolean available) { - this.available = available; - } - - public boolean available() { - return this.available; - } - - @Override - public int hashCode() { - return Objects.hashCode(available); - } - - @Override - public boolean equals(Object obj) { - if (this != obj) return false; - if (obj == null || getClass() != obj.getClass()) return false; - ZoneState that = ZoneState.class.cast(obj); - return Objects.equal(this.available, that.available); - } - - protected MoreObjects.ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("available", available); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java index 7b894fb..7624e69 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java @@ -24,7 +24,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; +import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.Fallback; http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java index 260c6c9..48b146f 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java @@ -23,22 +23,22 @@ import java.beans.ConstructorProperties; import javax.inject.Inject; import javax.inject.Singleton; -import com.google.common.base.Optional; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.internal.Arg0ToPagedIterable; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.domain.Flavor; import org.jclouds.openstack.nova.v2_0.features.FlavorApi; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails.Flavors; import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.v2_0.options.PaginationOptions; import com.google.common.annotations.Beta; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.inject.TypeLiteral; -import org.jclouds.openstack.v2_0.options.PaginationOptions; /** * boiler plate until we determine a better way @@ -71,8 +71,8 @@ public class ParseFlavorDetails extends ParseJson<Flavors> { @Override protected Function<Object, IterableWithMarker<Flavor>> markerToNextForArg0(Optional<Object> arg0) { - String zone = arg0.get().toString(); - final FlavorApi flavorApi = api.getFlavorApiForZone(zone); + String region = arg0.get().toString(); + final FlavorApi flavorApi = api.getFlavorApi(region); return new Function<Object, IterableWithMarker<Flavor>>() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java index 9b1b21c..dc2e1e8 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java @@ -71,8 +71,8 @@ public class ParseFlavors extends ParseJson<Flavors> { @Override protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) { - String zone = arg0.get().toString(); - final FlavorApi flavorApi = api.getFlavorApiForZone(zone); + String region = arg0.get().toString(); + final FlavorApi flavorApi = api.getFlavorApi(region); return new Function<Object, IterableWithMarker<Resource>>() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java index 39b3984..65c0aab 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java @@ -71,8 +71,8 @@ public class ParseImageDetails extends ParseJson<Images> { @Override protected Function<Object, IterableWithMarker<Image>> markerToNextForArg0(Optional<Object> arg0) { - String zone = arg0.get().toString(); - final ImageApi imageApi = api.getImageApiForZone(zone); + String region = arg0.get().toString(); + final ImageApi imageApi = api.getImageApi(region); return new Function<Object, IterableWithMarker<Image>>() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java index d4e1944..b33c2f9 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java @@ -23,22 +23,22 @@ import java.beans.ConstructorProperties; import javax.inject.Inject; import javax.inject.Singleton; -import com.google.common.base.Optional; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.internal.Arg0ToPagedIterable; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.features.ImageApi; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images; import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.options.PaginationOptions; import com.google.common.annotations.Beta; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.inject.TypeLiteral; -import org.jclouds.openstack.v2_0.options.PaginationOptions; /** * boiler plate until we determine a better way @@ -71,8 +71,8 @@ public class ParseImages extends ParseJson<Images> { @Override protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) { - String zone = arg0.get().toString(); - final ImageApi imageApi = api.getImageApiForZone(zone); + String region = arg0.get().toString(); + final ImageApi imageApi = api.getImageApi(region); return new Function<Object, IterableWithMarker<Resource>>() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java index e9389ca..f85e8a7 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java @@ -71,8 +71,8 @@ public class ParseServerDetails extends ParseJson<Servers> { @Override protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) { - String zone = arg0.get().toString(); - final ServerApi serverApi = api.getServerApiForZone(zone); + String region = arg0.get().toString(); + final ServerApi serverApi = api.getServerApi(region); return new Function<Object, IterableWithMarker<Server>>() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java index 15a932e..cc4d9ad 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java @@ -23,22 +23,22 @@ import java.beans.ConstructorProperties; import javax.inject.Inject; import javax.inject.Singleton; -import com.google.common.base.Optional; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.internal.Arg0ToPagedIterable; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.features.ServerApi; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers; import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.options.PaginationOptions; import com.google.common.annotations.Beta; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.inject.TypeLiteral; -import org.jclouds.openstack.v2_0.options.PaginationOptions; /** * boiler plate until we determine a better way @@ -71,8 +71,8 @@ public class ParseServers extends ParseJson<Servers> { @Override protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) { - String zone = arg0.get().toString(); - final ServerApi serverApi = api.getServerApiForZone(zone); + String region = arg0.get().toString(); + final ServerApi serverApi = api.getServerApi(region); return new Function<Object, IterableWithMarker<Resource>>() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java index 29ade1d..0ed8a69 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java @@ -360,7 +360,7 @@ public class CreateServerOptions implements MapBinder { * <p/> * <h3>Note</h3> * <p/> - * This requires that {@link NovaApi#getSecurityGroupExtensionForZone(String)} to return + * This requires that {@link NovaApi#getSecurityGroupExtensionApi(String)} to return * {@link Optional#isPresent present} */ public Set<String> getSecurityGroupNames() { @@ -376,7 +376,7 @@ public class CreateServerOptions implements MapBinder { public Set<String> getNetworks() { return networks; } - + /** * Get custom networks specified for the server. * @@ -429,7 +429,7 @@ public class CreateServerOptions implements MapBinder { /** * Determines if a configuration drive will be attached to the server or not. - * This can be used for cloud-init or other configuration purposes. + * This can be used for cloud-init or other configuration purposes. */ public boolean getConfigDrive() { return configDrive; http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java index 0899e88..578a484 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java @@ -28,8 +28,8 @@ import javax.inject.Singleton; import org.jclouds.logging.Logger; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName; +import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion; +import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName; import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi; import org.jclouds.rest.ResourceNotFoundException; @@ -42,7 +42,7 @@ import com.google.inject.Inject; * AtomicReference is so that we can return the securityGroup that matched. */ @Singleton -public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicReference<ZoneAndName>> { +public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicReference<RegionAndName>> { private final NovaApi novaApi; @@ -54,24 +54,24 @@ public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicR this.novaApi = checkNotNull(novaApi, "novaApi"); } - public boolean apply(AtomicReference<ZoneAndName> securityGroupInZoneRef) { - checkNotNull(securityGroupInZoneRef, "securityGroupRef"); - final ZoneAndName securityGroupInZone = checkNotNull(securityGroupInZoneRef.get(), "securityGroupInZone"); + public boolean apply(AtomicReference<RegionAndName> securityGroupInRegionRef) { + checkNotNull(securityGroupInRegionRef, "securityGroupRef"); + final RegionAndName securityGroupInRegion = checkNotNull(securityGroupInRegionRef.get(), "securityGroupInRegion"); - Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone()); + Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupApi(securityGroupInRegion.getRegion()); checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!"); - logger.trace("looking for security group %s", securityGroupInZone.slashEncode()); + logger.trace("looking for security group %s", securityGroupInRegion.slashEncode()); try { SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() { @Override public boolean apply(SecurityGroup input) { - return input.getName().equals(securityGroupInZone.getName()); + return input.getName().equals(securityGroupInRegion.getName()); } }); - securityGroupInZoneRef.set(new SecurityGroupInZone(returnVal, securityGroupInZone.getZone())); + securityGroupInRegionRef.set(new SecurityGroupInRegion(returnVal, securityGroupInRegion.getRegion())); return true; } catch (ResourceNotFoundException e) { return false; http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java index 18461d2..d29f081 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java @@ -57,18 +57,18 @@ public class ServerPredicates { /** * Waits until a Server is ACTIVE. - * - * @param serverApi The ServerApi in the zone where your Server resides. + * + * @param serverApi The ServerApi in the region where your Server resides. * @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes. */ public static Predicate<String> awaitActive(ServerApi serverApi) { return awaitStatus(serverApi, ACTIVE, TEN_MINUTES, FIVE_SECONDS); } - + /** * Waits until a Server is SHUTOFF. - * - * @param serverApi The ServerApi in the zone where your Server resides. + * + * @param serverApi The ServerApi in the region where your Server resides. * @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes. */ public static Predicate<String> awaitShutoff(ServerApi serverApi) { @@ -78,7 +78,7 @@ public class ServerPredicates { /** * Waits until a Server reaches Status. * - * @param serverApi The ServerApi in the zone where your Server resides. + * @param serverApi The ServerApi in the region where your Server resides. * @return Predicate that will check the status every periodInSec seconds for a maximum of maxWaitInSec minutes. */ public static Predicate<String> awaitStatus( @@ -87,7 +87,7 @@ public class ServerPredicates { return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS); } - + public static class ServerStatusPredicate implements Predicate<String> { private final ServerApi serverApi; private final Status status; http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java index 7cafdd5..47eeeaf 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java @@ -30,8 +30,8 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * - * @see KeystoneProperties#CREDENTIAL_TYPE + * + * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest") public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseNovaApiExpectTest { @@ -64,9 +64,9 @@ public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends Ba NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId, responseWithKeystoneAccess, listServers, listServersResponse); - assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); + assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); - assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), + assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(), new ParseServerListTest().expected().toString()); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java index a013889..a05e6c7 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * + * * @see KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest") @@ -64,9 +64,9 @@ public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName, responseWithKeystoneAccess, listServers, listServersResponse); - assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); + assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); - assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), + assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(), new ParseServerListTest().expected().toString()); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java index 8cc0539..ff6b068 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java @@ -29,8 +29,8 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * - * @see KeystoneProperties#CREDENTIAL_TYPE + * + * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest") public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiExpectTest { @@ -59,9 +59,9 @@ public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiEx NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName, responseWithKeystoneAccess, listServers, listServersResponse); - assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); + assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); - assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), + assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(), new ParseServerListTest().expected().toString()); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java index 59723b6..23a3c4c 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java @@ -46,7 +46,7 @@ public class EndpointIdIsRandomExpectTest extends BaseNovaApiExpectTest { return overrides; } - public void testVersionMatchOnConfiguredZonesWhenResponseIs2xx() { + public void testVersionMatchOnConfiguredRegionsWhenResponseIs2xx() { HttpRequest authenticate = HttpRequest .builder() @@ -63,7 +63,7 @@ public class EndpointIdIsRandomExpectTest extends BaseNovaApiExpectTest { NovaApi whenNovaRegionExists = requestSendsResponse(authenticate, authenticationResponse); - assertEquals(whenNovaRegionExists.getConfiguredZones(), ImmutableSet.of("RegionOne")); + assertEquals(whenNovaRegionExists.getConfiguredRegions(), ImmutableSet.of("RegionOne")); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java index 22b446e..55f1a21 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java @@ -27,15 +27,15 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * - * @see KeystoneProperties#CREDENTIAL_TYPE + * + * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "PasswordAuthenticationExpectTest") public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest { public PasswordAuthenticationExpectTest() { identity = "identity"; } - + public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest .builder() @@ -50,9 +50,9 @@ public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest { NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, listServers, listServersResponse); - assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); + assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); - assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), + assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(), new ParseServerListTest().expected().toString()); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java index b6cb881..87d3f37 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java @@ -29,8 +29,8 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * - * @see KeystoneProperties#CREDENTIAL_TYPE + * + * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest") public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiExpectTest { @@ -59,9 +59,9 @@ public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiE NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, listServers, listServersResponse); - assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); + assertEquals(apiWhenServersExist.getConfiguredRegions(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); - assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(), + assertEquals(apiWhenServersExist.getServerApi("az-1.region-a.geo-1").list().concat().toString(), new ParseServerListTest().expected().toString()); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java index 0a9aa06..35c5b39 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java @@ -35,8 +35,8 @@ import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions; import org.jclouds.openstack.nova.v2_0.domain.KeyPair; import org.jclouds.openstack.nova.v2_0.domain.Network; import org.jclouds.openstack.nova.v2_0.domain.Server; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName; +import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion; +import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceContextExpectTest; import org.testng.annotations.Test; @@ -92,7 +92,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forNetworks.getInstance(NovaComputeServiceAdapter.class); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); // Response irrelevant in this expect test - just verifying the request. } @@ -127,7 +127,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forDiskConfig.getInstance(NovaComputeServiceAdapter.class); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); assertEquals(server.getNode().getServer().getDiskConfig().orNull(), Server.DISK_CONFIG_AUTO); } @@ -162,7 +162,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forConfigDrive.getInstance(NovaComputeServiceAdapter.class); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); } @@ -209,7 +209,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forNovaNetworks.getInstance(NovaComputeServiceAdapter.class); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); } @@ -243,7 +243,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); assertEquals(server.getCredentials(), LoginCredentials.builder().password("ZWuHcmTMQ7eXoHeM").build()); @@ -286,13 +286,13 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class); // we expect to have already an entry in the cache for the key - LoadingCache<ZoneAndName, KeyPair> keyPairCache = forSecurityGroups.getInstance(Key - .get(new TypeLiteral<LoadingCache<ZoneAndName, KeyPair>>() { + LoadingCache<RegionAndName, KeyPair> keyPairCache = forSecurityGroups.getInstance(Key + .get(new TypeLiteral<LoadingCache<RegionAndName, KeyPair>>() { })); - keyPairCache.put(ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo") + keyPairCache.put(RegionAndName.fromRegionAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo") .privateKey("privateKey").build()); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); assertEquals(server.getCredentials(), LoginCredentials.builder().privateKey("privateKey").build()); @@ -333,7 +333,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class); - NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", + NodeAndInitialCredentials<ServerInRegion> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); assertNull(server.getCredentials()); @@ -417,8 +417,8 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); - // only specify one zone so that we don't have to configure requests for multiple zones - overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1"); + // only specify one region so that we don't have to configure requests for multiple regions + overrides.setProperty("jclouds.regions", "az-1.region-a.geo-1"); return overrides; } } http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java index f62e97e..3ec6102 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java @@ -50,17 +50,17 @@ import com.google.inject.TypeLiteral; */ @Test(groups = "unit", testName = "NovaComputeServiceExpectTest") public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest { - + @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); - // only specify limited zones so that we don't have to configure requests for multiple zones. + // only specify limited regions so that we don't have to configure requests for multiple regions. // since we are doing tests with keystone responses from hpcloud and also openstack, we have - // to whitelist one zone from each - overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1,RegionOne"); + // to whitelist one region from each + overrides.setProperty("jclouds.regions", "az-1.region-a.geo-1,RegionOne"); return overrides; } - + public void testListLocationsWhenResponseIs2xx() throws Exception { Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder() @@ -189,7 +189,7 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe HttpResponse securityGroupWithPort22 = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/securitygroup_details_port22.json")).build(); - + HttpRequest create = HttpRequest .builder() .method("POST") http://git-wip-us.apache.org/repos/asf/jclouds/blob/744cd5d7/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java index 8021cb9..08762cd 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java @@ -34,11 +34,11 @@ import com.google.common.util.concurrent.Futures; @Test(groups = "unit", testName = "NovaImageExtensionExpectTest") public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTest { - + @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); - overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1"); + overrides.setProperty("jclouds.regions", "az-1.region-a.geo-1"); return overrides; } @@ -58,7 +58,7 @@ public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTe payloadFromStringWithContentType( "{\"createImage\":{\"name\":\"test\", \"metadata\": {}}}", "application/json")).build(); - + HttpResponse createImageResponse = HttpResponse.builder().statusCode(202) .addHeader("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") .build(); @@ -67,7 +67,7 @@ public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTe .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); - + HttpResponse getImageResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/image_active.json")).build(); @@ -79,7 +79,7 @@ public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTe requestResponseMap.put(getImage, getImageResponse).build(); ImageExtension apiThatCreatesImage = requestsSendResponses(requestResponseMap.build()).getImageExtension().get(); - + ImageTemplate newImageTemplate = apiThatCreatesImage.buildImageTemplateFromNode("test", "az-1.region-a.geo-1/71752"); Image image = Futures.getUnchecked(apiThatCreatesImage.createImage(newImageTemplate));
