do not fail without objects
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								326f2644c7
							
						
					
				
			
			
				commit
				
					
						0d1f121e21
					
				
			
		
					 1 changed files with 16 additions and 14 deletions
				
			
		
							
								
								
									
										24
									
								
								bin/cdist
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								bin/cdist
									
										
									
									
									
								
							| 
						 | 
					@ -121,6 +121,9 @@ class Cdist:
 | 
				
			||||||
      # List of type explorers transferred
 | 
					      # List of type explorers transferred
 | 
				
			||||||
      self.type_explorers_transferred = {}
 | 
					      self.type_explorers_transferred = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # objects
 | 
				
			||||||
 | 
					      self.objects_prepared = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      self.remote_user = remote_user
 | 
					      self.remote_user = remote_user
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      # Mostly static, but can be overwritten on user demand
 | 
					      # Mostly static, but can be overwritten on user demand
 | 
				
			||||||
| 
						 | 
					@ -241,13 +244,10 @@ class Cdist:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return list
 | 
					      return list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   def list_object_paths(self, starting_point = False):
 | 
					   def list_object_paths(self, starting_point):
 | 
				
			||||||
      """Return list of paths of existing objects"""
 | 
					      """Return list of paths of existing objects"""
 | 
				
			||||||
      object_paths = []
 | 
					      object_paths = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if not starting_point:
 | 
					 | 
				
			||||||
         starting_point = self.object_base_dir
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      for content in os.listdir(starting_point):
 | 
					      for content in os.listdir(starting_point):
 | 
				
			||||||
         full_path = os.path.join(starting_point, content)
 | 
					         full_path = os.path.join(starting_point, content)
 | 
				
			||||||
         if os.path.isdir(full_path):
 | 
					         if os.path.isdir(full_path):
 | 
				
			||||||
| 
						 | 
					@ -288,17 +288,15 @@ class Cdist:
 | 
				
			||||||
      return [os.path.join(self.object_dir(cdist_object), "code-local"),
 | 
					      return [os.path.join(self.object_dir(cdist_object), "code-local"),
 | 
				
			||||||
              os.path.join(self.object_dir(cdist_object), "code-remote")]
 | 
					              os.path.join(self.object_dir(cdist_object), "code-remote")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   def list_objects(self, starting_point = False):
 | 
					   def list_objects(self):
 | 
				
			||||||
      """Return list of existing objects"""
 | 
					      """Return list of existing objects"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if not starting_point:
 | 
					 | 
				
			||||||
         starting_point = self.object_base_dir
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      object_paths = self.list_object_paths(starting_point)
 | 
					 | 
				
			||||||
      objects = []
 | 
					      objects = []
 | 
				
			||||||
 | 
					      if os.path.isdir(self.object_base_dir):
 | 
				
			||||||
 | 
					         object_paths = self.list_object_paths(self.object_base_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         for path in object_paths:
 | 
					         for path in object_paths:
 | 
				
			||||||
         objects.append(os.path.relpath(path, starting_point))
 | 
					            objects.append(os.path.relpath(path, self.object_base_dir))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return objects
 | 
					      return objects
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -561,10 +559,14 @@ class Cdist:
 | 
				
			||||||
      while old_objects != objects:
 | 
					      while old_objects != objects:
 | 
				
			||||||
         log.debug("Prepare stage")
 | 
					         log.debug("Prepare stage")
 | 
				
			||||||
         old_objects = list(objects)
 | 
					         old_objects = list(objects)
 | 
				
			||||||
         # FIXME: do not rerun existing objects!
 | 
					 | 
				
			||||||
         for cdist_object in objects:
 | 
					         for cdist_object in objects:
 | 
				
			||||||
 | 
					            if cdist_object in self.objects_prepared:
 | 
				
			||||||
 | 
					               log.debug("Skipping rerun of object %s", cdist_object)
 | 
				
			||||||
 | 
					               continue
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
               self.run_type_explorer(cdist_object)
 | 
					               self.run_type_explorer(cdist_object)
 | 
				
			||||||
               self.run_type_manifest(cdist_object)
 | 
					               self.run_type_manifest(cdist_object)
 | 
				
			||||||
 | 
					               self.objects_prepared.append(cdist_object)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         objects = self.list_objects()
 | 
					         objects = self.list_objects()
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue