• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.SystemOption类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.SystemOption的典型用法代码示例。如果您正苦于以下问题:Python SystemOption类的具体用法?Python SystemOption怎么用?Python SystemOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SystemOption类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: software_profile_create

def software_profile_create():
    # if not can_create_user(current_user):
    #    abort(401)

    db_session = DBSession()

    form = SoftwareProfileForm(request.form)
    server_dialog_form = ServerDialogForm(request.form)

    fill_servers(server_dialog_form.server_dialog_server.choices, get_server_list(db_session), False)

    if request.method == 'POST' and form.validate():

        software_profile = get_software_profile(db_session, form.profile_name.data)

        if software_profile is not None:
            return render_template('conformance/profile_edit.html',
                                   form=form, system_option=SystemOption.get(db_session), duplicate_error=True)

        software_profile = SoftwareProfile(
            name=form.profile_name.data,
            description=form.description.data,
            packages=','.join([l for l in form.software_packages.data.splitlines() if l]),
            created_by=current_user.username)

        db_session.add(software_profile)
        db_session.commit()

        return redirect(url_for('conformance.home'))
    else:

        return render_template('conformance/profile_edit.html',
                               form=form, server_dialog_form=server_dialog_form,
                               system_option=SystemOption.get(db_session))
开发者ID:kstaniek,项目名称:csm,代码行数:34,代码来源:conformance.py


示例2: software_profile_edit

def software_profile_edit(profile_name):
    db_session = DBSession()

    software_profile = get_software_profile(db_session, profile_name)
    if software_profile is None:
        abort(404)

    form = SoftwareProfileForm(request.form)
    server_dialog_form = ServerDialogForm(request.form)
    fill_servers(server_dialog_form.server_dialog_server.choices, get_server_list(db_session), False)

    if request.method == 'POST' and form.validate():
        if profile_name != form.profile_name.data and \
                        get_software_profile(db_session, form.profile_name.data) is not None:
            return render_template('conformance/profile_edit.html',
                                   form=form, server_dialog_form=server_dialog_form,
                                   system_option=SystemOption.get(db_session), duplicate_error=True)

        software_profile.name = form.profile_name.data
        software_profile.description = form.description.data
        software_profile.packages = ','.join([l for l in form.software_packages.data.splitlines() if l]),

        db_session.commit()

        return redirect(url_for('conformance.home'))
    else:
        form.profile_name.data = software_profile.name
        form.description.data = software_profile.description
        if software_profile.packages is not None:
            form.software_packages.data = '\n'.join(software_profile.packages.split(','))

    return render_template('conformance/profile_edit.html',
                           form=form, server_dialog_form=server_dialog_form,
                           system_option=SystemOption.get(db_session))
开发者ID:kstaniek,项目名称:csm,代码行数:34,代码来源:conformance.py


示例3: create_email_notification

    def create_email_notification(self, db_session, logger, host, install_job):
        try:
            session_log_link = "log/hosts/{}/install_job_history/session_log/{}?file_path={}".format(
                urllib.quote(host.hostname), install_job.id, install_job.session_log)

            message = '<html><head></head><body>'
            if install_job.status == JobStatus.COMPLETED:
                message += 'The scheduled installation for host "' + host.hostname + '" has COMPLETED.<br><br>'
            elif install_job.status == JobStatus.FAILED:
                message += 'The scheduled installation for host "' + host.hostname + '" has FAILED.<br><br>'

            message += 'Scheduled Time: ' + \
                       get_datetime_string(install_job.scheduled_time) + \
                       ' UTC<br>'
            message += 'Start Time: ' + \
                       get_datetime_string(install_job.start_time) + \
                       ' UTC<br>'
            message += 'Install Action: ' + install_job.install_action + '<br><br>'

            message = self.check_command_file_diff(install_job, message)

            session_log_url = SystemOption.get(db_session).base_url + '/' + session_log_link

            message += 'For more information, click the link below<br><br>'
            message += session_log_url + '<br><br>'

            if install_job.packages is not None and len(install_job.packages) > 0:
                message += 'Followings are the software packages: <br><br>' + install_job.packages.replace(',','<br>')

            message += '</body></html>'

            create_email_job(db_session, logger, message, install_job.created_by)

        except Exception:
            logger.exception('create_email_notification() hit exception')
开发者ID:smjurcak,项目名称:csm,代码行数:35,代码来源:install_work_unit.py


