Merge branch 'remove-singleton-object_id' of https://github.com/asteven/cdist
This commit is contained in:
		
				commit
				
					
						b84d3393a0
					
				
			
		
					 3 changed files with 8 additions and 11 deletions
				
			
		| 
						 | 
					@ -65,7 +65,7 @@ class CdistObject(object):
 | 
				
			||||||
    STATE_RUNNING = "running"
 | 
					    STATE_RUNNING = "running"
 | 
				
			||||||
    STATE_DONE = "done"
 | 
					    STATE_DONE = "done"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, cdist_type, base_path, object_id=None):
 | 
					    def __init__(self, cdist_type, base_path, object_id=''):
 | 
				
			||||||
        self.cdist_type = cdist_type # instance of Type
 | 
					        self.cdist_type = cdist_type # instance of Type
 | 
				
			||||||
        self.base_path = base_path
 | 
					        self.base_path = base_path
 | 
				
			||||||
        self.object_id = object_id
 | 
					        self.object_id = object_id
 | 
				
			||||||
| 
						 | 
					@ -107,7 +107,6 @@ class CdistObject(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        type_name = object_name.split(os.sep)[0]
 | 
					        type_name = object_name.split(os.sep)[0]
 | 
				
			||||||
        # FIXME: allow object without object_id? e.g. for singleton
 | 
					 | 
				
			||||||
        object_id = os.sep.join(object_name.split(os.sep)[1:])
 | 
					        object_id = os.sep.join(object_name.split(os.sep)[1:])
 | 
				
			||||||
        return type_name, object_id
 | 
					        return type_name, object_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ class Emulator(object):
 | 
				
			||||||
        self.stdin          = stdin
 | 
					        self.stdin          = stdin
 | 
				
			||||||
        self.env            = env
 | 
					        self.env            = env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.object_id      = False
 | 
					        self.object_id      = ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.global_path    = self.env['__global']
 | 
					        self.global_path    = self.env['__global']
 | 
				
			||||||
        self.target_host    = self.env['__target_host']
 | 
					        self.target_host    = self.env['__target_host']
 | 
				
			||||||
| 
						 | 
					@ -54,10 +54,10 @@ class Emulator(object):
 | 
				
			||||||
        """Add hostname and object to logs via logging Filter"""
 | 
					        """Add hostname and object to logs via logging Filter"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        prefix = self.target_host + ": (emulator)"
 | 
					        prefix = self.target_host + ": (emulator)"
 | 
				
			||||||
 | 
					        prefix = '{0}: emulator {1}'.format(
 | 
				
			||||||
        if self.object_id:
 | 
					            self.target_host,
 | 
				
			||||||
            prefix = prefix + " " + self.type_name + "/" + self.object_id
 | 
					            core.CdistObject.join_name(self.type_name, self.object_id)
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        record.msg = prefix + ": " + record.msg
 | 
					        record.msg = prefix + ": " + record.msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
| 
						 | 
					@ -122,9 +122,7 @@ class Emulator(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup_object(self):
 | 
					    def setup_object(self):
 | 
				
			||||||
        # Setup object_id - FIXME: unset / do not setup anymore!
 | 
					        # Setup object_id - FIXME: unset / do not setup anymore!
 | 
				
			||||||
        if self.cdist_type.is_singleton:
 | 
					        if not self.cdist_type.is_singleton:
 | 
				
			||||||
            self.object_id = "singleton"
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            self.object_id = self.args.object_id[0]
 | 
					            self.object_id = self.args.object_id[0]
 | 
				
			||||||
            del self.args.object_id
 | 
					            del self.args.object_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,7 +118,7 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
 | 
				
			||||||
        initial_manifest = os.path.join(self.local.manifest_path, "init")
 | 
					        initial_manifest = os.path.join(self.local.manifest_path, "init")
 | 
				
			||||||
        self.manifest.run_initial_manifest(initial_manifest)
 | 
					        self.manifest.run_initial_manifest(initial_manifest)
 | 
				
			||||||
        cdist_type = core.CdistType(self.local.type_path, '__saturn')
 | 
					        cdist_type = core.CdistType(self.local.type_path, '__saturn')
 | 
				
			||||||
        cdist_object = core.CdistObject(cdist_type, self.local.object_path, 'singleton')
 | 
					        cdist_object = core.CdistObject(cdist_type, self.local.object_path)
 | 
				
			||||||
        self.manifest.run_type_manifest(cdist_object)
 | 
					        self.manifest.run_type_manifest(cdist_object)
 | 
				
			||||||
        expected = ['__planet/Saturn', '__moon/Prometheus']
 | 
					        expected = ['__planet/Saturn', '__moon/Prometheus']
 | 
				
			||||||
        self.assertEqual(sorted(cdist_object.autorequire), sorted(expected))
 | 
					        self.assertEqual(sorted(cdist_object.autorequire), sorted(expected))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue