cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
42
Views
0
Helpful
2
Replies
Cisco Employee

Yang: Restricting/Refining list of enum values

For a service, I have typedef enum type as below

 

typedef si_type_type {
type enumeration {
enum “Service1";
enum "Service2";
enum "Service3";
enum "Service4";

}
}

 

While reusing it, I want to restrict the entries to only 2 of 4 options, e.g.

 

leaf service_type {

type cct:si_type_type;

mandatory true;

must "0 = compare(current(), 'Service1') or " +

"0 = compare(current(), 'Service2')"{

            error-message "Service Type should either Service1 or Service2 only";

}

}

 

NSO restricts the option at the time of new service Commit but not at the time of service update. I am using NSO 3.4.2.1.

Everyone's tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: Yang: Restricting/Refining list of enum values

I am a little puzzled by your solution strategy.

 

What about a different solution something like?

typedef si_type_type1 {
  type enumeration {
    enum ³Service1²;
    enum "Service2²;
   }
}

typedef si_type_type2 {
  type enumeration {
    enum ³Service3²;
    enum "Service4²;
   }
}

typedef si_type_type {
   type union {
     type si_type_type1;
     type si_type_type2;
   }     
}

 

Then you use any of the possible options.

View solution in original post

2 REPLIES 2
Highlighted
Cisco Employee

Re: Yang: Restricting/Refining list of enum values

I am a little puzzled by your solution strategy.

 

What about a different solution something like?

typedef si_type_type1 {
  type enumeration {
    enum ³Service1²;
    enum "Service2²;
   }
}

typedef si_type_type2 {
  type enumeration {
    enum ³Service3²;
    enum "Service4²;
   }
}

typedef si_type_type {
   type union {
     type si_type_type1;
     type si_type_type2;
   }     
}

 

Then you use any of the possible options.

View solution in original post

Highlighted
Cisco Employee

Re: Yang: Restricting/Refining list of enum values

Let me look into it. So we saying here to define separate types then union them together as needed and use individual types where a subset is needed.

Content for Community-Ad
FusionCharts will render here