示例4: scheduling

    def scheduling(self, scheduler, daily_time):
        
        # First, re-set up the scheduler for the next day the same time. It is important to have
        # this logic on the top so that if any error encountered below, the scheduling still works.
        t = datetime.datetime.combine(datetime.datetime.now() + datetime.timedelta(days=1), daily_time)
        scheduler.enterabs(time.mktime(t.timetuple()), 1, self.scheduling, (scheduler, daily_time,))
            
        db_session = DBSession()
        
        try:
            system_option = SystemOption.get(db_session)
            
            # If software inventory is enabled, submit the inventory jobs
            if system_option.enable_inventory:
                inventory_jobs = db_session.query(InventoryJob).all()

                if len(inventory_jobs)> 0:
                    for inventory_job in inventory_jobs:
                        inventory_job.pending_submit = True
                    db_session.commit()
                        
            #Check if there is any housekeeping work to do
            self.perform_housekeeping_tasks(db_session, system_option)
            
        except:
            logger.exception('InventoryManagerScheduler hit exception')
        finally:
            db_session.close()
开发者ID:ommaurya,项目名称:csm,代码行数:28,代码来源:scheduler.py


示例5: run

 def run(self):
     db_session = DBSession()   
     try:         
         system_option = SystemOption.get(db_session)            
         inventory_hour = system_option.inventory_hour
         db_session.close()
                     
         # Build a scheduler object that will look at absolute times
         scheduler = sched.scheduler(time.time, time.sleep)
         current_hour = datetime.datetime.now().hour
 
         # Put task for today at the designated hour.
         daily_time = datetime.time(inventory_hour)
         
         # If the scheduled time already passed, schedule it for tomorrow
         if current_hour > inventory_hour:
             first_time = datetime.datetime.combine(datetime.datetime.now() + datetime.timedelta(days=1), daily_time)
         else:
             first_time = datetime.datetime.combine(datetime.datetime.now(), daily_time)
         
         scheduler.enterabs(time.mktime(first_time.timetuple()), 1,
             self.scheduling, (scheduler, daily_time,))
        
         scheduler.run()
         
     except:
         logger.exception('InventoryManagerScheduler hit exception')
         db_session.close()
开发者ID:ommaurya,项目名称:csm,代码行数:28,代码来源:scheduler.py


示例6: refresh_all

    def refresh_all(cls):
        """
        Retrieves all the catalog data and SMU XML file data and updates the database.
        """
        db_session = DBSession()
        
        catalog = SMUInfoLoader.get_catalog_from_cco()
        if len(catalog) > 0:
            system_option = SystemOption.get(db_session)
            try:
                # Remove all rows first
                db_session.query(CCOCatalog).delete()
            
                for platform in catalog:
                    releases = catalog[platform]
                    for release in releases:
                        cco_catalog = CCOCatalog(platform=platform,release=release)
                        db_session.add(cco_catalog)

                        SMUInfoLoader(platform, release)
                
                system_option.cco_lookup_time = datetime.datetime.utcnow()
                db_session.commit()
                return True
            except Exception:
                logger.exception('refresh_all() hit exception')
                db_session.rollback()  
            
        return False
开发者ID:smjurcak,项目名称:csm,代码行数:29,代码来源:smu_info_loader.py


示例7: host_urls

    def host_urls(self):
        system_option = SystemOption.get(self.db_session)
        if system_option.enable_user_credential_for_host:
            user = get_user_by_id(self.db_session, self.install_job.user_id)
            if user is not None:
                return self.make_urls(user.username, user.host_password)

        return self.make_urls()
开发者ID:kstaniek,项目名称:csm,代码行数:8,代码来源:base.py


示例8: __init__

 def __init__(self, name, num_threads=None):
     threading.Thread.__init__(self, name = name)
     
     if num_threads is None:
         num_threads = SystemOption.get(DBSession()).inventory_threads
     
     # Set up the thread pool
     self.pool = Pool(num_threads)
开发者ID:ommaurya,项目名称:csm,代码行数:8,代码来源:sim.py


示例9: optimize_software

def optimize_software():
    server_dialog_form = ServerDialogForm(request.form)
    software_profile_form = SoftwareProfileForm(request.form)

    return render_template('cco/optimize_software.html',
                           server_dialog_form=server_dialog_form,
                           software_profile_form=software_profile_form,
                           system_option=SystemOption.get(DBSession()))
开发者ID:smjurcak,项目名称:csm,代码行数:8,代码来源:cco.py


示例10: __init__

 def __init__(self, name, num_threads=None):
     threading.Thread.__init__(self, name = name)
     
     db_session = DBSession()
     if num_threads is None:
         num_threads = SystemOption.get(db_session).install_threads
     
     # Set up the thread pool
     self.pool = Pool(num_threads)
开发者ID:ommaurya,项目名称:csm,代码行数:9,代码来源:sum.py


示例11: home

