'Test object type generic commands
@param str type object type
@param str name object name
@param dict attr object attributes to be tested.
Valid keys: name, long_name, initial_value, value
@param list objects list of objects returned in cobbler <type> list.
This is an input parameter for performance reasons. Objects
list is already generated before this call(), when object is
created, so there is no reason to regenerate it.'

def _test_generic_commands(self, type, name, attr, objects):

    new_name = ('test-%s2' % type)
    output = run_cmd(('cobbler    %s    report' % type))
    lines = output.split('\n')
    found_objects = {}
    for object in objects:
        found_objects[object] = False
    for line in lines:
        match_obj = re.match('Name\\s*:\\s*(.*)', line)
        if match_obj:
            object = match_obj.group(1)
            self.assertTrue((match_obj.group(1) in objects))
            found_objects[object] = True
    self.assertTrue((False not in found_objects.values()))
    output = run_cmd(('cobbler    %s    report    --name=%s' % (type, name)))
    regex = ('%s\\s+:\\s+%s' % (attr['long_name'], attr['initial_value']))
    lines = output.split('\n')
    found = False
    for line in lines:
        if re.match(regex, line):
            found = True
    self.assertTrue(found)
    cmd = ("cobbler    %s    edit    --name=%s    --%s='%s'" % (type, name, attr['name'], attr['value']))
    run_cmd(cmd)
    output = run_cmd(('cobbler    %s    report    --name=%s' % (type, name)))
    regex = ('%s\\s+:\\s+%s' % (attr['long_name'], attr['value']))
    lines = output.split('\n')
    found = False
    for line in lines:
        if re.match(regex, line):
            found = True
    self.assertTrue(found)
    cmd = ("cobbler    %s    find    --%s='%s'" % (type, attr['name'], attr['value']))
    output = run_cmd(cmd)
    lines = output.split('\n')
    self.assertTrue((len(lines) >= 1))
    run_cmd(('cobbler    %s    copy    --name=%s    --newname=%s' % (type, name, ('%s-copy' % name))))
    new_objects = self._list_objects(type)
    self.assertTrue((len(new_objects) == (len(objects) + 1)))
    cmd = ('cobbler    %s    rename    --name=%s    --newname=%s' % (type, name, new_name))
    run_cmd(cmd)
    cmd = ('cobbler    %s    rename    --name=%s    --newname=%s' % (type, new_name, name))
    run_cmd(cmd)
    run_cmd(('cobbler    %s    remove    --name=%s-copy' % (type, name)))
    new_objects = self._list_objects(type)
    self.assertTrue((len(new_objects) == len(objects)))
