Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A358D200B40 for ; Thu, 16 Jun 2016 10:12:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A1EE1160A61; Thu, 16 Jun 2016 08:12:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3799C160A52 for ; Thu, 16 Jun 2016 10:12:16 +0200 (CEST) Received: (qmail 63909 invoked by uid 500); 16 Jun 2016 08:12:05 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 61228 invoked by uid 99); 16 Jun 2016 08:12:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jun 2016 08:12:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4CC87E9E9F; Thu, 16 Jun 2016 08:12:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sateesh@apache.org To: commits@cloudstack.apache.org Date: Thu, 16 Jun 2016 08:12:36 -0000 Message-Id: <843a3fb7511c4b4aa1e8c97dbfb9d5f2@git.apache.org> In-Reply-To: <3abf179c1ff24ceab07691879f2366aa@git.apache.org> References: <3abf179c1ff24ceab07691879f2366aa@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [35/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d archived-at: Thu, 16 Jun 2016 08:12:18 -0000 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java new file mode 100644 index 0000000..8a4c053 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java @@ -0,0 +1,209 @@ +// +// 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 com.cloud.network.nicira; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +@SuppressWarnings("serial") +public class AclRule extends AccessRule { + + public static final String ETHERTYPE_ARP = "ARP"; + + /** + * @TODO Convert this String into Enum and check the JSON communication still works + */ + protected String action; + + protected String sourceIpPrefix; + + protected String destinationIpPrefix; + + protected String sourceMacAddress; + + protected String destinationMacAddress; + + protected Integer sourcePortRangeMin; + + protected Integer destinationPortRangeMin; + + protected Integer sourcePortRangeMax; + + protected Integer destinationPortRangeMax; + + protected Integer icmpProtocolCode; + + protected Integer icmpProtocolType; + + protected int order; + + + /** + * Default constructor + */ + public AclRule() { + } + + /** + * Fully parameterized constructor + */ + public AclRule(String ethertype, int protocol, String action, String sourceMacAddress, + String destinationMacAddress, String sourceIpPrefix, String destinationIpPrefix, + Integer sourcePortRangeMin, Integer sourcePortRangeMax, + Integer destinationPortRangeMin, Integer destinationPortRangeMax, + int order, Integer icmpProtocolCode, Integer icmpProtocolType) { + this.ethertype = ethertype; + this.protocol = protocol; + this.action = action; + this.sourceMacAddress = sourceMacAddress; + this.destinationMacAddress = destinationMacAddress; + this.sourceIpPrefix = sourceIpPrefix; + this.destinationIpPrefix = destinationIpPrefix; + this.sourcePortRangeMin = sourcePortRangeMin; + this.sourcePortRangeMax = sourcePortRangeMax; + this.destinationPortRangeMin = destinationPortRangeMin; + this.destinationPortRangeMax = destinationPortRangeMax; + this.order = order; + this.icmpProtocolCode = icmpProtocolCode; + this.icmpProtocolType = icmpProtocolType; + } + + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getSourceIpPrefix() { + return sourceIpPrefix; + } + + public void setSourceIpPrefix(String sourceIpPrefix) { + this.sourceIpPrefix = sourceIpPrefix; + } + + public String getDestinationIpPrefix() { + return destinationIpPrefix; + } + + public void setDestinationIpPrefix(String destinationIpPrefix) { + this.destinationIpPrefix = destinationIpPrefix; + } + + public String getSourceMacAddress() { + return sourceMacAddress; + } + + public void setSourceMacAddress(String sourceMacAddress) { + this.sourceMacAddress = sourceMacAddress; + } + + public String getDestinationMacAddress() { + return destinationMacAddress; + } + + public void setDestinationMacAddress(String destinationMacAddress) { + this.destinationMacAddress = destinationMacAddress; + } + + public Integer getSourcePortRangeMin() { + return sourcePortRangeMin; + } + + public void setSourcePortRangeMin(Integer sourcePortRangeMin) { + this.sourcePortRangeMin = sourcePortRangeMin; + } + + public Integer getDestinationPortRangeMin() { + return destinationPortRangeMin; + } + + public void setDestinationPortRangeMin(Integer destinationPortRangeMin) { + this.destinationPortRangeMin = destinationPortRangeMin; + } + + public Integer getSourcePortRangeMax() { + return sourcePortRangeMax; + } + + public void setSourcePortRangeMax(Integer sourcePortRangeMax) { + this.sourcePortRangeMax = sourcePortRangeMax; + } + + public Integer getDestinationPortRangeMax() { + return destinationPortRangeMax; + } + + public void setDestinationPortRangeMax(Integer destinationPortRangeMax) { + this.destinationPortRangeMax = destinationPortRangeMax; + } + + public Integer getIcmpProtocolCode() { + return icmpProtocolCode; + } + + public void setIcmpProtocolCode(Integer icmpProtocolCode) { + this.icmpProtocolCode = icmpProtocolCode; + } + + public Integer getIcmpProtocolType() { + return icmpProtocolType; + } + + public void setIcmpProtocolType(Integer icmpProtocolType) { + this.icmpProtocolType = icmpProtocolType; + } + + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 31) + .append(ethertype).append(protocol) + .toHashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof AclRule)) { + return false; + } + AclRule another = (AclRule) obj; + return new EqualsBuilder() + .append(ethertype, another.ethertype) + .append(protocol, another.protocol) + .isEquals(); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Attachment.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Attachment.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Attachment.java new file mode 100644 index 0000000..90ff131 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Attachment.java @@ -0,0 +1,24 @@ +// +// 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 com.cloud.network.nicira; + +public abstract class Attachment { + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraEntity.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraEntity.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraEntity.java new file mode 100644 index 0000000..afcd233 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraEntity.java @@ -0,0 +1,85 @@ +// +// 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 com.cloud.network.nicira; + +import java.io.Serializable; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ReflectionToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +public abstract class BaseNiciraEntity implements Serializable { + protected String href; + protected String schema; + protected String uuid; + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public String getHref() { + return href; + } + + public void setHref(final String href) { + this.href = href; + } + + public String getSchema() { + return schema; + } + + public void setSchema(final String schema) { + this.schema = schema; + } + + @Override + public String toString() { + return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 31) + .append(this.getClass()) + .append(uuid) + .toHashCode(); + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(this.getClass().isInstance(obj))) { + return false; + } + final BaseNiciraEntity another = (BaseNiciraEntity) obj; + return new EqualsBuilder().append(uuid, another.uuid).isEquals(); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraNamedEntity.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraNamedEntity.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraNamedEntity.java new file mode 100644 index 0000000..0e21ddb --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/BaseNiciraNamedEntity.java @@ -0,0 +1,44 @@ +// +// 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 com.cloud.network.nicira; + +import java.util.List; + +public abstract class BaseNiciraNamedEntity extends BaseNiciraEntity { + + protected String displayName; + protected List tags; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(final String displayName) { + this.displayName = displayName; + } + + public List getTags() { + return tags; + } + + public void setTags(final List tags) { + this.tags = tags; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ControlClusterStatus.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ControlClusterStatus.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ControlClusterStatus.java new file mode 100644 index 0000000..8d6399e --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ControlClusterStatus.java @@ -0,0 +1,87 @@ +// +// 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 com.cloud.network.nicira; + +public class ControlClusterStatus { + private String clusterStatus; + private Stats nodeStats; + private Stats queueStats; + private Stats portStats; + private Stats routerportStats; + private Stats switchStats; + private Stats zoneStats; + private Stats routerStats; + private Stats securityProfileStats; + + public String getClusterStatus() { + return clusterStatus; + } + + public Stats getNodeStats() { + return nodeStats; + } + + public Stats getLqueueStats() { + return queueStats; + } + + public Stats getLportStats() { + return portStats; + } + + public Stats getLrouterportStats() { + return routerportStats; + } + + public Stats getLswitchStats() { + return switchStats; + } + + public Stats getZoneStats() { + return zoneStats; + } + + public Stats getLrouterStats() { + return routerStats; + } + + public Stats getSecurityProfileStats() { + return securityProfileStats; + } + + public class Stats { + private int errorStateCount; + private int registeredCount; + private int activeCount; + + public int getErrorStateCount() { + return errorStateCount; + } + + public int getRegisteredCount() { + return registeredCount; + } + + public int getActiveCount() { + return activeCount; + } + + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/DestinationNatRule.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/DestinationNatRule.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/DestinationNatRule.java new file mode 100644 index 0000000..a0d5afc --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/DestinationNatRule.java @@ -0,0 +1,113 @@ +// +// 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 com.cloud.network.nicira; + +public class DestinationNatRule extends NatRule { + private String toDestinationIpAddress; + private Integer toDestinationPort; + + public DestinationNatRule() { + setType("DestinationNatRule"); + } + + public String getToDestinationIpAddress() { + return toDestinationIpAddress; + } + + public void setToDestinationIpAddress(final String toDestinationIpAddress) { + this.toDestinationIpAddress = toDestinationIpAddress; + } + + public Integer getToDestinationPort() { + return toDestinationPort; + } + + public void setToDestinationPort(final Integer toDestinationPort) { + this.toDestinationPort = toDestinationPort; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((toDestinationIpAddress == null) ? 0 : toDestinationIpAddress.hashCode()); + result = prime * result + ((toDestinationPort == null) ? 0 : toDestinationPort.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DestinationNatRule other = (DestinationNatRule)obj; + if (toDestinationIpAddress == null) { + if (other.toDestinationIpAddress != null) { + return false; + } + } else if (!toDestinationIpAddress.equals(other.toDestinationIpAddress)) { + return false; + } + if (toDestinationPort == null) { + if (other.toDestinationPort != null) { + return false; + } + } else if (!toDestinationPort.equals(other.toDestinationPort)) { + return false; + } + return true; + } + + @Override + public boolean equalsIgnoreUuid(Object obj) { + if (this == obj) { + return true; + } + if (!super.equalsIgnoreUuid(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DestinationNatRule other = (DestinationNatRule)obj; + if (toDestinationIpAddress == null) { + if (other.toDestinationIpAddress != null) { + return false; + } + } else if (!toDestinationIpAddress.equals(other.toDestinationIpAddress)) { + return false; + } + if (toDestinationPort == null) { + if (other.toDestinationPort != null) { + return false; + } + } else if (!toDestinationPort.equals(other.toDestinationPort)) { + return false; + } + return true; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/L3GatewayAttachment.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/L3GatewayAttachment.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/L3GatewayAttachment.java new file mode 100644 index 0000000..a1d5ce4 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/L3GatewayAttachment.java @@ -0,0 +1,55 @@ +// +// 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 com.cloud.network.nicira; + +/** + * + */ +public class L3GatewayAttachment extends Attachment { + private String l3GatewayServiceUuid; + private final String type = "L3GatewayAttachment"; + private Long vlanId; + + public L3GatewayAttachment(String l3GatewayServiceUuid) { + this.l3GatewayServiceUuid = l3GatewayServiceUuid; + } + + public L3GatewayAttachment(final String l3GatewayServiceUuid, final long vlanId) { + this.l3GatewayServiceUuid = l3GatewayServiceUuid; + this.vlanId = vlanId; + } + + public String getL3GatewayServiceUuid() { + return l3GatewayServiceUuid; + } + + public void setL3GatewayServiceUuid(final String l3GatewayServiceUuid) { + this.l3GatewayServiceUuid = l3GatewayServiceUuid; + } + + public long getVlanId() { + return vlanId; + } + + public void setVlanId(long vlanId) { + this.vlanId = vlanId; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouter.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouter.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouter.java new file mode 100644 index 0000000..edc9351 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouter.java @@ -0,0 +1,71 @@ +// +// 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 com.cloud.network.nicira; + + +/** + * + */ +public class LogicalRouter extends BaseNiciraNamedEntity { + public static final String REPLICATION_MODE_SERVICE = "service"; + public static final String REPLICATION_MODE_SOURCE = "source"; + + private final String type = "LogicalRouterConfig"; + private RoutingConfig routingConfig; + private boolean distributed; + private boolean natSynchronizationEnabled; + private String replicationMode; + + public String getType() { + return type; + } + + public RoutingConfig getRoutingConfig() { + return routingConfig; + } + + public void setRoutingConfig(final RoutingConfig routingConfig) { + this.routingConfig = routingConfig; + } + + public boolean isDistributed() { + return distributed; + } + + public void setDistributed(final boolean distributed) { + this.distributed = distributed; + } + + public boolean isNatSynchronizationEnabled() { + return natSynchronizationEnabled; + } + + public void setNatSynchronizationEnabled(final boolean natSynchronizationEnabled) { + this.natSynchronizationEnabled = natSynchronizationEnabled; + } + + public String getReplicationMode() { + return replicationMode; + } + + public void setReplicationMode(final String replicationMode) { + this.replicationMode = replicationMode; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouterPort.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouterPort.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouterPort.java new file mode 100644 index 0000000..d9ee09a --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalRouterPort.java @@ -0,0 +1,62 @@ +// +// 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 com.cloud.network.nicira; + +import java.util.List; + +public class LogicalRouterPort extends BaseNiciraNamedEntity { + private Integer portno; + private boolean adminStatusEnabled; + private List ipAddresses; + private String macAddress; + private final String type = "LogicalRouterPortConfig"; + + public int getPortno() { + return portno; + } + + public void setPortno(final int portno) { + this.portno = portno; + } + + public boolean isAdminStatusEnabled() { + return adminStatusEnabled; + } + + public void setAdminStatusEnabled(final boolean adminStatusEnabled) { + this.adminStatusEnabled = adminStatusEnabled; + } + + public List getIpAddresses() { + return ipAddresses; + } + + public void setIpAddresses(final List ipAddresses) { + this.ipAddresses = ipAddresses; + } + + public String getMacAddress() { + return macAddress; + } + + public void setMacAddress(final String macAddress) { + this.macAddress = macAddress; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitch.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitch.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitch.java new file mode 100644 index 0000000..b527d94 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitch.java @@ -0,0 +1,60 @@ +// +// 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 com.cloud.network.nicira; + +import java.util.List; + +public class LogicalSwitch extends BaseNiciraNamedEntity { + public static final String REPLICATION_MODE_SERVICE = "service"; + public static final String REPLICATION_MODE_SOURCE = "source"; + + private final String type = "LogicalSwitchConfig"; + private boolean portIsolationEnabled; + private List transportZones; + private String replicationMode; + + public boolean isPortIsolationEnabled() { + return portIsolationEnabled; + } + + public void setPortIsolationEnabled(final boolean portIsolationEnabled) { + this.portIsolationEnabled = portIsolationEnabled; + } + + public String getType() { + return type; + } + + public List getTransportZones() { + return transportZones; + } + + public void setTransportZones(final List transportZones) { + this.transportZones = transportZones; + } + + public String getReplicationMode() { + return replicationMode; + } + + public void setReplicationMode(final String replicationMode) { + this.replicationMode = replicationMode; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitchPort.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitchPort.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitchPort.java new file mode 100644 index 0000000..5e07423 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/LogicalSwitchPort.java @@ -0,0 +1,82 @@ +// +// 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 com.cloud.network.nicira; + +import java.util.List; + +public class LogicalSwitchPort extends BaseNiciraNamedEntity { + private Integer portno; + private boolean adminStatusEnabled; + private String queueUuid; + private List securityProfiles; + private List mirrorTargets; + private final String type = "LogicalSwitchPortConfig"; + + public LogicalSwitchPort() { + super(); + } + + public LogicalSwitchPort(final String displayName, final List tags, final boolean adminStatusEnabled) { + super(); + this.displayName = displayName; + this.tags = tags; + this.adminStatusEnabled = adminStatusEnabled; + } + + public Integer getPortno() { + return portno; + } + + public void setPortno(final Integer portno) { + this.portno = portno; + } + + public boolean isAdminStatusEnabled() { + return adminStatusEnabled; + } + + public void setAdminStatusEnabled(final boolean adminStatusEnabled) { + this.adminStatusEnabled = adminStatusEnabled; + } + + public String getQueueUuid() { + return queueUuid; + } + + public void setQueueUuid(final String queueUuid) { + this.queueUuid = queueUuid; + } + + public List getSecurityProfiles() { + return securityProfiles; + } + + public void setSecurityProfiles(final List securityProfiles) { + this.securityProfiles = securityProfiles; + } + + public List getMirrorTargets() { + return mirrorTargets; + } + + public void setMirrorTargets(final List mirrorTargets) { + this.mirrorTargets = mirrorTargets; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Match.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Match.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Match.java new file mode 100644 index 0000000..ae3a86c --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/Match.java @@ -0,0 +1,146 @@ +// +// 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 com.cloud.network.nicira; + +/** + * + */ +public class Match { + private Integer protocol; + private String sourceIpAddresses; + private String destinationIpAddresses; + private Integer sourcePort; + private Integer destinationPort; + private String ethertype = "IPv4"; + + public Integer getProtocol() { + return protocol; + } + + public void setProtocol(final Integer protocol) { + this.protocol = protocol; + } + + public Integer getSourcePort() { + return sourcePort; + } + + public void setSourcePort(final Integer sourcePort) { + this.sourcePort = sourcePort; + } + + public Integer getDestinationPort() { + return destinationPort; + } + + public void setDestinationPort(final Integer destinationPort) { + this.destinationPort = destinationPort; + } + + public String getEthertype() { + return ethertype; + } + + public void setEthertype(final String ethertype) { + this.ethertype = ethertype; + } + + public String getSourceIpAddresses() { + return sourceIpAddresses; + } + + public void setSourceIpAddresses(final String sourceIpAddresses) { + this.sourceIpAddresses = sourceIpAddresses; + } + + public String getDestinationIpAddresses() { + return destinationIpAddresses; + } + + public void setDestinationIpAddresses(final String destinationIpAddresses) { + this.destinationIpAddresses = destinationIpAddresses; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((destinationIpAddresses == null) ? 0 : destinationIpAddresses.hashCode()); + result = prime * result + ((destinationPort == null) ? 0 : destinationPort.hashCode()); + result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode()); + result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); + result = prime * result + ((sourceIpAddresses == null) ? 0 : sourceIpAddresses.hashCode()); + result = prime * result + ((sourcePort == null) ? 0 : sourcePort.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Match other = (Match)obj; + if (destinationIpAddresses == null) { + if (other.destinationIpAddresses != null) + return false; + } else if (!destinationIpAddresses.equals(other.destinationIpAddresses)) { + return false; + } + if (destinationPort == null) { + if (other.destinationPort != null) { + return false; + } + } else if (!destinationPort.equals(other.destinationPort)) { + return false; + } + if (ethertype == null) { + if (other.ethertype != null) + return false; + } else if (!ethertype.equals(other.ethertype)) { + return false; + } + if (protocol == null) { + if (other.protocol != null) + return false; + } else if (!protocol.equals(other.protocol)) { + return false; + } + if (sourceIpAddresses == null) { + if (other.sourceIpAddresses != null) + return false; + } else if (!sourceIpAddresses.equals(other.sourceIpAddresses)) { + return false; + } + if (sourcePort == null) { + if (other.sourcePort != null) + return false; + } else if (!sourcePort.equals(other.sourcePort)) { + return false; + } + return true; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRule.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRule.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRule.java new file mode 100644 index 0000000..912e352 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRule.java @@ -0,0 +1,130 @@ +// +// 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 com.cloud.network.nicira; + +import java.util.UUID; + +/** + * + */ +public abstract class NatRule { + protected Match match; + protected UUID uuid; + protected String type; + protected int order; + + public NatRule() { + } + + public Match getMatch() { + return match; + } + + public void setMatch(final Match match) { + this.match = match; + } + + public UUID getUuid() { + return uuid; + } + + public void setUuid(final UUID uuid) { + this.uuid = uuid; + } + + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + public int getOrder() { + return order; + } + + public void setOrder(final int order) { + this.order = order; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((match == null) ? 0 : match.hashCode()); + result = prime * result + order; + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NatRule other = (NatRule)obj; + if (match == null) { + if (other.match != null) + return false; + } else if (!match.equals(other.match)) + return false; + if (order != other.order) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + if (uuid == null) { + if (other.uuid != null) + return false; + } else if (!uuid.equals(other.uuid)) + return false; + return true; + } + + public boolean equalsIgnoreUuid(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NatRule other = (NatRule)obj; + if (match == null) { + if (other.match != null) + return false; + } else if (!match.equals(other.match)) + return false; + if (order != other.order) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java new file mode 100644 index 0000000..810453c --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java @@ -0,0 +1,658 @@ +// +// 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 com.cloud.network.nicira; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.reflect.TypeToken; + +import com.cloud.utils.rest.CloudstackRESTException; +import com.cloud.utils.rest.RESTServiceConnector; +import com.cloud.utils.rest.RESTValidationStrategy; + +@SuppressWarnings("rawtypes") +public class NiciraNvpApi { + protected static final String GET_METHOD_TYPE = "get"; + protected static final String DELETE_METHOD_TYPE = "delete"; + protected static final String PUT_METHOD_TYPE = "put"; + protected static final String POST_METHOD_TYPE = "post"; + + protected static final String SEC_PROFILE_URI_PREFIX = "/ws.v1/security-profile"; + protected static final String ACL_URI_PREFIX = "/ws.v1/acl"; + private static final String SWITCH_URI_PREFIX = "/ws.v1/lswitch"; + private static final String ROUTER_URI_PREFIX = "/ws.v1/lrouter"; + private static final String LOGIN_URL = "/ws.v1/login"; + + protected RESTServiceConnector restConnector; + + protected final static Map prefixMap; + + protected final static Map listTypeMap; + + protected final static Map defaultListParams; + + static { + prefixMap = new HashMap(); + prefixMap.put(SecurityProfile.class, SEC_PROFILE_URI_PREFIX); + prefixMap.put(Acl.class, ACL_URI_PREFIX); + prefixMap.put(LogicalSwitch.class, SWITCH_URI_PREFIX); + prefixMap.put(LogicalRouter.class, ROUTER_URI_PREFIX); + + listTypeMap = new HashMap(); + listTypeMap.put(SecurityProfile.class, new TypeToken>() { + }.getType()); + listTypeMap.put(Acl.class, new TypeToken>() { + }.getType()); + listTypeMap.put(LogicalSwitch.class, new TypeToken>() { + }.getType()); + listTypeMap.put(LogicalRouter.class, new TypeToken>() { + }.getType()); + + defaultListParams = new HashMap(); + defaultListParams.put("fields", "*"); + } + + public NiciraNvpApi() { + final List> classList = new ArrayList>(); + classList.add(NatRule.class); + classList.add(RoutingConfig.class); + final List> deserializerList = new ArrayList>(); + deserializerList.add(new NatRuleAdapter()); + deserializerList.add(new RoutingConfigAdapter()); + + restConnector = new RESTServiceConnector(new RESTValidationStrategy(LOGIN_URL), classList, deserializerList); + } + + public NiciraNvpApi(final String address, final String username, final String password) { + this(); + restConnector.setControllerAddress(address); + restConnector.setAdminCredentials(username, password); + } + + public void setControllerAddress(final String address) { + restConnector.setControllerAddress(address); + } + + public void setAdminCredentials(final String username, final String password) { + restConnector.setAdminCredentials(username, password); + } + + /** + * POST + * + * @param entity + * @return + * @throws NiciraNvpApiException + */ + protected T create(final T entity) throws NiciraNvpApiException { + final String uri = prefixMap.get(entity.getClass()); + return createWithUri(entity, uri); + } + + /** + * POST + * + * @param entity + * @return + * @throws NiciraNvpApiException + */ + protected T createWithUri(final T entity, final String uri) throws NiciraNvpApiException { + T createdEntity; + try { + createdEntity = restConnector.executeCreateObject(entity, new TypeToken() { + }.getType(), uri, Collections. emptyMap()); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + + return createdEntity; + } + + /** + * GET list of items + * + * @return + * @throws NiciraNvpApiException + */ + protected NiciraNvpList find(final Class clazz) throws NiciraNvpApiException { + return find(null, clazz); + } + + /** + * GET list of items + * + * @param uuid + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList find(final String uuid, final Class clazz) throws NiciraNvpApiException { + final String uri = prefixMap.get(clazz); + Map params = defaultListParams; + if (uuid != null) { + params = new HashMap(defaultListParams); + params.put("uuid", uuid); + } + + NiciraNvpList entities; + try { + entities = restConnector.executeRetrieveObject(listTypeMap.get(clazz), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + + if (entities == null) { + throw new NiciraNvpApiException("Unexpected response from API"); + } + + return entities; + } + + /** + * PUT item given a UUID as key and an item object + * with the new data + * + * @param item + * @param uuid + * @throws NiciraNvpApiException + */ + public void update(final T item, final String uuid) + throws NiciraNvpApiException { + final String uri = prefixMap.get(item.getClass()) + "/" + uuid; + updateWithUri(item, uri); + } + + /** + * PUT item given a UUID as key and an item object + * with the new data + * + * @param item + * @param uuid + * @throws NiciraNvpApiException + */ + public void updateWithUri(final T item, final String uri) + throws NiciraNvpApiException { + try { + restConnector.executeUpdateObject(item, uri, Collections. emptyMap()); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + } + + /** + * DELETE Security Profile given a UUID as key + * + * @param securityProfileUuid + * @throws NiciraNvpApiException + */ + public void delete(final String uuid, final Class clazz) + throws NiciraNvpApiException { + final String uri = prefixMap.get(clazz) + "/" + uuid; + deleteWithUri(uri); + } + + /** + * DELETE Security Profile given a UUID as key + * + * @param securityProfileUuid + * @throws NiciraNvpApiException + */ + public void deleteWithUri(final String uri) + throws NiciraNvpApiException { + try { + restConnector.executeDeleteObject(uri); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + } + + /** + * POST {@link SecurityProfile} + * + * @param securityProfile + * @return + * @throws NiciraNvpApiException + */ + public SecurityProfile createSecurityProfile(final SecurityProfile securityProfile) throws NiciraNvpApiException { + return create(securityProfile); + } + + /** + * GET list of {@link SecurityProfile} + * + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findSecurityProfile() throws NiciraNvpApiException { + return findSecurityProfile(null); + } + + /** + * GET list of {@link SecurityProfile} filtered by UUID + * + * We could have invoked the service: + * SEC_PROFILE_URI_PREFIX + "/" + securityProfileUuid + * but it is not working currently + * + * @param uuid + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findSecurityProfile(final String uuid) throws NiciraNvpApiException { + return find(uuid, SecurityProfile.class); + } + + /** + * PUT {@link SecurityProfile} given a UUID as key and a {@link SecurityProfile} + * with the new data + * + * @param securityProfile + * @param securityProfileUuid + * @throws NiciraNvpApiException + */ + public void updateSecurityProfile(final SecurityProfile securityProfile, + final String securityProfileUuid) + throws NiciraNvpApiException { + update(securityProfile, securityProfileUuid); + } + + /** + * DELETE Security Profile given a UUID as key + * + * @param securityProfileUuid + * @throws NiciraNvpApiException + */ + public void deleteSecurityProfile(final String securityProfileUuid) + throws NiciraNvpApiException { + delete(securityProfileUuid, SecurityProfile.class); + } + + + /** + * POST {@link Acl} + * + * @param acl + * @return + * @throws NiciraNvpApiException + */ + public Acl createAcl(final Acl acl) throws NiciraNvpApiException { + return create(acl); + } + + /** + * GET list of {@link Acl} + * + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findAcl() throws NiciraNvpApiException { + return findAcl(null); + } + + /** + * GET list of {@link Acl} filtered by UUID + * + * @param uuid + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findAcl(final String uuid) throws NiciraNvpApiException { + return find(uuid, Acl.class); + } + + /** + * PUT {@link Acl} given a UUID as key and a {@link Acl} + * with the new data + * + * @param acl + * @param aclUuid + * @throws NiciraNvpApiException + */ + public void updateAcl(final Acl acl, + final String aclUuid) + throws NiciraNvpApiException { + update(acl, aclUuid); + } + + /** + * DELETE Acl given a UUID as key + * + * @param acl + * @throws NiciraNvpApiException + */ + public void deleteAcl(final String aclUuid) throws NiciraNvpApiException { + delete(aclUuid, Acl.class); + } + + public LogicalSwitch createLogicalSwitch(final LogicalSwitch logicalSwitch) throws NiciraNvpApiException { + return create(logicalSwitch); + } + + /** + * GET list of {@link LogicalSwitch} + * + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findLogicalSwitch() throws NiciraNvpApiException { + return findLogicalSwitch(null); + } + + /** + * GET list of {@link LogicalSwitch} filtered by UUID + * + * @param uuid + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findLogicalSwitch(final String uuid) throws NiciraNvpApiException { + return find(uuid, LogicalSwitch.class); + } + + /** + * PUT {@link LogicalSwitch} given a UUID as key and a {@link LogicalSwitch} + * with the new data + * + * @param logicalSwitch + * @param logicalSwitchUuid + * @throws NiciraNvpApiException + */ + public void updateLogicalSwitch(final LogicalSwitch logicalSwitch, + final String logicalSwitchUuid) + throws NiciraNvpApiException { + update(logicalSwitch, logicalSwitchUuid); + } + + public void deleteLogicalSwitch(final String uuid) throws NiciraNvpApiException { + delete(uuid, LogicalSwitch.class); + } + + public LogicalSwitchPort createLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException { + final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport"; + return createWithUri(logicalSwitchPort, uri); + } + + public void updateLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException { + final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPort.getUuid(); + updateWithUri(logicalSwitchPort, uri); + } + + public void updateLogicalSwitchPortAttachment(final String logicalSwitchUuid, final String logicalSwitchPortUuid, + final Attachment attachment) throws NiciraNvpApiException { + final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid + "/attachment"; + updateWithUri(attachment, uri); + } + + public void deleteLogicalSwitchPort(final String logicalSwitchUuid, final String logicalSwitchPortUuid) throws NiciraNvpApiException { + final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid; + deleteWithUri(uri); + } + + public String findLogicalSwitchPortUuidByVifAttachmentUuid(final String logicalSwitchUuid, final String vifAttachmentUuid) throws NiciraNvpApiException { + final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport"; + final Map params = new HashMap(); + params.put("attachment_vif_uuid", vifAttachmentUuid); + params.put("fields", "uuid"); + + NiciraNvpList lspl; + try { + lspl = restConnector.executeRetrieveObject(new TypeToken>() { + }.getType(), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + + if (lspl == null || lspl.getResultCount() != 1) { + throw new NiciraNvpApiException("Unexpected response from API"); + } + + final LogicalSwitchPort lsp = lspl.getResults().get(0); + return lsp.getUuid(); + } + + public ControlClusterStatus getControlClusterStatus() throws NiciraNvpApiException { + final String uri = "/ws.v1/control-cluster/status"; + ControlClusterStatus ccs; + try { + ccs = restConnector.executeRetrieveObject(new TypeToken() { + }.getType(), uri, null); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + + return ccs; + } + + public NiciraNvpList findLogicalSwitchPortsByUuid(final String logicalSwitchUuid, final String logicalSwitchPortUuid) throws NiciraNvpApiException { + final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport"; + final Map params = new HashMap(); + params.put("uuid", logicalSwitchPortUuid); + params.put("fields", "uuid"); + + NiciraNvpList lspl; + try { + lspl = restConnector.executeRetrieveObject(new TypeToken>() { + }.getType(), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + + if (lspl == null) { + throw new NiciraNvpApiException("Unexpected response from API"); + } + + return lspl; + } + + public NiciraNvpList findLogicalRouterPortsByUuid(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport"; + final Map params = new HashMap(); + params.put("uuid", logicalRouterPortUuid); + params.put("fields", "uuid"); + + NiciraNvpList lrpl; + try { + lrpl = restConnector.executeRetrieveObject(new TypeToken>() { + }.getType(), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + + if (lrpl == null) { + throw new NiciraNvpApiException("Unexpected response from API"); + } + + return lrpl; + } + + public LogicalRouter createLogicalRouter(final LogicalRouter logicalRouter) throws NiciraNvpApiException { + return create(logicalRouter); + } + + /** + * GET list of {@link LogicalRouter} + * + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findLogicalRouter() throws NiciraNvpApiException { + return findLogicalRouter(null); + } + + /** + * GET list of {@link LogicalRouter} filtered by UUID + * + * @param uuid + * @return + * @throws NiciraNvpApiException + */ + public NiciraNvpList findLogicalRouter(final String uuid) throws NiciraNvpApiException { + return find(uuid, LogicalRouter.class); + } + + public LogicalRouter findOneLogicalRouterByUuid(final String logicalRouterUuid) throws NiciraNvpApiException { + return findLogicalRouter(logicalRouterUuid).getResults().get(0); + } + + public void updateLogicalRouter(final LogicalRouter logicalRouter, + final String logicalRouterUuid) + throws NiciraNvpApiException { + update(logicalRouter, logicalRouterUuid); + } + + public void deleteLogicalRouter(final String logicalRouterUuid) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid; + deleteWithUri(uri); + } + + public LogicalRouterPort createLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport"; + return createWithUri(logicalRouterPort, uri); + } + + public void deleteLogicalRouterPort(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid; + deleteWithUri(uri); + } + + public void updateLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPort.getUuid(); + updateWithUri(logicalRouterPort, uri); + } + + public void updateLogicalRouterPortAttachment(final String logicalRouterUuid, final String logicalRouterPortUuid, final Attachment attachment) + throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid + "/attachment"; + updateWithUri(attachment, uri); + } + + public NatRule createLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat"; + return createWithUri(natRule, uri); + } + + public void updateLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat/" + natRule.getUuid(); + updateWithUri(natRule, uri); + } + + public void deleteLogicalRouterNatRule(final String logicalRouterUuid, final UUID natRuleUuid) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString(); + deleteWithUri(uri); + } + + public NiciraNvpList findLogicalRouterPortByGatewayServiceAndVlanId(final String logicalRouterUuid, final String gatewayServiceUuid, + final long vlanId) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport"; + final Map params = new HashMap(); + params.put("attachment_gwsvc_uuid", gatewayServiceUuid); + params.put("attachment_vlan", "0"); + params.put("fields", "*"); + + try { + return restConnector.executeRetrieveObject(new TypeToken>() { + }.getType(), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + } + + public NiciraNvpList findNatRulesByLogicalRouterUuid(final String logicalRouterUuid) throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat"; + final Map params = new HashMap(); + params.put("fields", "*"); + + try { + return restConnector.executeRetrieveObject(new TypeToken>() { + }.getType(), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + } + + public NiciraNvpList findLogicalRouterPortByGatewayServiceUuid(final String logicalRouterUuid, final String l3GatewayServiceUuid) + throws NiciraNvpApiException { + final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport"; + final Map params = new HashMap(); + params.put("fields", "*"); + params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid); + + try { + return restConnector.executeRetrieveObject(new TypeToken>() { + }.getType(), uri, params); + } catch (final CloudstackRESTException e) { + throw new NiciraNvpApiException(e); + } + } + + public static class NatRuleAdapter implements JsonDeserializer { + + @Override + public NatRule deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException { + final JsonObject jsonObject = jsonElement.getAsJsonObject(); + + if (!jsonObject.has("type")) { + throw new JsonParseException("Deserializing as a NatRule, but no type present in the json object"); + } + + final String natRuleType = jsonObject.get("type").getAsString(); + if ("SourceNatRule".equals(natRuleType)) { + return context.deserialize(jsonElement, SourceNatRule.class); + } else if ("DestinationNatRule".equals(natRuleType)) { + return context.deserialize(jsonElement, DestinationNatRule.class); + } + + throw new JsonParseException("Failed to deserialize type \"" + natRuleType + "\""); + } + } + + public static class RoutingConfigAdapter implements JsonDeserializer { + + private static final String ROUTING_TABLE_ROUTING_CONFIG = "RoutingTableRoutingConfig"; + private static final String SINGLE_DEFAULT_ROUTE_IMPLICIT_ROUTING_CONFIG = "SingleDefaultRouteImplicitRoutingConfig"; + + @Override + public RoutingConfig deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException { + final JsonObject jsonObject = jsonElement.getAsJsonObject(); + + if (!jsonObject.has("type")) { + throw new JsonParseException("Deserializing as a RoutingConfig, but no type present in the json object"); + } + + final String routingConfigType = jsonObject.get("type").getAsString(); + if (SINGLE_DEFAULT_ROUTE_IMPLICIT_ROUTING_CONFIG.equals(routingConfigType)) { + return context.deserialize(jsonElement, SingleDefaultRouteImplicitRoutingConfig.class); + } else if (ROUTING_TABLE_ROUTING_CONFIG.equals(routingConfigType)) { + return context.deserialize(jsonElement, RoutingTableRoutingConfig.class); + } + + throw new JsonParseException("Failed to deserialize type \"" + routingConfigType + "\""); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApiException.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApiException.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApiException.java new file mode 100644 index 0000000..0d27820 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApiException.java @@ -0,0 +1,39 @@ +// +// 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 com.cloud.network.nicira; + +public class NiciraNvpApiException extends Exception { + + public NiciraNvpApiException() { + } + + public NiciraNvpApiException(final String message) { + super(message); + } + + public NiciraNvpApiException(final Throwable cause) { + super(cause); + } + + public NiciraNvpApiException(final String message, final Throwable cause) { + super(message, cause); + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpList.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpList.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpList.java new file mode 100644 index 0000000..34b5e19 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpList.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 com.cloud.network.nicira; + +import java.util.List; + +public class NiciraNvpList { + private List results; + private int resultCount; + + public List getResults() { + return this.results; + } + + public void setResults(List results) { + this.results = results; + } + + public int getResultCount() { + return resultCount; + } + + public void setResultCount(int resultCount) { + this.resultCount = resultCount; + } + + public boolean isEmpty() { + return this.resultCount == 0; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpTag.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpTag.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpTag.java new file mode 100644 index 0000000..625e49c --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpTag.java @@ -0,0 +1,64 @@ +// +// 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 com.cloud.network.nicira; + +import org.apache.log4j.Logger; + +public class NiciraNvpTag { + private static final int TAG_MAX_LEN = 40; + private static final Logger s_logger = Logger.getLogger(NiciraNvpTag.class); + private String scope; + private String tag; + + public NiciraNvpTag() { + } + + public NiciraNvpTag(String scope, String tag) { + this.scope = scope; + if (tag.length() > 40) { + s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters"); + this.tag = tag.substring(0, TAG_MAX_LEN); + } else { + this.tag = tag; + } + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + if (tag.length() > 40) { + s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters"); + this.tag = tag.substring(0, 40); + } else { + this.tag = tag; + } + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/PatchAttachment.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/PatchAttachment.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/PatchAttachment.java new file mode 100644 index 0000000..26fa048 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/PatchAttachment.java @@ -0,0 +1,41 @@ +// +// 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 com.cloud.network.nicira; + +/** + * + */ +public class PatchAttachment extends Attachment { + private final String type = "PatchAttachment"; + private String peerPortUuid; + + public PatchAttachment(String peerPortUuid) { + this.peerPortUuid = peerPortUuid; + } + + public String getPeerPortUuid() { + return peerPortUuid; + } + + public void setPeerPortUuid(String peerPortUuid) { + this.peerPortUuid = peerPortUuid; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RouterNextHop.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RouterNextHop.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RouterNextHop.java new file mode 100644 index 0000000..8dd8840 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RouterNextHop.java @@ -0,0 +1,40 @@ +// +// 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 com.cloud.network.nicira; + +/** + * + */ +public class RouterNextHop { + private String gatewayIpAddress; + private final String type = "RouterNextHop"; + + public RouterNextHop(String gatewayIpAddress) { + this.gatewayIpAddress = gatewayIpAddress; + } + + public String getGatewayIpAddress() { + return gatewayIpAddress; + } + + public void setGatewayIpAddress(String gatewayIpAddress) { + this.gatewayIpAddress = gatewayIpAddress; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingConfig.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingConfig.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingConfig.java new file mode 100644 index 0000000..5eaef0a --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingConfig.java @@ -0,0 +1,24 @@ +// +// 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 com.cloud.network.nicira; + +public class RoutingConfig { + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingTableRoutingConfig.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingTableRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingTableRoutingConfig.java new file mode 100644 index 0000000..f0a80b8 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/RoutingTableRoutingConfig.java @@ -0,0 +1,30 @@ +// +// 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 com.cloud.network.nicira; + +/** + * + */ +public class RoutingTableRoutingConfig extends RoutingConfig { + public final String type = "RoutingTableRoutingConfig"; + + public RoutingTableRoutingConfig() { + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityProfile.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityProfile.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityProfile.java new file mode 100644 index 0000000..d83ce49 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityProfile.java @@ -0,0 +1,24 @@ +// +// 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 com.cloud.network.nicira; + +@SuppressWarnings("serial") +public class SecurityProfile extends AccessConfiguration { +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityRule.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityRule.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityRule.java new file mode 100644 index 0000000..e23593c --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SecurityRule.java @@ -0,0 +1,138 @@ +// +// 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 com.cloud.network.nicira; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +@SuppressWarnings("serial") +public class SecurityRule extends AccessRule { + + protected String ipPrefix; + + protected int portRangeMin; + + protected int portRangeMax; + + protected String profileUuid; + + + /** + * Default constructor + */ + public SecurityRule() { + } + + /** + * Fully parameterized constructor + */ + public SecurityRule(final String ethertype, final String ipPrefix, final String profileUuid, + final int portRangeMin, final int portRangeMax, final int protocol) { + this.ethertype = ethertype; + this.ipPrefix = ipPrefix; + this.portRangeMin = portRangeMin; + this.portRangeMax = portRangeMax; + this.profileUuid = profileUuid; + this.protocol = protocol; + } + + @Override + public String getEthertype() { + return ethertype; + } + + @Override + public void setEthertype(final String ethertype) { + this.ethertype = ethertype; + } + + public String getIpPrefix() { + return ipPrefix; + } + + public void setIpPrefix(final String ipPrefix) { + this.ipPrefix = ipPrefix; + } + + public int getPortRangeMin() { + return portRangeMin; + } + + public void setPortRangeMin(final int portRangeMin) { + this.portRangeMin = portRangeMin; + } + + public int getPortRangeMax() { + return portRangeMax; + } + + public void setPortRangeMax(final int portRangeMax) { + this.portRangeMax = portRangeMax; + } + + public String getProfileUuid() { + return profileUuid; + } + + public void setProfileUuid(final String profileUuid) { + this.profileUuid = profileUuid; + } + + @Override + public int getProtocol() { + return protocol; + } + + @Override + public void setProtocol(final int protocol) { + this.protocol = protocol; + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 31) + .append(ethertype).append(ipPrefix) + .append(portRangeMin).append(portRangeMax) + .append(profileUuid).append(protocol) + .toHashCode(); + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof SecurityRule)) { + return false; + } + final SecurityRule another = (SecurityRule) obj; + return new EqualsBuilder() + .append(ethertype, another.ethertype) + .append(ipPrefix, another.ipPrefix) + .append(portRangeMin, another.portRangeMin) + .append(portRangeMax, another.portRangeMax) + .append(profileUuid, another.profileUuid) + .append(protocol, another.protocol) + .isEquals(); + } +}