-
Notifications
You must be signed in to change notification settings - Fork 0
/
iaasmodel.go
45 lines (40 loc) · 1.33 KB
/
iaasmodel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package state
import "github.com/juju/errors"
// IAASModel contains functionality that is specific to an
// Infrastructure-As-A-Service (IAAS) model. It embeds a Model so that
// all generic Model functionality is also available.
type IAASModel struct {
// TODO(caas) - this is all still messy until things shake out.
*Model
mb modelBackend
}
// IAASModel returns an Infrastructure-As-A-Service (IAAS) model.
func (m *Model) IAASModel() (*IAASModel, error) {
// We keep a check against the missing modelType to handle upgrades.
if modelType := m.Type(); modelType != ModelTypeIAAS && modelType != modelTypeNone {
return nil, errors.NotSupportedf("called IAASModel() on a non-IAAS Model")
}
return &IAASModel{
Model: m,
mb: m.st,
}, nil
}
// IAASModel returns an Infrastructure-As-A-Service (IAAS) model.
//
// TODO(caas): This is a convenience helper only and will go away
// once most model related functionality has been moved from State to
// Model/IAASModel. Model.IAASModel() should be preferred where-ever
// possible.
func (st *State) IAASModel() (*IAASModel, error) {
m, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
im, err := m.IAASModel()
if err != nil {
return nil, errors.Trace(err)
}
return im, nil
}