8 Replies Latest reply on Jan 9, 2018 11:53 PM by jorquesana

    On-Demand Inline load balancer in vRA

    ZCore Lurker

      Hi all,

       

      We are using vRA and we are starting to design some simple blueprint with only one load balancer and some Apache web server running on port 8080.

      LoadBalancer1.JPG

      We are trying to use an On-Demand Inline load balancer in the blueprint to have the load balancer connected to one VIP network and to one Web network. ( the Apache Web pool network )

       

      This design is executing properly but we want to customize and change the default Gateway for the Apache web server to point to the load balancer NSX Web interface.

      Currently the default Gateway for the Web server is provisionning by a network profile in vRA and it is an interface on the DLR router.

      Do you know how to change the default Gateway on VM during the blueprint execution or with Software component ?

      The goal is to get the ip address from the On-Demand  load balancer during blueprint execution and assign this Gateway to Web server.

       

      The final design should be like that. This should be automated during blueprint execution.

       

      Capture.JPG

       

      Any idea would be helpful

      thanks a lot !

        • 1. Re: On-Demand Inline load balancer in vRA
          ZCore Lurker

          Hello,

           

          Any help for this question ?

          Thanks a lot.

          • 2. Re: On-Demand Inline load balancer in vRA
            jasnyder Expert
            vExpert

            This design is complicated by the fact that IPs are consumed from a pool in order, thus you cannot predict what IP the LB will get on the ExternalWEB network.  So you have to discover what that IP is at runtime and change the gateway in the guest machine.  I'm thinking this would have to be done through vRO by calling a workflow after provisioning completes to discover the provisioned resources and LB internal IP, then execute a script to write to /etc/sysconfig/network/routes or whatever specific config happens on the linux distro to set the default route.  If you could know the LB IP ahead of time you could set the VirtualMachine.NetworkN.Gateway property to have it get set.

             

            So the steps are:

            1. Create vRO workflow that runs after provisioning (via event broker subscription)
            2. Workflow gets the vCenter Machine to call a script on
            3. Workflow gets the request ID
            4. Workflow gets all resources provisioned for the request
            5. Workflow reaches back to IaaS to discover Load Balancer info
            6. Workflow reaches out to NSX API (via NSX plugin) to query load balancer information
            7. Use collected LB info to set default gateway on vCenter VM by using the Run program in guest workflow to set it

             

            That's my high level thinking for now.  Might try to prototype this tomorrow if I have time.

            • 3. Re: On-Demand Inline load balancer in vRA
              ZCore Lurker

              Hi,

               

              Thanks for your answer. I didn't know subscription functionnality, so I started to play with subscription and I code some action on vRO but the script failed to execute.

              Do you have an idea why ?

               

              var executionContext = System.getContext();

              System.log("BlueprintName: " + payload.get("blueprintName")) ;
              System.log("ComponentId: " + payload.get("componentId")) ;
              System.log("ComponentTypeId: " + payload.get("componentTypeId")) ;
              System.log("EndpointId: " + payload.get("endpointId")) ;
              System.log("RequestId: " + payload.get("requestId")) ;
              System.log("VirtualMachineEvent: " + payload.get("virtualMachineEvent")) ;
              System.log("WorkflowNextState: " + payload.get("workflowNextState")) ;

              var lifecycleState = payload.get("lifecycleState") ;
              System.log("State: " + lifecycleState.get("state")) ;
              System.log("Phase: " + lifecycleState.get("phase")) ;
              System.log("Event: " + lifecycleState.get("event")) ;

              var machine = payload.get("machine") ;
              System.log("ID: " + machine.get("id")) ;
              System.log("Name: " + machine.get("name")) ;
              System.log("ExternalReference: " + machine.get("externalReference")) ;
              System.log("Owner: " + machine.get("owner")) ;
              System.log("Type: " + machine.get("type")) ;
              System.log("Properties: " + machine.get("properties")) ;

              var vmProperties = machine.get("properties");
              if (vmProperties != null) {
               var log = "";
               log += "vCAC VM properties :\n";
               var array = new Array();
               for each (var key in vmProperties.keys) {
                array.push(key + " : " + vmProperties.get(key)); 
               }
               array.sort();
               
               for each (var line in array) {
                log += "\t" + line + "\n";
               } 
               System.log(log); 
              }

              //Get custom properties from vRA and store in an attribute
              System.log('Getting the custom properties needed') ;
              var vmname = machine.get("name") ;
              var ipaddress = vCACVmProperties.get("VirtualMachine.Network0.Address") ;
              System.log("MyIP: " + ipaddress) ;
              //var myscript =  vCACVmProperties.get("myscript") ;
              */

               

              The error message is the following :

              2017-11-23 15:54:34.092] [E] Error in (Workflow:payload / Get vRA Properties (item1)#2) TypeError: Cannot call method "get" of null
              [2017-11-23 15:54:34.103] [E] Workflow execution stack:
              ***
              item: 'payload/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot call method "get" of null (Workflow:payload / Get vRA Properties (item1)#2)'

              • 4. Re: On-Demand Inline load balancer in vRA
                ZCore Lurker

                I tried also to use HAProxy instead of NSX Edge load balancer and tried to use Software component to change default gatway in the guest machine. You can get some properties from an object with the "~" caracters.

                CustomProperties.JPG

                The value for default Gateway should be HAProxy~nics~address ..... but you cannot validate this value with the OK button.

                • 5. Re: On-Demand Inline load balancer in vRA
                  daphnissov Guru
                  vExpertCommunity Warriors

                  If you use software components, when you do property binding there is no validation because the values do not exist yet. As you found out, you can bind using the tilde character and then selecting the hierarchy of objects you want.

                  • 6. Re: On-Demand Inline load balancer in vRA
                    jorquesana Lurker

                    My load balancer is generated with name "edge-Infoblox..4534jfsd235353 ... ".

                     

                    I have executed a workflow to change the name, it changes name in the VMs but not in the load balancer, what can I do?

                     

                    Can you help me?

                    • 7. Re: On-Demand Inline load balancer in vRA
                      daphnissov Guru
                      vExpertCommunity Warriors

                      Are you still facing issues with naming? If so, can you provide more information?

                      • 8. Re: On-Demand Inline load balancer in vRA
                        jorquesana Lurker

                        Yes. I have a blueprint, when I request it, it generates a load balancer and 2 vm.

                        Thiscalls an Orchestrator workflow, called Allocate (.from the infoblox library).

                         

                        The balancer is created with the name: edgeInfoblox***. For the vm  launch a subscription that calls the host naming workflow and this calle update workflow that update de hostname in infoblox.

                         

                        But for the balancer I do not know how to change this parameter. In fact, in vRealize the option to edit manually is not enabled.