aboutsummaryrefslogtreecommitdiffstats
path: root/src/ncm/pkg/networkintents/network.go
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-08-07 12:04:15 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-08-11 19:30:59 -0700
commit709d6d17a3b2f8bc9d46034295bd7c5a7fb76107 (patch)
treec028ad152f5cf50e4991ba1388561b2c83f1fca8 /src/ncm/pkg/networkintents/network.go
parente7061c31f693f0ee60040a67baaa3935c64786cb (diff)
Add appcontext state, status and resource status
Add support in the AppContext for managing an AppContext (composite app level) status value. Also adds support for tracking rsync status at the resource level. A mechanism for tracking history at the controlling resource level (i.e. DeploymentGroupIntnt or Cluster) is added, in part, so that all AppContexts associated can be deleted when the resource is eventually deleted. Issue-ID: MULTICLOUD-1042 Change-Id: I3d0a9a97ea45ca11f9f873104476e4b67521e56a Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Diffstat (limited to 'src/ncm/pkg/networkintents/network.go')
-rw-r--r--src/ncm/pkg/networkintents/network.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ncm/pkg/networkintents/network.go b/src/ncm/pkg/networkintents/network.go
index 58480cc8..7d6af444 100644
--- a/src/ncm/pkg/networkintents/network.go
+++ b/src/ncm/pkg/networkintents/network.go
@@ -95,7 +95,11 @@ func (v *NetworkClient) CreateNetwork(p Network, clusterProvider, cluster string
if err != nil {
return Network{}, pkgerrors.New("Unable to find the cluster")
}
- switch s.State {
+ stateVal, err := state.GetCurrentStateFromStateInfo(s)
+ if err != nil {
+ return Network{}, pkgerrors.Errorf("Error getting current state from Cluster stateInfo: " + cluster)
+ }
+ switch stateVal {
case state.StateEnum.Approved:
return Network{}, pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + state.StateEnum.Approved)
case state.StateEnum.Terminated:
@@ -107,7 +111,7 @@ func (v *NetworkClient) CreateNetwork(p Network, clusterProvider, cluster string
case state.StateEnum.Instantiated:
return Network{}, pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + state.StateEnum.Instantiated)
default:
- return Network{}, pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + s.State)
+ return Network{}, pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + stateVal)
}
//Check if this Network already exists
@@ -187,7 +191,11 @@ func (v *NetworkClient) DeleteNetwork(name, clusterProvider, cluster string) err
if err != nil {
return pkgerrors.New("Unable to find the cluster")
}
- switch s.State {
+ stateVal, err := state.GetCurrentStateFromStateInfo(s)
+ if err != nil {
+ return pkgerrors.Errorf("Error getting current state from Cluster stateInfo: " + cluster)
+ }
+ switch stateVal {
case state.StateEnum.Approved:
return pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + state.StateEnum.Approved)
case state.StateEnum.Terminated:
@@ -199,7 +207,7 @@ func (v *NetworkClient) DeleteNetwork(name, clusterProvider, cluster string) err
case state.StateEnum.Instantiated:
return pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + state.StateEnum.Instantiated)
default:
- return pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + s.State)
+ return pkgerrors.Errorf("Cluster is in an invalid state: " + cluster + " " + stateVal)
}
//Construct key and tag to select the entry