How to use setup_options method in autotest

Best Python code snippet using autotest_python

ceph_facts

Source:ceph_facts Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf-8 -*-3# (c) 2013, Jimmy Tang <jcftang@gmail.com>4#5# This file is part of Ansible6#7# Ansible is free software: you can redistribute it and/or modify8# it under the terms of the GNU General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# Ansible is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU General Public License for more details.16#17# You should have received a copy of the GNU General Public License18# along with Ansible. If not, see <http://www.gnu.org/licenses/>.19#20import fnmatch21DOCUMENTATION = '''22---23module: ceph_facts24short_description: Runs the I(ceph) monitoring programs on the remote system25description:26 - Runs the I(ceph) program to discover the filesystem status27 returning JSON data that can be useful for inventory purposes.28version_added: "1.1"29options:30 filter:31 description:32 - if supplied, only return facts that match this shell-style (fnmatch) wildcard.33 required: false34 default: '*' 35examples:36 - code: ansible monitor-ceph01.cluster -m ceph_facts37 description: "Get all the possible known information from ceph cluster"38 - code: ansible monitor-ceph01.cluster -m ceph_facts -a 'filter=quorum*'39 description: "Get all the information related to quorum status"40notes:41 - The facts are not very structured right now and requires more work.42requirements: [ "ceph" ]43author: Jimmy Tang44'''45try: 46 import json 47except ImportError: 48 import simplejson as json49def run_ceph_facts(module):50 setup_options = {}51 facts = {}52 # check for quorum of cluster, monmap53 cmd = ["/usr/bin/env", "ceph", "quorum_status"]54 rc, out, err = module.run_command(cmd, check_rc=True)55 quorum = True56 try:57 quorum_ds = json.loads(out)58 except:59 quorum = False60 if quorum:61 for (k,v) in quorum_ds.items():62 setup_options["quorum_status_%s" % k] = v63 # check for status of osd's64 cmd = ["/usr/bin/env", "ceph", "osd", "dump", "--format=json"]65 rc, out, err = module.run_command(cmd, check_rc=True)66 osd = True67 try:68 osd_ds = json.loads(out)69 except:70 osd = False71 if osd:72 for (k,v) in osd_ds.items():73 setup_options["osd_status_%s" % k] = v74 # check for status of mds's75 cmd = ["/usr/bin/env", "ceph", "mds", "dump", "--format=json"]76 rc, out, err = module.run_command(cmd, check_rc=True)77 mds = True78 try:79 mds_ds = json.loads(out)80 except:81 mds = False82 if mds:83 for (k,v) in mds_ds.items():84 setup_options["mds_status_%s" % k] = v85# # check for status of placement groups86# cmd = ["/usr/bin/env", "ceph", "pg", "dump", "--format=json"]87# rc, out, err = module.run_command(cmd, check_rc=True)88# pg = True89# try:90# pg_ds = json.loads(out)91# except:92# pg = False93# if pg:94# for (k,v) in pg_ds.items():95# setup_options["pg_%s" % k] = v96 # show osd tree97 cmd = ["/usr/bin/env", "ceph", "osd", "tree", "--format=json"]98 rc, out, err = module.run_command(cmd, check_rc=True)99 osd_tree = True100 try:101 osd_tree_ds = json.loads(out)102 except:103 osd_tree = False104 if osd_tree:105 for (k,v) in osd_tree_ds.items():106 setup_options["osd_tree_%s" % k] = v107 # show rados df108 cmd = ["/usr/bin/env", "rados", "df", "--format=json"]109 rc, out, err = module.run_command(cmd, check_rc=True)110 rados_df = True111 try:112 rados_df_ds = json.loads(out)113 except:114 rados_df = False115 if rados_df:116 for (k,v) in rados_df_ds.items():117 setup_options["rados_df_%s" % k] = v118 setup_options['rbd_images'] = {}119 for pool in setup_options.get('osd_status_pools', []):120 if 'rbd' in pool['application_metadata']:121 pool_name = pool['pool_name']122 setup_options['rbd_images'][pool_name] = {}123 cmd = ["/usr/bin/env", "rbd", "list", pool_name, "--format=json"]124 rc, out, err = module.run_command(cmd, check_rc=True)125 try:126 images = json.loads(out)127 except json.JsonDecodeError:128 continue129 for image in images:130 setup_options['rbd_images'][pool_name][image] = {}131 cmd = ["/usr/bin/env", "rbd", "status", pool_name+'/'+image, "--format=json"]132 rc, out, err = module.run_command(cmd, check_rc=True)133 try:134 setup_options['rbd_images'][pool_name][image]['status'] = json.loads(out)135 except json.JsonDecodeError:136 continue137 cmd = ["/usr/bin/env", "rbd", "info", pool_name+'/'+image, "--format=json"]138 rc, out, err = module.run_command(cmd, check_rc=True)139 try:140 setup_options['rbd_images'][pool_name][image]['info'] = json.loads(out)141 except json.JsonDecodeError:142 continue143 # business as usual144 for (k, v) in facts.items(): 145 setup_options["ansible_%s" % k.replace('-', '_')] = v146 ceph_facts_result = { 'ansible_facts': {} }147 for (k,v) in setup_options.items():148 if module.params['filter'] == '*' or fnmatch.fnmatch(k, module.params['filter']):149 ceph_facts_result['ansible_facts'][k] = v150 return ceph_facts_result151def main():152 global module153 module = AnsibleModule(154 argument_spec = dict(155 filter=dict(default="*", required=False),156 )157 )158 data = run_ceph_facts(module)159 module.exit_json(**data)160from ansible.module_utils.basic import *...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