def home(platform, release):
    system_option = SystemOption.get(DBSession())
    form = BrowseServerDialogForm(request.form)
    fill_servers(form.dialog_server.choices, get_server_list(DBSession()), False)
    export_software_information_form = ExportSoftwareInformationForm(request.form)

    return render_template('cco/home.html', form=form, platform=platform,
                           release=release, system_option=system_option,
                           export_software_information_form=export_software_information_form)
开发者ID:smjurcak,项目名称:csm,代码行数:9,代码来源:cco.py


示例12: make_urls

    def make_urls(self, preferred_host_username=None, preferred_host_password=None):
        urls = []

        if len(self.host.connection_param) > 0:
            connection = self.host.connection_param[0]
            jump_host_url = ''

            # Checks if there is a jump server
            if connection.jump_host_id is not None:
                try:
                    jump_host = self.db_session.query(JumpHost).filter(JumpHost.id == connection.jump_host_id).first()
                    if jump_host is not None:
                        jump_host_url = make_url(
                            connection_type=jump_host.connection_type,
                            host_username=jump_host.username,
                            host_password=jump_host.password,
                            host_or_ip=jump_host.host_or_ip,
                            port_number=jump_host.port_number)
                except:
                    pass

            host_username = connection.username
            host_password = connection.password

            if not is_empty(preferred_host_username) and not is_empty(preferred_host_password):
                host_username = preferred_host_username
                host_password = preferred_host_password
            else:
                system_option = SystemOption.get(self.db_session)
                if system_option.enable_default_host_authentication:
                    if not is_empty(system_option.default_host_username) and not is_empty(system_option.default_host_password):
                        if system_option.default_host_authentication_choice == DefaultHostAuthenticationChoice.ALL_HOSTS or \
                            (system_option.default_host_authentication_choice ==
                                DefaultHostAuthenticationChoice.HOSTS_WITH_NO_SPECIFIED_USERNAME_AND_PASSWORD and
                                is_empty(host_username) and
                                is_empty(host_password)):
                            host_username = system_option.default_host_username
                            host_password = system_option.default_host_password

            for host_or_ip in connection.host_or_ip.split(','):
                for port_number in connection.port_number.split(','):
                    host_urls = []
                    if not is_empty(jump_host_url):
                        host_urls.append(jump_host_url)

                    host_urls.append(make_url(
                        connection_type=connection.connection_type,
                        host_username=host_username,
                        host_password=host_password,
                        host_or_ip=host_or_ip,
                        port_number=port_number,
                        enable_password=connection.enable_password))

                    urls.append(host_urls)

        return urls
开发者ID:smjurcak,项目名称:csm,代码行数:56,代码来源:context.py


示例13: create_email_job_with_attachment_files

def create_email_job_with_attachment_files(db_session, message, file_paths, recipients):
    system_option = SystemOption.get(db_session)
    if not system_option.enable_email_notify:
        return

    email_job = EmailJob(recipients=recipients, message=message, created_by=current_user.username,
                         attachment_file_paths=file_paths)
    db_session.add(email_job)
    db_session.commit()
    return
开发者ID:smjurcak,项目名称:csm,代码行数:10,代码来源:inventory.py


示例14: user_list

def user_list():
    db_session = DBSession()

    users = get_user_list(db_session)
    if users is None:
        abort(404)

    if current_user.privilege == UserPrivilege.ADMIN:
        return render_template('user/index.html', users=users, system_option=SystemOption.get(db_session))

    return render_template('user/not_authorized.html', user=current_user)
开发者ID:smjurcak,项目名称:csm,代码行数:11,代码来源:authenticate.py


示例15: send_install_status_email

def send_install_status_email(install_job):
    db_session = DBSession
    username = install_job.created_by

    system_option = SystemOption.get(db_session)
    if not system_option.enable_email_notify:
        return
    
    smtp_server = get_smtp_server(db_session)
    if smtp_server is None:
        logger.error('mailer: SMTP Server has not been specified')
        return
    
    user = get_user(db_session, username)
    if user is None:
        logger.error('mailer: Unable to locate user "%s"' % username)
        return
    
    host = get_host(db_session, install_job.host_id)
    if host is None:
        logger.error('mailer: Unable to locate host id "%s"' % str(install_job.host_id))
        return
    
    message = '<html><head><body>'
    if install_job.status == JobStatus.COMPLETED:
        message += 'The scheduled installation for host "' + host.hostname + '" has COMPLETED<br><br>'
    elif install_job.status == JobStatus.FAILED:
        message += 'The scheduled installation for host "' + host.hostname + '" has FAILED<br><br>'
    
    message += 'Scheduled Time: ' + get_datetime_string(install_job.scheduled_time) + ' (UTC)<br>'    
    message += 'Start Time: ' + get_datetime_string(install_job.start_time) + ' (UTC)<br>'
    message += 'Install Action: ' + install_job.install_action + '<br><br>'
    
    session_log_url = system_option.base_url + '/' + get_session_log_link(host, install_job)
    
    message += 'For more information, click the link below<br><br>'
    message += session_log_url + '<br><br>'
    
    if install_job.packages is not None and len(install_job.packages) > 0:
        message += 'Followings are the software packages: <br><br>' + install_job.packages.replace(',','<br>')
        
    message += '</body></head></html>'
    
    sendmail(
        server=smtp_server.server, 
        server_port=smtp_server.server_port,
        sender=smtp_server.sender,
        recipient=user.email,
        message=message,
        use_authentication=smtp_server.use_authentication,
        username=smtp_server.username,
        password=smtp_server.password,
        secure_connection=smtp_server.secure_connection)
