Resource query examples

From Wikitech
Jump to navigation Jump to search

You can use Semantic MediaWiki's {{#ask}} syntax for inline queries or the Special:Ask query page to obtain information about instances. Some examples of inline queries are below. See Semantic MediaWiki's semantic search docs for additional information.

Basic query

{{#ask:[[Resource Type::instance]]
|?Instance Name
|?Instance Type
|?Image Id
|?Launch Time
|?Puppet Class
|?Modification date
|?Instance Host
|?Number of CPUs
|?RAM Size
|?Amount of Storage
|sort=Modification date

{{#ask:Resource Type::instance |?Instance Name |?Instance Type |?Project |?Image Id |?FQDN |?Launch Time |?Puppet Class |?Modification date |?Instance Host |?Number of CPUs |?RAM Size |?Amount of Storage |format=broadtable |limit=40 |order=DESC |sort=Modification date |offset=0 }}

Query for various host stats

{| class="wikitable sortable" style="width: 100%"
! Host
! Ram
! Storage
! Virtual CPUs
| virt2
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt2]]|?RAM Size|format=sum}}
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt2]]|?Amount of Storage|format=sum}}
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt2]]|?Number of CPUs|format=sum}}
| virt3
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt3]]|?RAM Size|format=sum}}
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt3]]|?Amount of Storage|format=sum}}
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt3]]|?Number of CPUs|format=sum}}
| virt4
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt4]]|?RAM Size|format=sum}}
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt4]]|?Amount of Storage|format=sum}}
| {{#ask:[[Resource Type::instance]]|[[Instance Host::virt4]]|?Number of CPUs|format=sum}}
Host Ram Storage Virtual CPUs
virt2 {{#ask:Resource Type::instance|Instance Host::virt2|?RAM Size|format=sum}} {{#ask:Resource Type::instance|Instance Host::virt2|?Amount of Storage|format=sum}} {{#ask:Resource Type::instance|Instance Host::virt2|?Number of CPUs|format=sum}}
virt3 {{#ask:Resource Type::instance|Instance Host::virt3|?RAM Size|format=sum}} {{#ask:Resource Type::instance|Instance Host::virt3|?Amount of Storage|format=sum}} {{#ask:Resource Type::instance|Instance Host::virt3|?Number of CPUs|format=sum}}
virt4 {{#ask:Resource Type::instance|Instance Host::virt4|?RAM Size|format=sum}} {{#ask:Resource Type::instance|Instance Host::virt4|?Amount of Storage|format=sum}} {{#ask:Resource Type::instance|Instance Host::virt4|?Number of CPUs|format=sum}}

Query for instance types, and return json format for system scripting

{{#ask:[[Resource Type::instance]][[Puppet Class::memcached]]

{{#ask:Resource Type::instancePuppet Class::memcached |?FQDN |format=json }}