2 * Copyright (C) 2014 Red Hat, Inc. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.neutron.spi;
11 import javax.xml.bind.annotation.XmlAccessType;
12 import javax.xml.bind.annotation.XmlAccessorType;
13 import javax.xml.bind.annotation.XmlElement;
14 import javax.xml.bind.annotation.XmlRootElement;
17 * See OpenStack Network API v2.0 Reference for description of
18 * annotated attributes. The current fields are as follows:
21 * id uuid (String) UUID for the security group rule.
22 * direction String Direction the VM traffic (ingress/egress).
23 * security_group_id The security group to associate rule with.
24 * protocol String IP Protocol (icmp, tcp, udp, etc) or uint8.
25 * port_range_min Integer Port at start of range
26 * port_range_max Integer Port at end of range
27 * ethertype String ethertype in L2 packet (IPv4, IPv6, etc)
28 * remote_ip_prefix String (IP cidr) CIDR for address range.
29 * remote_group_id uuid-str Source security group to apply to rule.
30 * tenant_id uuid-str Owner of security rule. Admin only outside tenant.
34 @XmlAccessorType(XmlAccessType.NONE)
35 public final class NeutronSecurityRule extends NeutronObject<NeutronSecurityRule> {
36 private static final long serialVersionUID = 1L;
38 @XmlElement(name = "direction")
39 String securityRuleDirection;
41 @XmlElement(name = "protocol")
42 String securityRuleProtocol;
44 @XmlElement(name = "port_range_min")
45 Integer securityRulePortMin;
47 @XmlElement(name = "port_range_max")
48 Integer securityRulePortMax;
50 @XmlElement(name = "ethertype")
51 String securityRuleEthertype;
53 @XmlElement(name = "remote_ip_prefix")
54 String securityRuleRemoteIpPrefix;
56 @XmlElement(name = "remote_group_id")
57 String securityRemoteGroupID;
59 @XmlElement(name = "security_group_id")
60 String securityRuleGroupID;
62 public NeutronSecurityRule() {
65 public String getSecurityRuleDirection() {
66 return securityRuleDirection;
69 public void setSecurityRuleDirection(String securityRuleDirection) {
70 this.securityRuleDirection = securityRuleDirection;
73 public String getSecurityRuleProtocol() {
74 return securityRuleProtocol;
77 public void setSecurityRuleProtocol(String securityRuleProtocol) {
78 this.securityRuleProtocol = securityRuleProtocol;
81 public Integer getSecurityRulePortMin() {
82 return securityRulePortMin;
85 public void setSecurityRulePortMin(Integer securityRulePortMin) {
86 this.securityRulePortMin = securityRulePortMin;
89 public Integer getSecurityRulePortMax() {
90 return securityRulePortMax;
93 public void setSecurityRulePortMax(Integer securityRulePortMax) {
94 this.securityRulePortMax = securityRulePortMax;
97 public String getSecurityRuleEthertype() {
98 return securityRuleEthertype;
101 public void setSecurityRuleEthertype(String securityRuleEthertype) {
102 this.securityRuleEthertype = securityRuleEthertype;
105 public String getSecurityRuleRemoteIpPrefix() {
106 return securityRuleRemoteIpPrefix;
109 public void setSecurityRuleRemoteIpPrefix(String securityRuleRemoteIpPrefix) {
110 this.securityRuleRemoteIpPrefix = securityRuleRemoteIpPrefix;
113 public String getSecurityRemoteGroupID() {
114 return securityRemoteGroupID;
117 public void setSecurityRemoteGroupID(String securityRemoteGroupID) {
118 this.securityRemoteGroupID = securityRemoteGroupID;
121 public String getSecurityRuleGroupID() {
122 return securityRuleGroupID;
125 public void setSecurityRuleGroupID(String securityRuleGroupID) {
126 this.securityRuleGroupID = securityRuleGroupID;
130 protected boolean extractField(String field, NeutronSecurityRule ans) {
133 ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
136 ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
138 case "port_range_min":
139 ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
141 case "port_range_max":
142 ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
145 ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
147 case "remote_ip_prefix":
148 ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
150 case "remote_group_id":
151 ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
153 case "security_group_id":
154 ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
157 return super.extractField(field, ans);
163 public String toString() {
164 return "NeutronSecurityRule{" + "securityRuleUUID='" + uuid + '\'' + ", securityRuleDirection='"
165 + securityRuleDirection + '\'' + ", securityRuleProtocol='" + securityRuleProtocol + '\''
166 + ", securityRulePortMin=" + securityRulePortMin + ", securityRulePortMax=" + securityRulePortMax
167 + ", securityRuleEthertype='" + securityRuleEthertype + '\'' + ", securityRuleRemoteIpPrefix='"
168 + securityRuleRemoteIpPrefix + '\'' + ", securityRemoteGroupID=" + securityRemoteGroupID
169 + ", securityRuleGroupID='" + securityRuleGroupID + '\'' + ", securityRuleTenantID='" + tenantID + '\''