• No results found

Code examples

In document VisiBroker Configuration Reference (Page 89-100)

All code examples should be read in conjunction with “Example of API usage” on page 8-13.

acCreateEvent

Description

This creates a user-defined event and sends it to the repository. The type of event is always UserEvent.

Syntax

void acCreateEvent( in string security, in string uuid,

in string severity, in string transition,in string cause, in string message, in string solution ) raises(Fail);

Parameters

Parameters for this operation include

In Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

severity string The severity of the event. transition string What has happened to the object. cause string The cause of the problem.

message string Some message that will show up detailing the event. solution string The suggestion action that can be taken for this event.

a c C y c l e

Values for security, UUID and severity are mandatory. Values for other parameters are optional and if you don't want to use them, just put NULL as the value.

Return value

Return values for this operation include

Example

//create event for Secure_Transfer object const char *severity = "Major";

const char *transition = "none"; const char *cause = "NOT FOUND";

const char *message = "Ping to Agent failed"; const char *solution = "Start the agent";

appCenter->acCreateEvent(security, uuid, severity, transition, cause, message, solution );

acCycle

Syntax

void acCycle( in string security, in string uuid ) raises(Fail);

Description

This cycles the specified object.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acCycle(security, uuid);

acDecrement

Syntax

void acDecrement ( in string security, in string uuid ) raises(Fail);

Description

This decreases by 1 the number of running objects in a specified group.

Return value Type Meaning

None

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

a c F a i l O v e r

C O R B A A P I f o r A p p C e n t e r 8-5

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acDecrement(security, uuid);

acFailOver

Syntax

void acFailOver( in string security, in string uuid ) raises(Fail);

Description

This instruction fails over the specified object.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acFailOver(security, uuid);

acFindObject

Syntax

void acFindObject( in string security, in string objectPath, out string uuid ) raises(Fail);

Description

This finds an object in the repository based on a supplied path name. The objectPath should be in the same form used by a UNIX file pathname, for example

/Configurations/GroupDemo/min_group

A pathname “/” represents the root object (the repository object).

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

None

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

a c G e t C h i l d r e n

Parameters

Parameters for this operation include

Return value

Return values for this operation include

Example

// get uuid of Secure_Transfer object

const char *objectPath = "/Configurations/Secure_Transfer"; char* uuid = NULL;

appCenter->acFindObject(security, objectPath, uuid); cout << "Out from acFindObject() uuid: "<<uuid<<endl;

acGetChildren

Syntax

void acGetChildren( in string security, in string parentUuid, out uuid_list children ) raises(Fail);

Description

This gets all of the children of a particular parent object. What is returned is an array of UUID strings that can be used in further operations.

Parameters

Parameters for this operation include

Return value

Return values for this operation include

Example

// Get children

const char *parentUuid = uuid; AppCenter::uuid_list *children = NULL;

appCenter->acGetChildren(security, parentUuid, children ); cout << "Out from acGetChildren() children: "<<children[0]<<endl;

Parameter Type Description

security string This string represents a simple form of user authentication. objectPath string The object path.

Return value Type Meaning

uuid string The string that is returned in “uuid” represents a unique handle to that object. This handle is used in many of the other routines in order to identify the object that you want to apply an action to.

Parameter Type Description

security string This string represents a simple form of user authentication. parentUuid string The UUID of the parent object used.

Return value Type Meaning

a c G e t O b j e c t H o s t

C O R B A A P I f o r A p p C e n t e r 8-7

acGetObjectHost

Syntax

void acGetObjectHost( in string security, in string uuid, out string host_uuid ) raises(Fail);

Description

Given a specific object’s UUID, this instruction gets the UUID of the host object that it belongs to.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

objectPath = "/Configurations/Secure_Transfer/Demeter"; uuid = NULL;

appCenter->acFindObject(security, objectPath, uuid); cout << "Out from acFindObject() uuid: "<<uuid<<endl; char* host_uuid = NULL;

