2 * host_type.c: Utilities for Virtualized Super Computer Management
4 * Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * Parses a host type from its string representation and returns it.
33 vsc_mgmt_host_type_parse (struct VscMgmtError *error,
34 const char *host_type_string)
36 VSC_MGMT__ASSERT (error != NULL);
37 VSC_MGMT__ASSERT (! error->occured);
39 if (strcasecmp (host_type_string, "Xen") == 0) {
40 return VSC_MGMT__HOST_TYPE__XEN;
41 } else if (strcasecmp (host_type_string, "ESX") == 0) {
42 return VSC_MGMT__HOST_TYPE__ESX;
43 } else if (strcasecmp (host_type_string, "KVM") == 0) {
44 return VSC_MGMT__HOST_TYPE__KVM;
47 VSC_MGMT__ERROR2 (error, VSC_MGMT__CODE__INVALID_HOST_TYPE_STRING, "'%s'",
50 return VSC_MGMT__HOST_TYPE__UNDEFINED;
54 * Returns the string representaion of the given host type.
56 * The string must not be freed by the caller.
59 vsc_mgmt_host_type_string (enum VscMgmtHostType host_type)
62 case VSC_MGMT__HOST_TYPE__XEN:
65 case VSC_MGMT__HOST_TYPE__ESX:
68 case VSC_MGMT__HOST_TYPE__KVM: