Project

General

Profile

Not able to create new VHOST using Adhoc command REST api

Mohd Rashid Rashidee
Added almost 4 years ago

Hi,

I am trying to create a new VHOST using the Adhoc REST API but so far failed to do so. However I managed to create new VHOST using PSI (calling the vhost-man)

Tigase-Server Version: 7.1.0-SNAPSHOT

Tigase-Http Version: 1.10

FYI - I am using the "comp-repo-item-add" instead of "VHOST-UPDATE" command (somehow VHOST-UPDATE request just hanged without any response)

API Endpoint:

http://{{hostname}}:{{port}}/rest/adhoc/vhost-man@localhost

Body (content type: application/json

{
  "command": {
    "node": "comp-repo-item-add",
    "fields": [
      {
        "var": "hostname",
        "value": "rest.local"
      },
      {
        "var": "enabled",
        "value": "0"
      },
      {
        "var": "administrators",
        "value": "admin@rest.local"
      },
      {
        "var": "owner",
        "value": "admin@workchat.local"
      }
    ]
  }
}

tigase.log.0 output

2015-02-24 01:48:36.994 [in_2-message-router]  MessageRouter.processPacket()  FINEST:   Processing packet: from=http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338, to=null, DATA=<iq from="admin@localhost" to="vhost-man@localhost" type="set" id="4bcbb491-2e1a-4fbf-adb8-b1c86badcf4a"><command node="comp-repo-item-add" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field var="hostname"><value>rest.local</value></field><field var="enabled"><value>0</value></field><field var="administrators"><value>admin@rest.local</value></field><field var="owner"><value>admin@workchat.local</value></field></x></command></iq>, SIZE=471, XMLNS=null, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=set
2015-02-24 01:48:37.001 [in_2-message-router]  MessageRouter.getLocalComponent()  FINEST: Called for : vhost-man@localhost
2015-02-24 01:48:37.001 [in_2-message-router]  MessageRouter.getLocalComponent()  FINEST: Called for : vhost-man@localhost
2015-02-24 01:48:37.002 [in_2-message-router]  MessageRouter.processPacket()  FINEST:   1. Packet will be processed by: vhost-man@localhost, from=http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338, to=null, DATA=<iq from="admin@localhost" to="vhost-man@localhost" type="set" id="4bcbb491-2e1a-4fbf-adb8-b1c86badcf4a"><command node="comp-repo-item-add" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field var="hostname"><value>rest.local</value></field><field var="enabled"><value>0</value></field><field var="administrators"><value>admin@rest.local</value></field><field var="owner"><value>admin@workchat.local</value></field></x></command></iq>, SIZE=471, XMLNS=null, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=set
2015-02-24 01:48:37.003 [in_2-message-router]  BasicComponent.processScriptCommand()  FINER: Processing admin command: from=http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338, to=null, DATA=<iq from="admin@localhost" to="vhost-man@localhost" type="set" id="4bcbb491-2e1a-4fbf-adb8-b1c86badcf4a"><command node="comp-repo-item-add" xmlns="http://jabber.org/protocol/commands"><x xmlns="jabber:x:data" type="submit"><field var="hostname"><value>rest.local</value></field><field var="enabled"><value>0</value></field><field var="administrators"><value>admin@rest.local</value></field><field var="owner"><value>admin@workchat.local</value></field></x></command></iq>, SIZE=471, XMLNS=null, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=set
2015-02-24 01:48:37.021 [in_14-message-router]  MessageRouter.processPacket()  FINEST:  Processing packet: from=vhost-man@localhost, to=http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338, DATA=<iq from="vhost-man@localhost" to="admin@localhost" type="result" id="4bcbb491-2e1a-4fbf-adb8-b1c86badcf4a"><command node="comp-repo-item-add" xmlns="http://jabber.org/protocol/commands" status="executing"><x xmlns="jabber:x:data" type="form"><field var="Domain name"><value/></field><field type="boolean" var="Enabled"><value>true</value></field><field type="boolean" var="Anonymous enabled"><value>true</value></field><field type="boolean" var="In-band registration"><value>true</value></field><field type="boolean" var="TLS required"><value>false</value></field><field var="S2S secret"><value>d7bc67bc-40b2-4076-8aaf-767a0f06c2f6</value></field><field type="list-single" var="Domain filter policy" label="Domain filter policy"><value>ALL</value><option label="ALL"><value>ALL</value></option><option label="LOCAL"><value>LOCAL</value></option><option label="OWN"><value>OWN</value></option><option label="LIST"><value>LIST</value></option><option label="BLACKLIST"><value>BLACKLIST</value></option><option label="BLOCK">< ... , SIZE=1700, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=result
2015-02-24 01:48:37.025 [in_14-message-router]  MessageRouter.getLocalComponent()  FINEST: Called for : admin@localhost
2015-02-24 01:48:37.025 [in_14-message-router]  MessageRouter.getLocalComponent()  FINEST: No componentID matches (fast lookup against exact address): admin@localhost, for map: [monitor@localhost, bosh@localhost, c2s@localhost, sess-man@localhost, http@localhost, vhost-man@localhost, amp@localhost, s2s@localhost, ws2s@localhost, stats@localhost, basic-conf@localhost]; trying VHost lookup
2015-02-24 01:48:37.026 [in_14-message-router]  MessageRouter.getLocalComponent()  FINEST: No component name matches (VHost lookup against component name): admin@localhost, for map: [c2s, basic-conf, s2s, bosh, vhost-man, sess-man, ws2s, message-router, stats, amp, monitor, http], for all VHosts: [localhost, workchat.local]; trying other forms of addressing
2015-02-24 01:48:37.027 [in_14-message-router]  MessageRouter.getLocalComponent()  FINEST: Called for : http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338
2015-02-24 01:48:37.027 [in_14-message-router]  MessageRouter.getLocalComponent()  FINEST: No componentID matches (fast lookup against exact address): http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338, for map: [monitor@localhost, bosh@localhost, c2s@localhost, sess-man@localhost, http@localhost, vhost-man@localhost, amp@localhost, s2s@localhost, ws2s@localhost, stats@localhost, basic-conf@localhost]; trying VHost lookup
2015-02-24 01:48:37.028 [in_14-message-router]  MessageRouter.processPacket()  FINEST:  1. Packet will be processed by: http@localhost, from=vhost-man@localhost, to=http@localhost/19fe65a8-5150-4e03-a249-84bf9ed15338, DATA=<iq from="vhost-man@localhost" to="admin@localhost" type="result" id="4bcbb491-2e1a-4fbf-adb8-b1c86badcf4a"><command node="comp-repo-item-add" xmlns="http://jabber.org/protocol/commands" status="executing"><x xmlns="jabber:x:data" type="form"><field var="Domain name"><value/></field><field type="boolean" var="Enabled"><value>true</value></field><field type="boolean" var="Anonymous enabled"><value>true</value></field><field type="boolean" var="In-band registration"><value>true</value></field><field type="boolean" var="TLS required"><value>false</value></field><field var="S2S secret"><value>d7bc67bc-40b2-4076-8aaf-767a0f06c2f6</value></field><field type="list-single" var="Domain filter policy" label="Domain filter policy"><value>ALL</value><option label="ALL"><value>ALL</value></option><option label="LOCAL"><value>LOCAL</value></option><option label="OWN"><value>OWN</value></option><option label="LIST"><value>LIST</value></option><option label="BLACKLIST"><value>BLACKLIST</value></option><option label="BLOCK">< ... , SIZE=1700, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=result

Thanks in advance


Replies (2)

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

Two issues:

  • the variable is Domain name@, not @hostname

  • you were missing command-marker filed.

This works:

{
  "command": {
    "node": "comp-repo-item-add",
    "fields": [
      {
        "var": "Domain name",
        "value": "rest.locals" 
      },
      {
        "var": "enabled",
        "value": "0" 
      },
      {
        "var": "administrators",
        "value": "admin@rest.local" 
      },
      {
        "var": "owner",
        "value": "admin@workchat.local" 
      },
      {
        "var": "command-marker",
        "value": "command-marker"
      }
    ]
  }
}

Added by Mohd Rashid Rashidee almost 4 years ago

Hey, thank you very much. It worked!

    (1-2/2)