Start a Conversation

Unsolved

This post is more than 5 years old

1212

May 24th, 2013 14:00

Create a Object in a Ionix Server Using a Perl Script

Hi to all, I have some questions about Perl API, because I have some problems at the moment of try to create an Object in a Ionix 9.1 Server using a Perl Scrip.

I have the next Perl Script, this script created a Object in Ionix Server 9.1 and after that update some attributes.

use InCharge::session;

my $session = InCharge::session->new(                                                           broker=>$brokerPort,                                                       domain=>$domainName,                                                        username=>$user, password=>$password);     

                                                      

my $ipObjectName = "IP_Object_Test01";

my $attributeName = "DisplayName";

my $attributeValue = "my ip object display name";

my $attributeName01 = "Address";

my $attributeValue01 = "192.168.1.2";

my $className ="IP";

                                                                          

$session->transactionStart(0);

CreateObject($className, $ipObjectName);

$session->transactionCommit();

Set_Put_Property($className, $ipObjectName, $attributeName01, $attributeValue01);

Set_Put_Property($className, $ipObjectName, $attributeName, $attributeValue);

$session->detach( );

#Subroutine Create new Object

sub CreateObject

{      print "\nCreate Object Called...";

       my($class, $objectName) = @_;

       my $object = $session->create( $class, $objectName);

       print "\nThe Object: $objectName was created successfully";

}

#Sub routine put/set a Property

sub Set_Put_Property()

{      my($className, $instanceName, $propertyName, $propertyValue)= @_;

      

       $access = $session->getPropAccess($className,$propertyName);

       $decrip = $session->getPropDescription($className,$propertyName);

       $type = $session->getPropType($className,$propertyName);

       $isRequired = $session->getPropIsRequired($className,$propertyName);

       $isReadOnly = $session->getPropIsReadonly($className,$propertyName);

       print "\n-->Property to Update.\nName:".$propertyName."\nAccess:".$access."\nType:".$type."\nIsRequired:".$isRequired."\nIsReadOnly:".$isReadOnly."\nDescription:".$decrip."\n\n";

       if(!$isReadOnly)

       {      my $object = $session->object( $className, $instanceName );

              $object->put( $propertyName, $propertyValue );

              print "\n".$propertyName." property is update successfully."        

       }

       else

       {             print "\n".$propertyName." property is read only."           

       }

}

  1. The problem is when I try to update some attributes apparently not Read only the script fail and say me that this attribute is read only L

This is the Console output of this script:

Create Object Called...

The Object: IP_Object_Test01 was created successfully

-->Property to Update.

Name:Address

Access:1

Type:13

IsRequired:0

IsReadOnly:0

Description:The IP address.

Address property is update successfully.

-->Property to Update.

Name:DisplayName

Access:2

Type:13

IsRequired:0

IsReadOnly:0

Description:The string shown in the GUI when this object's name is displayed.

[15] MR-E-WRITE_TO_READONLY-Tried to write to a read-only attribute??? at c:\InCharge\CONSOLE\smarts\perl\5.8.8/InCharge/remote.pm line 300. 

In this console output I first created a Object in a IP class successfully after that I start update some attributes, the first attribute is the Address that updated successfully (in yellow) after that I try to update the DisplayName attribute (in red), but this operation is not completed show me a read only message error(in green).

Anybody could you please help me with this problem, I try with other classes and I get the same problem.

What is the correct Validation in order to determine if the attribute is writable/updateable?

  1. Thanks.
No Responses!
No Events found!

Top