VMware Cloud Community
mulliganesx
Enthusiast
Enthusiast
Jump to solution

Nested Switch Issue with vRO

Does vRO work with nested switch statements for XaaS?   vRO is not differentiating between the case for "osType"   It is either or.  My current workaround is to hardcode 'osversion' to a particular "ValueSet.***" which works but is not extensible since I am locked to that cluster.  I am still learning, and looking for insight on how I can make the below code work.. Or for assistance to convert it into something extensible..

Thanks

// Nested switch

switch(osType){

// code to be executed if osVersion = Windows2012R2

             case "Windows2012R2":

   switch(reservationPolicy){

   // NX Datacenter

case 'NX-Cluster-01':

        osversion = "ValueSet.Windows2012R2Standard";

    break;

        case "NX-Cluster-02":

        osversion = "ValueSet.Windows2012R2Standard01";

    break;

case "NX-Cluster-03":

        osversion = "ValueSet.Windows2012R2Standard02";

    break;

        case "NX-Cluster-04":

        osversion = "ValueSet.Windows2012R2Standard";

    break;

        case "NX-Cluster-05":

        osversion = "ValueSet.Windows2012R2Standard";

    break;

        }

// code to be executed if osVersion = Windows2016

     case "Windows2016":

           switch(reservationPolicy){

   //AT Datacenter

case "AT-Cluster-01":

        osversion = "ValueSet.Windows2016Standard";

    break;

        case "AT-Cluster-01":

        osversion = "ValueSet.Windows2016Standard01";

    break;

case "AT-Cluster-01":

        osversion = "ValueSet.Windows2016Standard02";

    break;

        case "AT-Cluster-01":

        osversion = "ValueSet.Windows2016Standard";

    break;     

        case "AT-Cluster-01":

        osversion = "ValueSet.Windows2016Standard";

    break;

        }

  }

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

This question was brought to our internal channels yesterday, and it seems the code doesn't work simply because the outer switch lacks break statements (it was Brandon Saxe who spotted this).

So, to make the code work, you need to insert break; between lines 23-24 of your code (and optionally between lines 42-43).

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

View solution in original post

1 Reply
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

This question was brought to our internal channels yesterday, and it seems the code doesn't work simply because the outer switch lacks break statements (it was Brandon Saxe who spotted this).

So, to make the code work, you need to insert break; between lines 23-24 of your code (and optionally between lines 42-43).

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.