提交 1331e291 编写于 作者: P Pino Toscano

esx: split virtualswitchToNetwork helper

Move the creation of a virNetworkPtr object from the
esxVI_HostVirtualSwitch object of a virtual switch out of
esxNetworkLookupByName in an own helper. This way it can be used also
in other functions.
Signed-off-by: NPino Toscano <ptoscano@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 1652ce66
......@@ -167,20 +167,11 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
static virNetworkPtr
esxNetworkLookupByName(virConnectPtr conn, const char *name)
virtualswitchToNetwork(virConnectPtr conn,
esxVI_HostVirtualSwitch *hostVirtualSwitch)
{
virNetworkPtr network = NULL;
esxPrivate *priv = conn->privateData;
esxVI_HostVirtualSwitch *hostVirtualSwitch = NULL;
unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; /* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchByName(priv->primary, name,
&hostVirtualSwitch,
esxVI_Occurrence_RequiredItem) < 0) {
return NULL;
}
/*
* HostVirtualSwitch doesn't have a UUID, but we can use the key property
* as source for a UUID. The key is unique per host and cannot change
......@@ -192,7 +183,26 @@ esxNetworkLookupByName(virConnectPtr conn, const char *name)
if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) < 0)
return NULL;
network = virGetNetwork(conn, hostVirtualSwitch->name, md5);
return virGetNetwork(conn, hostVirtualSwitch->name, md5);
}
static virNetworkPtr
esxNetworkLookupByName(virConnectPtr conn, const char *name)
{
virNetworkPtr network = NULL;
esxPrivate *priv = conn->privateData;
esxVI_HostVirtualSwitch *hostVirtualSwitch = NULL;
if (esxVI_EnsureSession(priv->primary) < 0 ||
esxVI_LookupHostVirtualSwitchByName(priv->primary, name,
&hostVirtualSwitch,
esxVI_Occurrence_RequiredItem) < 0) {
return NULL;
}
network = virtualswitchToNetwork(conn, hostVirtualSwitch);
esxVI_HostVirtualSwitch_Free(&hostVirtualSwitch);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册