os-cmpi-xen

changeset 92:66600aae1e53

Added support for receiving type CIMInstance for EmbeddedInstance method parameters.
OpenWBEM and sfcb cimoms now support providing CIMInstances - i.e. the cimoms
handle parsing the embedded instances. Support for parsing MOF-encoded string
remains for the time.

Signed-off-by: Jim Fehlig
author Jim Fehlig <jfehlig@novell.com>
date Fri Mar 09 16:52:35 2007 -0700 (2007-03-09)
parents 315d491aec5f
children 44127f60b2da
files ChangeLog src/Xen_VirtualSystemManagementService.c
line diff
     1.1 --- a/ChangeLog	Wed Mar 07 19:28:29 2007 -0700
     1.2 +++ b/ChangeLog	Fri Mar 09 16:52:35 2007 -0700
     1.3 @@ -1,3 +1,12 @@
     1.4 +-------------------------------------------------------------------
     1.5 +Fri Mar  9 16:47:13 MST 2007 - jfehlig@novell.com
     1.6 +
     1.7 +        - Added support for receiving type CIMInstance (as well as
     1.8 +          string) for EmbeddedInstance method parameters.  OpenWBEM
     1.9 +	  and sfcb cimoms now support providing CIMInstances - i.e.
    1.10 +          the cimoms handle parsing the embedded instances.  Support
    1.11 +          for parsing MOF-encoded string remains for the time.
    1.12 +
    1.13  -------------------------------------------------------------------
    1.14  Wed Mar  7 19:24:17 MST 2007 - jfehlig@novell.com
    1.15  
     2.1 --- a/src/Xen_VirtualSystemManagementService.c	Wed Mar 07 19:28:29 2007 -0700
     2.2 +++ b/src/Xen_VirtualSystemManagementService.c	Fri Mar 09 16:52:35 2007 -0700
     2.3 @@ -86,10 +86,11 @@ static char * _CLASSNAME = "Xen_VirtualS
     2.4  const static char * _KEYNAMES[] = {"SystemName", "SystemCreationClassName", "Name", "CreationClassName", NULL}; 
     2.5  
     2.6  
     2.7 -static int create_vm(char *vsSettings, CMPIArray *resourceSettings,
     2.8 +static int create_vm(CMPIInstance* vsSettingsInst, 
     2.9 +                     CMPIArray *resourceSettings,
    2.10                       xen_vm *result, CMPIStatus *status);
    2.11  static int add_resource_to_vm(xen_vm_record *vmRec,
    2.12 -                               char *sourceSetting,
    2.13 +                               CMPIInstance *sourceSettingInst,
    2.14                                 CMPIObjectPath **resultSetting,
    2.15                                 char *namespace,
    2.16                                 CMPIStatus *status);
    2.17 @@ -798,16 +799,33 @@ static CMPIStatus InvokeMethod(
    2.18           goto Exit;
    2.19        }
    2.20  
    2.21 -      if (argdata.type != CMPI_string) {
    2.22 +      CMPIInstance* vsSettingDataInst; 
    2.23 +      if (argdata.type == CMPI_string)
    2.24 +      {
    2.25 +         char *vsSettingData = CMGetCharPtr(argdata.value.string);
    2.26 +         _SBLIM_TRACE(2,("--- Got string with embedded instance =\"%s\"", vsSettingData));
    2.27 +
    2.28 +         vsSettingDataInst = parse_embedded_instance(vsSettingData);
    2.29 +         if (vsSettingDataInst == NULL) { /* parser returns zero for success, non-zero for error */
    2.30 +            _SBLIM_TRACE(1,("--- Error parsing VirtualSystemSettingData: \"%s\"",vsSettingData));
    2.31 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_INVALID_PARAMETER, "Cannot parse VirtualSystemSettingData");
    2.32 +            rc = 5;
    2.33 +            goto Exit;
    2.34 +         }
    2.35 +      }
    2.36 +      else if (argdata.type == CMPI_instance)
    2.37 +      {
    2.38 +         vsSettingDataInst = argdata.value.inst;
    2.39 +         _SBLIM_TRACE(2,("--- Got embedded instance for vsSettingData"));
    2.40 +      }
    2.41 +      else
    2.42 +      {
    2.43           _SBLIM_TRACE(1,("--- Invalid setting type - %s", _CMPITypeName(argdata.type)));
    2.44           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid setting type");
    2.45           rc = 5;
    2.46           goto Exit; 
    2.47        }
    2.48 -
    2.49 -      char *vsSettingData = CMGetCharPtr(argdata.value.string);
    2.50 -      _SBLIM_TRACE(2,("--- vsSettingData=\"%s\"", vsSettingData));
    2.51 -
    2.52 +      
    2.53        /* Get input array of ResourceAllocationSettingData instances. */
    2.54        argdata = CMGetArgAt(argsin, 1, NULL, &status);
    2.55        if ((status.rc != CMPI_RC_OK) || CMIsNullValue(argdata)) {
    2.56 @@ -827,7 +845,7 @@ static CMPIStatus InvokeMethod(
    2.57  
    2.58        CMPIArray *resourceSettings = argdata.value.array;
    2.59        xen_vm vm;
    2.60 -      if (!create_vm(vsSettingData, resourceSettings, &vm, &status))
    2.61 +      if (!create_vm(vsSettingDataInst, resourceSettings, &vm, &status))
    2.62        {
    2.63           _SBLIM_TRACE(1,("--- create_vm() failed"));
    2.64           /* status set in create_vm */
    2.65 @@ -916,19 +934,31 @@ static CMPIStatus InvokeMethod(
    2.66           goto Exit;
    2.67        }
    2.68  
    2.69 -      if (argdata.type != CMPI_string) {
    2.70 +      CMPIInstance* newSettingInst; 
    2.71 +      if (argdata.type == CMPI_string){
    2.72 +         char* newSetting = CMGetCharPtr(argdata.value.string);
    2.73 +         _SBLIM_TRACE(2,("--- newSetting=\"%s\"", newSetting));
    2.74 +         newSettingInst = parse_embedded_instance(newSetting);
    2.75 +         if (newSettingInst == NULL) { /* parser returns zero for success, non-zero for error */
    2.76 +            _SBLIM_TRACE(1,("--- Error parsing ResourceSettingData: \"%s\"",newSetting));
    2.77 +            CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_INVALID_PARAMETER, "Cannot parse ResourceSettingData");
    2.78 +            rc = 5;
    2.79 +            goto Exit;
    2.80 +         }
    2.81 +      }
    2.82 +      else if (argdata.type == CMPI_instance) {
    2.83 +         newSettingInst = argdata.value.inst; 
    2.84 +      }
    2.85 +      else {
    2.86           _SBLIM_TRACE(1,("--- Invalid setting type - %s", _CMPITypeName(argdata.type)));
    2.87           CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid setting type");
    2.88           rc = 5;
    2.89           goto Exit; 
    2.90        }
    2.91  
    2.92 -      char *newSetting = CMGetCharPtr(argdata.value.string);
    2.93 -      _SBLIM_TRACE(2,("--- newSetting=\"%s\"", newSetting));
    2.94 -
    2.95  
    2.96        CMPIObjectPath *resultSetting;
    2.97 -      if (!add_resource_to_vm(vmRec, newSetting, &resultSetting, namespace, &status))
    2.98 +      if (!add_resource_to_vm(vmRec, newSettingInst, &resultSetting, namespace, &status))
    2.99        {
   2.100           _SBLIM_TRACE(1,("--- add_resource_to_vm() failed"));
   2.101           /* status set in add_resource_to_vm */
   2.102 @@ -1107,10 +1137,10 @@ CMMethodMIStub( , Xen_VirtualSystemManag
   2.103  }                                                                               \
   2.104  
   2.105  
   2.106 -static int create_vm(char *vsSettings, CMPIArray *resourceSettings,
   2.107 +static int create_vm(CMPIInstance* vsSettingsInst, 
   2.108 +                     CMPIArray *resourceSettings,
   2.109                       xen_vm *result, CMPIStatus *status)
   2.110  {
   2.111 -   CMPIInstance *instance;
   2.112     CMPIObjectPath *objectpath;
   2.113     char *settingclassname;
   2.114     xen_vm_record *vm_rec;
   2.115 @@ -1122,8 +1152,6 @@ static int create_vm(char *vsSettings, C
   2.116     int ccode;
   2.117     char error_msg[XEN_UTILS_ERROR_BUF_LEN];
   2.118     
   2.119 -   _SBLIM_TRACE(2,("--- vsSettings=\"%s\"", vsSettings));
   2.120 -
   2.121     vm_rec = xen_vm_record_alloc();
   2.122     if (vm_rec == NULL) {
   2.123        _SBLIM_TRACE(1,("--- Cannot malloc memory for vm record"));
   2.124 @@ -1131,15 +1159,7 @@ static int create_vm(char *vsSettings, C
   2.125        return 0;
   2.126     }
   2.127        
   2.128 -   instance = parse_embedded_instance(vsSettings);
   2.129 -   if (instance == NULL) { /* parser returns zero for success, non-zero for error */
   2.130 -      _SBLIM_TRACE(1,("--- Error parsing VirtualSystemSettingData: \"%s\"", vsSettings));
   2.131 -      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Cannot parse VirtualSystemSettingData");
   2.132 -
   2.133 -      return 0;
   2.134 -   }
   2.135 -   
   2.136 -   objectpath = CMGetObjectPath(instance, NULL);
   2.137 +   objectpath = CMGetObjectPath(vsSettingsInst, NULL);
   2.138     _SBLIM_TRACE(2,("--- objectpath=%s", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL))));
   2.139     
   2.140     /* Get the class type of the setting data instance */
   2.141 @@ -1154,14 +1174,14 @@ static int create_vm(char *vsSettings, C
   2.142     }
   2.143     
   2.144     /* Convert the domain settings to respective xen settings. */
   2.145 -   if (!vssd2xenconfig(instance, vm_rec, status)) {
   2.146 +   if (!vssd2xenconfig(vsSettingsInst, vm_rec, status)) {
   2.147        _SBLIM_TRACE(1,("--- failed to convert VSSD to xen_vmrecord"));
   2.148        xen_vm_record_free(vm_rec);
   2.149        return 0;
   2.150     }
   2.151     
   2.152 -
   2.153     /* Convert resource settings to their respecitve xen settings. */
   2.154 +   CMPIInstance *instance;
   2.155     char *setting;
   2.156     for (i = 0; i < CMGetArrayCount(resourceSettings, NULL); i++) {
   2.157        CMPIData settingdata = CMGetArrayElementAt(resourceSettings, i, status);
   2.158 @@ -1171,24 +1191,27 @@ static int create_vm(char *vsSettings, C
   2.159        }
   2.160        
   2.161        /* Check that the array element is an (embedded) instance */
   2.162 -      //         if (settingdata.type != CMPI_instance) {
   2.163 -      if (settingdata.type != CMPI_string) {
   2.164 +      if (settingdata.type == CMPI_string) {
   2.165 +         setting = CMGetCharPtr(settingdata.value.string);
   2.166 +         _SBLIM_TRACE(2,("--- Got string with embedded instance = %s", setting));
   2.167 +
   2.168 +         instance = parse_embedded_instance(setting);
   2.169 +         if (instance == NULL) {
   2.170 +            _SBLIM_TRACE(1,("--- unable to parse setting data %s", setting));
   2.171 +            CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Unable to parse resource setting data parameter");
   2.172 +            goto Error; 
   2.173 +         }
   2.174 +      }
   2.175 +      else if (settingdata.type == CMPI_instance) {
   2.176 +         instance = settingdata.value.inst;
   2.177 +         _SBLIM_TRACE(2,("--- Got embedded instance for setting"));
   2.178 +      }
   2.179 +      else {
   2.180           _SBLIM_TRACE(1,("--- Invalid setting type - %s", _CMPITypeName(settingdata.type)));
   2.181           CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid resource setting data parameter");
   2.182           goto Error; 
   2.183        }
   2.184        
   2.185 -      setting = CMGetCharPtr(settingdata.value.string);
   2.186 -      _SBLIM_TRACE(2,("--- setting=\"%s\"", setting));
   2.187 -
   2.188 -      instance = parse_embedded_instance(setting);
   2.189 -   
   2.190 -      if (instance == NULL) { /* Fail if we have an unparsable setting data? */
   2.191 -         _SBLIM_TRACE(1,("--- Error parsing RASD: \"%s\"", setting));
   2.192 -         CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Unable to parse resource setting data parameter");
   2.193 -         goto Error;
   2.194 -      }
   2.195 -
   2.196        _SBLIM_TRACE(2,("--- instance=%s", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   2.197        objectpath = CMGetObjectPath(instance, NULL);
   2.198        _SBLIM_TRACE(2,("--- objectpath=%s", CMGetCharPtr(CDToString(_BROKER, objectpath, NULL))));
   2.199 @@ -1360,12 +1383,11 @@ static int create_vm(char *vsSettings, C
   2.200  
   2.201  
   2.202  static int add_resource_to_vm(xen_vm_record *vmRec,
   2.203 -                               char *sourceSetting,
   2.204 -                               CMPIObjectPath **resultSetting,
   2.205 -                               char *namespace,
   2.206 -                               CMPIStatus *status)
   2.207 +                              CMPIInstance *sourceSettingInst,
   2.208 +                              CMPIObjectPath **resultSetting,
   2.209 +                              char *namespace,
   2.210 +                              CMPIStatus *status)
   2.211  {
   2.212 -   CMPIInstance *instance;
   2.213     CMPIObjectPath *op;
   2.214     char *settingclassname;
   2.215     CMPIData propertyvalue;
   2.216 @@ -1378,18 +1400,8 @@ static int add_resource_to_vm(xen_vm_rec
   2.217              
   2.218           };
   2.219     
   2.220 -
   2.221 -   /* Parse sourceSetting - creating a CIM instance */
   2.222 -   instance = parse_embedded_instance(sourceSetting);
   2.223 -   
   2.224 -   if (instance == NULL) { /* Fail if we have an unparsable setting data? */
   2.225 -      _SBLIM_TRACE(1,("--- Error parsing input RASD: \"%s\"", sourceSetting));
   2.226 -      CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "Unable to parse ResourceSetting parameter");
   2.227 -      return 0;
   2.228 -   }
   2.229 -
   2.230 -   _SBLIM_TRACE(2,("--- instance=%s", CMGetCharPtr(CDToString(_BROKER, instance, NULL))));
   2.231 -   op = CMGetObjectPath(instance, NULL);
   2.232 +   _SBLIM_TRACE(2,("--- instance=%s", CMGetCharPtr(CDToString(_BROKER, sourceSettingInst, NULL))));
   2.233 +   op = CMGetObjectPath(sourceSettingInst, NULL);
   2.234     _SBLIM_TRACE(2,("--- objectpath=%s", CMGetCharPtr(CDToString(_BROKER, op, NULL))));
   2.235     
   2.236     /* Get the class type of the setting data instance */
   2.237 @@ -1406,7 +1418,7 @@ static int add_resource_to_vm(xen_vm_rec
   2.238  #else
   2.239        /* Code for adding processors -- when Xen API supports it. */
   2.240        _SBLIM_TRACE(2,("--- adding Xen_ProcessorSettingData to configuration"));
   2.241 -      propertyvalue = CMGetProperty(instance, "VirtualQuantity", status);
   2.242 +      propertyvalue = CMGetProperty(sourceSettingInst, "VirtualQuantity", status);
   2.243        if ((status->rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
   2.244           _SBLIM_TRACE(1,("--- Unable to determine VirtualQuantity in Processor RASD"));
   2.245           CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "VirtualQuantity not specified in ResourceSetting");
   2.246 @@ -1443,7 +1455,7 @@ static int add_resource_to_vm(xen_vm_rec
   2.247  #else
   2.248        /* Code for adding memory -- when Xen API supports it. */
   2.249        _SBLIM_TRACE(2,("--- adding Xen_MemorySettingData to configuration"));
   2.250 -      propertyvalue = CMGetProperty(instance, "VirtualQuantity", status);
   2.251 +      propertyvalue = CMGetProperty(sourceSettingInst, "VirtualQuantity", status);
   2.252        if ((status->rc != CMPI_RC_OK) || CMIsNullValue(propertyvalue)) {
   2.253           _SBLIM_TRACE(1,("--- Unable to determine VirtualQuantity in Memory RASD"));
   2.254           CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERR_INVALID_PARAMETER, "VirtualQuantity not specified in ResourceSetting");
   2.255 @@ -1471,7 +1483,7 @@ static int add_resource_to_vm(xen_vm_rec
   2.256        _SBLIM_TRACE(2,("--- adding Xen_DiskSettingData to configuration"));
   2.257        
   2.258        xen_vbd_record *vbd_rec;
   2.259 -      if (!disk_rasd2vmconfig(instance, &vbd_rec, status)) {
   2.260 +      if (!disk_rasd2vmconfig(sourceSettingInst, &vbd_rec, status)) {
   2.261           /* status set in disk_rasd2vmconfig */
   2.262           _SBLIM_TRACE(1,("--- Error parsing disk settings"));
   2.263           return 0;
   2.264 @@ -1500,7 +1512,7 @@ static int add_resource_to_vm(xen_vm_rec
   2.265     else if (strcmp(settingclassname,"Xen_NetworkPortSettingData") == 0) {
   2.266        _SBLIM_TRACE(2,("--- adding Xen_NetworkPortSettingData to configuration"));
   2.267        xen_vif_record *vif_rec;
   2.268 -      if (!nic_rasd2vmconfig(instance, &vif_rec, status)) {
   2.269 +      if (!nic_rasd2vmconfig(sourceSettingInst, &vif_rec, status)) {
   2.270           /* status set in disk_rasd2vmconfig */
   2.271           _SBLIM_TRACE(1,("--- Error parsing network port settings"));
   2.272           return 0;