2 * Copyright (C) 2014 Red Hat, Inc.
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
10 package org.opendaylight.controller.networkconfig.neutron;
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlRootElement;
16 import java.io.Serializable;
17 import java.util.Iterator;
18 import java.util.List;
21 * See OpenStack Network API v2.0 Reference for description of
22 * annotated attributes. The current fields are as follows:
24 * id uuid (String) UUID for the security group rule.
25 * security_rule_id uuid (String) The security group to associate rule.
26 * direction String Direction the VM traffic (ingress/egress).
27 * security_group_id The security group to associate rule with.
28 * protocol String IP Protocol (icmp, tcp, udp, etc).
29 * port_range_min Integer Port at start of range
30 * port_range_max Integer Port at end of range
31 * ethertype String ethertype in L2 packet (IPv4, IPv6, etc)
32 * remote_ip_prefix String (IP cidr) CIDR for address range.
33 * remote_group_id uuid-str Source security group to apply to rule.
34 * tenant_id uuid-str Owner of security rule. Admin only outside tenant.
38 @XmlAccessorType(XmlAccessType.NONE)
40 public class NeutronSecurityRule implements Serializable {
41 private static final long serialVersionUID = 1L;
43 @XmlElement(name = "id")
44 String securityRuleUUID;
46 @XmlElement(name = "direction")
47 String securityRuleDirection;
49 @XmlElement(name = "protocol")
50 String securityRuleProtocol;
52 @XmlElement(name = "port_range_min")
53 Integer securityRulePortMin;
55 @XmlElement(name = " port_range_max")
56 Integer securityRulePortMax;
58 @XmlElement(name = "ethertype")
59 String securityRuleEthertype;
61 @XmlElement(name = "remote_ip_prefix")
62 String securityRuleRemoteIpPrefix;
64 @XmlElement(name = "remote_group_id")
65 String securityRemoteGroupID;
67 @XmlElement(name = "security_group_id")
68 String securityRuleGroupID;
70 @XmlElement(name = "tenant_id")
71 String securityRuleTenantID;
73 public NeutronSecurityRule() {
74 List<NeutronSecurityRule> securityRules;
77 public String getSecurityRuleUUID() {
78 return securityRuleUUID;
81 public void setSecurityRuleUUID(String securityRuleUUID) {
82 this.securityRuleUUID = securityRuleUUID;
85 public String getSecurityRuleDirection() {
86 return securityRuleDirection;
89 public void setSecurityRuleDirection(String securityRuleDirection) {
90 this.securityRuleDirection = securityRuleDirection;
93 public String getSecurityRuleProtocol() {
94 return securityRuleProtocol;
97 public void setSecurityRuleProtocol(String securityRuleProtocol) {
98 this.securityRuleProtocol = securityRuleProtocol;
101 public Integer getSecurityRulePortMin() {
102 return securityRulePortMin;
105 public void setSecurityRulePortMin(Integer securityRulePortMin) {
106 this.securityRulePortMin = securityRulePortMin;
109 public Integer getSecurityRulePortMax() {
110 return securityRulePortMax;
113 public void setSecurityRulePortMax(Integer securityRulePortMax) {
114 this.securityRulePortMax = securityRulePortMax;
117 public String getSecurityRuleEthertype() {
118 return securityRuleEthertype;
121 public void setSecurityRuleEthertype(String securityRuleEthertype) {
122 this.securityRuleEthertype = securityRuleEthertype;
125 public String getSecurityRuleRemoteIpPrefix() {
126 return securityRuleRemoteIpPrefix;
129 public void setSecurityRuleRemoteIpPrefix(String securityRuleRemoteIpPrefix) {
130 this.securityRuleRemoteIpPrefix = securityRuleRemoteIpPrefix;
133 public String getSecurityRemoteGroupID() {
134 return securityRemoteGroupID;
137 public void setSecurityRemoteGroupID(String securityRemoteGroupID) {
138 this.securityRemoteGroupID = securityRemoteGroupID;
141 public String getSecurityRuleGroupID() {
142 return securityRuleGroupID;
145 public void setSecurityRuleGroupID(String securityRuleGroupID) {
146 this.securityRuleGroupID = securityRuleGroupID;
149 public String getSecurityRuleTenantID() {
150 return securityRuleTenantID;
153 public void setSecurityRuleTenantID(String securityRuleTenantID) {
154 this.securityRuleTenantID = securityRuleTenantID;
157 public NeutronSecurityRule extractFields(List<String> fields) {
158 NeutronSecurityRule ans = new NeutronSecurityRule();
159 Iterator<String> i = fields.iterator();
160 while (i.hasNext()) {
162 if (s.equals("id")) {
163 ans.setSecurityRuleUUID(this.getSecurityRuleUUID());
165 if (s.equals("direction")) {
166 ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
168 if (s.equals("protocol")) {
169 ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
171 if (s.equals("port_range_min")) {
172 ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
174 if (s.equals("port_range_max")) {
175 ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
177 if (s.equals("ethertype")) {
178 ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
180 if (s.equals("remote_ip_prefix")) {
181 ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
183 if (s.equals("remote_group_id")) {
184 ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
186 if (s.equals("security_group_id")) {
187 ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
189 if (s.equals("tenant_id")) {
190 ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
197 public String toString() {
198 return "NeutronSecurityRule{" +
199 "securityRuleUUID='" + securityRuleUUID + '\'' +
200 ", securityRuleDirection='" + securityRuleDirection + '\'' +
201 ", securityRuleProtocol='" + securityRuleProtocol + '\'' +
202 ", securityRulePortMin=" + securityRulePortMin +
203 ", securityRulePortMax=" + securityRulePortMax +
204 ", securityRuleEthertype='" + securityRuleEthertype + '\'' +
205 ", securityRuleRemoteIpPrefix='" + securityRuleRemoteIpPrefix + '\'' +
206 ", securityRemoteGroupID=" + securityRemoteGroupID +
207 ", securityRuleGroupID='" + securityRuleGroupID + '\'' +
208 ", securityRuleTenantID='" + securityRuleTenantID + '\'' +
212 public void initDefaults() {
213 //TODO verify no defaults values are nessecary required.