cleanup.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:foreman-yml 作者: adfinis-sygroup 项目源码 文件源码
def process_cleanup_provisioningtpl(self):
        log.log(log.LOG_INFO, "Processing Cleanup of Provisioning Templates")
        ptlist = self.fm.provisioning_templates.index(per_page=99999)['results']
        for pt in self.get_config_section('cleanup-provisioning-template'):
            try:
                self.validator.cleanup_provt(pt)
            except MultipleInvalid as e:
                log.log(log.LOG_WARN, "Cannot delete Provisioning Template '{0}': YAML validation Error: {1}".format(pt['name'], e))
                continue

            # fm.provisioning_templates.show(name) does not work as expected, we need to iterate over fm.provisioning_templates.index()
            pt_deleted = False
            for ptc in ptlist:
                if (ptc['name'] == pt['name']):
                    pt_deleted = True
                    log.log(log.LOG_INFO, "Delete Provisioning Template '{0}'".format(pt['name']))

                    self.fm.provisioning_templates.destroy( pt['name'] )
                    continue
            if not pt_deleted:
                log.log(log.LOG_WARN, "Provisioning Template '{0}' already absent.".format(pt['name']))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号