Merge remote-tracking branch 'telmich/master'
This commit is contained in:
		
				commit
				
					
						0f413f8e4d
					
				
			
		
					 4 changed files with 11 additions and 22 deletions
				
			
		
							
								
								
									
										17
									
								
								bin/cdist
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								bin/cdist
									
										
									
									
									
								
							| 
						 | 
					@ -21,11 +21,11 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
import datetime
 | 
					 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
log = logging.getLogger("cdist")
 | 
					log = logging.getLogger("cdist")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,7 +112,7 @@ def configinstall(args, mode):
 | 
				
			||||||
    """Configure or install remote system"""
 | 
					    """Configure or install remote system"""
 | 
				
			||||||
    process = {}
 | 
					    process = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    time_start = datetime.datetime.now()
 | 
					    time_start = time.time()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    os.environ['__remote_exec'] = "ssh -o User=root -q"
 | 
					    os.environ['__remote_exec'] = "ssh -o User=root -q"
 | 
				
			||||||
    os.environ['__remote_copy'] = "scp -o User=root -q"
 | 
					    os.environ['__remote_copy'] = "scp -o User=root -q"
 | 
				
			||||||
| 
						 | 
					@ -133,17 +133,15 @@ def configinstall(args, mode):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # FIXME: error handling for parallel mode!
 | 
					    # FIXME: error handling for parallel mode!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    time_end = datetime.datetime.now()
 | 
					    time_end = time.time()
 | 
				
			||||||
    log.info("Total processing time for %s host(s): %s", len(args.host),
 | 
					    log.info("Total processing time for %s host(s): %s", len(args.host),
 | 
				
			||||||
                (time_end - time_start).total_seconds())
 | 
					                (time_end - time_start))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        logging.basicConfig(format='%(levelname)s: %(message)s')
 | 
					        logging.basicConfig(format='%(levelname)s: %(message)s')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time_start = datetime.datetime.now()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])):
 | 
					        if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])):
 | 
				
			||||||
            import cdist.emulator
 | 
					            import cdist.emulator
 | 
				
			||||||
            cdist.emulator.run(sys.argv)
 | 
					            cdist.emulator.run(sys.argv)
 | 
				
			||||||
| 
						 | 
					@ -154,13 +152,6 @@ if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            commandline()
 | 
					            commandline()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        time_end = datetime.datetime.now()
 | 
					 | 
				
			||||||
        duration = time_end - time_start
 | 
					 | 
				
			||||||
        # FIXME: move into runner
 | 
					 | 
				
			||||||
        # log.info("Finished run of %s in %s seconds", self.target_host,
 | 
					 | 
				
			||||||
        #     duration.total_seconds())
 | 
					 | 
				
			||||||
        log.info("Finished run in %s seconds", duration.total_seconds())
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    except KeyboardInterrupt:
 | 
					    except KeyboardInterrupt:
 | 
				
			||||||
        sys.exit(0)
 | 
					        sys.exit(0)
 | 
				
			||||||
    except cdist.Error as e:
 | 
					    except cdist.Error as e:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -331,3 +331,4 @@ eof
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- remote_prefix:
 | 
					- remote_prefix:
 | 
				
			||||||
   scp vs. ssh issue
 | 
					   scp vs. ssh issue
 | 
				
			||||||
 | 
					locale_type
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,14 +20,7 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import datetime
 | 
					 | 
				
			||||||
import logging
 | 
					 | 
				
			||||||
import os
 | 
					 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import cdist.config_install
 | 
					import cdist.config_install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
log = logging.getLogger(__name__)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Config(cdist.config_install.ConfigInstall):
 | 
					class Config(cdist.config_install.ConfigInstall):
 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@ import logging
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import stat
 | 
					import stat
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cdist.context
 | 
					import cdist.context
 | 
				
			||||||
import cdist.core
 | 
					import cdist.core
 | 
				
			||||||
| 
						 | 
					@ -194,7 +195,7 @@ class ConfigInstall:
 | 
				
			||||||
        self.transfer_object_parameter(cdist_object)
 | 
					        self.transfer_object_parameter(cdist_object)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for explorer in cdist_type.explorers:
 | 
					        for explorer in cdist_type.explorers:
 | 
				
			||||||
            remote_cmd = cmd + [os.path.join(self.context.type_base_path,
 | 
					            remote_cmd = cmd + [os.path.join(self.context.remote_base_path,
 | 
				
			||||||
                cdist_type.explorer_path, explorer)]
 | 
					                cdist_type.explorer_path, explorer)]
 | 
				
			||||||
            output = os.path.join(self.context.object_base_path,
 | 
					            output = os.path.join(self.context.object_base_path,
 | 
				
			||||||
                        cdist_object.explorer_path, explorer)
 | 
					                        cdist_object.explorer_path, explorer)
 | 
				
			||||||
| 
						 | 
					@ -230,7 +231,7 @@ class ConfigInstall:
 | 
				
			||||||
            output_fd = open(os.path.join(dst_path, explorer), mode='w')
 | 
					            output_fd = open(os.path.join(dst_path, explorer), mode='w')
 | 
				
			||||||
            cmd = []
 | 
					            cmd = []
 | 
				
			||||||
            cmd.append("__explorer=" + remote_dst_path)
 | 
					            cmd.append("__explorer=" + remote_dst_path)
 | 
				
			||||||
            cmd.append(os.path.join(src_path, explorer))
 | 
					            cmd.append(os.path.join(remote_dst_path, explorer))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True)
 | 
					            cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True)
 | 
				
			||||||
            output_fd.close()
 | 
					            output_fd.close()
 | 
				
			||||||
| 
						 | 
					@ -252,8 +253,11 @@ class ConfigInstall:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def deploy_and_cleanup(self):
 | 
					    def deploy_and_cleanup(self):
 | 
				
			||||||
        """Do what is most often done: deploy & cleanup"""
 | 
					        """Do what is most often done: deploy & cleanup"""
 | 
				
			||||||
 | 
					        start_time = time.time()
 | 
				
			||||||
        self.deploy_to()
 | 
					        self.deploy_to()
 | 
				
			||||||
        self.cleanup()
 | 
					        self.cleanup()
 | 
				
			||||||
 | 
					        log.info("Finished run of %s in %s seconds", 
 | 
				
			||||||
 | 
					            self.target_host, time.time() - start_time)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def stage_prepare(self):
 | 
					    def stage_prepare(self):
 | 
				
			||||||
        """Do everything for a deploy, minus the actual code stage"""
 | 
					        """Do everything for a deploy, minus the actual code stage"""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue