Skip to content

Instantly share code, notes, and snippets.

@sergiopena
Forked from enricruiz/api.md
Last active December 17, 2015 19:49
Show Gist options
  • Save sergiopena/5663438 to your computer and use it in GitHub Desktop.
Save sergiopena/5663438 to your computer and use it in GitHub Desktop.

VSM Rest API ( >= v2.2)

Take care to build the hypervisor address as follows (last '/' is mandatory):

http://#{ip}:#{port}/

Hypervisor types are:

  • VMX_04
  • XENSERVER
  • XEN_3
  • HYPERV_301
  • KVM
  • VBOX

Monitor physical machine

curl --verbose -H "Content-type:application/xml" -H "Accept:application/xml" "http://localhost:8888/vsm/monitors" -X POST -d @monitor.xml

Request DTO

<monitor>
    <id></id>
    <address>#{HypervisorURL}</address>
    <type>#{HypervisorType}</type>
</monitor>

Response DTO

<monitor>
    <id>#{id}</id>
    <address>#{HypervisorURL}</address>
    <type>#{HypervisorType}</type>
</monitor>

Unmonitor physical machine

curl --verbose "http://localhost:8888/vsm/monitors/1" -X DELETE

Request URI

http://localhost:8888/vsm/monitors/#{id}

Subscribe virtual machine

curl --verbose -H "Content-type:application/xml" -H "Accept:application/xml" "http://localhost:8888/vsm/subscriptions" -X POST -d @subscribe.xml

Request DTO

<subscription>
    <id></id>
    <uuid>#{name}</uuid>
    <notified>UNKNOWN</notified>
    <monitor>
        <id>#{id}</id>
        <address>#{HypervisorURL}</address>
        <type>#{HypervisorType}</type>
    </monitor>
</subscription>

Response DTO

<subscription>
    <id>#{id_vm}</id>
    <uuid>#{name}</uuid>
    <notified>#{state}</notified>
    <monitor>
        <id>#{id}</id>
        <address>#{HypervisorURL}</address>
        <type>#{HypervisorType}</type>
    </monitor>
</subscription>

Unsubscribe virtual machine

curl --verbose "http://localhost:8888/vsm/subscriptions/1" -X DELETE

Request URI

http://localhost:8888/vsm/subscriptions/#{vm_id}

Invalidate last virtual machine known state

 curl --verbose -X PUT -d @update.xml -H "Content-type:application/xml" "http://localhost/vsm/subscriptions/{subscription_id}"

Republish virtual machine state

 curl --verbose -X PUT -d @update.xml -H "Content-type:application/xml" "http://localhost/vsm/subscriptions/{subscription_id}"

Retrieve all subscriptions

curl --verbose -H "Accept:application/xml" "http://localhost:8888/vsm/subscriptions" -X GET

Retrieve subscription by virtual machine name

curl --verbose -H "Accept:application/xml" -X GET "http://localhost:8888/vsm/subscriptions?uuid=ABQ_1b0e7092-1fea-43fe-bb07-41b20f0bd567" 

Request URI

http://localhost:8888/vsm/api/subscriptions?uuid=#{name}
<monitor>
<id></id>
<address>http://10.60.1.120:443/</address>
<type>VMX_04</type>
</monitor>
<subscription>
<id></id>
<uuid>ABQ_1b0e7092-1fea-43fe-bb07-41b20f0bd567</uuid>
<notified>UNKNOWN</notified>
<monitor>
<id>1</id>
<type>VMX_04</type>
<address>http://10.60.1.120:443/</address>
</monitor>
</subscription>
SubscriptionUpdateType = [RESET, REFRESH, CHECK_EXISTENCE_AND_REFRESH]
/** Set the subscription last known state to {@link VMEventType#UNKNOWN} */
RESET,
/** Set the subscription last known state to {@link VMEventType#UNKNOWN} and refresh it */
REFRESH,
/**
* Set the subscription last known state to {@link VMEventType#UNKNOWN} and refresh it if the
* virtual machine exist in the hypervisor. If not exists a {@link VMEventType#DESTROYED} is
* notified.
*/
CHECK_EXISTENCE_AND_REFRESH;
<update>
<updateType>{SubscriptionUpdateType}</updateType>
</update>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment