1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-10-29 16:25:07 +03:00

admin: Add URI support and introduce virAdmGetDefaultURI

Since virt-admin should be able to connect to various admin servers
on hosted different daemons, we need to provide URI support to
libvirt-admin.
This commit is contained in:
Erik Skultety
2015-10-12 16:07:52 +02:00
parent 0ecf9b3e09
commit dbecb87f94
7 changed files with 142 additions and 33 deletions

View File

@@ -113,6 +113,39 @@ vshAdmReconnect(vshControl *ctl)
priv->wantReconnect = false;
}
/*
* 'uri' command
*/
static const vshCmdInfo info_uri[] = {
{.name = "help",
.data = N_("print the admin server URI")
},
{.name = "desc",
.data = ""
},
{.name = NULL}
};
static bool
cmdURI(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *uri;
vshAdmControlPtr priv = ctl->privData;
uri = virAdmConnectGetURI(priv->conn);
if (!uri) {
vshError(ctl, "%s", _("failed to get URI"));
return false;
}
vshPrint(ctl, "%s\n", uri);
VIR_FREE(uri);
return true;
}
/* ---------------
* Command Connect
* ---------------
@@ -425,6 +458,12 @@ static const vshCmdDef vshAdmCmds[] = {
VSH_CMD_HELP,
VSH_CMD_PWD,
VSH_CMD_QUIT,
{.name = "uri",
.handler = cmdURI,
.opts = NULL,
.info = info_uri,
.flags = 0
},
{.name = "connect",
.handler = cmdConnect,
.opts = opts_connect,