开发者ID:ponnadarahul,项目名称:csm,代码行数:53,代码来源:mailer.py


示例16: create_email_job

def create_email_job(db_session, logger, message, username):
    system_option = SystemOption.get(db_session)
    if not system_option.enable_email_notify:
        return
    
    user = get_user(db_session, username)
    if user is None:
        logger.error('mailer: Unable to locate user "%s"' % username)
        return

    email_job = EmailJob(recipients=user.email, message=message, created_by=username)
    db_session.add(email_job)
    db_session.commit()
开发者ID:kstaniek,项目名称:csm,代码行数:13,代码来源:mailer.py


示例17: __init__

    def __init__(self, platform, release, refresh=False):
        self.platform = self.get_cco_supported_platform(platform)
        self.release = self.get_cco_supported_release(release)
        self.smu_meta = None
        self.smus = {}
        self.service_packs = {}
        self.in_transit_smus = {}
        self.software = {}

        if SystemOption.get(DBSession()).enable_cco_lookup or refresh:
            self.get_smu_info_from_cco(platform, release)
        else:
            self.get_smu_info_from_db(platform, release)
开发者ID:anushreejangid,项目名称:csm,代码行数:13,代码来源:smu_info_loader.py


示例18: home

def home(hostname):
    db_session = DBSession()

    host = get_host(db_session, hostname)
    if host is None:
        abort(404)

    return render_template('host/host_dashboard.html', host=host,
                           form=get_host_schedule_install_form(request),
                           system_option=SystemOption.get(db_session),
                           package_states=[PackageState.ACTIVE_COMMITTED,
                                           PackageState.ACTIVE,
                                           PackageState.INACTIVE_COMMITTED,
                                           PackageState.INACTIVE])
开发者ID:smjurcak,项目名称:csm,代码行数:14,代码来源:host_dashboard.py


示例19: login

def login():

    form = LoginForm(request.form)
    error_message = None

    if request.method == 'POST' and form.validate():
        username = form.username.data.strip()
        password = form.password.data.strip()

        db_session = DBSession()

        user, authenticated = \
            User.authenticate(db_session.query, username, password)

        if authenticated:
            login_user(user)

            # record the base URL
            try:
                system_option = SystemOption.get(db_session)
                system_option.base_url = get_base_url(request.url)
                db_session.commit()
            except:
                logger.exception('login() hit exception')

            # Certain admin features (Admin Console/Create or Edit User require
            # re-authentication. The return_url indicates which admin feature the
            # user wants to access.
            return_url = get_return_url(request)
            if return_url is None:
                return redirect(request.args.get("next") or url_for('home'))
            else:
                return redirect(url_for(return_url))
        else:
            error_message = 'Your user name or password is incorrect.  \
                             Re-enter them again or contact your system administrator.'

    # Fill the username if the user is still logged in.
    username = get_username(current_user)
    if username is not None:
        form.username.data = username

    return render_template('user/login.html', form=form, error_message=error_message, username=username)
开发者ID:smjurcak,项目名称:csm,代码行数:43,代码来源:authenticate.py


示例20: dispatch

def dispatch():
    db_session = DBSession
    system_option = SystemOption.get(db_session)

    inventory_manager = InventoryManager(system_option.inventory_threads, 'Inventory-Manager')
    inventory_manager.start()
 
    software_manager = SoftwareManager(system_option.install_threads, 'Software-Manager')
    software_manager.start()
    
    download_manager = DownloadManager(system_option.download_threads, 'Download-Manager')
    download_manager.start()

    generic_job_manager = GenericJobManager(2, 'Generic-Job')
    generic_job_manager.start()

    scheduler = Scheduler('Scheduler')
    scheduler.start()

    print('csmdispatcher started')
开发者ID:anushreejangid,项目名称:csm,代码行数:20,代码来源:csmdispatcher.py



注:本文中的models.SystemOption类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Tag类代码示例发布时间:2022-05-27
下一篇:
Python models.SyndicatedPost类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap