APIs SDKs and Xen-ng
-
I can tell you can create VMs, that I'm sure But @julien-f will provide some details ASAP
-
This is handled by using
create_vm
, which is a pool action. There's an example in this blog post. -
@Danp yes i succeeded to create a vm
curl -k -b authenticationToken=<key> -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"name_label":"areni","template":"11fd3dc9-96cc-49af-b091-a2ca7e94c589"}' https://<ip>/rest/v0/pools/dd74abdd-7dd9-e95b-a241-dbd5b12b3ae1/actions/create_vm
basically this is working, then start to check create network
https://<ip>/rest/v0/networks/_/actions return empty array or under pool no network related action .
I would like to create vlan under bond interface mean Add Network or SDN , How could you support these ?
VM
-
@vahric-0 I don't believe that functionality exists yet for the newer REST API.
-
@Danp Okay, don't worry then without rest api , how could i automate this ? How XO doing it and how can i say to XO do it for out of REST ? @olivierlambert @julien-f
-
@vahric-0 See @julien-f response here -- https://xcp-ng.org/forum/post/75050
Once you know the JSON-RPC API syntax, then you should be able to automate it using
xo-cli
. -
I used the ?debug and from console i got the json call , thats okay.
Using @mbaron script , i get the methods and try to create network and looks like i could. Thank you very much
import json import aiohttp import asyncio from jsonrpc_websocket import Server async def routine(): async with aiohttp.ClientSession() as client: server = Server('ws://XO ip address/api/', client) await server.ws_connect() # No signIn required methodsInfoResult = await server.system.getMethodsInfo() print('\n'.join([str(e) for e in methodsInfoResult.keys()])) # signIn required result = await server.session.signIn(username='username', password='password') # email attribute is working in place of username result = await server.network.create (pif='8369d867-a6f8-61f2-8132-3b485c3b3a63',pool='dd74abdd-7dd9-e95b-a241-dbd5b12b3ae1',name='deneme3',vlan=2346) print('[') print(', \n'.join([str(json.dumps(e, indent=4)) for e in result.values()])) print(']') asyncio.get_event_loop().run_until_complete(routine()) result = await server.network.create (pif='8369d867-a6f8-61f2-8132-3b485c3b3a63',pool='dd74abdd-7dd9-e95b-a241-dbd5b12b3ae1',name='deneme3',vlan=2346)
I guess its will be perfect to move everything rest api and have well documentation.
One thing, i can not delete created test network because of HA, is it normal ?
Regards
VM -
@vahric-0 said in APIs SDKs and Xen-ng:
One thing, i can not delete created test network because of HA, is it normal ?
IDK. What error did you receive?
-
@Danp I was getting error like below but right now i can delete it ? How it could happen ?
network.delete { "network": "7d1cd2b9-15a3-6aa5-20bf-ac22e8ad362f" } { "code": "HA_IS_ENABLED", "params": [], "task": { "uuid": "f8c23f0a-7525-c5b7-07e3-923d431acccc", "name_label": "Async.VLAN.destroy", "name_description": "", "allowed_operations": [], "current_operations": {}, "created": "20240521T08:40:24Z", "finished": "20240521T08:40:24Z", "status": "failure", "resident_on": "OpaqueRef:c790d455-3678-4ae0-a02f-40a16bb0f394", "progress": 1, "type": "<none/>", "result": "", "error_info": [ "HA_IS_ENABLED" ], "other_config": {}, "subtask_of": "OpaqueRef:NULL", "subtasks": [], "backtrace": "(((process xapi)(filename ocaml/xapi/rbac.ml)(line 205))((process xapi)(filename ocaml/xapi/server_helpers.ml)(line 95)))" }, "message": "HA_IS_ENABLED()", "name": "XapiError", "stack": "XapiError: HA_IS_ENABLED() at Function.wrap (file:///usr/local/lib/node_modules/xo-server/node_modules/xen-api/_XapiError.mjs:16:12) at default (file:///usr/local/lib/node_modules/xo-server/node_modules/xen-api/_getTaskResult.mjs:11:29) at Xapi._addRecordToCache (file:///usr/local/lib/node_modules/xo-server/node_modules/xen-api/index.mjs:1029:24) at file:///usr/local/lib/node_modules/xo-server/node_modules/xen-api/index.mjs:1063:14 at Array.forEach (<anonymous>) at Xapi._processEvents (file:///usr/local/lib/node_modules/xo-server/node_modules/xen-api/index.mjs:1053:12) at Xapi._watchEvents (file:///usr/local/lib/node_modules/xo-server/node_modules/xen-api/index.mjs:1226:14)" }
-
@vahric-0 You're saying that it worked in one instance but failed in a prior attempt? Did something change in the environment in between the attempts? Was the vlan in use by any VMs?
-
@Danp No, vlans was created only for test no any vm is attached
XO should not say to me this is used , you can not delete it ?
why its generating HA_IS_ENABLED message ? -
@vahric-0 Sorry, but I'm not sure that I understand your setup. Perhaps it would help if you restated the issue making sure to address the following items --
- Is HA enabled on your pool?
- Are you able to delete the VLAN using XOA web interface?
- Are you able to delete the VLAN using XOA API?
- etc
-
HA is enabled for the pool
After first creation network via api , i can not deleye it from gui
i did not tried delete vlan via apiI will try to reproduce
-
yeap , i did it again
-
-
@vahric-0 It is recommended to disable HA whenever you are performing maintenance (adjusting networking, applying updates, etc) on your pool.
-
@Danp if this is the rule , what i can say.
I will try one thing more because to create xostore step by step I shutdown servers and add disks after that i could delete the network -
@vahric-0 I didn't understand what you were trying to say above. Are you unable to temporarily disable HA to perform maintenance?
-
@Danp No of course i can disable it , okay i will not struggle with it
After disable HA , i could delete it , thanks