VMware {code} Community
nehaparmar
Contributor
Contributor
Jump to solution

Plugin Development

I am trying to develop a plugin for orchestrator using sdk. I am stuck
with event handling and policies. Can you please elaborate on these two
topics? Also, i want to use api of vcenter server into the plugin that i
am developing. Can you please tell me what steps need to be followed to complete this task?

1 Solution

Accepted Solutions
sanchezs
VMware Employee
VMware Employee
Jump to solution

Hi Neha,

I'm not sure I completely understood your use case. You want to use the VI SDK API from your plug-in, but do you want to use it internally within your plug-in Java code or you want to use it from your plug-in scripting code and workflows??

If it's for Java internal use, the plug-in behaves as any other Java application and you just need to configure and use the corresponding libraries (from the VI SDK API) at build time, and to make sure that when the plug-in's DAR file is created, those libraries and their dependencies are included within the lib directory of the DAR file.

If you want to expose elements of that VI SDK API as part of your plug-in API inside vCO, then you need to define as scripting objects inside your plug-in vso.xml file the types that you want to use from that VI SDK API. And to make sure that the required libraries as added to the DAR file as before.

But keep in mind that vCO provides already a vCenter plug-in that you can use directly (its workflows, actions and scripting objects) from your own workflows and actions.

Regards,

Sergio

View solution in original post

Reply
0 Kudos
11 Replies
igorstoyanov
VMware Employee
VMware Employee
Jump to solution

Hi,

>Also, i want to use api of vcenter server into the plugin that i am developing.

I am not sure about what APIs of vcenter server you are talking about. In case, you are asking the APIs exposed via vCO vCenter Plug-in, then you are not able to use them in the plug-in from the java side. Only within the javascript context. You can access other plug-ins scripting api only withing the scripting.

>I am stuck with event handling and policies.

Could you please specify a bit more what are the issues.

Thanks.

Visit http://blogs.vmware.com/orchestrator for the latest in Cloud Orchestration.
nehaparmar
Contributor
Contributor
Jump to solution

Hi,

    Thanks for replying to the question regarding using vcenter server api. Actually, i want to develop a sample application to demonstrate use of events and policies for plugin. Following are the details  : There is a file Person.java which is base file. Then two files Employee.java and Student.java which have their own attributes and methods. For event, i have salarychanged as one of my event in Employee file. But, when i go through solarsystem sample project, they have mentioned event called as generateflareevent on star object and added some policy element in EventGenerator file. I am actually not able to clearly understand as to what is a policy and event ?

Reply
0 Kudos
sanchezs
VMware Employee
VMware Employee
Jump to solution

Hi,

Policies and Events are related in vCO but they are not the same. You could see the Policies as rules that you can define in vCO for example to run specific workflows when some specific conditions are accomplished. And the Events, in that case, would be the elements that may activate those rules.

For example, within the domain of employees and so, one rule could say that "the company should pay the salary to all the employees on 1st of every month". Then you could create a Policy in vCO configured to be started on 1st of every month and that should run a workflow called "Transfer the salaries". In that case the Event that triggers the Policy is a time-based event, and vCO is able to handle it automatically and the plug-in doesn't have to do anything else.

Also, another rule could say "when the company' stocks pass the value X then increase the salary to all the employees by 1% (and update X)". And you have implemented a StockMarketMonitor that every morning retrieves the real value of the stocks. Then you could create a Policy configured to be activated (and to run the corresponding workflow) every time when the value retrieved by the StockMarketMonitor is higher than the value X. Rules like that are based on Gauges and the Solar System plug-in contains the example of the Flare Events. The only difference is that in the Solar System those events are generated manually (with the “Generate Flare Event” workflow) and in the employees’ example they would be generated by a background process.

And, another rule could say "when the company's CEO sends an email to sharebenefits@coolcompany.com then calculate and pay an extra month salary to all employees". And you have implemented a CEOMailChecker that periodically checks the email account and sends a notification in case of receiving the CEO's email. Then you could create a Policy configured to be triggered (and to run the corresponding workflow) every time when the CEOMailChecker notifies vCO that the email has been received. Rules like that are based on Triggers and the Solar System plug-in doesn't provide a direct example but you can imagine it as a Policy based on Flare Events where you don't care about the flare’s magnitude but you want to react to all the flares.

For those last two situations with Gauges and Triggers you may have to implement within your plug-in a secondary process that monitors the external system responsible to produce the Events which you are interested in (e.g. the StockMarketMonitor or the CEOMailChecker). Then you can notify those Events to the Policies configured in vCO through the IPluginEventPublisher interface, with the methods pushGauge(...) or pushTrigger(...) depending on the type of Policy you are using.

And that's more or less the relationship between Policies and Events. I hope it helps.

Sergio

nehaparmar
Contributor
Contributor
Jump to solution

Hi,

    Thanks for the reply. I want to use VI SDK API in plugin that i am developing. For example, list out all the VM's. I tried to embed the code of VI SDK API in the plugin SDK(orchestrator) bt the method in which i have written my code for VI SDK API, does not appear in the API Explorer of Orchestrator client. If i remove the code of VI SDK,than the method appears in Orchestrator client. I have included both the jars required for VI SDK in the plugin project, as well as set the SDKHOME parameter. The code for VI SDK works fine independently. Can you please tell me what needs to be done??

