Skip to content

Instantly share code, notes, and snippets.

@vmwarecode
Created December 11, 2016 23:01

Revisions

  1. @vmwsrpbot vmwsrpbot created this gist Dec 11, 2016.
    32 changes: 32 additions & 0 deletions snippet.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    // Copyright 2016, VMware, Inc. All Rights Reserved
    //
    // VMware vRealize Orchestrator action sample
    //
    // Given a Managed Object Reference Id of a DistributedVirtualPortgroup
    // (ex: dvportgroup-714) return the VC:DistributedVirtualPortgroup object.
    //
    //Action Inputs:
    // id - string
    //
    //Return type: VC:DistributedVirtualPortgroup


    var moRef = new VcManagedObjectReference();
    moRef.type = "DistributedVirtualPortgroup";
    moRef.value = id;
    var connections = VcPlugin.allSdkConnections;
    var dvpg = null;
    for (var i in connections) {
    try {
    System.log("connection: "+connections[i]);
    dvpg = VcPlugin.convertToVimManagedObject(connections[i], moRef);
    System.log("dvpg: "+dvpg);
    if(dvpg != null) {
    //found it
    break;
    }
    } catch (e) {
    System.error(e);
    }
    }
    return dvpg;