Jamie Hannaford | fba65af | 2014-11-03 10:32:37 +0100 | [diff] [blame] | 1 | package lbs |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 5 | |
| 6 | "github.com/rackspace/gophercloud" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 7 | "github.com/rackspace/gophercloud/pagination" |
Jamie Hannaford | cfe2f28 | 2014-11-07 15:11:21 +0100 | [diff] [blame] | 8 | "github.com/rackspace/gophercloud/rackspace/lb/v1/acl" |
Jamie Hannaford | 21a3eb1 | 2014-11-03 10:34:29 +0100 | [diff] [blame] | 9 | "github.com/rackspace/gophercloud/rackspace/lb/v1/nodes" |
Jamie Hannaford | 6bc93aa | 2014-11-06 12:37:52 +0100 | [diff] [blame] | 10 | "github.com/rackspace/gophercloud/rackspace/lb/v1/sessions" |
Jamie Hannaford | cfe2f28 | 2014-11-07 15:11:21 +0100 | [diff] [blame] | 11 | "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle" |
Jamie Hannaford | 1c81731 | 2014-11-04 10:56:58 +0100 | [diff] [blame] | 12 | "github.com/rackspace/gophercloud/rackspace/lb/v1/vips" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 13 | ) |
| 14 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 15 | // Protocol represents the network protocol which the load balancer accepts. |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 16 | type Protocol struct { |
| 17 | // The name of the protocol, e.g. HTTP, LDAP, FTP, etc. |
| 18 | Name string |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 19 | |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 20 | // The port number for the protocol. |
| 21 | Port int |
| 22 | } |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 23 | |
| 24 | // Algorithm defines how traffic should be directed between back-end nodes. |
Jamie Hannaford | 4633628 | 2014-11-04 14:48:20 +0100 | [diff] [blame] | 25 | type Algorithm struct { |
| 26 | // The name of the algorithm, e.g RANDOM, ROUND_ROBIN, etc. |
| 27 | Name string |
| 28 | } |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 29 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 30 | // Status represents the potential state of a load balancer resource. |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 31 | type Status string |
| 32 | |
| 33 | const ( |
| 34 | // ACTIVE indicates that the LB is configured properly and ready to serve |
| 35 | // traffic to incoming requests via the configured virtual IPs. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 36 | ACTIVE Status = "ACTIVE" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 37 | |
| 38 | // BUILD indicates that the LB is being provisioned for the first time and |
| 39 | // configuration is being applied to bring the service online. The service |
| 40 | // cannot yet serve incoming requests. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 41 | BUILD Status = "BUILD" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 42 | |
| 43 | // PENDINGUPDATE indicates that the LB is online but configuration changes |
| 44 | // are being applied to update the service based on a previous request. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 45 | PENDINGUPDATE Status = "PENDING_UPDATE" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 46 | |
| 47 | // PENDINGDELETE indicates that the LB is online but configuration changes |
| 48 | // are being applied to begin deletion of the service based on a previous |
| 49 | // request. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 50 | PENDINGDELETE Status = "PENDING_DELETE" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 51 | |
| 52 | // SUSPENDED indicates that the LB has been taken offline and disabled. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 53 | SUSPENDED Status = "SUSPENDED" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 54 | |
| 55 | // ERROR indicates that the system encountered an error when attempting to |
| 56 | // configure the load balancer. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 57 | ERROR Status = "ERROR" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 58 | |
| 59 | // DELETED indicates that the LB has been deleted. |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 60 | DELETED Status = "DELETED" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 61 | ) |
| 62 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 63 | // Datetime represents the structure of a Created or Updated field. |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 64 | type Datetime struct { |
| 65 | Time string |
| 66 | } |
| 67 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 68 | // LoadBalancer represents a load balancer API resource. |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 69 | type LoadBalancer struct { |
| 70 | // Human-readable name for the load balancer. |
| 71 | Name string |
| 72 | |
| 73 | // The unique ID for the load balancer. |
| 74 | ID int |
| 75 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 76 | // Represents the service protocol being load balanced. See Protocol type for |
| 77 | // a list of accepted values. |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 78 | // See http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html |
| 79 | // for a full list of supported protocols. |
| 80 | Protocol string |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 81 | |
| 82 | // Defines how traffic should be directed between back-end nodes. The default |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 83 | // algorithm is RANDOM. See Algorithm type for a list of accepted values. |
Jamie Hannaford | 4633628 | 2014-11-04 14:48:20 +0100 | [diff] [blame] | 84 | Algorithm string |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 85 | |
| 86 | // The current status of the load balancer. |
| 87 | Status Status |
| 88 | |
| 89 | // The number of load balancer nodes. |
| 90 | NodeCount int `mapstructure:"nodeCount"` |
| 91 | |
| 92 | // Slice of virtual IPs associated with this load balancer. |
Jamie Hannaford | 1c81731 | 2014-11-04 10:56:58 +0100 | [diff] [blame] | 93 | VIPs []vips.VIP `mapstructure:"virtualIps"` |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 94 | |
| 95 | // Datetime when the LB was created. |
| 96 | Created Datetime |
| 97 | |
| 98 | // Datetime when the LB was created. |
| 99 | Updated Datetime |
| 100 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 101 | // Port number for the service you are load balancing. |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 102 | Port int |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 103 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 104 | // HalfClosed provides the ability for one end of the connection to |
| 105 | // terminate its output while still receiving data from the other end. This |
| 106 | // is only available on TCP/TCP_CLIENT_FIRST protocols. |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 107 | HalfClosed bool |
| 108 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 109 | // Timeout represents the timeout value between a load balancer and its |
| 110 | // nodes. Defaults to 30 seconds with a maximum of 120 seconds. |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 111 | Timeout int |
| 112 | |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 113 | // The cluster name. |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 114 | Cluster Cluster |
| 115 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 116 | // Nodes shows all the back-end nodes which are associated with the load |
| 117 | // balancer. These are the devices which are delivered traffic. |
Jamie Hannaford | 21a3eb1 | 2014-11-03 10:34:29 +0100 | [diff] [blame] | 118 | Nodes []nodes.Node |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 119 | |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 120 | // Current connection logging configuration. |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 121 | ConnectionLogging ConnectionLogging |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 122 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 123 | // SessionPersistence specifies whether multiple requests from clients are |
| 124 | // directed to the same node. |
Jamie Hannaford | 6bc93aa | 2014-11-06 12:37:52 +0100 | [diff] [blame] | 125 | SessionPersistence sessions.SessionPersistence |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 126 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 127 | // ConnectionThrottle specifies a limit on the number of connections per IP |
| 128 | // address to help mitigate malicious or abusive traffic to your applications. |
Jamie Hannaford | cfe2f28 | 2014-11-07 15:11:21 +0100 | [diff] [blame] | 129 | ConnectionThrottle throttle.ConnectionThrottle |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 130 | |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 131 | // The source public and private IP addresses. |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 132 | SourceAddrs SourceAddrs `mapstructure:"sourceAddresses"` |
Jamie Hannaford | cfe2f28 | 2014-11-07 15:11:21 +0100 | [diff] [blame] | 133 | |
| 134 | // Represents the access rules for this particular load balancer. IP addresses |
| 135 | // or subnet ranges, depending on their type (ALLOW or DENY), can be permitted |
| 136 | // or blocked. |
| 137 | AccessList acl.AccessList |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 140 | // SourceAddrs represents the source public and private IP addresses. |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 141 | type SourceAddrs struct { |
| 142 | IPv4Public string `json:"ipv4Public" mapstructure:"ipv4Public"` |
| 143 | IPv4Private string `json:"ipv4Servicenet" mapstructure:"ipv4Servicenet"` |
| 144 | IPv6Public string `json:"ipv6Public" mapstructure:"ipv6Public"` |
| 145 | IPv6Private string `json:"ipv6Servicenet" mapstructure:"ipv6Servicenet"` |
| 146 | } |
| 147 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 148 | // ConnectionLogging - temp |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 149 | type ConnectionLogging struct { |
| 150 | Enabled bool |
| 151 | } |
| 152 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 153 | // Cluster - temp |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 154 | type Cluster struct { |
| 155 | Name string |
| 156 | } |
| 157 | |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 158 | // LBPage is the page returned by a pager when traversing over a collection of |
| 159 | // LBs. |
| 160 | type LBPage struct { |
| 161 | pagination.LinkedPageBase |
| 162 | } |
| 163 | |
| 164 | // IsEmpty checks whether a NetworkPage struct is empty. |
| 165 | func (p LBPage) IsEmpty() (bool, error) { |
| 166 | is, err := ExtractLBs(p) |
| 167 | if err != nil { |
| 168 | return true, nil |
| 169 | } |
| 170 | return len(is) == 0, nil |
| 171 | } |
| 172 | |
| 173 | // ExtractLBs accepts a Page struct, specifically a LBPage struct, and extracts |
| 174 | // the elements into a slice of LoadBalancer structs. In other words, a generic |
| 175 | // collection is mapped into a relevant slice. |
| 176 | func ExtractLBs(page pagination.Page) ([]LoadBalancer, error) { |
| 177 | var resp struct { |
| 178 | LBs []LoadBalancer `mapstructure:"loadBalancers" json:"loadBalancers"` |
| 179 | } |
| 180 | |
| 181 | err := mapstructure.Decode(page.(LBPage).Body, &resp) |
| 182 | |
| 183 | return resp.LBs, err |
| 184 | } |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 185 | |
| 186 | type commonResult struct { |
| 187 | gophercloud.Result |
| 188 | } |
| 189 | |
| 190 | // Extract interprets any commonResult as a LB, if possible. |
| 191 | func (r commonResult) Extract() (*LoadBalancer, error) { |
| 192 | if r.Err != nil { |
| 193 | return nil, r.Err |
| 194 | } |
| 195 | |
| 196 | var response struct { |
| 197 | LB LoadBalancer `mapstructure:"loadBalancer"` |
| 198 | } |
| 199 | |
| 200 | err := mapstructure.Decode(r.Body, &response) |
| 201 | |
| 202 | return &response.LB, err |
| 203 | } |
| 204 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 205 | // CreateResult represents the result of a create operation. |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 206 | type CreateResult struct { |
| 207 | commonResult |
| 208 | } |
Jamie Hannaford | 1c26033 | 2014-10-31 15:57:22 +0100 | [diff] [blame] | 209 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 210 | // DeleteResult represents the result of a delete operation. |
Jamie Hannaford | 1c26033 | 2014-10-31 15:57:22 +0100 | [diff] [blame] | 211 | type DeleteResult struct { |
| 212 | gophercloud.ErrResult |
| 213 | } |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 214 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 215 | // UpdateResult represents the result of an update operation. |
Jamie Hannaford | 76fcc83 | 2014-10-31 16:56:50 +0100 | [diff] [blame] | 216 | type UpdateResult struct { |
| 217 | gophercloud.ErrResult |
| 218 | } |
| 219 | |
Jamie Hannaford | b2007ee | 2014-11-03 16:24:43 +0100 | [diff] [blame] | 220 | // GetResult represents the result of a get operation. |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 221 | type GetResult struct { |
| 222 | commonResult |
| 223 | } |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 224 | |
| 225 | // ProtocolPage is the page returned by a pager when traversing over a |
| 226 | // collection of LB protocols. |
| 227 | type ProtocolPage struct { |
| 228 | pagination.SinglePageBase |
| 229 | } |
| 230 | |
| 231 | // IsEmpty checks whether a ProtocolPage struct is empty. |
| 232 | func (p ProtocolPage) IsEmpty() (bool, error) { |
| 233 | is, err := ExtractProtocols(p) |
| 234 | if err != nil { |
| 235 | return true, nil |
| 236 | } |
| 237 | return len(is) == 0, nil |
| 238 | } |
| 239 | |
| 240 | // ExtractProtocols accepts a Page struct, specifically a ProtocolPage struct, |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 241 | // and extracts the elements into a slice of Protocol structs. In other |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 242 | // words, a generic collection is mapped into a relevant slice. |
| 243 | func ExtractProtocols(page pagination.Page) ([]Protocol, error) { |
| 244 | var resp struct { |
| 245 | Protocols []Protocol `mapstructure:"protocols" json:"protocols"` |
| 246 | } |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 247 | err := mapstructure.Decode(page.(ProtocolPage).Body, &resp) |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 248 | return resp.Protocols, err |
| 249 | } |
Jamie Hannaford | 4633628 | 2014-11-04 14:48:20 +0100 | [diff] [blame] | 250 | |
| 251 | // AlgorithmPage is the page returned by a pager when traversing over a |
| 252 | // collection of LB algorithms. |
| 253 | type AlgorithmPage struct { |
| 254 | pagination.SinglePageBase |
| 255 | } |
| 256 | |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 257 | // IsEmpty checks whether an AlgorithmPage struct is empty. |
Jamie Hannaford | 4633628 | 2014-11-04 14:48:20 +0100 | [diff] [blame] | 258 | func (p AlgorithmPage) IsEmpty() (bool, error) { |
| 259 | is, err := ExtractAlgorithms(p) |
| 260 | if err != nil { |
| 261 | return true, nil |
| 262 | } |
| 263 | return len(is) == 0, nil |
| 264 | } |
| 265 | |
| 266 | // ExtractAlgorithms accepts a Page struct, specifically a AlgorithmPage struct, |
| 267 | // and extracts the elements into a slice of Algorithm structs. In other |
| 268 | // words, a generic collection is mapped into a relevant slice. |
| 269 | func ExtractAlgorithms(page pagination.Page) ([]Algorithm, error) { |
| 270 | var resp struct { |
| 271 | Algorithms []Algorithm `mapstructure:"algorithms" json:"algorithms"` |
| 272 | } |
| 273 | err := mapstructure.Decode(page.(AlgorithmPage).Body, &resp) |
| 274 | return resp.Algorithms, err |
| 275 | } |
Jamie Hannaford | da45b42 | 2014-11-10 11:00:38 +0100 | [diff] [blame] | 276 | |
| 277 | // ErrorPage represents the HTML file that is shown to an end user who is |
| 278 | // attempting to access a load balancer node that is offline/unavailable. |
| 279 | // |
| 280 | // During provisioning, every load balancer is configured with a default error |
| 281 | // page that gets displayed when traffic is requested for an offline node. |
| 282 | // |
| 283 | // You can add a single custom error page with an HTTP-based protocol to a load |
| 284 | // balancer. Page updates override existing content. If a custom error page is |
| 285 | // deleted, or the load balancer is changed to a non-HTTP protocol, the default |
| 286 | // error page is restored. |
| 287 | type ErrorPage struct { |
| 288 | Content string |
| 289 | } |
| 290 | |
| 291 | // ErrorPageResult represents the result of an error page operation - |
| 292 | // specifically getting or creating one. |
| 293 | type ErrorPageResult struct { |
| 294 | gophercloud.Result |
| 295 | } |
| 296 | |
| 297 | // Extract interprets any commonResult as an ErrorPage, if possible. |
| 298 | func (r ErrorPageResult) Extract() (*ErrorPage, error) { |
| 299 | if r.Err != nil { |
| 300 | return nil, r.Err |
| 301 | } |
| 302 | |
| 303 | var response struct { |
| 304 | ErrorPage ErrorPage `mapstructure:"errorpage"` |
| 305 | } |
| 306 | |
| 307 | err := mapstructure.Decode(r.Body, &response) |
| 308 | |
| 309 | return &response.ErrorPage, err |
| 310 | } |
Jamie Hannaford | 3da6528 | 2014-11-10 11:36:16 +0100 | [diff] [blame] | 311 | |
| 312 | // Stats represents all the key information about a load balancer's usage. |
| 313 | type Stats struct { |
| 314 | // The number of connections closed by this load balancer because its |
| 315 | // ConnectTimeout interval was exceeded. |
| 316 | ConnectTimeout int `mapstructure:"connectTimeOut"` |
| 317 | |
| 318 | // The number of transaction or protocol errors for this load balancer. |
| 319 | ConnectError int |
| 320 | |
| 321 | // Number of connection failures for this load balancer. |
| 322 | ConnectFailure int |
| 323 | |
| 324 | // Number of connections closed by this load balancer because its Timeout |
| 325 | // interval was exceeded. |
| 326 | DataTimedOut int |
| 327 | |
| 328 | // Number of connections closed by this load balancer because the |
| 329 | // 'keepalive_timeout' interval was exceeded. |
| 330 | KeepAliveTimedOut int |
| 331 | |
| 332 | // The maximum number of simultaneous TCP connections this load balancer has |
| 333 | // processed at any one time. |
| 334 | MaxConnections int `mapstructure:"maxConn"` |
| 335 | |
| 336 | // Number of simultaneous connections active at the time of the request. |
| 337 | CurrentConnections int `mapstructure:"currentConn"` |
| 338 | |
| 339 | // Number of SSL connections closed by this load balancer because the |
| 340 | // ConnectTimeout interval was exceeded. |
| 341 | SSLConnectTimeout int `mapstructure:"connectTimeOutSsl"` |
| 342 | |
| 343 | // Number of SSL transaction or protocol erros in this load balancer. |
| 344 | SSLConnectError int `mapstructure:"connectErrorSsl"` |
| 345 | |
| 346 | // Number of SSL connection failures in this load balancer. |
| 347 | SSLConnectFailure int `mapstructure:"connectFailureSsl"` |
| 348 | |
| 349 | // Number of SSL connections closed by this load balancer because the |
| 350 | // Timeout interval was exceeded. |
| 351 | SSLDataTimedOut int `mapstructure:"dataTimedOutSsl"` |
| 352 | |
| 353 | // Number of SSL connections closed by this load balancer because the |
| 354 | // 'keepalive_timeout' interval was exceeded. |
| 355 | SSLKeepAliveTimedOut int `mapstructure:"keepAliveTimedOutSsl"` |
| 356 | |
| 357 | // Maximum number of simultaneous SSL connections this load balancer has |
| 358 | // processed a any one time. |
| 359 | SSLMaxConnections int `mapstructure:"maxConnSsl"` |
| 360 | |
| 361 | // Number of simultaneous SSL connections active at the time of the request. |
| 362 | SSLCurrentConnections int `mapstructure:"currentConnSsl"` |
| 363 | } |
| 364 | |
Jamie Hannaford | 227d959 | 2014-11-13 10:32:07 +0100 | [diff] [blame^] | 365 | // StatsResult represents the result of a Stats operation. |
Jamie Hannaford | 3da6528 | 2014-11-10 11:36:16 +0100 | [diff] [blame] | 366 | type StatsResult struct { |
| 367 | gophercloud.Result |
| 368 | } |
| 369 | |
| 370 | // Extract interprets any commonResult as a Stats struct, if possible. |
| 371 | func (r StatsResult) Extract() (*Stats, error) { |
| 372 | if r.Err != nil { |
| 373 | return nil, r.Err |
| 374 | } |
| 375 | res := &Stats{} |
| 376 | err := mapstructure.Decode(r.Body, res) |
| 377 | return res, err |
| 378 | } |