VMware {code} Community
amishera
Contributor
Contributor

The setting of property is not working

my $entity_type = "HostSystem";
my $entity_view = Vim::find_entity_view(view_type => $entity_type, filter => {name => '10.15.213.99'});

# Process the findings and output to the console

    my $entity_name = $entity_view->name;
    Util::trace(0, "Found $entity_type: $entity_name\n");

    my $entity_subentity_arr = $entity_view->config->network->vswitch;
    if (defined($entity_subentity_arr)) {
       
        my $entity_subentity = @$entity_subentity_arr[0];       
        my $entity_subentity_1 = $entity_subentity->spec->policy->nicTeaming->policy;
        print $entity_subentity_1;
        $entity_subentity->spec->policy->nicTeaming->policy('loadbalance_srcid');
    }
#}

# Disconnect from the server
Util::disconnect();

0 Kudos
2 Replies
amishera
Contributor
Contributor

I was trying to set the network policy. In this example I was trying to set it to "loadbalance_srcid". I had the sample script from the documentation. I went through the API reference guide and modified my code. But whatever I do, there is no effect of the statement in bold ($entity_subentity->spec->policy->nicTeaming->policy('loadbalance_srcid');)

I am not sure whether this is the right way to set properties. I just followed what is mentioned in the document:

You can modify a data object’s property value by passing the new value, as follows:
$data_object-> <property> (<new value>);
$data_object is a blessed reference to a Perl object or class name, and property is a method call on the object.
For example, you can change the force property to false, as follows:
$host_connect_spec->force ('false');

But even though I can access the property, I can't set this. I can set invalid value (eg integer instead of string). But there is no complain or any response and the outcome is unchanged from the existing one.

Does anyone know how to set property gracefully?

Thanks

0 Kudos
stumpr
Virtuoso
Virtuoso

You'll need to use http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.host.NetworkSystem.html#....  The properties you're modifying are client side only, you'll need to use a SOAP function to update values on vCenter and HostSystems.

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos