Commit 65094f19 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

modified frontend to send scenario-update event to disable/terminate MEC Services

parent bb919226
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ class AppContainer extends Component {
  createAppInstance(param) {
    var formParams = {
      'name': param.appName,
      'mepName': param.mepName,
      'nodeName': param.mepName,
      'type': 'USER',
      'persist': false
    };
@@ -1075,10 +1075,17 @@ class AppContainer extends Component {
      let appInstance = this.getAppInstance(edgeApp.id, appInstances);
      let svcInstance = this.getSvcInstance(edgeApp.id, services);

      // Update app instance ID when available
      if (appInstance && !edgeApp.appId) {
        edgeApp.appId = edgeApp.id;
        updateRequired = true;
      }

      // Update service state
      if (appInstance === null || svcInstance === null) {
      if (!appInstance || !svcInstance) {
        if (edgeApp.enabled) {
          edgeApp.enabled = false;
          edgeApp.appId = '';
          edgeApp.svcId = '';
          updateRequired = true;
        }
@@ -1128,8 +1135,12 @@ class AppContainer extends Component {
        if (edgeApp.enableInProgressCount < (EDGE_APP_ENABLE_COUNT_MAX - BLACKOUT_TIME)) {
          let appInstance = this.getAppInstance(edgeApp.id, appInstances);
          let svcInstance = this.getSvcInstance(edgeApp.id, services);
          if (appInstance !== null && svcInstance !== null) {
          if (appInstance && !edgeApp.appId) {
            edgeApp.appId = edgeApp.id;
          }
          if (appInstance && svcInstance) {
            edgeApp.instance = appInstance.name;
            edgeApp.appId = edgeApp.id;
            edgeApp.svcId = svcInstance.id;
            edgeApp.enabled = true;
            edgeApp.enableInProgressCount = -1;
@@ -1142,8 +1153,9 @@ class AppContainer extends Component {
        if (edgeApp.disableInProgressCount < (EDGE_APP_DISABLE_COUNT_MAX - BLACKOUT_TIME)) {
          let appInstance = this.getAppInstance(edgeApp.id, appInstances);
          let svcInstance = this.getSvcInstance(edgeApp.id, services);
          if (appInstance === null || svcInstance === null) {
          if (!appInstance || !svcInstance) {
            edgeApp.enabled = false;
            edgeApp.appId = '';
            edgeApp.svcId = '';
            edgeApp.disableInProgressCount = -1;
          }
+27 −9
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class AppInstanceInfo extends Component {

    if (checked) {
      // Send event to enable service
      var sandboxEvent = {
      var enableEvent = {
        name: 'name',
        type: 'SCENARIO-UPDATE',
        eventScenarioUpdate: {
@@ -49,15 +49,33 @@ class AppInstanceInfo extends Component {
          }
        }
      };
      this.props.eventsApi.sendEvent('SCENARIO-UPDATE', sandboxEvent);
      this.props.eventsApi.sendEvent('SCENARIO-UPDATE', enableEvent);

      // Enable edge app & start timer to temporarily ignore backend
      edgeApp.enabled = true;
      edgeApp.enableInProgressCount = EDGE_APP_ENABLE_COUNT_MAX;

    } else {
      // Delete app instance
      this.props.applicationsApi.applicationsAppInstanceIdDELETE(edgeApp.id, null);
      // Send event to disable service
      var disableEvent = {
        name: 'name',
        type: 'SCENARIO-UPDATE',
        eventScenarioUpdate: {
          action: 'REMOVE',
          gracePeriod: 10,
          node: {
            type: 'EDGE-APP',
            parent: edgeApp.mepName,
            nodeDataUnion: {
              process: {
                id: edgeApp.id,
                name: edgeApp.name
              }
            }
          }
        }
      };
      this.props.eventsApi.sendEvent('SCENARIO-UPDATE', disableEvent);

      // Disable edge app & start timer to temporarily ignore backend 
      edgeApp.enabled = false;
@@ -94,7 +112,7 @@ class AppInstanceInfo extends Component {
      return (
        <>
          <div style={{ marginTop: 15 }}>
            <Typography theme="primary" use="body1">MEC service startup in progress...<br/>This operation may take a few seconds.</Typography>
            <Typography theme="primary" use="body1">MEC Service startup in progress...<br/>This operation may take a few seconds.</Typography>
          </div>
        </>
      );
@@ -104,7 +122,7 @@ class AppInstanceInfo extends Component {
      return (
        <>
          <div style={{ marginTop: 15 }}>
            <Typography theme="primary" use="body1">MEC service shutdown in progress...<br/>This operation may take a few seconds.</Typography>
            <Typography theme="primary" use="body1">MEC Service shutdown in progress...<br/>This operation may take a few seconds.</Typography>
          </div>
        </>
      );
@@ -114,7 +132,7 @@ class AppInstanceInfo extends Component {
      return (
        <>
          <div style={{ marginTop: 15 }}>
            <Typography theme="primary" use="body1">This MEC service is currently disabled.</Typography>
            <Typography theme="primary" use="body1">This MEC Service is currently disabled.</Typography>
          </div>
        </>
      );
@@ -131,7 +149,7 @@ class AppInstanceInfo extends Component {
    let isMec011 = edgeApp.pseudoName.includes('011');
    let disabled = (isMec011 || edgeApp.enableInProgressCount !== -1 || edgeApp.disableInProgressCount !== -1) ? true : false;
    let mepInfoStr = (isMec011) ? edgeApp.mepName + ' platform API' : edgeApp.instance + ' running on ' + edgeApp.mepName;
    let appInfoStr = 'appInstanceId: ' + edgeApp.id;
    let appInfoStr = 'appInstanceId: ' + ((edgeApp.appId) ? edgeApp.appId : 'unavailable');
    let svcInfoStr = 'serviceId: ' + ((edgeApp.svcId) ? edgeApp.svcId : 'unavailable');

    return (
@@ -139,7 +157,7 @@ class AppInstanceInfo extends Component {
        <Grid style={{ marginTop: 0}}>
          <GridCell title="Enable or disable the selected MEC API" span={12}>
            <p style={{ marginTop: 5, marginBottom: 10 }}>
              <Typography theme="primary" use="headline6">Application details</Typography>
              <Typography theme="primary" use="headline6">MEC Service details</Typography>
            </p>
            <Typography className="text-color-main" use="body1">
              {mepInfoStr}
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class AppInstanceTable extends Component {
                          />
                        </TableCell>
                        <TableCell className={classes.tableBodyCellNoWrap} scope="row">
                          {row.name} running on {row.mepName}<br/>
                          {row.name} running on {row.nodeName}<br/>
                          ID: {row.id}
                        </TableCell>
                      </TableRow>