appCenter->acGetObjectHost(security, uuid, host_uuid );

cout << "Out from acGetObjectHost() host_uuid: "<<host_uuid<<endl;

acGetObjectLabel

Syntax

void acGetObjectLabel( in string security, in string uuid, out string label ) raises(Fail);

Description

Given a specific object’s UUID, this instruction gets the label name of the object.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

host_uuid string The UUID of the host object.

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

a c G e t O b j e c t S t a t u s

Example

// Get object label Secure_Transfer char* label = NULL;

appCenter->acGetObjectLabel(security, uuid, label ); cout << "Out from acGetObjectLabel() label: "<<label<<endl;

acGetObjectStatus

Syntax

void acGetObjectStatus( in string security, in string uuid, out short status ) raises(Fail);

Description

Given a specific object’s UUID, this instruction gets the current status of that object. The return status is a short integer. The potential values of this integer can be found in the include file db_types.h.

Parameters

Parameters for this operation include

Return value

Return values for this operation include

Example

CORBA::Short status;

appCenter->acGetObjectStatus(security, uuid, status ); cout << "Out from acGetObjectStatus() status: "<<status<<endl;

acGetObjectType

Syntax

void acGetObjectType( in string security, in string uuid, out short type, out short folder ) raises(Fail);

Description

Given a specific object’s UUID, this instruction gets the object type and also whether it is a folder or not.

Parameters

Parameters for this operation include

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

status short Various object statuses.

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

a c G e t P r o p e r t y V a l u e

C O R B A A P I f o r A p p C e n t e r 8-9

Return values

Return values for this operation include

Example

objectPath = "/Configurations/Secure_Transfer/Demeter"; uuid = NULL;

appCenter->acFindObject(security, objectPath, uuid); cout << "Out from acFindObject() uuid: "<<uuid<<endl; CORBA::Short type;

CORBA::Short folder;

appCenter->acGetObjectType(security, uuid, type, folder);

cout << "Out from acGetObjectType() type: "<<type<<" folder: "<<folder<<endl;

acGetPropertyValue

Syntax

void acGetPropertyValue( in string security, in string uuid, in string key, out string value ) raises(Fail);

Description

This gets a property value for a selected object by specifying the property key and the object’s UUID. Property keys can be found in the object’s properties inspector in the viewer by clicking on the Key column box.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

const char *key = "AM_COMMAND"; char* value = NULL;

appCenter->acGetPropertyValue(security, uuid, key, value); cout << "Out from acGetPropertyValue() value: "<<value<<endl;

Return value Type Meaning

type short Refer to include file db_types.h

folder short 0 = The object is not a folder. Any other value means that the object is a folder

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

key string The specific property key to be used.

Return value Type Meaning

a c I d l e

acIdle

Syntax

void acIdle( in string security, in string uuid ) raises(Fail);

Description

This instruction makes the specified object idle.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acIdle(security, uuid);

acIncrement

Syntax

void acIncrement ( in string security, in string uuid ) raises(Fail);

Description

This increases by 1 the number of running objects in a specified object.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acIncrement(security, uuid);

acLogin

Syntax

void acLogin( in string name, in string password, out string security ) raises(Fail);

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

None

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

a c L o g o u t

C O R B A A P I f o r A p p C e n t e r 8-11

Description

This is the instruction to login to AppCenter. This operation must be called

before using any of the object operations. You must supply a valid name and password that exists in the AppCenter repository.

Parameters

Parameters for this operation include

Return value

Return values for this operation include

Example

// login to AppCenter

const char *name = "admin"; const char *password = ""; char* security = NULL;

appCenter->acLogin( name, password, security);

cout << "Out from acLogin() security: "<<security<<endl;

acLogout

Syntax

void acLogout(in string security) raises(Fail);

Description

The instruction to logout of AppCenter. You will no longer be able to use any of the object operations once this has been passed.

Parameters

Parameters for this operation include

Return value

Return values for this operation include

Example

// logout of AppCenter

