3304927c30a082ef68f7de1797ea68addc5a5a5a
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronLoadBalancer.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.  All rights reserved.
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 package org.opendaylight.neutron.spi;
10
11 import java.io.Serializable;
12 import java.util.Iterator;
13 import java.util.List;
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 /**
20  * OpenStack Neutron v2.0 Load Balancer as a service
21  * (LBaaS) bindings. See OpenStack Network API
22  * v2.0 Reference for description of  the fields:
23  * Implemented fields are as follows:
24  *
25  * id                 uuid-str
26  * tenant_id          uuid-str
27  * name               String
28  * status             String
29  * vip_address        IP address
30  * vip_subnet         uuid-str
31  * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
32  */
33
34 @XmlRootElement
35 @XmlAccessorType(XmlAccessType.NONE)
36 public class NeutronLoadBalancer extends NeutronObject<NeutronLoadBalancer>
37         implements Serializable, INeutronObject<NeutronLoadBalancer> {
38     private static final long serialVersionUID = 1L;
39
40     @XmlElement(name = "name")
41     String loadBalancerName;
42
43     @XmlElement(name = "status")
44     String loadBalancerStatus;
45
46     @XmlElement(name = "admin_state_up")
47     Boolean loadBalancerAdminStateUp;
48
49     @XmlElement(name = "vip_address")
50     String loadBalancerVipAddress;
51
52     @XmlElement(name = "vip_subnet_id")
53     String loadBalancerVipSubnetID;
54
55     public String getLoadBalancerName() {
56         return loadBalancerName;
57     }
58
59     public void setLoadBalancerName(String loadBalancerName) {
60         this.loadBalancerName = loadBalancerName;
61     }
62
63     public String getLoadBalancerStatus() {
64         return loadBalancerStatus;
65     }
66
67     public void setLoadBalancerStatus(String loadBalancerStatus) {
68         this.loadBalancerStatus = loadBalancerStatus;
69     }
70
71     public Boolean getLoadBalancerAdminStateUp() {
72         return loadBalancerAdminStateUp;
73     }
74
75     public void setLoadBalancerAdminStateUp(Boolean loadBalancerAdminStateUp) {
76         this.loadBalancerAdminStateUp = loadBalancerAdminStateUp;
77     }
78
79     public String getLoadBalancerVipAddress() {
80         return loadBalancerVipAddress;
81     }
82
83     public void setLoadBalancerVipAddress(String loadBalancerVipAddress) {
84         this.loadBalancerVipAddress = loadBalancerVipAddress;
85     }
86
87     public String getLoadBalancerVipSubnetID() {
88         return loadBalancerVipSubnetID;
89     }
90
91     public void setLoadBalancerVipSubnetID(String loadBalancerVipSubnetID) {
92         this.loadBalancerVipSubnetID = loadBalancerVipSubnetID;
93     }
94
95     public NeutronLoadBalancer extractFields(List<String> fields) {
96         NeutronLoadBalancer ans = new NeutronLoadBalancer();
97         Iterator<String> i = fields.iterator();
98         while (i.hasNext()) {
99             String s = i.next();
100             if (s.equals("id")) {
101                 ans.setID(this.getID());
102             }
103             if (s.equals("tenant_id")) {
104                 ans.setTenantID(this.getTenantID());
105             }
106             if (s.equals("name")) {
107                 ans.setLoadBalancerName(this.getLoadBalancerName());
108             }
109             if (s.equals("vip_address")) {
110                 ans.setLoadBalancerVipAddress(this.getLoadBalancerVipAddress());
111             }
112             if (s.equals("vip_subnet_id")) {
113                 ans.setLoadBalancerVipSubnetID(this.getLoadBalancerVipSubnetID());
114             }
115             if (s.equals("status")) {
116                 ans.setLoadBalancerStatus(this.getLoadBalancerStatus());
117             }
118             if (s.equals("admin_state_up")) {
119                 ans.setLoadBalancerAdminStateUp(this.getLoadBalancerAdminStateUp());
120             }
121         }
122         return ans;
123     }
124
125     @Override
126     public String toString() {
127         return "NeutronLoadBalancer{" + "loadBalancerID='" + uuid + '\'' + ", loadBalancerTenantID='" + tenantID + '\''
128                 + ", loadBalancerName='" + loadBalancerName + '\'' + ", loadBalancerStatus='" + loadBalancerStatus
129                 + '\'' + ", loadBalancerAdminStateUp='" + loadBalancerAdminStateUp + '\'' + ", loadBalancerVipAddress='"
130                 + loadBalancerVipAddress + '\'' + ", loadBalancerVipSubnetID='" + loadBalancerVipSubnetID + '\'' + '}';
131     }
132 }