Problems with recursive path of the inventory (c# and web services)

For starters, let me say that my goal was to write a piece of code that would take the ManagedObjectReference (MOR) of HostSystem when given the MOR in the folder root ESXi system.

However I can't get this to work with recursion at all. I could just manually each way (no recursion), but because I need to work with the web services SDK much, I really want to get this working.

I usually get exceptions like "traversal spec labeled" or "invalid type. Invalid type is caused by an error in the capitalization of the letters in the TraversalSpec.type property. But why it tells me I have a "labeled traversal spec' when I took care to specify the names in each TraversalSpec.

Can anyone provide an example on how to set up a PropertyFilterSpec to browse from the folder root to HostSystem using recursive calls via SelectionSpec?

Below is some of my code relating to the crossing of the inventory. It's a mess right now and not exactly set up for recursive as calls I kept trying different things to make it work.

Help is greatly appreciated.

               ObjectSpec objSpec = new ObjectSpec();
            PropertySpec pSpec = new PropertySpec();
            PropertyFilterSpec pFilterSpec = new PropertyFilterSpec();

            SelectionSpec sSpec = new SelectionSpec();
            sSpec.name = "travelFolder";

            SelectionSpec sSpec2 = new SelectionSpec();
            sSpec.name = "travelDCtoFolder";

            TraversalSpec travelDCtoFolder = new TraversalSpec();
            travelDCtoFolder.name = "travelDCtoFolder";
            travelDCtoFolder.skip = false;
            travelDCtoFolder.type = "Datacenter";
            travelDCtoFolder.path = "hostFolder";
            travelDCtoFolder.selectSet = new SelectionSpec[] { new SelectionSpec() };
            travelDCtoFolder.selectSet[0].name = "travelFolder";

            TraversalSpec travelCRtoHF = new TraversalSpec();
            travelDCtoFolder.name = "travelCRtoHF";
            travelDCtoFolder.skip = false;
            travelDCtoFolder.type = "ComputeResource";
            travelDCtoFolder.path = "host";

            TraversalSpec travelFolder = new TraversalSpec();
            travelFolder.name = "travelFolder";
            travelFolder.type = "Folder";
            travelFolder.path = "childEntity";
            travelFolder.skip = false;
            travelFolder.selectSet = new SelectionSpec[] { };



            objSpec.obj = hostMOR;
            objSpec.skip = false;
            objSpec.selectSet = new SelectionSpec[] { travelFolder, travelDCtoFolder, travelFolder, travelCRtoHF };

            pSpec.type = "ManagedEntity";
            pSpec.pathSet = new string[] { "name" };

            pFilterSpec.objectSet = new ObjectSpec[] { objSpec };
            pFilterSpec.propSet = new PropertySpec[] { pSpec };

Here is an example in Java in VI it is must show the way:

        TraversalSpec findHosts = new TraversalSpec();
        findHosts.setType("ComputeResource");
        findHosts.setPath("host");

        SelectionSpec recurseFolders = new SelectionSpec();
        recurseFolders.setName("FolderParent");

        TraversalSpec findClusters = new TraversalSpec();
        findClusters.setType("Datacenter");
        findClusters.setPath("hostFolder");
        findClusters.setSelectSet(new SelectionSpec[] {recurseFolders} );

        TraversalSpec findFolders = new TraversalSpec();
        findFolders.setName("FolderParent");
        findFolders.setType("Folder");
        findFolders.setPath("childEntity");
        findFolders.setSkip(Boolean.FALSE);
        findFolders.setSelectSet(new SelectionSpec[] { recurseFolders, findClusters, findHosts });

        ObjectSpec searchFromRoot = new ObjectSpec();
        searchFromRoot.setObj(si.getRootFolder().getMOR());
        searchFromRoot.setSelectSet(new SelectionSpec[] { findFolders });

        PropertySpec reportHostName = new PropertySpec();
        reportHostName.setType("HostSystem");
        reportHostName.setPathSet(new String[] { "name" });

        PropertyFilterSpec pfSpec = new PropertyFilterSpec();
        pfSpec.setObjectSet(new ObjectSpec[] { searchFromRoot });
        pfSpec.setPropSet(new PropertySpec[] { reportHostName });

        PropertyCollector pc = si.getPropertyCollector();
        ObjectContent[] ocs = pc.retrieveProperties(new PropertyFilterSpec[] { pfSpec });

        if (ocs != null) {
            for (ObjectContent oc : ocs) {
                ManagedObjectReference dc = oc.getObj();
                DynamicProperty[] props = oc.getPropSet();
                if (props != null && props.length == 1) {
                    String name = (String) props[0].getVal();
                    System.out.println("Found " + dc.getType() + " name is '" + name + "'");
                }
            }
        }

It's a bit old, so I don't know I can explain it all, but here goes.

First of all, the ObjectSpec specifies the root folder as starting point, with the 'findFolders' TraversalSpec tell what to look for from there.

Second place, findFolders, which specifies a found file, select the objects in its list of childEntity.

If the selected child object of a folder is another folder, the SelectionSpec 'recurseFolders' will point to "findFolders" looking for the child.

If the selected child object of a record is a data center, "findClusters" will choose its object 'hostFolder' and again use "recurseFolders" looking for this folder.

If the selected child object of a record is a ComputeResource, he will choose the objects in his list of 'host' and look no further.

Tags: VMware

Similar Questions

  • problem with magic network after the recent windows and mcafee updates

    There seems to be a conflict with of cicso latest windows and mcafee updates Network Magic platform. Hard to say which is originally the closing down due to the fact they both tend to update together or to the one right after the other. Could someone look into this?

    Hello

    Thanks for posting this question in the Microsoft Community.

    I'll certainly try and help you get the problem solved.

    I suggest you to check that the windows update history to verify that Windows update may cause the problem.

    (a) click on the "Start" button and select "Control Panel" from the menu that appears.

    (b) double click on "Add or Remove Programs".

    (c) click the checkbox next to 'Show the update' at the top of the window.

    (d) locate the "Windows XP - software updates" header. Below, you will find a list of updates all the date where they have been installed and the installation of the window.

    Provide us update KB number that may cause the closing.

    You can also use the shutdown Event Tracker to stop suddenly.

    Hope this helps and let us know if you need more assistance. We will be happy to help you.

  • Problem with El Captain (5.1.7 server) and the management of permissions

    Hello world

    I have a big problem with our Mac Mini Server (El Captain) and the server program.

    In recent weeks, the server didn't give the permissions of a folder.

    for example:

    Mr. X had permission to read and write to a folder.
    Mr Y too.

    Mr. X has create a new folder one record something in it.

    Mr Y had the permission to read or write to the folder create Mr. x. But he should have.

    Or

    Mr. X has save a file to a folder

    When he opens it again it is write protected and cannot be replaced.

    So you have to save under a different name in the same folder.

    And every time he save/close the file.

    Anyone know what could be the problem?

    Thank you

    Greetings from the Germany

    Chris

    My guess:

    A few weeks ago someone messed with the permissions on your server and made a mistake. So, you got an inappropriate list ACL (Access Control), which is rampant in the file and must be removed or fixed.

    http://www.TechRepublic.com/blog/Apple-in-the-enterprise/introduction-to-OS-x-AC cess-control-lists-ACL.

    C.

  • my computer will not install itunes 10.5, it tells me "Setup has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2330.

    original title: Itunes problem

    my computer will not install itunes 10.5, it tells me "Setup has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2330. "What should I do?

    Contact the manufacturer (Apple) of the application (iTunes) you are having problems with.

    Uninstall all previous versions, try to download (re-record not running) and then do a right click on it and RUN AS ADMINISTRATOR.

    (Vista 32-bit or 64-bit)?

  • Problems with Vista start after the update of Norton.

    I had problems with start-up since Norton updated and re-printing my subscription a few days ago.  Initially, the splash screen would freeze, I'll try to re-start, only to be refrozen.  After several attempts, with different amounts of time in between, I tried to start a 'normal', but are also intended to "launch fix."  Microsoft solution is to go back to "settings" before the new and improved Norton Security has been installed.  "Norton isn't too happy with this solution, warning: your firewall is disabled, you are vulnerable to all viruses known to humanity" and Norton resets security and the volley continues.  At some point, the screen may freeze, and I have to start all over again.  Had my Vista Home premium SP1 and SP2 installed this past year, patches and I have had no problems since, so far.  If anything is not easy? The pearls of wisdom would be greatly appreciated.  The garbage man comes tomorrow, I'm tempted to put my computer out of the trash.  Help. Please, I beg you.

    Hello, Heather,

    Boot safe mode with networking.  Download the following tool and run a full scan to exclude the malware.  If the system is infected, Norton will be compromised and would not be able to detect malware.

    http://www.Microsoft.com/download/en/details.aspx?displaylang=en&id=16

    Reboot - still problems with startup?  Uninstall Norton - use the uninstaller to remove all traces.  Restart your system and reinstall the software.

    Norton Removal Tool

    https://www-secure.Symantec.com/Norton-support/JSP/help-solutions.jsp?docid=20080710133834EN&LG=English&CT=United+States&product=home&version=1&PVID=f-home&entsrc=redirect_pubweb

    Once you have completed and reinstalled Norton, test - you still having the problem?  Try the link to clean boot troubleshooting below.

    The best advice I can give you is not no use Norton products.  Use Microsoft Security Essentials, which is freeware.

    Perform a clean boot

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

  • Problem with Windows Update after the new installation of Windows 7 Pro the Lenovo ThinkPad X 200

    I'm trying to do a fresh install of Windows 7 Pro on a Lenovo ThinkPad X 200. The product key is easy to find on the sticker of the ThinkPad. However, the version of Windows is hidden (for example, I can't check that my ThinkPad had originally installed Windows 7 Pro). I was able to install by using a Pro Win 7 SP1 CD ROM I bought for another installation. I used the ThinkPad I was trying to make the new facility on the product key. I was able to activate the Windows 7 Pro using the phone call and my cell phone. I checked the activation! However, I have problems with Windows update. The product key may be a different version of Windows 7. If so, why did it install and activate OK? Y at - it a fix for this problem or I have to buy a new version of Windows 7 Pro? Please note that I have not yet installed all drivers Lenovo ThinkPad as I can't seem to install correctly. Thank you!

    Since the issue is updated to Windows, it is not a product number key.

    You can reset the Windows Update components by running the Fixit on this page. But if there is malware present, she will continue to reset the connection to the update servers:

    How to reset the Windows Update components

    http://support.Microsoft.com/kb/971058

    Suggest you download and save the Fixit. Then configure the system before the clean boot by running:

    How to troubleshoot a problem by performing a clean boot in Windows Vista/Windows 7

    http://support.Microsoft.com/kb/929135

    Once the Fixit has been downloaded and the system is started in the pure State, check that the native Windows Firewall is now on if a 3rd party firewall has been used previously. Now run the Fixit and choose the default mode. Restart once it's done and see if the system can be connected to the update servers. If he can't, then rerun the Fixit and choose aggressive mode. Turn it back on when he finished the race and updates.

  • Problem with silverlight download, download the error code 2104.

    Original title: problem with Sliverlight download
    get the error code 2104. tried to uninstall and reinstall

    Hello

    Thanks for the reply.

    We are pleased to know that the problem is solved. Please do not hesitate to answer, in the case where you are facing in the future other problems with Windows. Please contact the Windows community.

  • I have problems with my application of the java language.

    I have problems with my application of the java language. It will be open only for about one second, and it won't let me write all programs, it looks like the command prompt when opening. what the * is underway and what can I do to solve this problem.

    Hey Kevin,

    The description of the problem seems a little unclear and I wish I had a better understanding before you start working on it.

    I would really appreciate if you could answer the following questions:

    1. is the specific question of the application of the Java language?

    2. did you of recent changes made to your computer before the show?

    3. you receive an error code or message?

    Please provide us with more information on the specific question to help you to fix as soon as possible.

    If the problem is specific to the Java application, then I suggest you to contact Java support from the links below:

    http://www.Java.com/en/download/support.jsp

    Java Help Center:

    http://www.Java.com/en/download/help/

    Your response is very important for us to ensure a proper resolution. Please get back to us with the information above to help you accordingly.

  • Problem with changing photos in the live App Photo tile.

    Original title: remove tile App.

    Hello!

    "Please tell me how I delete this image of my" ""Start " of the Photos app. Now my photos app status is ' activate live tile " , but does not properly.

    Hi Malik.

    This problem could occur due to these reasons.

    1. If the application is not configured correctly.
    2. If the application settings are incorrect.

    Try the steps listed here and see if it helps.

    Method 1:
    I suggest you try the steps to put the Photos of tiles. Check if it helps.

    1. From the home screen, open the app photo.
    2. Go to the photo that you want to use and tap or click on to open it.
    3. Swipe in the bottom edge to see the commands of the app.
      (If you use a mouse, right-click in the application.)
    4. Press or click on set asand then press or click the photo mosaic.

    Next time you go to start, you tap or click on this picture to open the Photos app.

    Method 2:
    If the problem persists, I suggest trying the following steps and check if it helps.

    Step 1:
    We will run the troubleshooter app and check if it helps.

    Solving the problems of the app

    Step 2:
    If the problem persists, I suggest you to install all the available Windows updates. Check if it helps.

    See the article for more information.

    Soft pictures for Windows: FAQ

    Hope this information helps. Answer the post with an up-to-date issue report to help you further.

  • I have problem with value NULL when the use CASE statement please help this question

    I have problem with value NULL when the use CASE statement please help this question


    Table: digital_val

    SNO cl C2

    1 San1 11

    2 22 San2

    Actual result: expected to A         B

    A            B                                                                           11        22

    11 NULL

    22 NULL



    query:

    Select case when c1 = "san1" then c2,.

    case If c1 = "san2" then c2 B

    of digital_val

    I'm more curious why, when you select 2 rows, you expect a result of row?

    WITH digital_val

    AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)

    UNION ALL

    2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)

    SELECT CASE WHEN c1 is "San1" THEN END AS A c2.

    CASE WHEN c1 = "San2" THEN END AS B c2

    OF digital_val;

    With no other input, if you select 2 rows, you get 2 rows.  One of the other solutions use a max function, but is this really what you want, does not specify?

  • Bridge does not open? Initially the 8.1 Win & problem had started. Have now earn 10 & still a problem with not to open the bridge?

    Bridge does not open? Initially the 8.1 Win & problem had started. Have now earn 10 & still a problem with not to open the bridge?

    Hi Matthew,

    If you use Bridge CC, update to the latest version 6.2. Adobe Bridge CC 6.2 version now available! Adobe content corner

    1. Please, do a right-click on the bridge on the desktop icon and select "Run as Administrator".
    2. If this does not help, reset the Bridge preferences and then try it.

    Steps: -.

    Start Adobe Bridge, and immediately press Ctrl + Alt + Shift (Windows) or command + Option + shift (Mac OS down) until the dialogue box reset settings appears.

    Select all three options - reset preferences, reset Standard Workspaces and all miniature Purge Cache - and then click OK.

    Reference: troubleshooting errors, freezes | Adobe Bridge | Windows, Mac OS

    Let us know if it works.

    Kind regards

    Assani

  • problem with bind variables in the SQL query view object

    Hi all

    I use JDev 11.1.2.4.0.

    I have a problem with bind variables in the SQL query view object.

    This is my original SQL

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE t.nctuser_id = '20022' 
          AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929')
    group by t.legertype_id
    

    In my view .xml object query tab, I am writing this

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE   t.nctuser_id = '20022'
        AND to_char(t.insertdate,'YYYYMMDD') in :dddd
    group by t.legertype_id
    

    Davis here is a variable of Type liaison: String, updatable and necessary.

    I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.

    But failed. The view object retrieves 0 line after that I run.

    Why?

    Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')

    A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.

    Timo

  • Problem with livemail, upgrade Windows 7 to 10 and back again

    Separated from this thread.

    Hello

    Having problem with livemail, improved Windiws 7 to 10 and then uninstalled immediately revert to the original with option to the program (things not working not properly).   All rolled back does OK no message or data errors.

    Now all the direct mail has duplicated, will remove some, but others won't.

    Can you post help or solution, please

    John

    It seems that many of those who go back to Windows 7 from Windows 10 experience a corruption of the store folder (the folder where messages, calendars and the account settings are stored). According to your storage folder is how complex (several accounts, calendars a lot, a lot of messages number of files), it can be simpler to just create a new storage folder and fills again:

    1. Looking at your list of messages in Windows Live Mail, press Ctrl-Shift-O for Options. On the Advanced tab, click Maintenance and then store the file. Copy the path to locate the storage folder.
    2. Close Windows Live Mail and wait a few minutes (the program will continue to run in the background, while he does his household).
    3. Press the Windows key + E to open an Explorer window, and then paste or type the path that you copied to the (1) in the address bar and press ENTER. This should open your storage folder.
    4. Right-click on the name of the folder in the navigation pane, and select Rename. Call the Live Mail Backup.
    5. A repair must check that all the program files are present and correct and properly registered, as appropriate. To do this, close all running programs, and then press Windows key + R, type wlarp and press ENTER. In the window that opens, select repair all Windows Essentials programs:


      When it is finished, restart the computer.

    6. Start Windows Live Mail and wait the program installs before doing anything. Press Ctrl-Shift-T to start the add your Assistant e-mail accounts and follow the prompts to add your e-mail accounts.
    7. Click once on the work online on the status bar and deconnecter disconnect Internet to avoid interference email downloads, and then use the file > import messages (I Alt - F) and point the wizard to the Live Mail Backup folder level. Do not intervene while the import happens.
    8. Leave the program alone for a while (an hour or two, or even a night or more) to enable him to reindex all your messages, then close and wait half an hour for the program to do his household.
    9. Relaunch the program and look at your messages under folder imported into storage folders. Take it slow, drag files out of any folder and drop in the location you want. Again, give the program time to re - indexing messages in their new location.

    Note that you can not drag files out of storage files. If you want to forward messages to a high plu account folder in the folders pane, you need to select messages to transfer, and then use the right click > move or copy folder. The controls are also available as buttons in the folders of the Ribbon tab.

  • Having a problem with my computer I try to restart and get BSOD saying internal error Planner video background

    Original title: Blue Screen of Death (BSOD)

    Hello im having a problem with my computer I try to reboot and I get BSOD saying internal error Planner video background

    Here is my mini dump file:

    https://onedrive.live.com/redir?RESID=60FEBF11B9A3D76! 4807 & authkey =! AGKWUp-ndI0XBgE & ithint = the file % 2cdmp

    and here is my system info:

    https://onedrive.live.com/redir?RESID=60FEBF11B9A3D76! 4810 & authkey =! AFloWJarqiE83QM & ithint = the file % 2cnfo

    im hoping that this will let you know what is wrong or not

    RW

    This phenomenon was linked to your video driver (atikmpag.sys) /DirectX.  I would completely remove the current driver and install the latest driver available.

  • I am running windows vista and am warned there is a problem with windows media center, restart my computer and try again. It did not work. Help

    I am running windows vista and am warned there is a problem with windows media center, restart my computer and try again. It did not work. Help

    Run the Setup again.

    Open WMC > tasks > settings > General > installation Windows Media Center > rerun the installation

    Does that help?

    If the above does not help then try to reset WMC: -.

    Open Control Panel > uninstall a program > turn Windows features on or off > scroll multimedia features > uncheck the box against Windows Media Center > follow the instructions on the screen > Reboot > open again to turn Windows features on or off in the control panel > scroll multimedia features > check the box against Windows Media Center.

    Now reconfigure WMC again

Maybe you are looking for