本文整理匯總了Python中__main__.display.vvv方法的典型用法代碼示例。如果您正苦於以下問題:Python display.vvv方法的具體用法?Python display.vvv怎麽用?Python display.vvv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類__main__.display
的用法示例。
在下文中一共展示了display.vvv方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: service_account_update
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def service_account_update(sid, groups):
"""Update service_account groups"""
display.vvv("DC/OS: IAM update service_account {}".format(sid))
for g in groups:
display.vvv("Assigning service_account {} to group {}".format(
sid,g))
cmd = [
'dcos',
'security',
'org',
'groups',
'add_user',
g,
sid
]
run_command(cmd, 'update service_account', stop_on_error=False)
示例2: get_pool_state
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def get_pool_state(pool_id, instance_name):
"""Get the current state of a pool."""
r = subprocess.check_output([
'dcos',
'edgelb',
'list',
'--name=' + instance_name,
'--json'
], env=_dcos_path())
pools = json.loads(r)
display.vvv('looking for pool_id {}'.format(pool_id))
state = 'absent'
for p in pools:
try:
if pool_id in p['name']:
state = 'present'
display.vvv('found pool: {}'.format(pool_id))
except KeyError:
continue
return state
示例3: pool_create
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def pool_create(pool_id, instance_name, options):
"""Create a pool"""
display.vvv("DC/OS: edgelb create pool {}".format(pool_id))
# create a temporary file for the options json file
with tempfile.NamedTemporaryFile('w+') as f:
json.dump(options, f)
# force write the file to disk to make sure subcommand can read it
f.flush()
os.fsync(f)
display.vvv(subprocess.check_output(
['cat', f.name]).decode())
cmd = [
'dcos',
'edgelb',
'create',
'--name=' + instance_name,
f.name
]
run_command(cmd, 'update pool', stop_on_error=True)
示例4: pool_update
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def pool_update(pool_id, instance_name, options):
"""Update an pool"""
display.vvv("DC/OS: Edgelb update pool {}".format(pool_id))
# create a temporary file for the options json file
with tempfile.NamedTemporaryFile('w+') as f:
json.dump(options, f)
# force write the file to disk to make sure subcommand can read it
f.flush()
os.fsync(f)
display.vvv(subprocess.check_output(
['cat', f.name]).decode())
cmd = [
'dcos',
'edgelb',
'update',
'--name=' + instance_name,
f.name
]
run_command(cmd, 'update pool', stop_on_error=True)
示例5: get_current_version
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def get_current_version(package, app_id):
"""Get the current version of an installed package."""
r = subprocess.check_output(['dcos', 'package', 'list', '--json', '--app-id='+app_id ], env=_dcos_path())
packages = json.loads(r)
display.vvv('looking for package {} app_id {}'.format(package, app_id))
v = None
for p in packages:
try:
if p['name'] == package and '/' + app_id in p['apps']:
v = p['version']
except KeyError:
continue
display.vvv('{} current version: {}'.format(package, v))
return v
示例6: connect_cluster
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def connect_cluster(**kwargs):
"""Connect to a DC/OS cluster by url"""
changed = False
url = kwargs.get('url')
if not check_cluster(kwargs.get('name'), url):
if url is None:
raise AnsibleActionFail(
'Not connected: you need to specify the cluster url')
display.vvv('DC/OS cluster not setup, setting up')
cli_args = parse_connect_options(**kwargs)
display.vvv('args: {}'.format(cli_args))
subprocess.check_call(['dcos', 'cluster', 'setup', url] + cli_args, env=_dcos_path())
changed = True
# ensure_auth(**kwargs)
return changed
示例7: ensure_dcos
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def ensure_dcos():
"""Check whether the dcos cli is installed."""
try:
r = subprocess.check_output(['dcos', '--version'], env=_dcos_path()).decode()
except subprocess.CalledProcessError:
raise AnsibleActionFail("DC/OS CLI is not installed!")
raw_version = ''
for line in r.strip().split('\n'):
display.vvv(line)
k, v = line.split('=')
if k == 'dcoscli.version':
raw_version = v
v = _version(raw_version)
if v < (0, 5, 0):
raise AnsibleActionFail(
"DC/OS CLI 0.5.x is required, found {}".format(v))
if v >= (0, 7, 0):
raise AnsibleActionFail(
"DC/OS CLI version > 0.7.x detected, may not work")
display.vvv("dcos: all prerequisites seem to be in order")
示例8: ensure_dcos_security
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def ensure_dcos_security():
"""Check whether the dcos[cli] security extension is installed."""
raw_version = ''
try:
r = subprocess.check_output(['dcos', 'security', '--version'], env=_dcos_path()).decode()
except:
display.vvv("dcos security: not installed")
install_dcos_security_cli()
r = subprocess.check_output(['dcos', 'security', '--version'], env=_dcos_path()).decode()
v = _version(r)
if v < (1, 2, 0):
raise AnsibleActionFail(
"DC/OS Security CLI 1.2.x is required, found {}".format(v))
display.vvv("dcos security: all prerequisites seem to be in order")
示例9: run_command
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def run_command(cmd, description='run command', stop_on_error=False, input=None):
"""Run a command and catch exceptions for Ansible."""
display.vvv("command: " + ' '.join(cmd))
from subprocess import CalledProcessError, check_output
try:
output = check_output(cmd, env=_dcos_path(),stderr=subprocess.STDOUT)
#output = check_output(cmd, env=_dcos_path())
returncode = 0
except CalledProcessError as e:
output = e.output
returncode = e.returncode
if stop_on_error and returncode != 0:
raise AnsibleActionFail('Failed to {}: {}'.format(description, e))
return output
示例10: get_app_state
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def get_app_state(app_id):
"""Get the current state of an app."""
r = subprocess.check_output(['dcos', 'marathon', 'app', 'list', '--json' ], env=_dcos_path())
apps = json.loads(r)
display.vvv('looking for app_id {}'.format(app_id))
state = 'absent'
for a in apps:
try:
if app_id in a['id']:
state = 'present'
display.vvv('found app: {}'.format(app_id))
except KeyError:
continue
return state
示例11: app_create
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def app_create(app_id, options):
"""Deploy an app via Marathon"""
display.vvv("DC/OS: Marathon create app {}".format(app_id))
# create a temporary file for the options json file
with tempfile.NamedTemporaryFile('w+') as f:
json.dump(options, f)
# force write the file to disk to make sure subcommand can read it
f.flush()
os.fsync(f)
display.vvv(subprocess.check_output(
['cat', f.name]).decode())
cmd = [
'dcos',
'marathon',
'app',
'add',
f.name
]
run_command(cmd, 'add app', stop_on_error=True)
示例12: secret_create
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def secret_create(path, value, store):
"""Create a secret"""
display.vvv("DC/OS: create secret {} with {}".format(path, value))
cmd = [
'dcos',
'security',
'secrets',
'create',
'--store-id',
store,
'--value',
value,
path
]
run_command(cmd, 'create secret', stop_on_error=True)
示例13: secret_update
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def secret_update(path, value, store):
"""Update a secret"""
display.vvv("DC/OS: update secret {} with {}".format(path, value))
cmd = [
'dcos',
'security',
'secrets',
'update',
'--store-id',
store,
'--value',
value,
path
]
run_command(cmd, 'update secret', stop_on_error=True)
示例14: group_update
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def group_update(gid, permissions):
"""Update group permissions"""
display.vvv("DC/OS: IAM update group {}".format(gid))
for p in permissions:
display.vvv("Granting {} permission on {} to group {}".format(
p['rid'], p['action'], gid))
cmd = [
'dcos',
'security',
'org',
'groups',
'grant',
gid,
p['rid'],
p['action']
]
run_command(cmd, 'update group', stop_on_error=False)
示例15: user_update
# 需要導入模塊: from __main__ import display [as 別名]
# 或者: from __main__.display import vvv [as 別名]
def user_update(uid, groups):
"""Update user groups"""
display.vvv("DC/OS: IAM update user {}".format(uid))
for g in groups:
display.vvv("Assigning user {} to group {}".format(
uid,g))
cmd = [
'dcos',
'security',
'org',
'groups',
'add_user',
g,
uid
]
run_command(cmd, 'update user', stop_on_error=False)