cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1180
Views
5
Helpful
2
Replies

how? nano service: post-action-node in ncs:delete

Nickolay Belchugov
Cisco Employee
Cisco Employee

How plan-outline should be defined if I want to do staged delete with nano services and a no-op action?
I have managed to make "staged create" with no-op. However, the staged delete creates zombie services.
Sharing the service model:

            tailf:action no-op {
              tailf:actionpoint no-op-actionpoint;
            //   input {}
            //   output {}
            }
        }
    }

    ncs:plan-outline service-plan {
        description
        "Make before brake vlan plan";

        ncs:component-type "ncs:self" {
            ncs:state "ncs:init" {
                ncs:create {
                    ncs:nano-callback;
                    ncs:post-action-node "/rpcs" {
                        ncs:action-name "no-op";
                        // ncs:result-expr "*";
                    }
                }
                ncs:delete {
                    ncs:pre-condition {
                        ncs:monitor "$PLAN/component[type='ncs:self'][name='self']/state"
                                    + "[name='ncs:ready']" {
                                    ncs:trigger-expr "post-action-status = 'delete-reached'";
                        }
                    }
                }
            }
            ncs:state "ncs:ready" {
                ncs:create {
                    ncs:nano-callback;
                    ncs:pre-condition {
                        ncs:monitor "$PLAN/component[type='ncs:self'][name='self']/state"
                                    + "[name='ncs:init']" {
                                    ncs:trigger-expr "post-action-status = 'create-reached'";
                        }
                    }
                }
                ncs:delete {
                    ncs:post-action-node "/rpcs" {
                        ncs:action-name "no-op";
                        // ncs:result-expr "*";
                    }
                }
            }
        }
    }

  ncs:service-behavior-tree service-servicepoint {
    ncs:plan-outline-ref service-plan;
    ncs:selector {
      ncs:create-component "'self'" {
        ncs:component-type-ref "ncs:self";
      }
    }
  }
1 Accepted Solution

Accepted Solutions

rogaglia
Cisco Employee
Cisco Employee

Hi, there is $ZOMBIE variable that connects you with the plan on the delete sequence:

        ncs:delete {
          ncs:pre-condition {
            ncs:monitor  "$ZOMBIE/plan/component[type='ncs:self'][name='self']/state[name='nokiadm:cross-connect']" {
              ncs:trigger-expr "post-action-status = 'delete-reached'";
            }
          }
          ncs:post-action-node "$SERVICE" {
            ncs:action-name "reactive-re-deploy";
          }
        }

View solution in original post

2 Replies 2

rogaglia
Cisco Employee
Cisco Employee

Hi, there is $ZOMBIE variable that connects you with the plan on the delete sequence:

        ncs:delete {
          ncs:pre-condition {
            ncs:monitor  "$ZOMBIE/plan/component[type='ncs:self'][name='self']/state[name='nokiadm:cross-connect']" {
              ncs:trigger-expr "post-action-status = 'delete-reached'";
            }
          }
          ncs:post-action-node "$SERVICE" {
            ncs:action-name "reactive-re-deploy";
          }
        }

Hi,

I have a follow-up question.

 

$ZOMBIE only works when the entire service is being deleted, but if i have a component in the nano-service that is being deleted I would have to use $PLAN (or $SERVICE) in the delete pre-condition. But as stated, that wont work when I'm deleting the entire service.

How can I monitor both $ZOMBIE and $SERVICE in the same pre-condition?

 

Simple example:

  ncs:plan-outline deployment-plan {
    ncs:component-type "ncs:self" {
      ncs:state "ncs:init" {
        ncs:create {
          ncs:nano-callback;
        }
      }
      ncs:state "ncs:ready" {
        ncs:create {
          ncs:pre-condition {
            ncs:monitor "$PLAN" {
              ncs:trigger-expr
                "not(component/state[name != 'ncs:ready'][status != 'reached'])";
            }
          }
        }
      }
    }
    ncs:component-type "abc:extra" {
      ncs:state "ncs:init" {
        ncs:create {
          ncs:nano-callback;
        }
        ncs:delete {
          ncs:pre-condition {
            ncs:monitor "$SERVICE/plan/component[name='extra'][type='abc:extra']/state[name='ncs:ready']" {   // HERE IS THE PROBLEM
              ncs:trigger-expr "post-action-status = 'delete-reached'";
            }
          }
        }
      }
      ncs:state "ncs:ready" {
        ncs:delete {
          ncs:post-action-node "$ZOMBIE" {
            ncs:action-name "re-deploy";
          }
        }
      }
    }
  }

  ncs:service-behavior-tree abc-servicepoint {
    description
      "Informative description";

    ncs:plan-outline-ref deployment-plan;

    ncs:selector {
      ncs:variable "ABC_NAME" {
        ncs:value-expr "name";
      }
      ncs:create-component "'self'" {
        ncs:component-type-ref "ncs:self";
      }
      ncs:create-component "'extra'" {
        ncs:component-type-ref "abc:extra";
        ncs:pre-condition {
          ncs:monitor "$SERVICE/extra" {
          }
        }
      }
    }
  }