Skip to content

Commit

Permalink
Merged latest blessed master into machine-dep-engine branch
Browse files Browse the repository at this point in the history
Conflicts:
	cmd/jujud/agent/machine.go (very minor)
  • Loading branch information
Menno Smits committed Jan 11, 2016
2 parents 305f614 + 4c95437 commit fb498b1
Show file tree
Hide file tree
Showing 160 changed files with 1,706 additions and 15,756 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Azure, HP your data center and even your own Ubuntu based laptop.
Moving between environments is simple giving you the flexibility to switch hosts
whenever you want — for free.

For more information, see the [docs](https://juju.ubuntu.com/docs/).
For more information, see the [docs](https://jujucharms.com/docs/stable/getting-started).

Getting started
===============
Expand Down
102 changes: 70 additions & 32 deletions api/storage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,60 @@ func NewClient(st base.APICallCloser) *Client {
return &Client{ClientFacade: frontend, facade: backend}
}

// Show retrieves information about desired storage instances.
func (c *Client) Show(tags []names.StorageTag) ([]params.StorageDetailsResult, error) {
// StorageDetails retrieves details about desired storage instances.
func (c *Client) StorageDetails(tags []names.StorageTag) ([]params.StorageDetailsResult, error) {
found := params.StorageDetailsResults{}
entities := make([]params.Entity, len(tags))
for i, tag := range tags {
entities[i] = params.Entity{Tag: tag.String()}
}
if err := c.facade.FacadeCall("Show", params.Entities{Entities: entities}, &found); err != nil {
if err := c.facade.FacadeCall("StorageDetails", params.Entities{Entities: entities}, &found); err != nil {
return nil, errors.Trace(err)
}
return found.Results, nil
}

// List lists all storage.
func (c *Client) List() ([]params.StorageDetailsResult, error) {
found := params.StorageDetailsResults{}
if err := c.facade.FacadeCall("List", nil, &found); err != nil {
// ListStorageDetails lists all storage.
func (c *Client) ListStorageDetails() ([]params.StorageDetails, error) {
args := params.StorageFilters{
[]params.StorageFilter{{}}, // one empty filter
}
var results params.StorageDetailsListResults
if err := c.facade.FacadeCall("ListStorageDetails", args, &results); err != nil {
return nil, errors.Trace(err)
}
return found.Results, nil
if len(results.Results) != 1 {
return nil, errors.Errorf(
"expected 1 result, got %d",
len(results.Results),
)
}
if results.Results[0].Error != nil {
return nil, errors.Trace(results.Results[0].Error)
}
return results.Results[0].Result, nil
}

// ListPools returns a list of pools that matches given filter.
// If no filter was provided, a list of all pools is returned.
func (c *Client) ListPools(providers, names []string) ([]params.StoragePool, error) {
args := params.StoragePoolFilter{
Names: names,
Providers: providers,
args := params.StoragePoolFilters{
Filters: []params.StoragePoolFilter{{
Names: names,
Providers: providers,
}},
}
found := params.StoragePoolsResult{}
if err := c.facade.FacadeCall("ListPools", args, &found); err != nil {
var results params.StoragePoolsResults
if err := c.facade.FacadeCall("ListPools", args, &results); err != nil {
return nil, errors.Trace(err)
}
return found.Results, nil
if len(results.Results) != 1 {
return nil, errors.Errorf("expected 1 result, got %d", len(results.Results))
}
if err := results.Results[0].Error; err != nil {
return nil, err
}
return results.Results[0].Result, nil
}

// CreatePool creates pool with specified parameters.
Expand All @@ -76,32 +96,50 @@ func (c *Client) CreatePool(pname, provider string, attrs map[string]interface{}

// ListVolumes lists volumes for desired machines.
// If no machines provided, a list of all volumes is returned.
func (c *Client) ListVolumes(machines []string) ([]params.VolumeDetailsResult, error) {
tags := make([]string, len(machines))
for i, one := range machines {
tags[i] = names.NewMachineTag(one).String()
}
args := params.VolumeFilter{Machines: tags}
found := params.VolumeDetailsResults{}
if err := c.facade.FacadeCall("ListVolumes", args, &found); err != nil {
func (c *Client) ListVolumes(machines []string) ([]params.VolumeDetailsListResult, error) {
filters := make([]params.VolumeFilter, len(machines))
for i, machine := range machines {
filters[i].Machines = []string{names.NewMachineTag(machine).String()}
}
if len(filters) == 0 {
filters = []params.VolumeFilter{{}}
}
args := params.VolumeFilters{filters}
var results params.VolumeDetailsListResults
if err := c.facade.FacadeCall("ListVolumes", args, &results); err != nil {
return nil, errors.Trace(err)
}
return found.Results, nil
if len(results.Results) != len(filters) {
return nil, errors.Errorf(
"expected %d result(s), got %d",
len(filters), len(results.Results),
)
}
return results.Results, nil
}

// ListFilesystems lists filesystems for desired machines.
// If no machines provided, a list of all filesystems is returned.
func (c *Client) ListFilesystems(machines []string) ([]params.FilesystemDetailsResult, error) {
tags := make([]string, len(machines))
for i, one := range machines {
tags[i] = names.NewMachineTag(one).String()
}
args := params.FilesystemFilter{Machines: tags}
found := params.FilesystemDetailsResults{}
if err := c.facade.FacadeCall("ListFilesystems", args, &found); err != nil {
func (c *Client) ListFilesystems(machines []string) ([]params.FilesystemDetailsListResult, error) {
filters := make([]params.FilesystemFilter, len(machines))
for i, machine := range machines {
filters[i].Machines = []string{names.NewMachineTag(machine).String()}
}
if len(filters) == 0 {
filters = []params.FilesystemFilter{{}}
}
args := params.FilesystemFilters{filters}
var results params.FilesystemDetailsListResults
if err := c.facade.FacadeCall("ListFilesystems", args, &results); err != nil {
return nil, errors.Trace(err)
}
return found.Results, nil
if len(results.Results) != len(filters) {
return nil, errors.Errorf(
"expected %d result(s), got %d",
len(filters), len(results.Results),
)
}
return results.Results, nil
}

// AddToUnit adds specified storage to desired units.
Expand Down
Loading

0 comments on commit fb498b1

Please sign in to comment.