1#!/usr/bin/env python2# This file is part of Xpra.3# Copyright (C) 2010-2013 Antoine Martin <antoine@devloop.org.uk>4# Xpra is released under the terms of the GNU GPL v2, or, at your option, any5# later version. See the file COPYING for details.6import glob7from distutils.core import setup8from distutils.extension import Extension9import py2app #@UnresolvedImport10assert py2app is not None11import subprocess, sys, traceback12import os.path13import stat14setup_options = {}15setup_options["name"] = "Xpra"16setup_options["author"] = "Antoine Martin"17setup_options["author_email"] = "antoine@devloop.org.uk"18setup_options["version"] = "0.8.0"19setup_options["url"] = "http://xpra.org/"20setup_options["download_url"] = "http://xpra.org/src/"21setup_options["description"] = """'screen for X' -- a tool to detach/reattach running X programs"""22data_files = []23setup_options["data_files"] = data_files24packages = ["osxxpra"]25setup_options["packages"] = packages26Plist = dict(CFBundleDocumentTypes=[27 dict(CFBundleTypeExtensions=["Xpra"],28 CFBundleTypeName="Xpra Session Config File",29 CFBundleName="Xpra",30 CFBundleTypeRole="Viewer"),31 ]32 )33setup_options["app"]= ["osxxpra/osx_xpra_launcher.py"]34includes = ["glib", "gio", "cairo", "pango", "pangocairo", "atk", "gobject", "gtk.keysyms",35 "osxxpra",36 "hashlib", "Image"]37py2app_options = {38 'iconfile': './xpra.icns',39 'plist': Plist,40 'site_packages': False,41 'argv_emulation': True,42 'strip': False,43 "includes": includes,44 'packages': packages,45 "frameworks": ['CoreFoundation', 'Foundation', 'AppKit'],46 }47print("")48print("py2app setup_options:")49for k,v in py2app_options.items():50 print("%s : %s" % (k,v))51print("")52setup_options["options"] = {"py2app": py2app_options}53xpra_src = "../src/"54data_files += [55 ("share/man/man1", [xpra_src+"man/xpra.1", xpra_src+"man/xpra_launcher.1"]),56 ("share/xpra", [xpra_src+"README", xpra_src+"COPYING"]),57 ("share/xpra/icons", glob.glob(xpra_src+"icons/*")),58 ("share/applications", [xpra_src+"xdg/xpra_launcher.desktop"]),59 ("share/applications", [xpra_src+"xdg/xpra.desktop"]),60 ("share/icons", [xpra_src+"xdg/xpra.png"])61 ]62data_files.append(('share/xpra/webm', [xpra_src+"xpra/codecs/webm/LICENSE"]))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful