Use get - view to get the host data center

Hey guys,.

I'm trying to shoot the host number of name and the version with get-view.

I got to that, but I also want to get the data center that host belongs to.

How can I get that advice please, don't have Googling has not helped a lot.

Thank you

RJ

With the ExtensionData property we have access to the object VirtualMachine .

Most of the managed objects vSphere has a property, called Parent, which points to the object that is connected to our object (the ' mother' in other words).

The content of the Parent property is a MoRef (pointer). To get the real object, we use the cmdlet Get-view with this MoRef.

We repeat this process in a while loop until the parent object is an object of data center .

It's a bit like the structure of the tree in the vSphere Client.

You start with the ESX (i) server and back up in the tree until you encounter a data center.

Tags: VMware

Similar Questions

  • example of Perl to get the host data center

    Hi all

    I try to get the data center for a specific host.  Now I can get the full list of data centers with:

    use strict;

    use warnings;

    use VMware::VIM2Runtime;

    use VMware::VILib;

    OPTS::parse();

    OPTS::Validate();

    Util::Connect();

    My $dcenter_views = Vim::find_entity_views (view_type = & gt; "Data center");

    {foreach (@$dcenter_views)}

    Print $_ - & gt; name. "," . $_ - & gt; name. ";;";

    }

    But I can't seem to find a way that works to get it to only a specific host, rather then a complete list.  Could someone please provide an example of how to do this?

    So I cleaned up your script a little, mostly some optimizations.  I used the construction in the occupied Palestinian territories: module to add a host name parameter to the script instead of using ARGV.  I changed it so it checks for a valid host view before you start your loop, no point in a loop in data centers, if your host name is not a valid real hostname in your inventory of VI.  Take a look at the label of the LOOP, I cleaned up.   You want to leave the loop after you find the data center.

    Just to show you how much faster my original script is logical, I wrote it also another version of my script using the Perl toolkit.  It was > 3.5s faster on my independent ESX host.  It is largely because find_entity_view() functions essentially look the whole game ManagedObject property reference, which is pretty intensive.  This gets quite slow in a larger environment and is compounded in a nested loop.  Usually, I try to avoid the use of find_entity_view() strongly in my scripts for this reason.

    Do not hesitate to work with whatever version you like best.  I think the good scripts to do the work.

    Find_entity_views() using nested:

    #!/usr/bin/perl -w
    
    use strict;
    use warnings;
    
    use VMware::VIRuntime;
    
    my %opts = (
         hostname => {
         type => "=s",
         variable => "HOSTNAME",
         help => "Name of managed ESX host",
         required => 1,
         }
    );
    Opts::add_options(%opts);
    Opts::parse();
    Opts::validate();
    
    Util::connect();
    
    my ($host_views, $datacenter, $hostname);
    $hostname = Opts::get_option('hostname');
    
    my $host = Vim::find_entity_view(
         view_type => 'HostSystem',
         filter => { name => $hostname },
    );
    
    unless (defined $host) {
         Util::disconnect();
         die "No host matching '$hostname' found.\n";
    }
    
    my $datacenter_view = Vim::find_entity_views(view_type => 'Datacenter');
    
    LOOP: foreach (@$datacenter_view)
    {
         $datacenter = $_->name;
         $host_views = Vim::find_entity_views(
              view_type => 'HostSystem', begin_entity => $_
         );
    
         foreach (@$host_views)
         {
              if ($_->name eq $host->name)
              {
                   print "$datacenter\n";
                   last LOOP;
    
              }
         }
    }
    
    Util::disconnect();
    

    The sample output:

    $time perl test.pl --server=172.16.14.51 --username=root --password=vmware --hostname=ESX-01.vmwlab.local
    ha-datacenter
    
    real     0m7.502s
    user     0m1.872s
    sys     0m0.078s
    

    By using the property parent ManagedObject:

    #!/usr/bin/perl -w
    
    use strict;
    use warnings;
    
    use VMware::VIRuntime;
    
    my %opts = (
         hostname => {
         type => "=s",
         variable => "HOSTNAME",
         help => "Name of managed ESX host",
         required => 1,
         }
    );
    Opts::add_options(%opts);
    Opts::parse();
    Opts::validate();
    
    Util::connect();
    
    my $hostname = Opts::get_option('hostname');
    
    my $entity_view;
    sub FindDatacenter
    {
    
         my ($entity) = shift;
    
         unless ( defined $entity )
         {
              print "Root folder reached and datacenter not found!\n";
              return;
         }
         if($entity->type eq "Datacenter")
         {
              my $datacenter_view = Vim::get_view(mo_ref => $entity, properties =>  \['name']); # remove the \ before the property list.
    
              print "Datacenter for HostSystem '" . $hostname . "' = " . $datacenter_view->name . "\n";
              return;
         }
    
         $entity_view = Vim::get_view(mo_ref => $entity, properties => \['parent']); # remove the \ before the property list.
         FindDatacenter($entity_view->parent);
    }
    
    my $host = Vim::find_entity_view(
         view_type => 'HostSystem',
         filter => { name => $hostname },
    );
    
    unless (defined $host)
    {
         die "No host matching \'$hostname\' found.\n";     
    
    }
    
    FindDatacenter($host->parent);
    
    Util::disconnect();
    

    The sample output:

    $time perl test2.pl --server=172.16.14.51 --username=root --password=vmware --hostname=ESX-01.vmwlab.local
    Datacenter for HostSystem 'ESX-01.vmwlab.local' = ha-datacenter
    
    real     0m4.326s
    user     0m1.429s
    sys     0m0.072s
    
  • Get the latest data of Variable shared before disconnecting from the network

    Hello.

    I use Shared - published network variables for my communication between two PC's. Each LV software will pass the data to another.

    Sometimes the wireless connection to become really bad and the network connection stops.

    I want to get the latest data. Currently my VI will show the value '0' on the variable shared data once the connection is cut.

    I tried using shift, but she registers the same results.

    Can someone show me how I can stay past data when the network connection is disconnected.

    Thank you very much.

    Kind regards

    Hello Fan, Ravens

    It works! Thank you very much.

    Kind regards

  • Get the raw data to map its (SDK)

    I did a search on sound cards and many forums have been useful.  I have just a few quick questions.

    I have a card his (CardDeluxe http://www.digitalaudio.com/) connected to the computer through a PCI.  My goal is to get the raw data from the card and plug and it blow in analytics in CVI.  I don't know how to "talk" to my sound card.

    Of course, my main question is above, but to the refine some concerns...

    I guess I need the SDK libraries for that.  For this, I just need to install the MSN help libraries?

    Is this possible in the Basic Version, or if the full Package of CVI is necessary?

    I have not done things well at low altitude, but it looks like getting a wav file is necessary.  I can't use anything outside of the applications I want to eventually create a program automatically record and play at a time (sync) précis.

    Thanks in advance.

    This site is what I was looking for.  The zip file contains an exe as file c source code.

    http://paulhoule.com/phsrec/index.php

    Edit:

    There is also some info here - http://forums.ni.com/t5/LabWindows-CVI/wav/m-p/235344

  • problem to get the current date in qml

    Hello world

    I'm trying to get the current date in c ++ and qml and I used the class QDate, but it still has some problems:

    Code:

    =====================================================

    QDate * nowdate = new QDate;
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (nowdate-> currentDate()));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    ===========================================================

    After setting the nowdateMap, I'm able to get the date in the application, but the format is really weird, I did not use QDatetime, but the restult of shows like ' 2013-1 - 3 T 00: 00:00 ", how can I get rid of the final"T00:00:00 "? or is there a better way to get the current date?

    Thank you

    QDate nowdate is QDate::currentDate();.

    QString nowdatestring = nowdate.toString (); / / to get the date string format, you can define the shape of toString(), you can //search it
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (QString (nowdatestring)));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    then in the file qml, using nowdateMap.date will do.

  • I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows?

    I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows so that I can do the calculations?

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

  • How to get the host name of the physical computer inside a virtual machine until the user logs in Windows?

    I don't know if this is the right place to post this question, I develop software to support VMWare PCoIP and need to know how to get the host name of the physical machine (which manages the virtual machine and View Client) within a virtual machine before the user logs in Windows of the virtual machine.

    I understand there are two ways to read the host name, via the HKEY_CURRENT_USER\Volatile Environment registry and environment variables, but they are available once the user is connected. I need info before the user connects.

    Is there a VMware API that can be called or asked the host name?

    Thank you.

    Not on the broker, but there are the startup scripts to log on to the computer virtual itself: http://pubs.vmware.com/view-52/topic/com.vmware.view.integration.doc/view_integration_startsession_script.9.2.html

    Note that these executed when a virtual desktop computer allocated connection, not to the point that the client connects - it is possible for the customer to not complete the connection (crash, cancel, network failure) and so any what solution you design must handle this.

    Mike

  • How to get the old data 6 months from the current date?

    Hi friends,

    I have a table which includes historical data, which are having more than 1 years old data. The historical table gets updated once a week. My requirement is that I should get the latest data from the week of each month for 6 months according to the current data. I use oracle 10g.

    Can you please someone help in this.

    Thanks in advance

    SELECT last_day (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL))-7 start_dt.
    LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL)) end_dt
    OF THE DOUBLE
    CONNECT BY LEVEL<=>

    change as a result, I have provided you the start and end dates for your logic...

  • How can I get the filtered data from the first form

    How can I get the filtered data from the first form in a second form to make an update of the multi.
    Thank you very much

    William,

    I would use for this collections. A link is good if you need to pass a single value.

    1. create a collection
    2 fill the collection with your result set
    3. go in the page target and uses a method of a query in your link to this page
    4. your target page receives a request and allows you to edit documents.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

  • How to add two lines when the second row is not visible, but also gets the first data line too?

    Mr President

    Jdev worm is 12.2.1

    How to add two lines when the second row is not visible, but also gets the first data line too?

    I want to add two lines like below picture, but want the second to remain invisible.

    tworows.png

    I asked this question but my way of asking was wrong, that's why for me once again.

    Concerning

    Try to follow these steps:

    1. in the database table to add the new column "JOIN_COLUMN" and add the new sequence "JOIN_SEQ".

    2. Add this new column in the entity object. (You can add this in entity object by right clicking on the entity object and then select "Synchronize with database" then the new column and press on sync)

    3. in your bookmark create button to create only one line NOT 2 rows.

    4 - Open the object entity--> java--> java class--> on the entity object class generate and Tick tick on the accessors and methods of data manipulation

    5 - Open the generated class to EntityImpl and go to the doDML method and write this code

      protected void doDML(int operation, TransactionEvent e)
      {
        if(operation == DML_INSERT)
        {
          SequenceImpl seq = new SequenceImpl("JOIN_SEQ", getDBTransaction());
          oracle.jbo.domain.Number seqValue = seq.getSequenceNumber();
          setJoinColumn(seqValue);
          insertSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        if(operation == DML_UPDATE)
        {
          updateSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        super.doDML(operation, e);
      }
    
      private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "Insert into table_name (COLUMN_1,COLUMN_2,COLUMN_3,JOIN_COLUMN, HIDDEN_COLUMN) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + joinColumn + "', 1)";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "update table_name set column_1='" + value1 + "', column_2='" + value2 + "', column_3='" + value3 + "' where JOIN_COLUMN='" + joinColumn + "'";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • How to get the current date to display in the Spanish format.

    The coding is in format Adobe Acrobat, DC. The coding I have for the English today's date is:

    var d = new Date();

    sDate = util.printd var ("dd mmmm yyyy", d);

    this.getField("Text1").value = sDate;

    How can I get the current date displayed in this Spanish format: 07 December 2015

    Thank you

    It's a little complicated... But this code should do the trick:

    util.printd("dd", d) + " de " + util.printd("date(es){MMMM}", d, true) + " de " + util.printd("yyyy", d);
    

    Edit: Fixed the code... Did not notice the 'of' second before.

  • Error "could not get the audio data in the file.

    Hello

    I get a lot of mistakes "Could not get the audio data in the file" when you open a project. Sometimes they will plant Premiere Pro CC 7.01 (Mac). But if no first works as usual, with the audio.

    I tried to convert the audio files (from the hearing) from 32 to 16 bit. It worked while opening a project once, but not the next time.

    Where can it be?

    Edit: I also get this error when importing audio: "error: Premiere Pro version 7.0 is not compatible with the first version of plugin Pro 5.7.4. Maybe it's related.

    I have it! This is the plugin Smartsound hurt. Got rid of him and no more errors.

  • get the current date for condition satisfied

    Hello world

    I want to get the current date for the following query.

    SELECT B.NAME, C.FST_NAME, C WHERE S_CONTACT, S_ORG_EXT B, C.LAST_NAME OF S_PARTY_PER A (B.ROW_ID = A.PARTY_ID AND C.ROW_ID = A.PERSON_ID AND A.PERSON_ID IN (select D.NEW_VAL from the S_AUDIT_ITEM where D.OPERATION_CD = 'Associate' and OPERATION_DT = 'I want the current date from 07/10/2008 12:00:00 AM to 07/10/2008 23:55:55 '))

    Help, please...

    Hello

    Like this?

    SELECT B.NAME, C.FST_NAME, C.LAST_NAME
      FROM S_PARTY_PER A, S_ORG_EXT B, S_CONTACT C
     WHERE (B.ROW_ID = A.PARTY_ID AND C.ROW_ID = A.PERSON_ID AND
           A.PERSON_ID IN
           (select D.NEW_VAL
               from S_AUDIT_ITEM D
              where D.OPERATION_CD = 'Associate'
                and trunc(OPERATION_DT) = trunc(sysdate)
    --                'i want current date start from 10/7/2008 12:00:00 AM to 10/7/2008 11:55:55 PM'))
    
  • The number of heartbeat for the host data warehouses is 0, which is less than required: 2

    Hello

    I have trouble creating my DRS cluster + storage of DRS, I have 3 hosts esxi 5.1 for the task

    First, I created the cluster, no problem with that, so the DRS storage was created and now I can see in the Summary tab

    "The number of heartbeat for the host data warehouses is 0, which is less than required: 2".

    I search the Web and there are similar problems when people has only a single data store (the one that came with ESXi) and need to add another but in my case... vcenter detects any...

    In the views of storage I see the store of data (VMFS) but for some strange reason the cluster not

    In order to achieve data warehouses minimum (2) can I create an NFS and map it in THE 3 esxi hosts? Vcenter which consider a play config?

    Thank you

    You probably only have local data warehouses, which are not that HA would require for this feature (pulsations datastore) to work properly.

    You will need either 2 iSCSI, FC 2 or 2 NFS volumes... Or a combination of the any of them, for this feature to work. If you don't want to use this feature, you can also turn it off:

    http://www.yellow-bricks.com/2012/04/05/the-number-of-vSphere-HA-heartbeat-datastores-for-this-host-is-1-which-is-less-than-required-2/

Maybe you are looking for

  • Now start (end) MM 2014 out SSD external; What should I do with the profile on my HHD?

    As indicated in the title, I copied my HARD whole on an external SSD drive which is running off the coast of USB 3.0. Things work terribly for months now, so I think I'm ready to wipe the HARD disk partition original that was made when initially, I s

  • My Mac has a virus or is this malware?

    While browsing with Safari a message popped up on my computer.  Should I take seriously or is - this malware that I must be wary?  The message was: In "apple.com - messenging.» *** » VIRUS DETECTED A Web site that you visited today has infected your

  • Export bookmarks from a Mac with broken video

    I can't export the bookmarks of the iMac broke because his video has failed, but I can access the content of its HD on the network and can see the... Library/Caches/Firefox/Profiles folder. It seems empty but Get Info says that it contains 380.5 Mb.

  • Problems with Pandora APP - 4th generation Apple TV

    I installed APP Pandora for the 4th generation Apple TV and connected to my subscription account a Pandora. I tried to listen to one of my station, but he would not play. I tried to other stations, but the same problem it does not. My sound is fine w

  • open my computer, I get this error message:

    Error loading c:\windows\KBDMPT.dill could not be found. Please tell me what it means, so that this computer is restored in good shape, but this message has begun to show months later, I've spent