-Thanks

Neha.

Reply
0 Kudos
sanchezs
VMware Employee
VMware Employee
Jump to solution

Hi Neha,

I'm not sure I completely understood your use case. You want to use the VI SDK API from your plug-in, but do you want to use it internally within your plug-in Java code or you want to use it from your plug-in scripting code and workflows??

If it's for Java internal use, the plug-in behaves as any other Java application and you just need to configure and use the corresponding libraries (from the VI SDK API) at build time, and to make sure that when the plug-in's DAR file is created, those libraries and their dependencies are included within the lib directory of the DAR file.

If you want to expose elements of that VI SDK API as part of your plug-in API inside vCO, then you need to define as scripting objects inside your plug-in vso.xml file the types that you want to use from that VI SDK API. And to make sure that the required libraries as added to the DAR file as before.

But keep in mind that vCO provides already a vCenter plug-in that you can use directly (its workflows, actions and scripting objects) from your own workflows and actions.

Regards,

Sergio

Reply
0 Kudos
nehaparmar
Contributor
Contributor
Jump to solution

Hi Sergio,

        Thanks alot. It worked. I have two more queries regarding the plugin installation and uninstallation.

1. Installing plugin

     Everytime you update a plugin you have to install the dar file in the orchestrator configuration interface,than restart the server and than you can use the plugin. Is there any other way using which i can install the updated dar file directly?? In maven-build.properties,there is a property deploy.dar. I set that property to true,bt it didnt work. Restarting server each time after plugin installation consumes more time. Can you throw some light on this??

2.Uninstaling plugin

    When you want uninstall a plugin from orhcestrator,you have to manually delete the file from the vmware folder on disk. Is there any other way to uninstall the plugin through orchestrator UI??

Thanks,

Neha.

Reply
0 Kudos
nehaparmar
Contributor
Contributor
Jump to solution

Hi,

      While developing workflows, i am going to list all the vm's as output in orchestrator using VI SDK API code in plugin. Now,i want user to select one vm out of the listed vm's for which he wants to get details of that particular vm. I am stuck as to how can i get that value from client and pass it to plugin method again,which will implement the function for getting details of the vm using VI SDK API. Any solution to this??

-Neha.

Reply
0 Kudos
sanchezs
VMware Employee
VMware Employee
Jump to solution

Hi Neha,

About plug-in installation:

Yes, during the development process you can avoid using the Web Configurator to reinstall your plug-in. You can directly stop the vCO server, overwrite the DAR file of your plug-in and start the vCO server again. You can avoid the Web Configurator but so far you can't avoid restarting the vCO server.

About plug-in uninstallation:

Yes again, you have to delete the plug-in's DAR file manually and restart the vCO server, so far it's not possible to uninstall the plug-in from the Web Configurator. Also, if your plug-in has a web configuration part which appears on the Web Configurator, then you need to manually delete the WAR file (${your_vco_installation}\configuration\jetty\webapps\your_plugin_file.war) and the context XML file (${your_vco_installation}\configuration\jetty\contexts\your_plugin_file.xml) as well to completely remove the plug-in. If you just update the plug-in (overwriting the DAR file), those files are updated automatically.

About passing objects from the client to the plug-in:

The idea is that you create a class in Java that wraps the kind of objects you want to expose, like VM. Then you expose that class within the vso.xml and vCO will handle automatically the conversion of your object from the scripting blocks to the Java side and in opposite. But remember to implement together with your class, the logic inside your PluginFactory to be able to find objects of that type inside your plug-in (the find and findAll methods, and the hasChildrenInRelation and findRelation methods if you need them as well).

Regards,

Sergio

Reply
0 Kudos
nehaparmar
Contributor
Contributor
Jump to solution

Hi Sergio,

        Thanks alot. Actually, i am currently trying to understand the workflow part. I want user to select one vm out of the list of vm's that are listed and displayed in the log. What i understood so far is, that i can use user interaction box avaliable to take the input. Is ther any other way of doing this???

        Also, once i get the name of the vm the user is interested in,how do i pass that name to the java class which implements the function to find network configuration for that particular vm??

Thanks,

Neha.

Reply
0 Kudos
nehaparmar
Contributor
Contributor
Jump to solution

Hi,

    I went through all the methods of factory class. For plugin that i am developing, i think i should use find, find all or findbytype method to list all the vm's and find a particular vm. But, where do i exactly write the code for connecting using serverinstance for VISDK?? Should it be included in a seprate file? Please guide me through this.

Thanks,

Neha.

Reply
0 Kudos
nehaparmar
Contributor
Contributor
Jump to solution

Hi,

       I want to find out network configuration of the selected virtual  machine out of list of VM's using sdk api in java. I tried using the  guestinfo object. But, it returns NULL everytime. moreover,  vm.getguest() returns "com.vmware.vim25.GuestInfo@64f6cd". Please guide me through this.

Thanks,

Neha.

Reply
0 Kudos