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.ArrayList;
18 import java.util.Iterator;
19 import java.util.List;
22 * OpenStack Neutron v2.0 Security Group bindings.
23 * See OpenStack Network API v2.0 Reference for description of
24 * annotated attributes. The current fields are as follows:
26 * id uuid-str unique ID for the security group.
27 * name String name of the security group.
28 * description String name of the security group.
29 * tenant_id uuid-str Owner of security rule..
30 * security_group_rules List<NeutronSecurityRule> nested RO in the sec group.
34 @XmlAccessorType(XmlAccessType.NONE)
36 public class NeutronSecurityGroup implements Serializable {
37 private static final long serialVersionUID = 1L;
39 @XmlElement(name = "id")
40 String securityGroupUUID;
42 @XmlElement(name = "name")
43 String securityGroupName;
45 @XmlElement(name = "description")
46 String securityGroupDescription;
48 @XmlElement(name = "tenant_id")
49 String securityGroupTenantID;
51 @XmlElement(name = "security_group_rules")
52 List<NeutronSecurityRule> neutronSecurityRule;
54 List<NeutronPort> neutronPorts;
56 public NeutronSecurityGroup() {
57 neutronPorts = new ArrayList<NeutronPort> ();
58 List<NeutronSecurityRule> securityRules;
62 public String getSecurityGroupUUID() {
63 return securityGroupUUID;
66 public void setSecurityGroupUUID(String securityGroupUUID) {
67 this.securityGroupUUID = securityGroupUUID;
70 public String getSecurityGroupName() {
71 return securityGroupName;
74 public void setSecurityGroupName(String securityGroupName) {
75 this.securityGroupName = securityGroupName;
78 public String getSecurityGroupDescription() {
79 return securityGroupDescription;
82 public void setSecurityGroupDescription(String securityGroupDescription) {
83 this.securityGroupDescription = securityGroupDescription;
86 public String getSecurityGroupTenantID() {
87 return securityGroupTenantID;
90 public void setSecurityGroupTenantID(String securityGroupTenantID) {
91 this.securityGroupTenantID = securityGroupTenantID;
95 public List<NeutronSecurityRule> getSecurityRules() {
96 return neutronSecurityRule;
99 public void setSecurityRules(NeutronSecurityRule neutronSecurityRule) {
100 this.neutronSecurityRule = (List<NeutronSecurityRule>) neutronSecurityRule;
103 public NeutronSecurityGroup extractFields(List<String> fields) {
104 NeutronSecurityGroup ans = new NeutronSecurityGroup ();
105 Iterator<String> i = fields.iterator ();
106 while (i.hasNext ()) {
107 String s = i.next ();
108 if (s.equals ("id")) {
109 ans.setSecurityGroupUUID (this.getSecurityGroupUUID ());
111 if (s.equals ("name")) {
112 ans.setSecurityGroupName (this.getSecurityGroupName ());
114 if (s.equals ("description")) {
115 ans.setSecurityGroupDescription (this.getSecurityGroupDescription ());
117 if (s.equals ("tenant_id")) {
118 ans.setSecurityGroupTenantID (this.getSecurityGroupTenantID ());
120 if (s.equals ("security_group_rules")) {
121 ans.setSecurityRules ((NeutronSecurityRule) this.getSecurityRules ());
128 public String toString() {
129 return "NeutronSecurityGroup{" +
130 "securityGroupUUID='" + securityGroupUUID + '\'' +
131 ", securityGroupName='" + securityGroupName + '\'' +
132 ", securityGroupDescription='" + securityGroupDescription + '\'' +
133 ", securityGroupTenantID='" + securityGroupTenantID + '\'' +
134 ", securityRules=" + neutronSecurityRule + "]";
137 public void initDefaults() {
138 //TODO verify no defaults values are nessecary required.