~cmars/juju-core/local-repo-resolve

« back to all changes in this revision

Viewing changes to state/apiserver/provisioner/provisioner.go

[r=dimitern] state;api: Allow adding existing networks/NICs

Added an AlreadyExistsError in errors/ and in
state/api/params with IsAlreadyExistsError and
IsCodeAlreadyExists helpers. This is used in
the provisioner API to report networks and
interfaces that already exist, and is needed
so that when provisioning more machines on the
same network wont' lead to errors (trying to
add existing network/NIC is just ignored).

https://codereview.appspot.com/85380043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
432
432
        return result, nil
433
433
}
434
434
 
435
 
// AddNetwork creates one or more new networks with the given parameters.
436
 
// Only the environment manager can add networks.
 
435
// AddNetwork creates one or more new networks with the given
 
436
// parameters. Only the environment manager can add networks. If any
 
437
// of the given networks already exists, an error satisfying
 
438
// params.IsCodeAlreadyExists will be returned for it.
437
439
func (p *ProvisionerAPI) AddNetwork(args params.AddNetworkParams) (params.ErrorResults, error) {
438
440
        result := params.ErrorResults{
439
441
                Results: make([]params.ErrorResult, len(args.Networks)),
449
451
}
450
452
 
451
453
// AddNetworkInterface creates one or more new network interfaces with
452
 
// the given parameters.
 
454
// the given parameters. If any of the given interfaces already exist,
 
455
// an error satisfying params.IsCodeAlreadyExists will be returned for
 
456
// it.
453
457
func (p *ProvisionerAPI) AddNetworkInterface(args params.AddNetworkInterfaceParams) (params.ErrorResults, error) {
454
458
        result := params.ErrorResults{
455
459
                Results: make([]params.ErrorResult, len(args.Interfaces)),