Skip to content

Instantly share code, notes, and snippets.

@enricruiz
Created December 15, 2011 15:54
Show Gist options
  • Save enricruiz/1481595 to your computer and use it in GitHub Desktop.
Save enricruiz/1481595 to your computer and use it in GitHub Desktop.
VSM API cheatsheet ( < v2.2)

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/api/physicalmachines" -u root:temporal -X POST -d @monitor.xml

Request DTO

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

Response DTO

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

Unmonitor physical machine

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

Request URI

http://localhost:8888/vsm/api/physicalmachines/#{id}

Subscribe virtual machine

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

Request DTO

<virtualmachine>
    <id></id>
    <name>#{name}</name>
    <lastKnownState>UNKNOWN</lastKnownState>
    <physicalMachine>
        <id>#{id}</id>
        <address>#{HypervisorURL}</address>
        <type>#{HypervisorType}</type>
    </physicalMachine>
</virtualmachine>

Response DTO

<virtualmachine>
    <id>#{id_vm}</id>
    <name>#{name}</name>
    <lastKnownState>#{state}</lastKnownState>
    <physicalMachine>
        <id>#{id}</id>
        <address>#{HypervisorURL}</address>
        <type>#{HypervisorType}</type>
    </physicalMachine>
</virtualmachine>

Unsubscribe virtual machine

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

Request URI

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

Invalidate last virtual machine known state (v2.0)

curl --verbose -H "Accept:application/xml" "http://localhost:8888/vsm/api/physicalmachines/1/virtualmachine/ABQ_1b0e7092-1fea-43fe-bb07-41b20f0bd567" -X DELETE

Request URI

http://localhost:8888/vsm/api/physicalmachines/#{id}/virtualmachines/#{name}

Republish virtual machine state

curl --verbose -H "Accept:application/xml" "http://localhost:8888/vsm/api/physicalmachines/1/virtualmachine/ABQ_1b0e7092-1fea-43fe-bb07-41b20f0bd567" -X GET

Request URI

http://localhost:8888/vsm/api/physicalmachines/#{id}/virtualmachines/#{name}

Retrieve all subscriptions

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

Retrieve subscription by virtual machine name

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

Request URI

http://localhost:8888/vsm/api/subscriptions?virtualmachine=#{name}
<physicalmachine>
<id></id>
<address>http://10.60.1.120:443/</address>
<type>VMX_04</type>
</physicalmachine>
<virtualmachine>
<id></id>
<name>ABQ_1b0e7092-1fea-43fe-bb07-41b20f0bd567</name>
<lastKnownState>UNKNOWN</lastKnownState>
<physicalMachine>
<id>1</id>
<type>VMX_04</type>
<address>http://10.60.1.120:443/</address>
</physicalMachine>
</virtualmachine>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment