'Given a registered classname, create an object of name object_name and
with the properties found on objargs. ID will be generated for you.
If workspace_name is None, it will be inferred from the CONF module.
parent_id should only be None if classname is \'Host\' or maybe \'Note\' or \'Credential\'.'

def createModelObject(self, classname, object_name, workspace_name=None, parent_id=None, **objargs):

    if (not workspace_name):
        workspace_name = CONF.getLastWorkspace()
    if (classname in self._registered_objects):
        if (object_name is not None):
            objargs['name'] = object_name
            objargs['_id'] = (-1)
            objargs['id'] = (-1)
            tmpObj = self._registered_objects[classname](objargs, workspace_name)
            tmpObj.setID(parent_id)
            return tmpObj
        else:
            raise Exception(('Object    name    parameter    missing.    Cannot    create    object    class:    %s' % classname))
    else:
        raise Exception(('Object    class    %s    not    registered    in    factory.    Cannot    create    object.' % classname))
