Make neutron a simple osgi app
[controller.git] / opendaylight / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / NeutronSecurityRule.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.
3  *
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
7  *
8  */
9
10 package org.opendaylight.controller.networkconfig.neutron;
11
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;
19
20 /**
21  * See OpenStack Network API v2.0 Reference for description of
22  * annotated attributes. The current fields are as follows:
23  * <p/>
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.
35  */
36
37 @XmlRootElement
38 @XmlAccessorType(XmlAccessType.NONE)
39
40 public class NeutronSecurityRule implements Serializable {
41     private static final long serialVersionUID = 1L;
42
43     @XmlElement(name = "id")
44     String securityRuleUUID;
45
46     @XmlElement(name = "direction")
47     String securityRuleDirection;
48
49     @XmlElement(name = "protocol")
50     String securityRuleProtocol;
51
52     @XmlElement(name = "port_range_min")
53     Integer securityRulePortMin;
54
55     @XmlElement(name = " port_range_max")
56     Integer securityRulePortMax;
57
58     @XmlElement(name = "ethertype")
59     String securityRuleEthertype;
60
61     @XmlElement(name = "remote_ip_prefix")
62     String securityRuleRemoteIpPrefix;
63
64     @XmlElement(name = "remote_group_id")
65     String securityRemoteGroupID;
66
67     @XmlElement(name = "security_group_id")
68     String securityRuleGroupID;
69
70     @XmlElement(name = "tenant_id")
71     String securityRuleTenantID;
72
73     public NeutronSecurityRule() {
74         List<NeutronSecurityRule> securityRules;
75     }
76
77     public String getSecurityRuleUUID() {
78         return securityRuleUUID;
79     }
80
81     public void setSecurityRuleUUID(String securityRuleUUID) {
82         this.securityRuleUUID = securityRuleUUID;
83     }
84
85     public String getSecurityRuleDirection() {
86         return securityRuleDirection;
87     }
88
89     public void setSecurityRuleDirection(String securityRuleDirection) {
90         this.securityRuleDirection = securityRuleDirection;
91     }
92
93     public String getSecurityRuleProtocol() {
94         return securityRuleProtocol;
95     }
96
97     public void setSecurityRuleProtocol(String securityRuleProtocol) {
98         this.securityRuleProtocol = securityRuleProtocol;
99     }
100
101     public Integer getSecurityRulePortMin() {
102         return securityRulePortMin;
103     }
104
105     public void setSecurityRulePortMin(Integer securityRulePortMin) {
106         this.securityRulePortMin = securityRulePortMin;
107     }
108
109     public Integer getSecurityRulePortMax() {
110         return securityRulePortMax;
111     }
112
113     public void setSecurityRulePortMax(Integer securityRulePortMax) {
114         this.securityRulePortMax = securityRulePortMax;
115     }
116
117     public String getSecurityRuleEthertype() {
118         return securityRuleEthertype;
119     }
120
121     public void setSecurityRuleEthertype(String securityRuleEthertype) {
122         this.securityRuleEthertype = securityRuleEthertype;
123     }
124
125     public String getSecurityRuleRemoteIpPrefix() {
126         return securityRuleRemoteIpPrefix;
127     }
128
129     public void setSecurityRuleRemoteIpPrefix(String securityRuleRemoteIpPrefix) {
130         this.securityRuleRemoteIpPrefix = securityRuleRemoteIpPrefix;
131     }
132
133     public String getSecurityRemoteGroupID() {
134         return securityRemoteGroupID;
135     }
136
137     public void setSecurityRemoteGroupID(String securityRemoteGroupID) {
138         this.securityRemoteGroupID = securityRemoteGroupID;
139     }
140
141     public String getSecurityRuleGroupID() {
142         return securityRuleGroupID;
143     }
144
145     public void setSecurityRuleGroupID(String securityRuleGroupID) {
146         this.securityRuleGroupID = securityRuleGroupID;
147     }
148
149     public String getSecurityRuleTenantID() {
150         return securityRuleTenantID;
151     }
152
153     public void setSecurityRuleTenantID(String securityRuleTenantID) {
154         this.securityRuleTenantID = securityRuleTenantID;
155     }
156
157     public NeutronSecurityRule extractFields(List<String> fields) {
158         NeutronSecurityRule ans = new NeutronSecurityRule();
159         Iterator<String> i = fields.iterator();
160         while (i.hasNext()) {
161             String s = i.next();
162             if (s.equals("id")) {
163                 ans.setSecurityRuleUUID(this.getSecurityRuleUUID());
164             }
165             if (s.equals("direction")) {
166                 ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
167             }
168             if (s.equals("protocol")) {
169                 ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
170             }
171             if (s.equals("port_range_min")) {
172                 ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
173             }
174             if (s.equals("port_range_max")) {
175                 ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
176             }
177             if (s.equals("ethertype")) {
178                 ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
179             }
180             if (s.equals("remote_ip_prefix")) {
181                 ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
182             }
183             if (s.equals("remote_group_id")) {
184                 ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
185             }
186             if (s.equals("security_group_id")) {
187                 ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
188             }
189             if (s.equals("tenant_id")) {
190                 ans.setSecurityRuleTenantID(this.getSecurityRuleTenantID());
191             }
192         }
193         return ans;
194     }
195
196     @Override
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 + '\'' +
209             '}';
210     }
211
212     public void initDefaults() {
213         //TODO verify no defaults values are nessecary required.
214     }
215 }