From 289cce042a81782f3ef5f4128ba3482f59d72007 Mon Sep 17 00:00:00 2001 From: Andrea Turli Date: Tue, 9 Jun 2015 17:25:25 +0200 Subject: [PATCH] add FWaaS extension to openstack-neutron --- apis/openstack-neutron/pom.xml | 5 + .../openstack/neutron/v2/NeutronApi.java | 11 + .../neutron/v2/domain/CreateFirewall.java | 120 +++ .../v2/domain/CreateFirewallPolicy.java | 142 +++ .../neutron/v2/domain/CreateFirewallRule.java | 231 ++++ .../openstack/neutron/v2/domain/Firewall.java | 47 + .../neutron/v2/domain/FirewallPolicies.java | 36 + .../neutron/v2/domain/FirewallPolicy.java | 48 + .../neutron/v2/domain/FirewallRule.java | 52 + .../neutron/v2/domain/FirewallRules.java | 36 + .../neutron/v2/domain/Firewalls.java | 36 + .../neutron/v2/domain/IpVersion.java | 50 + .../neutron/v2/domain/UpdateFirewall.java | 68 ++ .../v2/domain/UpdateFirewallPolicy.java | 80 ++ .../neutron/v2/domain/UpdateFirewallRule.java | 100 ++ .../v2/extensions/ExtensionNamespaces.java | 4 + .../neutron/v2/extensions/FWaaSApi.java | 253 +++++ .../FirewallPolicyToPagedIterable.java | 63 ++ .../FirewallRuleToPagedIterable.java | 63 ++ .../v2/functions/FirewallToPagedIterable.java | 63 ++ .../v2/functions/ParseFirewallPolicies.java | 38 + .../v2/functions/ParseFirewallRules.java | 38 + .../neutron/v2/functions/ParseFirewalls.java | 38 + .../v2/extensions/FWaaSApiLiveTest.java | 199 ++++ .../v2/extensions/FWaaSApiMockTest.java | 984 ++++++++++++++++++ .../v2/features/ExtensionApiMockTest.java | 2 +- .../src/test/resources/extension_list.json | 262 +++-- .../resources/firewall_create_request.json | 6 + .../resources/firewall_create_response.json | 11 + .../test/resources/firewall_get_response.json | 11 + .../resources/firewall_list_response.json | 13 + .../firewall_policy_create_request.json | 8 + .../firewall_policy_create_response.json | 11 + .../firewall_policy_get_response.json | 14 + .../firewall_policy_insert_rule_request.json | 1 + .../firewall_policy_insert_rule_response.json | 10 + .../firewall_policy_list_response.json | 255 +++++ .../firewall_rule_create_request.json | 12 + .../firewall_rule_create_response.json | 19 + .../resources/firewall_rule_get_response.json | 19 + .../firewall_rule_update_request.json | 6 + .../firewall_rule_update_response.json | 19 + .../resources/firewall_update_request.json | 5 + .../resources/firewall_update_response.json | 11 + .../src/test/resources/logback.xml | 43 +- 45 files changed, 3371 insertions(+), 172 deletions(-) create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewall.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallPolicy.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallRule.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewall.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicies.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicy.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRule.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRules.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewalls.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/IpVersion.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewall.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallPolicy.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallRule.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApi.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallPolicyToPagedIterable.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallRuleToPagedIterable.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallToPagedIterable.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallPolicies.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallRules.java create mode 100644 apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewalls.java create mode 100644 apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiLiveTest.java create mode 100644 apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiMockTest.java create mode 100644 apis/openstack-neutron/src/test/resources/firewall_create_request.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_create_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_get_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_list_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_policy_create_request.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_policy_create_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_policy_get_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_request.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_policy_list_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_rule_create_request.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_rule_create_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_rule_get_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_rule_update_request.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_rule_update_response.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_update_request.json create mode 100644 apis/openstack-neutron/src/test/resources/firewall_update_response.json diff --git a/apis/openstack-neutron/pom.xml b/apis/openstack-neutron/pom.xml index 15e022505e..42da458e5e 100644 --- a/apis/openstack-neutron/pom.xml +++ b/apis/openstack-neutron/pom.xml @@ -111,6 +111,11 @@ auto-service provided + + com.google.auto.value + auto-value + provided + diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java index 4dca71b95b..6eb3f534ca 100644 --- a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java @@ -26,6 +26,7 @@ import org.jclouds.openstack.neutron.v2.extensions.FloatingIPApi; import org.jclouds.openstack.neutron.v2.extensions.RouterApi; import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi; import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi; +import org.jclouds.openstack.neutron.v2.extensions.FWaaSApi; import org.jclouds.openstack.neutron.v2.features.NetworkApi; import org.jclouds.openstack.neutron.v2.features.PortApi; import org.jclouds.openstack.neutron.v2.features.SubnetApi; @@ -120,4 +121,14 @@ public interface NeutronApi extends Closeable { */ @Delegate Optional getLBaaSApi(@EndpointParam(parser = VersionAwareRegionToEndpoint.class) String region); + + /** + * Provides access to FWaaS features. + * + *

NOTE

+ * This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type + * to determine if it is present. + */ + @Delegate + Optional getFWaaSApi(@EndpointParam(parser = VersionAwareRegionToEndpoint.class) String region); } diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewall.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewall.java new file mode 100644 index 0000000000..9c65419e48 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewall.java @@ -0,0 +1,120 @@ +/* + * 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.neutron.v2.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +/** + * Representation of creation options for an OpenStack Neutron Firewall. + * + * @see api + * doc + */ +@AutoValue +public abstract class CreateFirewall { + + /** + * @see Builder#tenantId(String) + */ + @Nullable public abstract String getTenantId(); + + /** + * @see Builder#name(String) + */ + @Nullable public abstract String getName(); + + /** + * @see Builder#description(String) + */ + @Nullable public abstract String getDescription(); + + /** + * @see Builder#adminStateUp(Boolean) + */ + @Nullable public abstract Boolean getAdminStateUp(); + + /** + * @see Builder#firewallPolicyId(String) + */ + @Nullable public abstract String getFirewallPolicyId(); + + @SerializedNames({ "tenant_id", "name", "description", "admin_state_up", "firewall_policy_id"}) + public static CreateFirewall create(String tenantId, String name, String description, Boolean adminStateUp, String firewallPolicyId) { + return builder().tenantId(tenantId).name(name).description(description).adminStateUp(adminStateUp) + .firewallPolicyId(firewallPolicyId).build(); + } + + public static Builder builder() { + return new AutoValue_CreateFirewall.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + + /** + * + * @param tenantId Owner of the firewall. Only admin users can specify a tenant_id other than its own. + * @return The CreateFirewall builder. + */ + public abstract Builder tenantId(String tenantId); + + /** + * + * @param name Human readable name for the firewall (255 characters limit). + * @return The CreateFirewall builder. + */ + public abstract Builder name(String name); + + /** + * + * @param description Human readable description for the firewall (1024 characters limit). + * @return The CreateFirewall builder. + */ + public abstract Builder description(String description); + + /** + * + * @param adminStateUp The administrative state of the firewall. If False (down), the firewall does not forward any packets. + * @return The CreateFirewall builder. + */ + public abstract Builder adminStateUp(Boolean adminStateUp); + + /** + * + * @param firewallPolicyId The firewall policy uuid that this firewall is associated with. This firewall implements the rules contained in the + * firewall policy represented by this uuid. + * + * @return The CreateFirewall builder. + */ + public abstract Builder firewallPolicyId(String firewallPolicyId); + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getAdminStateUp(); + @Nullable public abstract String getFirewallPolicyId(); + + public abstract CreateFirewall build(); + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallPolicy.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallPolicy.java new file mode 100644 index 0000000000..6418c0df67 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallPolicy.java @@ -0,0 +1,142 @@ +/* + * 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.neutron.v2.domain; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +/** + * Representation of creation options for an OpenStack Neutron Firewall Policy. + * + * @see api + * doc + */ +@AutoValue +public abstract class CreateFirewallPolicy { + + /** + * @see Builder#tenantId(String) + */ + @Nullable public abstract String getTenantId(); + + /** + * @see Builder#name(String) + */ + @Nullable public abstract String getName(); + + /** + * @see Builder#description(String) + */ + @Nullable public abstract String getDescription(); + + /** + * @see Builder#shared(Boolean) + */ + @Nullable public abstract Boolean getShared(); + + /** + * @see Builder#firewallRules(java.util.List) + */ + @Nullable public abstract List getFirewallRules(); + + /** + * @see Builder#audited(Boolean) + */ + @Nullable public abstract Boolean getAudited(); + + @SerializedNames({"tenant_id", "name", "description", "shared", "firewall_rules", "audited"}) + private static CreateFirewallPolicy create(String tenantId, String name, String description, Boolean shared, List firewallRules, Boolean audited) { + return builder().tenantId(tenantId).name(name).description(description).shared(shared).firewallRules(firewallRules).audited(audited).build(); + } + + public static Builder builder() { + return new AutoValue_CreateFirewallPolicy.Builder().shared(false).audited(false); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + + /** + * + * @param tenantId Owner of the firewall. Only admin users can specify a tenant_id other than its own. + * @return The CreateFirewallPolicy builder. + */ + public abstract Builder tenantId(String tenantId); + + /** + * + * @param name Human readable name for the firewall (255 characters limit). + * @return The CreateFirewallPolicy builder. + */ + public abstract Builder name(String name); + + /** + * + * @param description Human readable description for the firewall (1024 characters limit). + * @return The CreateFirewallPolicy builder. + */ + public abstract Builder description(String description); + + /** + * + * @param shared When set to True makes this firewall policy visible to tenants other than its owner and + * can be used to associate with firewalls not owned by its tenant. + * @return The CreateFirewallPolicy builder. + */ + public abstract Builder shared(Boolean shared); + + /** + * + * @param firewallRules This is an ordered list of firewall rule uuids. + * The firewall applies the rules in the order in which they appear in this list. + * @return The CreateFirewallPolicy builder. + */ + public abstract Builder firewallRules(List firewallRules); + + /** + * + * @param audited When set to True by the policy owner indicates that the firewall policy has been audited. This attribute is meant to aid in the + * firewall policy audit work flows. Each time the firewall policy or the associated firewall rules are changed, this attribute is set + * to False and must be explicitly set to True through an update operation. + * @return The CreateFirewallPolicy builder. + */ + public abstract Builder audited(Boolean audited); + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getShared(); + @Nullable public abstract List getFirewallRules(); + @Nullable public abstract Boolean getAudited(); + + abstract CreateFirewallPolicy autoBuild(); + + public CreateFirewallPolicy build() { + firewallRules(getFirewallRules() != null ? ImmutableList.copyOf(getFirewallRules()) : ImmutableList.of()); + return autoBuild(); + } + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallRule.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallRule.java new file mode 100644 index 0000000000..0e7bdbec60 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/CreateFirewallRule.java @@ -0,0 +1,231 @@ +/* + * 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.neutron.v2.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +/** + * Representation of creation options for an OpenStack Neutron Firewall Rule. + * + * @see api + * doc + */ +@AutoValue +public abstract class CreateFirewallRule { + + /** + * @see Builder#tenantId(String) + */ + @Nullable public abstract String getTenantId(); + /** + * @see Builder#name(String) + */ + @Nullable public abstract String getName(); + /** + * @see Builder#description(String) + */ + @Nullable public abstract String getDescription(); + /** + * @see Builder#firewallPolicyId(String) + */ + @Nullable public abstract String getFirewallPolicyId(); + /** + * @see Builder#shared(Boolean) + */ + @Nullable public abstract Boolean getShared(); + /** + * @see Builder#protocol(String) + */ + @Nullable public abstract String getProtocol(); + /** + * @see Builder#ipVersion(IpVersion) + */ + @Nullable public abstract IpVersion getIpVersion(); + /** + * @see Builder#sourceIpAddress(String) + */ + @Nullable public abstract String getSourceIpAddress(); + /** + * @see Builder#destinationIpAddress(String) + */ + @Nullable public abstract String getDestinationIpAddress(); + /** + * @see Builder#sourcePort(String) + */ + @Nullable public abstract String getSourcePort(); + /** + * @see Builder#destinationPort(String) + */ + @Nullable public abstract String getDestinationPort(); + /** + * see Builder#position(Integer) + */ + @Nullable public abstract Integer getPosition(); + /** + * @see Builder#action(String) + */ + @Nullable public abstract String getAction(); + /** + * @see Builder#enabled(Boolean) + */ + @Nullable public abstract Boolean getEnabled(); + + @SerializedNames({ "tenant_id", "name", "description", "firewall_policy_id", "shared", "protocol", "ip_version", "source_ip_address", + "destination_ip_address", "source_port", "destination_port", "position", "action", "enabled"}) + public static CreateFirewallRule create(String tenantId, String name, String description, String firewallPolicyId, Boolean shared, String protocol, + IpVersion ipVersion, String sourceIpAddress, String destinationIpAddress, String sourcePort, String destinationPort, int position, + String action, Boolean enabled) { + return builder().tenantId(tenantId).name(name).description(description).firewallPolicyId(firewallPolicyId).shared(shared) + .protocol(protocol).ipVersion(ipVersion).sourceIpAddress(sourceIpAddress).destinationIpAddress(destinationIpAddress).sourcePort(sourcePort) + .destinationPort(destinationPort).position(position).action(action).enabled(enabled).build(); + } + + public static Builder builder() { + return new AutoValue_CreateFirewallRule.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + + /** + * + * @param tenantId Owner of the firewall. Only admin users can specify a tenant_id other than its own. + * @return The CreateFirewallRule builder. + */ + public abstract Builder tenantId(String tenantId); + + /** + * + * @param name Human readable name for the firewall (255 characters limit). + * @return The CreateFirewallRule builder. + */ + public abstract Builder name(String name); + + /** + * + * @param description Human readable description for the firewall (1024 characters limit). + * @return The CreateFirewallRule builder. + */ + public abstract Builder description(String description); + + /** + * + * @param shared When set to True makes this firewall policy visible to tenants other than its owner and + * can be used to associate with firewalls not owned by its tenant. + * @return The CreateFirewallRule builder. + */ + public abstract Builder shared(Boolean shared); + + /** + * + * @param firewallPolicyId This is a read-only attribute that gets populated with the uuid of the firewall policy when this firewall rule is associated + * with a firewall policy. A firewall rule can be associated with only one firewall policy at a time. However, the association + * can be changed to a different firewall policy. + * @return The CreateFirewallRule builder. + */ + public abstract Builder firewallPolicyId(String firewallPolicyId); + + /** + * + * @param protocol IP protocol (icmp, tcp, udp, None). + * @return The CreateFirewallRule builder. + */ + public abstract Builder protocol(String protocol); + + /** + * + * @param ipVersion IP version (4, 6). + * @return The CreateFirewallRule builder. + */ + public abstract Builder ipVersion(IpVersion ipVersion); + + /** + * + * @param sourceIpAddress Source IP address or CIDR. + * @return The CreateFirewallRule builder. + */ + public abstract Builder sourceIpAddress(String sourceIpAddress); + + /** + * + * @param destinationIpAddress Destination IP address or CIDR. + * @return The CreateFirewallRule builder. + */ + public abstract Builder destinationIpAddress(String destinationIpAddress); + + /** + * + * @param sourcePort Source port number or a range. + * @return The CreateFirewallRule builder. + */ + public abstract Builder sourcePort(String sourcePort); + + /** + * + * @param destinationPort Destination port number or a range. + * @return The CreateFirewallRule builder. + */ + public abstract Builder destinationPort(String destinationPort); + + /** + * + * @param position This is a read-only attribute that gets assigned to this rule when the rule is associated with a firewall policy. It indicates the + * position of this rule in that firewall policy. + * @return The CreateFirewallRule builder. + */ + public abstract Builder position(Integer position); + + /** + * + * @param action Action to be performed on the traffic matching the rule (allow, deny). + * @return The CreateFirewallRule builder. + */ + public abstract Builder action(String action); + + /** + * + * @param enabled When set to False, disables this rule in the firewall policy. Facilitates selectively turning off rules without having to + * disassociate the rule from the firewall policy. + * @return The CreateFirewallRule builder. + */ + public abstract Builder enabled(Boolean enabled); + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getShared(); + @Nullable public abstract String getFirewallPolicyId(); + @Nullable public abstract String getProtocol(); + @Nullable public abstract IpVersion getIpVersion(); + @Nullable public abstract String getSourceIpAddress(); + @Nullable public abstract String getDestinationIpAddress(); + @Nullable public abstract String getSourcePort(); + @Nullable public abstract String getDestinationPort(); + @Nullable public abstract Integer getPosition(); + @Nullable public abstract String getAction(); + @Nullable public abstract Boolean getEnabled(); + + public abstract CreateFirewallRule build(); + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewall.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewall.java new file mode 100644 index 0000000000..e9e8e6e8ed --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewall.java @@ -0,0 +1,47 @@ +/* + * 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.neutron.v2.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +/** + * A Firewall + * + * @see api + * doc + */ +@AutoValue +public abstract class Firewall { + + public abstract String getId(); + public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean isAdminStateUp(); + public abstract String getStatus(); + @Nullable public abstract String getFirewallPolicyId(); + + @SerializedNames({"id", "tenant_id", "name", "description", "admin_state_up", "status", "firewall_policy_id"}) + public static Firewall create(String id, String tenantId, String name, String description, Boolean adminStateUp, String status, String firewallPolicyId) { + return new AutoValue_Firewall(id, tenantId, name, description, adminStateUp, status, firewallPolicyId); + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicies.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicies.java new file mode 100644 index 0000000000..1dbf42908a --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicies.java @@ -0,0 +1,36 @@ +/* + * 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.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of FirewallPolicies + */ +public class FirewallPolicies extends PaginatedCollection { + public static final FirewallPolicies EMPTY = new FirewallPolicies(ImmutableSet. of(), ImmutableSet. of()); + + @ConstructorProperties({"firewall_policies", "firewall_policies_links"}) + protected FirewallPolicies(Iterable firewallPolicies, Iterable firewallPoliciesLinks) { + super(firewallPolicies, firewallPoliciesLinks); + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicy.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicy.java new file mode 100644 index 0000000000..d0f2fecb88 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallPolicy.java @@ -0,0 +1,48 @@ +/* + * 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.neutron.v2.domain; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +/** + * A firewall policy + * + * @see api doc + */ +@AutoValue +public abstract class FirewallPolicy { + + public abstract String getId(); + public abstract String getTenantId(); + public abstract String getName(); + @Nullable public abstract String getDescription(); + public abstract boolean isShared(); + @Nullable public abstract List getFirewallRules(); + public abstract boolean isAudited(); + + @SerializedNames({"id", "tenant_id", "name", "description", "shared", "firewall_rules", "audited"}) + private static FirewallPolicy create(String id, String tenantId, String name, String description, boolean shared, List firewallRules, boolean audited) { + return new AutoValue_FirewallPolicy(id, tenantId, name, description, shared, firewallRules, audited); + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRule.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRule.java new file mode 100644 index 0000000000..0bc23debc2 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRule.java @@ -0,0 +1,52 @@ +/* + * 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.neutron.v2.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class FirewallRule { + + public abstract String getId(); + public abstract String getTenantId(); + public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract String getFirewallPolicyId(); + public abstract boolean isShared(); + @Nullable public abstract String getProtocol(); + @Nullable public abstract IpVersion getIpVersion(); + @Nullable public abstract String getSourceIpAddress(); + @Nullable public abstract String getDestinationIpAddress(); + @Nullable public abstract String getSourcePort(); + @Nullable public abstract String getDestinationPort(); + @Nullable public abstract Integer getPosition(); // for AutoValue.builder + @Nullable public abstract String getAction(); + public abstract boolean isEnabled(); + + @SerializedNames({"id", "tenant_id", "name", "description", "firewall_policy_id", "shared", "protocol", "ip_version", "source_ip_address", + "destination_ip_address", "source_port", "destination_port", "position", "action", "enabled"}) + public static FirewallRule create(String id, String tenantId, String name, String description, String firewallPolicyId, boolean shared, String protocol, + IpVersion ipVersion, String sourceIpAddress, String destinationIpAddress, String sourcePort, String destinationPort, int position, + String action, boolean enabled) { + return new AutoValue_FirewallRule(id, tenantId, name, description, firewallPolicyId, shared, protocol, ipVersion, sourceIpAddress, + destinationIpAddress, sourcePort, destinationPort, position, action, enabled); + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRules.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRules.java new file mode 100644 index 0000000000..79281b8f8e --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/FirewallRules.java @@ -0,0 +1,36 @@ +/* + * 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.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of FirewallRules + */ +public class FirewallRules extends PaginatedCollection { + public static final FirewallRules EMPTY = new FirewallRules(ImmutableSet. of(), ImmutableSet. of()); + + @ConstructorProperties({"firewall_rules", "firewall_rules_links"}) + protected FirewallRules(Iterable firewallRules, Iterable firewallRulesLinks) { + super(firewallRules, firewallRulesLinks); + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewalls.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewalls.java new file mode 100644 index 0000000000..739e0e2faa --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/Firewalls.java @@ -0,0 +1,36 @@ +/* + * 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.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Firewalls + */ +public class Firewalls extends PaginatedCollection { + public static final Firewalls EMPTY = new Firewalls(ImmutableSet. of(), ImmutableSet. of()); + + @ConstructorProperties({"firewalls", "firewalls_links"}) + protected Firewalls(Iterable firewalls, Iterable firewallsLinks) { + super(firewalls, firewallsLinks); + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/IpVersion.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/IpVersion.java new file mode 100644 index 0000000000..c1be3476b4 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/IpVersion.java @@ -0,0 +1,50 @@ +/* + * 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.neutron.v2.domain; + +public enum IpVersion { + + IPV4(4), + IPV6(6), + UNRECOGNIZED(Integer.MAX_VALUE);; + + private final int version; + + IpVersion(int version) { + this.version = version; + } + + public int version() { + return this.version; + } + + public static IpVersion fromValue(String value) { + try { + int statusCode = Integer.parseInt(value); + switch (statusCode) { + case 4: + return IpVersion.IPV4; + case 6: + return IpVersion.IPV6; + default: + return IpVersion.IPV4; + } + } catch (NumberFormatException e) { + return IpVersion.UNRECOGNIZED; + } + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewall.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewall.java new file mode 100644 index 0000000000..10f5cab6ff --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewall.java @@ -0,0 +1,68 @@ +/* + * 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.neutron.v2.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + + +/** + * Representation of update options for an OpenStack Neutron Firewall. + * + * @see api + * doc + */ +@AutoValue +public abstract class UpdateFirewall { + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getAdminStateUp(); + @Nullable public abstract String getFirewallPolicyId(); + + @SerializedNames({"tenant_id", "name", "description", "admin_state_up", "firewall_policy_id"}) + public static UpdateFirewall create(String tenantId, String name, String description, Boolean adminStateUp, String firewallPolicyId) { + return builder().tenantId(tenantId).name(name).description(description).adminStateUp(adminStateUp).firewallPolicyId(firewallPolicyId).build(); + } + + public static Builder builder() { + return new AutoValue_UpdateFirewall.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder tenantId(String tenantId); + public abstract Builder name(String name); + public abstract Builder description(String description); + public abstract Builder adminStateUp(Boolean adminStateUp); + public abstract Builder firewallPolicyId(String firewallPolicyId); + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getAdminStateUp(); + @Nullable public abstract String getFirewallPolicyId(); + + public abstract UpdateFirewall build(); + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallPolicy.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallPolicy.java new file mode 100644 index 0000000000..3791b34e1b --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallPolicy.java @@ -0,0 +1,80 @@ +/* + * 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.neutron.v2.domain; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +/** + * Representation of update options for an OpenStack Neutron Firewall Policy. + * + * @see api + * doc + */ +@AutoValue +public abstract class UpdateFirewallPolicy { + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getShared(); + @Nullable public abstract List getFirewallRules(); + @Nullable public abstract Boolean getAudited(); + + @SerializedNames({"tenant_id", "name", "description", "shared", "firewall_rules", "audited"}) + private static UpdateFirewallPolicy create(String tenantId, String name, String description, Boolean shared, List firewallRules, Boolean audited) { + return builder().tenantId(tenantId).name(name).description(description).shared(shared).firewallRules(firewallRules).audited(audited).build(); + } + + public static Builder builder() { + return new AutoValue_UpdateFirewallPolicy.Builder().shared(false).audited(false); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder tenantId(String tenantId); + public abstract Builder name(String name); + public abstract Builder description(String description); + public abstract Builder shared(Boolean shared); + public abstract Builder firewallRules(List firewallRules); + public abstract Builder audited(Boolean audited); + + abstract UpdateFirewallPolicy autoBuild(); + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract Boolean getShared(); + @Nullable public abstract List getFirewallRules(); + @Nullable public abstract Boolean getAudited(); + + public UpdateFirewallPolicy build() { + firewallRules(getFirewallRules() != null ? ImmutableList.copyOf(getFirewallRules()) : ImmutableList.of()); + return autoBuild(); + } + + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallRule.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallRule.java new file mode 100644 index 0000000000..b66e9027b9 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/UpdateFirewallRule.java @@ -0,0 +1,100 @@ +/* + * 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.neutron.v2.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +/** + * Representation of update options for an OpenStack Neutron Firewall Rule. + * + * @see api + * doc + */ +@AutoValue +public abstract class UpdateFirewallRule { + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract String getFirewallPolicyId(); + @Nullable public abstract Boolean getShared(); + @Nullable public abstract String getProtocol(); + @Nullable public abstract IpVersion getIpVersion(); + @Nullable public abstract String getSourceIpAddress(); + @Nullable public abstract String getDestinationIpAddress(); + @Nullable public abstract String getSourcePort(); + @Nullable public abstract String getDestinationPort(); + @Nullable public abstract Integer getPosition(); + @Nullable public abstract String getAction(); + @Nullable public abstract Boolean getEnabled(); + + @SerializedNames({ "tenant_id", "name", "description", "firewall_policy_id", "shared", "protocol", "ip_version", "source_ip_address", + "destination_ip_address", "source_port", "destination_port", "position", "action", "enabled"}) + public static UpdateFirewallRule create(String tenantId, String name, String description, String firewallPolicyId, Boolean shared, String protocol, + IpVersion ipVersion, String sourceIpAddress, String destinationIpAddress, String sourcePort, String destinationPort, int position, + String action, Boolean enabled) { + return builder().tenantId(tenantId).name(name).description(description).firewallPolicyId(firewallPolicyId).shared(shared) + .protocol(protocol).ipVersion(ipVersion).sourceIpAddress(sourceIpAddress).destinationIpAddress(destinationIpAddress).sourcePort(sourcePort) + .destinationPort(destinationPort).position(position).action(action).enabled(enabled).build(); + } + + public static Builder builder() { + return new AutoValue_UpdateFirewallRule.Builder().shared(false).enabled(false).position(null); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder tenantId(String tenantId); + public abstract Builder name(String name); + public abstract Builder description(String description); + public abstract Builder firewallPolicyId(String firewallPolicyId); + public abstract Builder shared(Boolean shared); + public abstract Builder protocol(String protocol); + public abstract Builder ipVersion(IpVersion ipVersion); + public abstract Builder sourceIpAddress(String sourceIpAddress); + public abstract Builder destinationIpAddress(String destinationIpAddress); + public abstract Builder sourcePort(String sourcePort); + public abstract Builder destinationPort(String destinationPort); + public abstract Builder position(Integer position); + public abstract Builder action(String action); + public abstract Builder enabled(Boolean enabled); + + @Nullable public abstract String getTenantId(); + @Nullable public abstract String getName(); + @Nullable public abstract String getDescription(); + @Nullable public abstract String getFirewallPolicyId(); + @Nullable public abstract Boolean getShared(); + @Nullable public abstract String getProtocol(); + @Nullable public abstract IpVersion getIpVersion(); + @Nullable public abstract String getSourceIpAddress(); + @Nullable public abstract String getDestinationIpAddress(); + @Nullable public abstract String getSourcePort(); + @Nullable public abstract String getDestinationPort(); + @Nullable public abstract Integer getPosition(); + @Nullable public abstract String getAction(); + @Nullable public abstract Boolean getEnabled(); + + public abstract UpdateFirewallRule build(); + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java index 60d23a32a3..2130972a14 100644 --- a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java @@ -32,6 +32,10 @@ public final class ExtensionNamespaces { * LBaaS Extension. */ public static final String LBAAS = "http://wiki.openstack.org/neutron/LBaaS/API_1.0"; + /** + * FWaaS Extension. + */ + public static final String FWAAS = "http://wiki.openstack.org/Neutron/FWaaS/API_1.0"; private ExtensionNamespaces() { throw new AssertionError("intentionally unimplemented"); diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApi.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApi.java new file mode 100644 index 0000000000..6c5338f50b --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApi.java @@ -0,0 +1,253 @@ +/* + * 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.neutron.v2.extensions; + +import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import static org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import static org.jclouds.Fallbacks.NullOnNotFoundOr404; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.collect.PagedIterable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewall; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewallRule; +import org.jclouds.openstack.neutron.v2.domain.Firewall; +import org.jclouds.openstack.neutron.v2.domain.FirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.FirewallRule; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewall; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewallRule; +import org.jclouds.openstack.neutron.v2.functions.FirewallPolicyToPagedIterable; +import org.jclouds.openstack.neutron.v2.functions.FirewallRuleToPagedIterable; +import org.jclouds.openstack.neutron.v2.functions.FirewallToPagedIterable; +import org.jclouds.openstack.neutron.v2.functions.ParseFirewallPolicies; +import org.jclouds.openstack.neutron.v2.functions.ParseFirewallRules; +import org.jclouds.openstack.neutron.v2.functions.ParseFirewalls; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.openstack.v2_0.services.Extension; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.annotations.WrapWith; + +import com.google.common.annotations.Beta; + +/** + * The FWaaS extension provides OpenStack users with the ability to deploy firewalls to protect their networks. + *

+ * + * @see api doc + */ +@Beta +@Path("/fw") +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +@Extension(of = ServiceType.NETWORK, namespace = ExtensionNamespaces.FWAAS) +public interface FWaaSApi { + + /** + * Returns the list of all routers currently defined in Neutron for the current tenant. The list provides the unique + * identifier of each firewall configured for the tenant + * + * @return the list of all firewall references configured for the tenant. + */ + @Named("fw:list") + @GET + @Transform(FirewallToPagedIterable.class) + @ResponseParser(ParseFirewalls.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + @Path("/firewalls") + PagedIterable list(); + + /** + * @return the list of all firewall references configured for the tenant. + */ + @Named("firewall:list") + @GET + @ResponseParser(ParseFirewalls.class) + @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) + @Path("/firewalls") + PaginatedCollection list(PaginationOptions options); + + /** + * Returns the details for a specific firewall. + * + * @param id the id of the firewall to return + * @return firewall or empty if not found + */ + @Named("firewall:get") + @GET + @Path("/firewalls/{id}") + @SelectJson("firewall") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Firewall get(@PathParam("id") String id); + + /** + * Create a new firewall + * + * @param firewall Options for creating a firewall + * @return the newly created firewall + */ + @Named("firewall:create") + @POST + @SelectJson("firewall") + @Path("/firewalls") + Firewall create(@WrapWith("firewall") CreateFirewall firewall); + + /** + * Update a firewall + * + * @param id the id of the firewall to update + * @param updateFirewall Contains only the attributes to update + * @return The modified firewall + */ + @Named("firewall:update") + @PUT + @Path("/firewalls/{id}") + @SelectJson("firewall") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Firewall update(@PathParam("id") String id, @WrapWith("firewall") UpdateFirewall updateFirewall); + + /** + * Deletes the specified firewall + * + * @param id the id of the firewall to delete + * @return true if delete successful, false if not + */ + @Named("firewall:delete") + @DELETE + @Path("/firewalls/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); + + @Named("firewall:createPolicy") + @POST + @SelectJson("firewall_policy") + @Path("/firewall_policies") + FirewallPolicy createFirewallPolicy(@WrapWith("firewall_policy") CreateFirewallPolicy firewallPolicy); + + @Named("firewall:listPolicies") + @GET + @Transform(FirewallPolicyToPagedIterable.class) + @ResponseParser(ParseFirewallPolicies.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + @Path("/firewall_policies") + PagedIterable listFirewallPolicies(); + + @Named("firewall:listPolicies") + @GET + @ResponseParser(ParseFirewallPolicies.class) + @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) + @Path("/firewall_policies") + PaginatedCollection listFirewallPolicies(PaginationOptions options); + + @Named("firewall:getPolicy") + @GET + @SelectJson("firewall_policy") + @Fallback(NullOnNotFoundOr404.class) + @Path("/firewall_policies/{id}") + FirewallPolicy getFirewallPolicy(@PathParam("id") String id); + + @Named("firewall:updatePolicy") + @PUT + @SelectJson("firewall_policy") + @Fallback(NullOnNotFoundOr404.class) + @Path("/firewall_policies/{id}") + FirewallPolicy updateFirewallPolicy(@PathParam("id") String id, @WrapWith("firewall_policy") UpdateFirewallPolicy updateFirewallPolicy); + + @Named("firewall:deletePolicy") + @DELETE + @Path("/firewall_policies/{id}") + boolean deleteFirewallPolicy(@PathParam("id") String id); + + @Named("firewall:createFirewallRule") + @POST + @SelectJson("firewall_rule") + @Path("/firewall_rules") + FirewallRule createFirewallRule(@WrapWith("firewall_rule") CreateFirewallRule firewallRule); + + @Named("firewall:listFirewallRules") + @GET + @Transform(FirewallRuleToPagedIterable.class) + @ResponseParser(ParseFirewallRules.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + @Path("/firewall_rules") + PagedIterable listFirewallRules(); + + @Named("firewall:listFirewallRules") + @GET + @ResponseParser(ParseFirewallRules.class) + @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) + @Path("/firewall_rules") + PaginatedCollection listFirewallRules(PaginationOptions options); + + @Named("firewall:getFirewallRule") + @GET + @Path("/firewall_rules/{id}") + @SelectJson("firewall_rule") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + FirewallRule getFirewallRule(@PathParam("id") String firewallRuleId); + + @Named("firewall:updateFirewallRule") + @PUT + @Path("/firewall_rules/{id}") + @SelectJson("firewall_rule") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + FirewallRule updateFirewallRule(@PathParam("id") String id, @WrapWith("firewall_rule") UpdateFirewallRule updateFirewallRule); + + @Named("firewall:deleteFirewallRule") + @DELETE + @Path("/firewall_rules/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean deleteFirewallRule(@PathParam("id") String id); + + @Named("firewall:insertFirewallRuleToPolicy") + @PUT + @Path("/firewall_policies/{id}/insert_rule") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + FirewallPolicy insertFirewallRuleToPolicy(@PathParam("id") String policyId, @WrapWith("firewall_rule_id") String firewallRuleId); + + @Named("firewall:removeFirewallRuleFromPolicy") + @DELETE + @Path("/firewall_policies/{id}/remove_rule") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + FirewallPolicy removeFirewallRuleFromPolicy(@PathParam("id") String policyId, @WrapWith("firewall_rule_id") String firewallRuleId); + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallPolicyToPagedIterable.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallPolicyToPagedIterable.java new file mode 100644 index 0000000000..f70a83db8a --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallPolicyToPagedIterable.java @@ -0,0 +1,63 @@ +/* + * 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.neutron.v2.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.FirewallPolicy; +import org.jclouds.openstack.neutron.v2.extensions.FWaaSApi; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Ensures FirewallRule works as PagedIterable. + */ +public class FirewallPolicyToPagedIterable extends Arg0ToPagedIterable.FromCaller { + + private final NeutronApi api; + + @Inject + protected FirewallPolicyToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function> markerToNextForArg0(Optional arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final FWaaSApi firewallApi = api.getFWaaSApi(region).get(); + return new Function>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker apply(Object input) { + return IterableWithMarker.class.cast(firewallApi.listFirewallPolicies()); + } + + @Override + public String toString() { + return "listFirewallPolicies()"; + } + }; + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallRuleToPagedIterable.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallRuleToPagedIterable.java new file mode 100644 index 0000000000..eff4dc1692 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallRuleToPagedIterable.java @@ -0,0 +1,63 @@ +/* + * 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.neutron.v2.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.FirewallRule; +import org.jclouds.openstack.neutron.v2.extensions.FWaaSApi; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Ensures FirewallRule works as PagedIterable. + */ +public class FirewallRuleToPagedIterable extends Arg0ToPagedIterable.FromCaller { + + private final NeutronApi api; + + @Inject + protected FirewallRuleToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function> markerToNextForArg0(Optional arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final FWaaSApi firewallApi = api.getFWaaSApi(region).get(); + return new Function>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker apply(Object input) { + return IterableWithMarker.class.cast(firewallApi.listFirewallRules()); + } + + @Override + public String toString() { + return "listFirewallRules()"; + } + }; + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallToPagedIterable.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallToPagedIterable.java new file mode 100644 index 0000000000..5d6892a056 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/FirewallToPagedIterable.java @@ -0,0 +1,63 @@ +/* + * 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.neutron.v2.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.Firewall; +import org.jclouds.openstack.neutron.v2.extensions.FWaaSApi; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Ensures Firewall works as PagedIterable. + */ +public class FirewallToPagedIterable extends Arg0ToPagedIterable.FromCaller { + + private final NeutronApi api; + + @Inject + protected FirewallToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function> markerToNextForArg0(Optional arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final FWaaSApi firewallApi = api.getFWaaSApi(region).get(); + return new Function>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker apply(Object input) { + return IterableWithMarker.class.cast(firewallApi.list()); + } + + @Override + public String toString() { + return "listFirewalls()"; + } + }; + } + +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallPolicies.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallPolicies.java new file mode 100644 index 0000000000..4773e2ba78 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallPolicies.java @@ -0,0 +1,38 @@ +/* + * 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.neutron.v2.functions; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.FirewallPolicies; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseFirewallPolicies extends ParseJson { + + @Inject + public ParseFirewallPolicies(Json json) { + super(json, TypeLiteral.get(FirewallPolicies.class)); + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallRules.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallRules.java new file mode 100644 index 0000000000..126a2ce3a2 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewallRules.java @@ -0,0 +1,38 @@ +/* + * 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.neutron.v2.functions; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.FirewallRules; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseFirewallRules extends ParseJson { + + @Inject + public ParseFirewallRules(Json json) { + super(json, TypeLiteral.get(FirewallRules.class)); + } +} diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewalls.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewalls.java new file mode 100644 index 0000000000..89208cd505 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFirewalls.java @@ -0,0 +1,38 @@ +/* + * 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.neutron.v2.functions; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.Firewalls; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseFirewalls extends ParseJson { + + @Inject + public ParseFirewalls(Json json) { + super(json, TypeLiteral.get(Firewalls.class)); + } +} diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiLiveTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiLiveTest.java new file mode 100644 index 0000000000..62f09fb51a --- /dev/null +++ b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiLiveTest.java @@ -0,0 +1,199 @@ +/* + * 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.neutron.v2.extensions; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.neutron.v2.domain.CreateFirewall; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewallRule; +import org.jclouds.openstack.neutron.v2.domain.Firewall; +import org.jclouds.openstack.neutron.v2.domain.FirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.FirewallRule; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewall; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewallRule; +import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.google.common.base.Optional; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; + +/** + * Tests parsing and Guice wiring of FWaaSApi + */ +@Test(groups = "live", testName = "FWaaSApiLiveTest") +public class FWaaSApiLiveTest extends BaseNeutronApiLiveTest { + + private FWaaSApi fWaaSApi; + + @BeforeMethod + void setUp() { + Optional optionalRegion = Iterables.tryFind(api.getConfiguredRegions(), Predicates.notNull()); + if (!optionalRegion.isPresent()) Assert.fail(); + fWaaSApi = api.getFWaaSApi(optionalRegion.get()).get(); + } + /** + * Smoke test for the Firewall extension for Neutron + */ + public void testCreateUpdateAndDeleteFirewallRule() { + + String inboundPort = "22"; + FirewallRule firewallRule = null; + + try { + // methods under test + firewallRule = fWaaSApi.createFirewallRule(CreateFirewallRule.builder() + .name(String.format("jclouds-test-%s-fw-rule-%s", this.getClass().getCanonicalName().toLowerCase(), inboundPort)) + .description("jclouds test fw rule") + .destinationIpAddress("192.168.0.1") + .destinationPort(inboundPort) + .enabled(true) + .action("allow") + .protocol("tcp") + .build()); + + assertFalse(fWaaSApi.listFirewallRules().concat().toList().isEmpty()); + assertNotNull(fWaaSApi.listFirewallRules(PaginationOptions.Builder.limit(1))); + + // get + firewallRule = fWaaSApi.getFirewallRule(firewallRule.getId()); + assertEquals(firewallRule.getName(), String.format("jclouds-test-%s-fw-rule-%s", this.getClass().getCanonicalName().toLowerCase(), inboundPort)); + assertEquals(firewallRule.getDescription(), "jclouds test fw rule"); + + // update + FirewallRule updatedFirewallRule = fWaaSApi.updateFirewallRule(firewallRule.getId(), UpdateFirewallRule.builder().name(firewallRule.getName() + "-updated").build()); + firewallRule = fWaaSApi.getFirewallRule(firewallRule.getId()); + assertEquals(updatedFirewallRule, firewallRule); + } finally { + // delete + if (fWaaSApi != null) { + assertTrue(fWaaSApi.deleteFirewallRule(firewallRule.getId())); + } + } + } + + public void testCreateUpdateAndDeleteFirewallPolicy() { + + String inboundPort = "80"; + FirewallRule firewallRule = fWaaSApi.createFirewallRule(CreateFirewallRule.builder() + .name(String.format("jclouds-test-%s-fw-rule-%s", this.getClass().getCanonicalName().toLowerCase(), inboundPort)) + .description("jclouds test fw rule") + .destinationIpAddress("192.168.0.1") + .destinationPort(inboundPort) + .enabled(true) + .action("allow") + .protocol("tcp") + .build()); + FirewallPolicy firewallPolicy = null; + + try { + // methods under test + firewallPolicy = fWaaSApi.createFirewallPolicy(CreateFirewallPolicy.builder() + .name(String.format("jclouds-test-%s-fw-policy", this.getClass().getCanonicalName().toLowerCase())) + .description("jclouds test fw policy") + .build()); + + assertFalse(fWaaSApi.listFirewallPolicies().concat().toList().isEmpty()); + assertNotNull(fWaaSApi.listFirewallPolicies(PaginationOptions.Builder.limit(1))); + + // get + firewallPolicy = fWaaSApi.getFirewallPolicy(firewallPolicy.getId()); + assertEquals(firewallPolicy.getName(), String.format("jclouds-test-%s-fw-policy", this.getClass().getCanonicalName().toLowerCase())); + assertEquals(firewallPolicy.getDescription(), "jclouds test fw policy"); + + // update + FirewallPolicy updatedFirewallPolicy = fWaaSApi.updateFirewallPolicy(firewallPolicy.getId(), UpdateFirewallPolicy.builder() + .name(String.format("jclouds-test-%s-fw-policy-update", this.getClass().getCanonicalName().toLowerCase())).build()); + firewallPolicy = fWaaSApi.getFirewallPolicy(firewallPolicy.getId()); + assertEquals(updatedFirewallPolicy, firewallPolicy); + + firewallPolicy = fWaaSApi.insertFirewallRuleToPolicy(firewallPolicy.getId(), firewallRule.getId()); + assertNotNull(firewallPolicy); + assertFalse(firewallPolicy.getFirewallRules().isEmpty()); + + firewallPolicy = fWaaSApi.removeFirewallRuleFromPolicy(firewallPolicy.getId(), firewallRule.getId()); + assertNotNull(firewallPolicy); + assertTrue(firewallPolicy.getFirewallRules().isEmpty()); + } finally { + // delete + if (fWaaSApi != null) { + try { + if (firewallPolicy != null) { + assertTrue(fWaaSApi.deleteFirewallPolicy(firewallPolicy.getId())); + } + } finally { + assertTrue(fWaaSApi.deleteFirewallRule(firewallRule.getId())); + } + } + } + } + + public void testCreateUpdateAndDeleteFirewall() { + + FirewallPolicy firewallPolicy = fWaaSApi.createFirewallPolicy(CreateFirewallPolicy.builder() + .name(String.format("jclouds-test-%s-fw-policy", this.getClass().getCanonicalName().toLowerCase())) + .description("jclouds test fw policy") + .build()); + + Firewall firewall = null; + + try { + // methods under test + firewall = fWaaSApi.create(CreateFirewall.builder().name(String.format("jclouds-test-%s-fw", this.getClass().getCanonicalName().toLowerCase())) + .description("jclouds test firewall") + .firewallPolicyId(firewallPolicy.getId()) + .build()); + + assertFalse(fWaaSApi.list().concat().toList().isEmpty()); + assertNotNull(fWaaSApi.list(PaginationOptions.Builder.limit(1))); + + // get + firewall = fWaaSApi.get(firewall.getId()); + assertEquals(firewall.getName(), String.format("jclouds-test-%s-fw", this.getClass().getCanonicalName().toLowerCase())); + assertEquals(firewall.getDescription(), "jclouds test firewall"); + + // update + Firewall updatedFirewall = fWaaSApi.update(firewall.getId(), UpdateFirewall.builder().name(String.format("jclouds-test-%s-fw_updated", this.getClass() + .getCanonicalName().toLowerCase())).build()); + firewall = fWaaSApi.get(firewall.getId()); + assertEquals(updatedFirewall, firewall); + + } finally { + // delete + if (fWaaSApi != null) { + try { + if (firewallPolicy != null) { + assertTrue(fWaaSApi.deleteFirewallPolicy(firewallPolicy.getId())); + } + } finally { + if (firewall != null) { + assertTrue(fWaaSApi.delete(firewall.getId())); + } } + } + } + } + +} diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiMockTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiMockTest.java new file mode 100644 index 0000000000..fe7a879385 --- /dev/null +++ b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/FWaaSApiMockTest.java @@ -0,0 +1,984 @@ +/* + * 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.neutron.v2.extensions; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; + +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewall; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.CreateFirewallRule; +import org.jclouds.openstack.neutron.v2.domain.Firewall; +import org.jclouds.openstack.neutron.v2.domain.FirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.FirewallRule; +import org.jclouds.openstack.neutron.v2.domain.FloatingIP; +import org.jclouds.openstack.neutron.v2.domain.FloatingIPs; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewall; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewallPolicy; +import org.jclouds.openstack.neutron.v2.domain.UpdateFirewallRule; +import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rest.ResourceNotFoundException; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; + +/** + * Tests Floating Api Guice wiring and parsing + * + */ +@Test +public class FWaaSApiMockTest extends BaseNeutronApiMockTest { + + public void testCreateFirewall() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_create_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + CreateFirewall firewallRequest = CreateFirewall.builder() + .firewallPolicyId("c69933c1-b472-44f9-8226-30dc4ffd454c") + .adminStateUp(Boolean.TRUE) + .build(); + + Firewall firewall = api.create(firewallRequest); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "POST", uriApiVersion + "/fw/firewalls", "/firewall_create_request.json"); + + /* + * Check response + */ + assertNotNull(firewall); + assertEquals(firewall.getName(), ""); + assertEquals(firewall.getTenantId(), "45977fa2dbd7482098dd68d0d8970117"); + assertEquals(firewall.getDescription(), ""); + assertEquals(firewall.getId(), "3b0ef8f4-82c7-44d4-a4fb-6177f9a21977"); + assertEquals(firewall.getStatus(), "PENDING_CREATE"); + assertTrue(firewall.isAdminStateUp()); + assertEquals(firewall.getFirewallPolicyId(), "c69933c1-b472-44f9-8226-30dc4ffd454c"); + } finally { + server.shutdown(); + } + } + + @Test(expectedExceptions = ResourceNotFoundException.class) + public void testCreateFirewallFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + CreateFirewall firewallRequest = CreateFirewall.builder() + .firewallPolicyId("c69933c1-b472-44f9-8226-30dc4ffd454c") + .adminStateUp(Boolean.TRUE) + .build(); + + Firewall firewall = api.create(firewallRequest); + } finally { + server.shutdown(); + } + } + + public void testListSpecificPageFirewall() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/firewall_list_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + PaginatedCollection firewalls = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg")); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewalls?limit=2&marker=abcdefg"); + + /* + * Check response + */ + assertNotNull(firewalls); + assertEquals(firewalls.size(), 1); + assertEquals(Iterables.getFirst(firewalls, null).getId(), "5eb708e7-3856-449a-99ac-fec27cd745f9"); + assertEquals(firewalls.get(0).getId(), "5eb708e7-3856-449a-99ac-fec27cd745f9"); + } finally { + server.shutdown(); + } + } + + public void testListSpecificPageFirewallFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); + + FloatingIPs floatingIPs = api.list(PaginationOptions.Builder.limit(2).marker("abcdefg")); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/floatingips?limit=2&marker=abcdefg"); + + /* + * Check response + */ + assertNotNull(floatingIPs); + assertTrue(floatingIPs.isEmpty()); + } finally { + server.shutdown(); + } + } + + public void testListPagedFirewall() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged1.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/floatingip_list_response_paged2.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); + + // Note: Lazy! Have to actually look at the collection. + List floatingIPs = api.list().concat().toList(); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 4); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/floatingips"); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/floatingips?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718"); + + /* + * Check response + */ + assertNotNull(floatingIPs); + assertEquals(floatingIPs.size(), 4); + assertEquals(floatingIPs.get(0).getId(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7"); + assertEquals(floatingIPs.get(3).getId(), "61cea855-49cb-4846-997d-801b70c71bdd2"); + } finally { + server.shutdown(); + } + } + + public void testListPagedFirewallFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FloatingIPApi api = neutronApi.getFloatingIPApi("RegionOne").get(); + + // Note: Lazy! Have to actually look at the collection. + List floatingIPs = api.list().concat().toList(); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/floatingips"); + + /* + * Check response + */ + assertNotNull(floatingIPs); + assertTrue(floatingIPs.isEmpty()); + } finally { + server.shutdown(); + } + } + + public void testGetFirewall() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_get_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + Firewall firewall = api.get("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewalls/12345"); + + /* + * Check response + */ + assertNotNull(firewall); + assertEquals(firewall.getId(), "3b0ef8f4-82c7-44d4-a4fb-6177f9a21977"); + assertEquals(firewall.getTenantId(), "45977fa2dbd7482098dd68d0d8970117"); + assertEquals(firewall.getDescription(), ""); + assertEquals(firewall.getName(), ""); + assertEquals(firewall.getStatus(), "ACTIVE"); + assertEquals(firewall.getFirewallPolicyId(), "c69933c1-b472-44f9-8226-30dc4ffd454c"); + + } finally { + server.shutdown(); + } + } + + public void testGetFirewallFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + Firewall firewall = api.get("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewalls/12345"); + + /* + * Check response + */ + assertNull(firewall); + + } finally { + server.shutdown(); + } + } + + public void testUpdateFirewall() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_update_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + UpdateFirewall updateFirewall = UpdateFirewall.builder() + .adminStateUp(false) + .build(); + + Firewall firewall = api.update("12345", updateFirewall); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewalls/12345", "/firewall_update_request.json"); + + /* + * Check response + */ + assertNotNull(firewall); + assertFalse(firewall.isAdminStateUp()); + + } finally { + server.shutdown(); + } + } + + public void testUpdateFirewallFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + UpdateFirewall updateFirewall = UpdateFirewall.builder() + .adminStateUp(false) + .build(); + + Firewall firewall = api.update("12345", updateFirewall); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewalls/12345", "/firewall_update_request.json"); + + /* + * Check response + */ + assertNull(firewall); + } finally { + server.shutdown(); + } + } + + public void testDeleteFirewall() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + boolean result = api.delete("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "DELETE", uriApiVersion + "/fw/firewalls/12345"); + + /* + * Check response + */ + assertTrue(result); + } finally { + server.shutdown(); + } + } + + public void testDeleteFirewallFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + boolean result = api.delete("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "DELETE", uriApiVersion + "/fw/firewalls/12345"); + + /* + * Check response + */ + assertFalse(result); + } finally { + server.shutdown(); + } + } + + public void testCreateFirewallPolicy() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_policy_create_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + CreateFirewallPolicy firewallPolicyRequest = CreateFirewallPolicy.builder() + .name("jclouds-fw-policy_group-52-e8b") + .build(); + + FirewallPolicy firewallPolicy = api.createFirewallPolicy(firewallPolicyRequest); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "POST", uriApiVersion + "/fw/firewall_policies", "/firewall_policy_create_request.json"); + + /* + * Check response + */ + assertNotNull(firewallPolicy); + assertEquals(firewallPolicy.getName(), "jclouds-fw-policy_group-52-e8b"); + assertEquals(firewallPolicy.getTenantId(), "3e00d5716204446c8d3c47a466eec25a"); + assertEquals(firewallPolicy.getDescription(), ""); + assertEquals(firewallPolicy.getId(), "12971159-95cf-4ca1-9baa-c82298ae0918"); + assertEquals(firewallPolicy.isShared(), false); + assertEquals(firewallPolicy.getFirewallRules(), ImmutableList.of()); + assertEquals(firewallPolicy.isAudited(), false); + } finally { + server.shutdown(); + } + } + + @Test(expectedExceptions = ResourceNotFoundException.class) + public void testCreateFirewallPolicyFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + CreateFirewallPolicy firewallPolicyRequest = CreateFirewallPolicy.builder() + .name("jclouds-fw-policy_group-52-e8b") + .build(); + + FirewallPolicy firewallPolicy = api.createFirewallPolicy(firewallPolicyRequest); + + } finally { + server.shutdown(); + } + } + + public void testGetFirewallPolicy() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_policy_get_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + FirewallPolicy firewallPolicy = api.getFirewallPolicy("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewall_policies/12345"); + + /* + * Check response + */ + assertNotNull(firewallPolicy); + assertEquals(firewallPolicy.getId(), "18d2f4e5-afdd-4c10-87ea-d35f38faf98c"); + assertEquals(firewallPolicy.getTenantId(), "e1defcdd823741c89afd5824040deed2"); + assertEquals(firewallPolicy.getDescription(), ""); + assertEquals(firewallPolicy.getName(), "myfirewallrule"); + assertEquals(firewallPolicy.isAudited(), false); + assertEquals(firewallPolicy.isShared(), true); + + } finally { + server.shutdown(); + } + } + + public void testGetFirewallPolicyFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + FirewallPolicy firewallPolicy = api.getFirewallPolicy("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewall_policies/12345"); + + /* + * Check response + */ + assertNull(firewallPolicy); + + } finally { + server.shutdown(); + } + } + + public void testUpdateFirewallPolicy() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_policy_get_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + UpdateFirewallPolicy updateFirewallPolicy = UpdateFirewallPolicy.builder() + .shared(true) + .build(); + + FirewallPolicy firewallPolicy = api.updateFirewallPolicy("12345", updateFirewallPolicy); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewall_policies/12345"); + + /* + * Check response + */ + assertNotNull(firewallPolicy); + assertEquals(firewallPolicy.getId(), "18d2f4e5-afdd-4c10-87ea-d35f38faf98c"); + assertEquals(firewallPolicy.getTenantId(), "e1defcdd823741c89afd5824040deed2"); + assertEquals(firewallPolicy.getDescription(), ""); + assertEquals(firewallPolicy.getName(), "myfirewallrule"); + assertEquals(firewallPolicy.isAudited(), false); + assertEquals(firewallPolicy.isShared(), true); + + } finally { + server.shutdown(); + } + } + + public void testUpdateFirewallPolicyFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + UpdateFirewallPolicy updateFirewallPolicy = UpdateFirewallPolicy.builder() + .shared(true) + .build(); + + FirewallPolicy firewallPolicy = api.updateFirewallPolicy("12345", updateFirewallPolicy); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewall_policies/12345"); + + /* + * Check response + */ + assertNull(firewallPolicy); + + } finally { + server.shutdown(); + } + } + + public void testInsertFirewallRuleIntoFirewallPolicy() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_policy_insert_rule_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + FirewallPolicy updatedFirewallPolicy = api.insertFirewallRuleToPolicy("12345", "59585143-e819-48c9-944d-f03e0f049dba"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewall_policies/12345/insert_rule", "/firewall_policy_insert_rule_request.json"); + + /* + * Check response + */ + assertNotNull(updatedFirewallPolicy); + + } finally { + server.shutdown(); + } + } + + public void testInsertFirewallRuleIntoFirewallPolicyFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + FirewallPolicy updatedFirewallPolicy = api.insertFirewallRuleToPolicy("12345", "59585143-e819-48c9-944d-f03e0f049dba"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewall_policies/12345/insert_rule", "/firewall_policy_insert_rule_request.json"); + + /* + * Check response + */ + assertNull(updatedFirewallPolicy); + } finally { + server.shutdown(); + } + } + + public void testCreateFirewallRule() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_rule_create_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + CreateFirewallRule firewallRuleRequest = CreateFirewallRule.builder() + .name("jclouds-fw-rule_group-52-e8b_port-22") + .tenantId("3e00d5716204446c8d3c47a466eec25a") + .protocol("tcp") + .destinationIpAddress("192.168.0.117") + .destinationPort("22") + .action("allow") + .shared(false) + .enabled(true) + .build(); + + FirewallRule firewallRule = api.createFirewallRule(firewallRuleRequest); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "POST", uriApiVersion + "/fw/firewall_rules", "/firewall_rule_create_request.json"); + + /* + * Check response + */ + assertNotNull(firewallRule); + assertEquals(firewallRule.getName(), "jclouds-fw-rule_group-52-e8b_port-22"); + assertEquals(firewallRule.getTenantId(), "3e00d5716204446c8d3c47a466eec25a"); + assertEquals(firewallRule.getDescription(), ""); + assertEquals(firewallRule.getId(), "59585143-e819-48c9-944d-f03e0f049dba"); + assertEquals(firewallRule.isShared(), false); + assertEquals(firewallRule.isEnabled(), true); + } finally { + server.shutdown(); + } + } + + @Test(expectedExceptions = ResourceNotFoundException.class) + public void testCreateFirewallRuleFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + CreateFirewallRule firewallRuleRequest = CreateFirewallRule.builder() + .name("jclouds-fw-rule_group-52-e8b_port-22") + .build(); + + FirewallRule firewallRule = api.createFirewallRule(firewallRuleRequest); + + } finally { + server.shutdown(); + } + } + + public void testGetFirewallRule() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_rule_get_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + FirewallRule firewallRule = api.getFirewallRule("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewall_rules/12345"); + + /* + * Check response + */ + assertNotNull(firewallRule); + assertEquals(firewallRule.getId(), "736b1686-3301-4a3d-9eaf-15e3c2682edc"); + assertEquals(firewallRule.getTenantId(), "3e00d5716204446c8d3c47a466eec25a"); + assertEquals(firewallRule.getDescription(), "jclouds test fw rule"); + assertEquals(firewallRule.getName(), "jclouds-test-org.jclouds.openstack.neutron.v2.extensions.fwaasapilivetest-fw-rule-22"); + assertEquals(firewallRule.getAction(), "allow"); + assertEquals(firewallRule.isEnabled(), true); + assertEquals(firewallRule.getIpVersion().version(), 4); + assertEquals(firewallRule.isShared(), false); + + } finally { + server.shutdown(); + } + } + + public void testGetFirewallRuleFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + FirewallRule firewallRule = api.getFirewallRule("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "GET", uriApiVersion + "/fw/firewall_rules/12345"); + + /* + * Check response + */ + assertNull(firewallRule); + + } finally { + server.shutdown(); + } + } + + public void testUpdateFirewallRule() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201).setBody(stringFromResource("/firewall_rule_update_response.json")))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + UpdateFirewallRule updateFirewallRule = UpdateFirewallRule.builder() + .build(); + + FirewallRule firewallRule = api.updateFirewallRule("12345", updateFirewallRule); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewall_rules/12345", "/firewall_rule_update_request.json"); + + /* + * Check response + */ + assertNotNull(firewallRule); + + } finally { + server.shutdown(); + } + } + + public void testUpdateFirewallRuleFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + UpdateFirewallRule updateFirewallRule = UpdateFirewallRule.builder() + .build(); + + FirewallRule firewallRule = api.updateFirewallRule("12345", updateFirewallRule); + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "PUT", uriApiVersion + "/fw/firewall_rules/12345", "/firewall_rule_update_request.json"); + + /* + * Check response + */ + assertNull(firewallRule); + } finally { + server.shutdown(); + } + } + + public void testDeleteFirewallRule() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(201))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + boolean result = api.deleteFirewallRule("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "DELETE", uriApiVersion + "/fw/firewall_rules/12345"); + + /* + * Check response + */ + assertTrue(result); + } finally { + server.shutdown(); + } + } + + public void testDeleteFirewallRuleFail() throws IOException, InterruptedException, URISyntaxException { + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list.json")))); + server.enqueue(addCommonHeaders( + new MockResponse().setResponseCode(404))); + + try { + NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides); + FWaaSApi api = neutronApi.getFWaaSApi("RegionOne").get(); + + boolean result = api.deleteFirewallRule("12345"); + + /* + * Check request + */ + assertEquals(server.getRequestCount(), 3); + assertAuthentication(server); + assertExtensions(server, uriApiVersion + ""); + assertRequest(server.takeRequest(), "DELETE", uriApiVersion + "/fw/firewall_rules/12345"); + + /* + * Check response + */ + assertFalse(result); + } finally { + server.shutdown(); + } + } + +} diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java index 38d36fb6e8..e0b6e1cd82 100644 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java +++ b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/features/ExtensionApiMockTest.java @@ -61,7 +61,7 @@ public class ExtensionApiMockTest extends BaseNeutronApiMockTest { * Check response */ assertNotNull(extensions); - assertEquals(extensions.size(), 17); + assertEquals(extensions.size(), 15); } finally { server.shutdown(); } diff --git a/apis/openstack-neutron/src/test/resources/extension_list.json b/apis/openstack-neutron/src/test/resources/extension_list.json index 9f85e1e437..acdd36a074 100644 --- a/apis/openstack-neutron/src/test/resources/extension_list.json +++ b/apis/openstack-neutron/src/test/resources/extension_list.json @@ -1,140 +1,124 @@ { - "extensions": [ - { - "updated": "2013-01-20T00:00:00-00:00", - "name": "Neutron Service Type Management", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", - "alias": "service-type", - "description": "API for retrieving service providers for Neutron advanced services" - }, - { - "updated": "2012-10-05T10:00:00-00:00", - "name": "security-group", - "links": [], - "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0", - "alias": "security-group", - "description": "The security groups extension." - }, - { - "updated": "2013-02-07T10:00:00-00:00", - "name": "L3 Agent Scheduler", - "links": [], - "namespace": "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0", - "alias": "l3_agent_scheduler", - "description": "Schedule routers among l3 agents" - }, - { - "updated": "2013-02-07T10:00:00-00:00", - "name": "Loadbalancer Agent Scheduler", - "links": [], - "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0", - "alias": "lbaas_agent_scheduler", - "description": "Schedule pools among lbaas agents" - }, - { - "updated": "2013-03-28T10:00:00-00:00", - "name": "Neutron L3 Configurable external gateway mode", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/ext-gw-mode/api/v1.0", - "alias": "ext-gw-mode", - "description": "Extension of the router abstraction for specifying whether SNAT should occur on the external gateway" - }, - { - "updated": "2014-02-03T10:00:00-00:00", - "name": "Port Binding", - "links": [], - "namespace": "http://docs.openstack.org/ext/binding/api/v1.0", - "alias": "binding", - "description": "Expose port bindings of a virtual port to external application" - }, - { - "updated": "2012-09-07T10:00:00-00:00", - "name": "Provider Network", - "links": [], - "namespace": "http://docs.openstack.org/ext/provider/api/v1.0", - "alias": "provider", - "description": "Expose mapping of virtual networks to physical networks" - }, - { - "updated": "2013-02-03T10:00:00-00:00", - "name": "agent", - "links": [], - "namespace": "http://docs.openstack.org/ext/agent/api/v2.0", - "alias": "agent", - "description": "The agent management extension." - }, - { - "updated": "2012-07-29T10:00:00-00:00", - "name": "Quota management support", - "links": [], - "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0", - "alias": "quotas", - "description": "Expose functions for quotas management per tenant" - }, - { - "updated": "2013-02-07T10:00:00-00:00", - "name": "DHCP Agent Scheduler", - "links": [], - "namespace": "http://docs.openstack.org/ext/dhcp_agent_scheduler/api/v1.0", - "alias": "dhcp_agent_scheduler", - "description": "Schedule networks among dhcp agents" - }, - { - "updated": "2013-06-27T10:00:00-00:00", - "name": "Multi Provider Network", - "links": [], - "namespace": "http://docs.openstack.org/ext/multi-provider/api/v1.0", - "alias": "multi-provider", - "description": "Expose mapping of virtual networks to multiple physical networks" - }, - { - "updated": "2013-01-14T10:00:00-00:00", - "name": "Neutron external network", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0", - "alias": "external-net", - "description": "Adds external network attribute to network resource." - }, - { - "updated": "2012-07-20T10:00:00-00:00", - "name": "Neutron L3 Router", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0", - "alias": "router", - "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway." - }, - { - "updated": "2013-07-23T10:00:00-00:00", - "name": "Allowed Address Pairs", - "links": [], - "namespace": "http://docs.openstack.org/ext/allowedaddresspairs/api/v2.0", - "alias": "allowed-address-pairs", - "description": "Provides allowed address pairs" - }, - { - "updated": "2013-03-17T12:00:00-00:00", - "name": "Neutron Extra DHCP opts", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/extra_dhcp_opt/api/v1.0", - "alias": "extra_dhcp_opt", - "description": "Extra options configuration for DHCP. For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, server-ip-address, bootfile-name)" - }, - { - "updated": "2012-10-07T10:00:00-00:00", - "name": "LoadBalancing service", - "links": [], - "namespace": "http://wiki.openstack.org/neutron/LBaaS/API_1.0", - "alias": "lbaas", - "description": "Extension for LoadBalancing service" - }, - { - "updated": "2013-02-01T10:00:00-00:00", - "name": "Neutron Extra Route", - "links": [], - "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0", - "alias": "extraroute", - "description": "Extra routes configuration for L3 router" - } - ] -} + "extensions": [ + { + "updated": "2013-01-20T00:00:00-00:00", + "name": "Neutron Service Type Management", + "links": [], + "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", + "alias": "service-type", + "description": "API for retrieving service providers for Neutron advanced services" + }, + { + "updated": "2012-10-05T10:00:00-00:00", + "name": "security-group", + "links": [], + "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0", + "alias": "security-group", + "description": "The security groups extension." + }, + { + "updated": "2013-02-07T10:00:00-00:00", + "name": "Loadbalancer Agent Scheduler", + "links": [], + "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0", + "alias": "lbaas_agent_scheduler", + "description": "Schedule pools among lbaas agents" + }, + { + "updated": "2013-02-25T10:00:00-00:00", + "name": "Firewall service", + "links": [], + "namespace": "http://wiki.openstack.org/Neutron/FWaaS/API_1.0", + "alias": "fwaas", + "description": "Extension for Firewall service" + }, + { + "updated": "2014-02-03T10:00:00-00:00", + "name": "Port Binding", + "links": [], + "namespace": "http://docs.openstack.org/ext/binding/api/v1.0", + "alias": "binding", + "description": "Expose port bindings of a virtual port to external application" + }, + { + "updated": "2012-07-29T10:00:00-00:00", + "name": "Quota management support", + "links": [], + "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0", + "alias": "quotas", + "description": "Expose functions for quotas management per tenant" + }, + { + "updated": "2014-01-01T10:00:00-00:00", + "name": "Nuage security-group", + "links": [], + "namespace": "http://nuagenetworks.net/ext/secgroup/api/v1.0", + "alias": "nuage-security-group", + "description": "Nuage security-group" + }, + { + "updated": "2014-01-01T10:00:00-00:00", + "name": "Nuage router", + "links": [], + "namespace": "http://nuagenetworks.net/ext/routers/api/v1.0", + "alias": "nuage-router", + "description": "Nuage Router" + }, + { + "updated": "2013-01-14T10:00:00-00:00", + "name": "Neutron external network", + "links": [], + "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0", + "alias": "external-net", + "description": "Adds external network attribute to network resource." + }, + { + "updated": "2012-07-20T10:00:00-00:00", + "name": "Neutron L3 Router", + "links": [], + "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0", + "alias": "router", + "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway." + }, + { + "updated": "2014-01-01T10:00:00-00:00", + "name": "Nuage subnet", + "links": [], + "namespace": "http://nuagenetworks.net/ext/subnets/api/v1.0", + "alias": "nuage-subnet", + "description": "Nuage subnet" + }, + { + "updated": "2013-05-29T10:00:00-00:00", + "name": "VPN service", + "links": [], + "namespace": "https://wiki.openstack.org/Neutron/VPNaaS", + "alias": "vpnaas", + "description": "Extension for VPN service" + }, + { + "updated": "2014-01-01T10:00:00-00:00", + "name": "NetPartition", + "links": [], + "namespace": "http://nuagenetworks.net/ext/net_partition/api/v1.0", + "alias": "net-partition", + "description": "NetPartition" + }, + { + "updated": "2012-10-07T10:00:00-00:00", + "name": "LoadBalancing service", + "links": [], + "namespace": "http://wiki.openstack.org/neutron/LBaaS/API_1.0", + "alias": "lbaas", + "description": "Extension for LoadBalancing service" + }, + { + "updated": "2013-02-01T10:00:00-00:00", + "name": "Neutron Extra Route", + "links": [], + "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0", + "alias": "extraroute", + "description": "Extra routes configuration for L3 router" + } + ] +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/firewall_create_request.json b/apis/openstack-neutron/src/test/resources/firewall_create_request.json new file mode 100644 index 0000000000..7a7a5e7672 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_create_request.json @@ -0,0 +1,6 @@ +{ + "firewall": { + "admin_state_up": true, + "firewall_policy_id": "c69933c1-b472-44f9-8226-30dc4ffd454c" + } +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/firewall_create_response.json b/apis/openstack-neutron/src/test/resources/firewall_create_response.json new file mode 100644 index 0000000000..0433a765d2 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_create_response.json @@ -0,0 +1,11 @@ +{ + "firewall": { + "admin_state_up": true, + "description": "", + "firewall_policy_id": "c69933c1-b472-44f9-8226-30dc4ffd454c", + "id": "3b0ef8f4-82c7-44d4-a4fb-6177f9a21977", + "name": "", + "status": "PENDING_CREATE", + "tenant_id": "45977fa2dbd7482098dd68d0d8970117" + } +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/firewall_get_response.json b/apis/openstack-neutron/src/test/resources/firewall_get_response.json new file mode 100644 index 0000000000..14425e121a --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_get_response.json @@ -0,0 +1,11 @@ +{ + "firewall": { + "admin_state_up": true, + "description": "", + "firewall_policy_id": "c69933c1-b472-44f9-8226-30dc4ffd454c", + "id": "3b0ef8f4-82c7-44d4-a4fb-6177f9a21977", + "name": "", + "status": "ACTIVE", + "tenant_id": "45977fa2dbd7482098dd68d0d8970117" + } +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/firewall_list_response.json b/apis/openstack-neutron/src/test/resources/firewall_list_response.json new file mode 100644 index 0000000000..9881360231 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_list_response.json @@ -0,0 +1,13 @@ +{ + "firewalls": [ + { + "status": "ACTIVE", + "name": "fw", + "admin_state_up": true, + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "firewall_policy_id": "5083ef0d-7ad2-4305-acd8-bd036c332e1e", + "id": "5eb708e7-3856-449a-99ac-fec27cd745f9", + "description": "" + } + ] +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/firewall_policy_create_request.json b/apis/openstack-neutron/src/test/resources/firewall_policy_create_request.json new file mode 100644 index 0000000000..d5d417da79 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_policy_create_request.json @@ -0,0 +1,8 @@ +{ + "firewall_policy": { + "name": "jclouds-fw-policy_group-52-e8b", + "shared": false, + "firewall_rules": [], + "audited": false + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_policy_create_response.json b/apis/openstack-neutron/src/test/resources/firewall_policy_create_response.json new file mode 100644 index 0000000000..8e3dd37472 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_policy_create_response.json @@ -0,0 +1,11 @@ +{ + "firewall_policy": { + "name": "jclouds-fw-policy_group-52-e8b", + "firewall_rules": [], + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "audited": false, + "shared": false, + "id": "12971159-95cf-4ca1-9baa-c82298ae0918", + "description": "" + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_policy_get_response.json b/apis/openstack-neutron/src/test/resources/firewall_policy_get_response.json new file mode 100644 index 0000000000..9ee2a170ae --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_policy_get_response.json @@ -0,0 +1,14 @@ +{ + "firewall_policy": { + "name": "myfirewallrule", + "firewall_rules": [ + "3e5a4e53-4390-4b22-baea-75529dbeafb8", + "4e58f636-1ef1-4e8e-b3ad-5f7f9d1f9f23" + ], + "tenant_id": "e1defcdd823741c89afd5824040deed2", + "audited": false, + "shared": true, + "id": "18d2f4e5-afdd-4c10-87ea-d35f38faf98c", + "description": "" + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_request.json b/apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_request.json new file mode 100644 index 0000000000..eba7d52a70 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_request.json @@ -0,0 +1 @@ +{"firewall_rule_id": "59585143-e819-48c9-944d-f03e0f049dba"} diff --git a/apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_response.json b/apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_response.json new file mode 100644 index 0000000000..9f58f2077d --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_policy_insert_rule_response.json @@ -0,0 +1,10 @@ +{ + "name": "jclouds-fw-policy_group-52-e8b", + "firewall_rules": ["59585143-e819-48c9-944d-f03e0f049dba"], + "shared": false, + "audited": false, + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "id": "12971159-95cf-4ca1-9baa-c82298ae0918", + "firewall_list": [], + "description": "" +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_policy_list_response.json b/apis/openstack-neutron/src/test/resources/firewall_policy_list_response.json new file mode 100644 index 0000000000..ecf2e3dcfc --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_policy_list_response.json @@ -0,0 +1,255 @@ +{ + "firewall_policies": [ + { + "name": "myfirewallrule", + "firewall_rules": [ + "3e5a4e53-4390-4b22-baea-75529dbeafb8", + "4e58f636-1ef1-4e8e-b3ad-5f7f9d1f9f23" + ], + "tenant_id": "e1defcdd823741c89afd5824040deed2", + "audited": false, + "shared": true, + "id": "18d2f4e5-afdd-4c10-87ea-d35f38faf98c", + "description": "" + }, + { + "name": "Policy SBT", + "firewall_rules": [], + "tenant_id": "ba6ba03f266e4ccfb07d2372bc8d68a2", + "audited": false, + "shared": true, + "id": "31d6368b-3d8b-49a1-af5d-901283223801", + "description": "" + }, + { + "name": "FW-POLICY-DEMO", + "firewall_rules": [ + "e434b562-c33f-4d64-84da-adfaaa94630e", + "03a3d9d7-eb92-49c4-83c1-a479ec37d87b", + "1086d52d-2323-434d-a1e8-ade5791fb5ac", + "7240cdf3-a8da-4006-90e2-9191d998fee0", + "eec4cdbe-859f-45c5-9acb-1935056af1e4", + "a18ee08e-9d5d-4c9e-9372-c4b8f71c6c75", + "7aefe7f9-01f6-4387-900e-177684e3c59d", + "b6017900-7811-4428-9940-a02033042c88", + "94129848-4eb8-4c8e-9164-cd8ee60faa49", + "e0649a2b-a327-45ed-a3a0-f068cb3fcf37", + "53f5bf0a-05e3-4a30-800b-611151a9685d", + "e07558b1-5e18-4d2d-a79b-0a95f36d1715", + "43931a28-513d-4cbb-80fa-464bf49df65f", + "79572a32-fda4-4f2c-bdad-bb11a08af9ed" + ], + "tenant_id": "cfb5b69938dc49f19f192eabf62a32e6", + "audited": false, + "shared": true, + "id": "4c0743e4-0361-4ed0-a6ce-2a8959d978a9", + "description": "" + }, + { + "name": "fw-policy", + "firewall_rules": [ + "3c51d308-1c5c-4776-b4ac-6d3c9ebd5685", + "e614f597-4eb2-457a-a102-5b9ad2beba42", + "e908239c-2b40-4afa-8ec3-9c4b437367da", + "1ae9b906-9250-4f8c-a262-b0fe6e7b1680", + "daa2ee3c-760c-4c67-81a8-e61a310366f1", + "1bd356b4-d0b0-4a86-a5a3-3245ac838960", + "e72605a4-f866-4cfe-9962-6577c4a87a4d" + ], + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "audited": false, + "shared": false, + "id": "5083ef0d-7ad2-4305-acd8-bd036c332e1e", + "description": "" + }, + { + "name": "PolicyOfTheVoid", + "firewall_rules": [], + "tenant_id": "85c79b517ef6431881c9477d2227be5f", + "audited": true, + "shared": true, + "id": "60779a72-21bd-4b97-a587-cd5fb8b8e7c0", + "description": "" + }, + { + "name": "Policy", + "firewall_rules": [ + "2b6646ea-a0d8-4982-b3e2-e14ad2743428", + "21a42289-b05c-4271-9f06-1172b88c8465", + "7b998345-1660-428f-969d-bfcdb4c0dbaf", + "8996fcfd-b88d-4b68-bff7-5fb07fc0088a", + "55b96a08-f868-45fd-9386-1fd831b7b63b", + "df5aaeb6-50d7-4344-9f00-f973d5e28185", + "bc23bcb1-1a81-4658-b72d-485da3af8a8a" + ], + "tenant_id": "ccef3550ec724607a8024977b3b4e410", + "audited": false, + "shared": true, + "id": "63337440-d0ad-4a3c-9e26-777a6e360119", + "description": "Ping + SSH" + }, + { + "name": "allow_all", + "firewall_rules": ["d52ea23a-9911-44ef-815b-f3b4b6b0df64"], + "tenant_id": "53b1ed26b8874556bc7141f9482fd789", + "audited": false, + "shared": true, + "id": "6e3d5d6d-1356-43eb-91ef-d6f70888632d", + "description": "Allow All" + }, + { + "name": "Politique Production", + "firewall_rules": [ + "a6f58b76-5c90-4530-908c-cc7dbd945a4b", + "3521380b-624c-42a1-8415-992b52a9dfec", + "fbcf3060-bd0c-4cd9-b4b1-cf3c76b7fe7d", + "45aecaba-a659-490a-8f12-92adfda79c15", + "5cfc4e09-a765-4f4e-93d5-8a9650f051f8", + "304ff502-eb6f-46b5-8110-c75a483c23e0", + "1662f0bb-a9a6-415a-b1a7-19ba113d7a52", + "8bbd0490-452c-4bee-a70f-213558e0bc65", + "e39fcf85-bea2-49fa-8a8e-c69c5f2e29ae", + "1bbdd6ba-9ae8-4cd3-8815-ef992c56cb63", + "100e638c-77cf-4f1e-8194-5a26171f645a", + "91b8316c-96ae-41da-9c14-42e1f778c0a8" + ], + "tenant_id": "13a12b25d3cf4275905e2a6b9878a619", + "audited": false, + "shared": true, + "id": "89d7ef67-4cb8-485f-83ac-14085e616137", + "description": "" + }, + { + "name": "any-shared", + "firewall_rules": ["b35ab1c6-309d-4690-b16c-0343a535651c"], + "tenant_id": "3fdcdc95fc88431597700dbb20be37c6", + "audited": false, + "shared": true, + "id": "a0a3a1b1-d985-4507-b785-311f8e981fa6", + "description": "" + }, + { + "name": "production", + "firewall_rules": ["5dbe3498-b230-4b34-9915-7bcc22bed99c"], + "tenant_id": "94eb5f2fd9ed471992e2c5c2313b0703", + "audited": false, + "shared": true, + "id": "a23d0af2-3124-49cf-ae04-02c175eda549", + "description": "production" + }, + { + "name": "PolProdStdDmz1", + "firewall_rules": [ + "3178c9f6-f017-462b-b93f-715e11247c30", + "2b775a98-9813-48e0-8f32-a04dfc176872", + "a5a7e990-fbe4-429b-a55c-35df087b6f80", + "6ca67373-b89e-492d-94c6-1c40765800ce", + "bf93dda9-6f42-42cf-852f-689b6facf5b4", + "e3bd91ee-1337-4d73-9484-836a0fb5869b" + ], + "tenant_id": "3345a933109049779647ff02ca498f3a", + "audited": false, + "shared": true, + "id": "afc19c5c-d136-4dbf-b614-c0b784a4f68d", + "description": "" + }, + { + "name": "ALL", + "firewall_rules": [ + "43bfdc83-5f76-407d-b851-5803d4e23f0b", + "316965f2-4242-4c56-8e34-22f4ff1992a3", + "1fb6cbde-4446-4bef-9eac-cc6b76afc565", + "a3da3767-608d-493d-b15a-1793d66891c8", + "6f58413b-3667-41f6-93b4-eef813632aee", + "a28bdf75-894f-4af5-9063-e2fcee4cb01d", + "0ed005c7-2d89-43a1-8aaf-714d44858173", + "710e513c-df2b-4c78-8572-bd9701f5b108", + "016922c5-7810-41cb-ae2c-04bbd87b3b24", + "22d6ade0-0f0d-473a-9cec-4b5ba22db8e4", + "7ed0e62c-848d-4e4e-baa7-eea7e9c3c3ec", + "05a34244-0922-4a6d-b551-c95c500f2194", + "9d40ac55-0802-4590-aa89-8199dab7038f", + "3d1f3c70-44e1-4c6e-9253-53421976d707", + "4d22985f-ad50-459d-af00-eea902900e41", + "dd16596d-065d-4a3a-bb75-054ab7acf54f", + "33228008-6dba-4270-9c55-3d8752472795", + "46ea5a1c-8b4b-4eaf-b9c2-767efa8bc2ae", + "3b3c3136-d914-46ae-ace3-726f638ed1d5", + "2c3f8fce-3d05-405a-8249-1d3843b8a62d", + "23106a5d-556e-4e78-af13-1d0c9280b2e2", + "40e342d6-86fc-4205-b306-e9dcd816b958", + "bf290614-8ab0-487f-811f-4474a51a40d3", + "08b91c69-310d-4d55-bea1-ffe0d95e150b", + "8e9509ff-93cb-442d-92c6-1cfb79b9243c", + "019bd1b9-2f2b-4cfa-b645-6eb779d4622e", + "4f7fd6e2-7ac5-4a46-8e3d-c4dcdde8a3f0", + "4fd8fc8b-c449-457d-8526-6ba23f6f299d", + "e2a96758-70ba-499c-bd97-6d8ee55610ed", + "ade798f5-862a-442b-8168-f39a06030535" + ], + "tenant_id": "b6e174b62a964db7bf897a38b92fc217", + "audited": false, + "shared": true, + "id": "e0f918c2-7a10-45d1-a5f9-9b2a2026bf3e", + "description": "" + }, + { + "name": "Pre-Prod", + "firewall_rules": [ + "fd124f42-f064-4259-b840-1ca05203c6b7", + "f03bd950-6c56-4f5e-a307-45967078f507" + ], + "tenant_id": "80cf934d6ffb4ef5b244f1c512ad1e61", + "audited": false, + "shared": true, + "id": "e2a5fb51-698c-4898-87e8-f1eee6b50919", + "description": "" + }, + { + "name": "ports VM ouverts", + "firewall_rules": ["c5535724-8ed8-4e50-933a-17e37b06994d"], + "tenant_id": "66165eac36f846099ab3f667f0c05229", + "audited": false, + "shared": true, + "id": "e5b8e392-1e70-4948-a6a4-b3726b528059", + "description": "ouverture de tous les ports du projet stagiaires" + }, + { + "name": "www", + "firewall_rules": [ + "75452b36-268e-4e75-aaf4-f0e7ed50bc97", + "c9e77ca0-1bc8-497d-904d-948107873dc6", + "67004fb6-9111-441f-a3c1-b94b08bbd496", + "80965cc0-2d60-48e8-8fe9-78be016f10b6", + "41c72886-f39d-450e-b4b5-818ebddf17d5", + "c854fab5-bdaf-4a86-9359-78de93e5df01", + "350288f9-4aea-4e13-b434-91141e5e5960", + "03d2a6ad-633f-431a-8463-4370d06a22c8" + ], + "tenant_id": "9145d91459d248b1b02fdaca97c6a75d", + "audited": false, + "shared": true, + "id": "f2b08c1e-aa81-4668-8ae1-1401bcb0576c", + "description": "" + }, + { + "name": "fw-policy", + "firewall_rules": [ + "32ea5280-b601-4531-903f-ddef6dd1b733", + "f6f39ac3-0bda-47ff-b8b9-f089a5440e19", + "dad47cfb-893f-4d7c-8e40-c7a86bcda175", + "1d089edc-ae35-4c60-b6af-79b69e2f3247", + "eac689d5-ce70-4d4a-bf43-5d1416ebb770", + "3c1318de-e095-4870-a2ec-3091fee81683", + "beb6249b-5e98-4c25-a356-d45f5b0cae29", + "b4b2362e-0d16-42ef-b8e4-9de56ca00c84", + "72c159d0-4777-4468-9136-543ba42d18f0" + ], + "tenant_id": "94eb5f2fd9ed471992e2c5c2313b0703", + "audited": false, + "shared": true, + "id": "f66e862e-9982-465e-a5af-79d61ca9c6eb", + "description": "" + } + ] +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_rule_create_request.json b/apis/openstack-neutron/src/test/resources/firewall_rule_create_request.json new file mode 100644 index 0000000000..5dcacfe969 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_rule_create_request.json @@ -0,0 +1,12 @@ +{ + "firewall_rule": { + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "name": "jclouds-fw-rule_group-52-e8b_port-22", + "shared": false, + "protocol": "tcp", + "destination_ip_address": "192.168.0.117", + "destination_port": "22", + "action": "allow", + "enabled": true + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_rule_create_response.json b/apis/openstack-neutron/src/test/resources/firewall_rule_create_response.json new file mode 100644 index 0000000000..eb835f225c --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_rule_create_response.json @@ -0,0 +1,19 @@ +{ + "firewall_rule": { + "protocol": "tcp", + "description": "", + "source_port": null, + "source_ip_address": null, + "destination_ip_address": "192.168.0.117", + "firewall_policy_id": null, + "position": null, + "destination_port": "22", + "id": "59585143-e819-48c9-944d-f03e0f049dba", + "name": "jclouds-fw-rule_group-52-e8b_port-22", + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "enabled": true, + "action": "allow", + "ip_version": 4, + "shared": false + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_rule_get_response.json b/apis/openstack-neutron/src/test/resources/firewall_rule_get_response.json new file mode 100644 index 0000000000..860d6b1d9b --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_rule_get_response.json @@ -0,0 +1,19 @@ +{ + "firewall_rule": { + "protocol": "tcp", + "description": "jclouds test fw rule", + "source_port": null, + "source_ip_address": null, + "destination_ip_address": "192.168.0.1", + "firewall_policy_id": null, + "position": null, + "destination_port": "22", + "id": "736b1686-3301-4a3d-9eaf-15e3c2682edc", + "name": "jclouds-test-org.jclouds.openstack.neutron.v2.extensions.fwaasapilivetest-fw-rule-22", + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "enabled": true, + "action": "allow", + "ip_version": 4, + "shared": false + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_rule_update_request.json b/apis/openstack-neutron/src/test/resources/firewall_rule_update_request.json new file mode 100644 index 0000000000..9850b8bc1d --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_rule_update_request.json @@ -0,0 +1,6 @@ +{ + "firewall_rule": { + "shared": false, + "enabled": false + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_rule_update_response.json b/apis/openstack-neutron/src/test/resources/firewall_rule_update_response.json new file mode 100644 index 0000000000..0ba9c1fed8 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_rule_update_response.json @@ -0,0 +1,19 @@ +{ + "firewall_rule": { + "protocol": "tcp", + "description": "jclouds test fw rule", + "source_port": null, + "source_ip_address": null, + "destination_ip_address": "192.168.0.1", + "firewall_policy_id": null, + "position": null, + "destination_port": "22", + "id": "736b1686-3301-4a3d-9eaf-15e3c2682edc", + "name": "jclouds-test-org.jclouds.openstack.neutron.v2.extensions.fwaasapilivetest-fw-rule-22-updated", + "tenant_id": "3e00d5716204446c8d3c47a466eec25a", + "enabled": false, + "action": "allow", + "ip_version": 4, + "shared": false + } +} diff --git a/apis/openstack-neutron/src/test/resources/firewall_update_request.json b/apis/openstack-neutron/src/test/resources/firewall_update_request.json new file mode 100644 index 0000000000..58021f75ba --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_update_request.json @@ -0,0 +1,5 @@ +{ + "firewall": { + "admin_state_up": false + } +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/firewall_update_response.json b/apis/openstack-neutron/src/test/resources/firewall_update_response.json new file mode 100644 index 0000000000..cc9635fe24 --- /dev/null +++ b/apis/openstack-neutron/src/test/resources/firewall_update_response.json @@ -0,0 +1,11 @@ +{ + "firewall": { + "admin_state_up": false, + "description": "", + "firewall_policy_id": "c69933c1-b472-44f9-8226-30dc4ffd454c", + "id": "3b0ef8f4-82c7-44d4-a4fb-6177f9a21977", + "name": "", + "status": "PENDING_UPDATE", + "tenant_id": "45977fa2dbd7482098dd68d0d8970117" + } +} \ No newline at end of file diff --git a/apis/openstack-neutron/src/test/resources/logback.xml b/apis/openstack-neutron/src/test/resources/logback.xml index d7c463a01a..02685ca090 100644 --- a/apis/openstack-neutron/src/test/resources/logback.xml +++ b/apis/openstack-neutron/src/test/resources/logback.xml @@ -17,40 +17,19 @@ limitations under the License. --> - - - target/test-data/jclouds.log - + + - %d %-5p [%c] [%thread] %m%n + - %msg%n - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - + + - - - - - - - - - - - - - - - - + + + + + +