2929
3030/**
3131 * A bean representing a public IP Address
32- *
33- * @author Will Chan
3432 *
3533 */
3634@ Entity
3735@ Table (name =("user_ip_address" ))
3836public class IPAddressVO implements IpAddress {
3937 @ Column (name ="account_id" )
40- private Long accountId = null ;
38+ private Long allocatedToAccountId = null ;
4139
4240 @ Column (name ="domain_id" )
43- private Long domainId = null ;
41+ private Long allocatedInDomainId = null ;
4442
4543 @ Id
4644 @ Column (name ="public_ip_address" )
@@ -54,22 +52,34 @@ public class IPAddressVO implements IpAddress {
5452
5553 @ Column (name ="allocated" )
5654 @ Temporal (value =TemporalType .TIMESTAMP )
57- private Date allocated ;
55+ private Date allocatedTime ;
5856
5957 @ Column (name ="vlan_db_id" )
60- private long vlanDbId ;
58+ private long vlanId ;
6159
6260 @ Column (name ="one_to_one_nat" )
6361 private boolean oneToOneNat ;
62+
63+ @ Column (name ="state" )
64+ private State state ;
6465
6566 protected IPAddressVO () {
67+ }
68+
69+ @ Override
70+ public boolean readyToUse () {
71+ return state == State .Allocated ;
6672 }
6773
6874 public IPAddressVO (String address , long dataCenterId , long vlanDbId , boolean sourceNat ) {
6975 this .address = address ;
7076 this .dataCenterId = dataCenterId ;
71- this .vlanDbId = vlanDbId ;
72- this .sourceNat = sourceNat ;
77+ this .vlanId = vlanDbId ;
78+ this .sourceNat = sourceNat ;
79+ this .allocatedInDomainId = null ;
80+ this .allocatedToAccountId = null ;
81+ this .allocatedTime = null ;
82+ this .state = State .Free ;
7383 }
7484
7585 @ Override
@@ -80,68 +90,80 @@ public long getDataCenterId() {
8090 @ Override
8191 public String getAddress () {
8292 return address ;
83- }
93+ }
94+
8495 @ Override
85- public Long getAccountId () {
86- return accountId ;
87- }
96+ public Long getAllocatedToAccountId () {
97+ return allocatedToAccountId ;
98+ }
99+
88100 @ Override
89- public Long getDomainId () {
90- return domainId ;
91- }
101+ public Long getAllocatedInDomainId () {
102+ return allocatedInDomainId ;
103+ }
104+
92105 @ Override
93- public Date getAllocated () {
94- return allocated ;
95- }
96- @ Override
97- public boolean isSourceNat () {
98- return sourceNat ;
106+ public Date getAllocatedTime () {
107+ return allocatedTime ;
99108 }
100109
101- @ Override
102- public void setAccountId (Long accountId ) {
103- this .accountId = accountId ;
110+ public void setAllocatedToAccountId (Long accountId ) {
111+ this .allocatedToAccountId = accountId ;
104112 }
105113
106- @ Override
107- public void setDomainId (Long domainId ) {
108- this .domainId = domainId ;
114+ public void setAllocatedInDomainId (Long domainId ) {
115+ this .allocatedInDomainId = domainId ;
109116 }
110117
111- @ Override
112118 public void setSourceNat (boolean sourceNat ) {
113119 this .sourceNat = sourceNat ;
114120 }
115121
116122 @ Override
117- public boolean getSourceNat () {
118- return this . sourceNat ;
123+ public boolean isSourceNat () {
124+ return sourceNat ;
119125 }
120126
121- @ Override
122- public void setAllocated (Date allocated ) {
123- this .allocated = allocated ;
127+ public void setAllocatedTime (Date allocated ) {
128+ this .allocatedTime = allocated ;
124129 }
125130
126131 @ Override
127- public long getVlanDbId () {
128- return this .vlanDbId ;
132+ public long getVlanId () {
133+ return this .vlanId ;
129134 }
130135
131- @ Override
132- public void setVlanDbId (long vlanDbId ) {
133- this .vlanDbId = vlanDbId ;
136+ public void setVlanId (long vlanDbId ) {
137+ this .vlanId = vlanDbId ;
134138 }
135139
136140 @ Override
137141 public boolean isOneToOneNat () {
138142 return oneToOneNat ;
139143 }
140144
141- @ Override
142145 public void setOneToOneNat (boolean oneToOneNat ) {
143146 this .oneToOneNat = oneToOneNat ;
144147 }
148+
149+ @ Override
150+ public long getDomainId () {
151+ return allocatedInDomainId == null ? -1 : allocatedInDomainId ;
152+ }
153+
154+ @ Override
155+ public long getAccountId () {
156+ return allocatedToAccountId == null ? -1 : allocatedToAccountId ;
157+ }
158+
159+ @ Override
160+ public State getState () {
161+ return state ;
162+ }
163+
164+ public void setState (State state ) {
165+ this .state = state ;
166+ }
145167
146168 @ Override
147169 public String toString () {
0 commit comments