appCenter->acLogout(security);

Parameter Type Description

name string The name that the user employs to log in. password string The recognized password for that user.

Return value Type Meaning

security string This string represents a simple form of user authentication. This string must be used with all other object routines.

Parameter Type Description

security string This string represents a simple form of user authentication.

Return value Type Meaning

a c S e t P r o p e r t y V a l u e

acSetPropertyValue

Syntax

void acSetPropertyValue( in string security, in string uuid, in string key, in string value ) raises(Fail);

Description

This sets the value of a specific property on a specific object according to your instructions. Even if the property is an integer, you still pass in a string value and the routine will take a copy of this value string.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acSetPropertyValue(security, uuid, key, value);

acStart

Syntax

void acStart( in string security, in string uuid ) raises(Fail);

Description

This instruction starts the specified object.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

key string The specific property key to be used. value string The new value of the specified property.

Return value Type Meaning

None

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

a c S t o p

C O R B A A P I f o r A p p C e n t e r 8-13

Example

// get uuid of Secure_Transfer object

const char *objectPath = "/Configurations/Secure_Transfer"; char* uuid = NULL;

appCenter->acFindObject(security, objectPath, uuid); cout << "Out from acFindObject() uuid: "<<uuid<<endl; // start Secure_Transfer object

appCenter->acStart(security, uuid);

acStop

Syntax

void acStop( in string security, in string uuid ) raises(Fail);

Description

This instruction stops the specified object.

Parameters

Parameters for this operation include

Return values

Return values for this operation include

Example

appCenter->acStop(security, uuid);

Example of API usage

The following illustrates a sample invocation to some operations from client program. This test_client program can be found in the directory AppCenter/ DevKit/Corba.

// test_client.cpp #include <fstream.h> #include "appCenter_c.hh"

int main(int argc, char* const* argv) { try {

// Initialize the ORB.

CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // Bind to an appCenter.

AppCenter::AppCenterI_var appCenter = AppCenter::AppCenterI::_bind("AppCenter1");

Parameter Type Description

security string This string represents a simple form of user authentication. uuid string The UUID of the object used.

Return value Type Meaning

H o w t o c o m p i l e t h e t e s t _ c l i e n t . c p p p r o g r a m

// login to AppCenter const char *name = "admin"; const char *password = ""; char* security = NULL;

appCenter->acLogin( name, password, security);

cout << "Out from acLogin() security: "<<security<<endl; // get uuid of Secure_Transfer object

const char *objectPath = "/Configurations/Secure_Transfer"; char* uuid = NULL;

appCenter->acFindObject(security, objectPath, uuid); cout << "Out from acFindObject() uuid: "<<uuid<<endl; // start Secure_Transfer object

appCenter->acStart(security, uuid); // Get children

const char *parentUuid = uuid; AppCenter::uuid_list *children = NULL;

appCenter->acGetChildren(security, parentUuid, children ); cout << "Out from acGetChildren() children: "<<children[0]<<endl; AppCenter::uuid_list::_release(children);

// create event for Secure_Transfer object const char *severity = "Major"; const char *transition = "none"; const char *cause = "NOT FOUND";

const char *message = "Ping to Agent failed"; const char *solution = "Start the agent";

appCenter->acCreateEvent(security, uuid, severity, transition, cause,message, solution);

// Get object label Secure_Transfer char* label = NULL;

appCenter->acGetObjectLabel(security, uuid, label ); cout << "Out from acGetObjectLabel() label: "<<label<<endl; } catch(const CORBA::Exception& e) { return(1); } return(0); } Output:

Out from acLogin() security: * Out from acFindObject() uuid: L:……….

Out from acGetChildren() children: 2 L:…….. L:……. Out from acGetObjectLabel() label: Secure_Transfer

This starts Secure_Transfer configuration, creates an event and sends it to the repository that can be viewed at AppCenter Viewer.

In document VisiBroker Configuration Reference (Page 89-100)

Related documents