Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Commit

Permalink
Add fault to server details for more information when the Status is E…
Browse files Browse the repository at this point in the history
…rror.
  • Loading branch information
tkuhlman committed May 1, 2017
1 parent d633fb9 commit 9fc1d74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nova/live_test.go
Expand Up @@ -115,6 +115,8 @@ func (s *LiveTests) assertServerDetails(c *gc.C, sr *nova.ServerDetail) {
if s.testAvailabilityZone != "" {
c.Check(sr.AvailabilityZone, gc.Equals, s.testAvailabilityZone)
}
c.Check(sr.Status, gc.Equals, nova.StatusActive)
c.Check(sr.Fault.Code, gc.Equals, 0)
}

func (s *LiveTests) TestListFlavors(c *gc.C) {
Expand Down
2 changes: 2 additions & 0 deletions nova/local_test.go
Expand Up @@ -257,6 +257,8 @@ func (s *localLiveSuite) TestRunServerAvailabilityZone(c *gc.C) {
server, err := s.nova.GetServer(inst.Id)
c.Assert(err, gc.IsNil)
c.Assert(server.AvailabilityZone, gc.Equals, "az2")
c.Assert(server.Status, gc.Equals, nova.StatusActive)
c.Assert(server.Fault.Code, gc.Equals, 0)
}

func (s *localLiveSuite) TestRunServerAvailabilityZoneNotAvailable(c *gc.C) {
Expand Down
10 changes: 10 additions & 0 deletions nova/nova.go
Expand Up @@ -199,6 +199,13 @@ func (c *Client) ListServers(filter *Filter) ([]Entity, error) {
return resp.Servers, nil
}

// Fault describes the error a Nova server has encountered
type Fault struct {
Code int
Created string // Created holds the fault timestamp in RFC3339 format.
Message string
}

// IPAddress describes a single IPv4/6 address of a server.
type IPAddress struct {
Version int `json:"version"`
Expand Down Expand Up @@ -243,6 +250,9 @@ type ServerDetail struct {
// one of the Status* constants.
Status string

// Fault is populated only when the status is error
Fault Fault `json:",omitempty"`

TenantId string `json:"tenant_id"`

// Updated holds the timestamp of the last update
Expand Down

0 comments on commit 9fc1d74

Please sign in to comment.