本文整理汇总了Python中appcontroller_client.AppControllerClient.set_admin_role方法的典型用法代码示例。如果您正苦于以下问题:Python AppControllerClient.set_admin_role方法的具体用法?Python AppControllerClient.set_admin_role怎么用?Python AppControllerClient.set_admin_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appcontroller_client.AppControllerClient
的用法示例。
在下文中一共展示了AppControllerClient.set_admin_role方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_instances
# 需要导入模块: from appcontroller_client import AppControllerClient [as 别名]
# 或者: from appcontroller_client.AppControllerClient import set_admin_role [as 别名]
def run_instances(cls, options):
"""Starts a new AppScale deployment with the parameters given.
Args:
options: A Namespace that has fields for each parameter that can be
passed in via the command-line interface.
Raises:
AppControllerException: If the AppController on the head node crashes.
When this occurs, the message in the exception contains the reason why
the AppController crashed.
BadConfigurationException: If the user passes in options that are not
sufficient to start an AppScale deployment (e.g., running on EC2 but
not specifying the AMI to use), or if the user provides us
contradictory options (e.g., running on EC2 but not specifying EC2
credentials).
"""
LocalState.make_appscale_directory()
LocalState.ensure_appscale_isnt_running(options.keyname, options.force)
if options.infrastructure:
if not options.disks and not options.test and not options.force:
LocalState.ensure_user_wants_to_run_without_disks()
AppScaleLogger.log("Starting AppScale " + APPSCALE_VERSION +
" over the " + options.infrastructure + " cloud.")
else:
AppScaleLogger.log("Starting AppScale " + APPSCALE_VERSION +
" over a virtualized cluster.")
my_id = str(uuid.uuid4())
AppScaleLogger.remote_log_tools_state(options, my_id, "started",
APPSCALE_VERSION)
node_layout = NodeLayout(options)
if not node_layout.is_valid():
raise BadConfigurationException("There were errors with your " + \
"placement strategy:\n{0}".format(str(node_layout.errors())))
public_ip, instance_id = RemoteHelper.start_head_node(options, my_id,
node_layout)
AppScaleLogger.log("\nPlease wait for AppScale to prepare your machines " +
"for use. This can take few minutes.")
# Write our metadata as soon as possible to let users SSH into those
# machines via 'appscale ssh'.
LocalState.update_local_metadata(options, node_layout, public_ip,
instance_id)
RemoteHelper.copy_local_metadata(public_ip, options.keyname,
options.verbose)
acc = AppControllerClient(public_ip, LocalState.get_secret_key(
options.keyname))
# Let's now wait till the server is initialized.
while not acc.is_initialized():
AppScaleLogger.log('Waiting for head node to initialize...')
# This can take some time in particular the first time around, since
# we will have to initialize the database.
time.sleep(cls.SLEEP_TIME*3)
try:
# We don't need to have any exception information here: we do expect
# some anyway while the UserAppServer is coming up.
acc.does_user_exist("non-existent-user", True)
except Exception as exception:
AppScaleLogger.log('UserAppServer not ready yet. Retrying ...')
time.sleep(cls.SLEEP_TIME)
# Update our metadata again so that users can SSH into other boxes that
# may have been started.
LocalState.update_local_metadata(options, node_layout, public_ip,
instance_id)
RemoteHelper.copy_local_metadata(public_ip, options.keyname,
options.verbose)
if options.admin_user and options.admin_pass:
AppScaleLogger.log("Using the provided admin username/password")
username, password = options.admin_user, options.admin_pass
elif options.test:
AppScaleLogger.log("Using default admin username/password")
username, password = LocalState.DEFAULT_USER, LocalState.DEFAULT_PASSWORD
else:
username, password = LocalState.get_credentials()
RemoteHelper.create_user_accounts(username, password, public_ip,
options.keyname, options.clear_datastore)
acc.set_admin_role(username, 'true', cls.ADMIN_CAPABILITIES)
RemoteHelper.wait_for_machines_to_finish_loading(public_ip, options.keyname)
# Finally, update our metadata once we know that all of the machines are
# up and have started all their API services.
LocalState.update_local_metadata(options, node_layout, public_ip,
instance_id)
RemoteHelper.copy_local_metadata(public_ip, options.keyname,
options.verbose)
RemoteHelper.sleep_until_port_is_open(LocalState.get_login_host(
options.keyname), RemoteHelper.APP_DASHBOARD_PORT, options.verbose)
AppScaleLogger.success("AppScale successfully started!")
AppScaleLogger.success("View status information about your AppScale " + \
"deployment at http://{0}:{1}/status".format(LocalState.get_login_host(
options.keyname), RemoteHelper.APP_DASHBOARD_PORT))
#.........这里部分代码省略.........
示例2: run_instances
# 需要导入模块: from appcontroller_client import AppControllerClient [as 别名]
# 或者: from appcontroller_client.AppControllerClient import set_admin_role [as 别名]
#.........这里部分代码省略.........
LocalState.ensure_user_wants_to_run_without_disks()
reduced_version = ".".join(x for x in APPSCALE_VERSION.split(".")[:2])
AppScaleLogger.log("Starting AppScale " + reduced_version)
my_id = str(uuid.uuid4())
AppScaleLogger.remote_log_tools_state(options, my_id, "started", APPSCALE_VERSION)
node_layout = NodeLayout(options)
if not node_layout.is_valid():
raise BadConfigurationException(
"There were errors with your " + "placement strategy:\n{0}".format(str(node_layout.errors()))
)
head_node = node_layout.head_node()
# Start VMs in cloud via cloud agent.
if options.infrastructure:
instance_ids, public_ips, private_ips = RemoteHelper.start_all_nodes(options, len(node_layout.nodes))
AppScaleLogger.log(
"\nPlease wait for AppScale to prepare your machines " "for use. This can take few minutes."
)
# Set newly obtained node layout info for this deployment.
for i, _ in enumerate(instance_ids):
node_layout.nodes[i].public_ip = public_ips[i]
node_layout.nodes[i].private_ip = private_ips[i]
node_layout.nodes[i].instance_id = instance_ids[i]
# Enables root logins and SSH access on the head node.
RemoteHelper.enable_root_ssh(options, head_node.public_ip)
AppScaleLogger.verbose("Node Layout: {}".format(node_layout.to_list()), options.verbose)
# Ensure all nodes are compatible.
RemoteHelper.ensure_machine_is_compatible(head_node.public_ip, options.keyname, options.verbose)
# Use rsync to move custom code into the deployment.
if options.scp:
AppScaleLogger.log("Copying over local copy of AppScale from {0}".format(options.scp))
RemoteHelper.rsync_files(head_node.public_ip, options.keyname, options.scp, options.verbose)
# Start services on head node.
RemoteHelper.start_head_node(options, my_id, node_layout)
# Write deployment metadata to disk (facilitates SSH operations, etc.)
db_master = node_layout.db_master().private_ip
head_node = node_layout.head_node().public_ip
LocalState.update_local_metadata(options, db_master, head_node)
# Copy the locations.json to the head node
RemoteHelper.copy_local_metadata(node_layout.head_node().public_ip, options.keyname, options.verbose)
# Wait for services on head node to start.
secret_key = LocalState.get_secret_key(options.keyname)
acc = AppControllerClient(head_node, secret_key)
try:
while not acc.is_initialized():
AppScaleLogger.log("Waiting for head node to initialize...")
# This can take some time in particular the first time around, since
# we will have to initialize the database.
time.sleep(cls.SLEEP_TIME * 3)
except socket.error as socket_error:
AppScaleLogger.warn("Unable to initialize AppController: {}".format(socket_error.message))
message = RemoteHelper.collect_appcontroller_crashlog(head_node, options.keyname, options.verbose)
raise AppControllerException(message)
# Set up admin account.
try:
# We don't need to have any exception information here: we do expect
# some anyway while the UserAppServer is coming up.
acc.does_user_exist("non-existent-user", True)
except Exception:
AppScaleLogger.log("UserAppServer not ready yet. Retrying ...")
time.sleep(cls.SLEEP_TIME)
if options.admin_user and options.admin_pass:
AppScaleLogger.log("Using the provided admin username/password")
username, password = options.admin_user, options.admin_pass
elif options.test:
AppScaleLogger.log("Using default admin username/password")
username, password = LocalState.DEFAULT_USER, LocalState.DEFAULT_PASSWORD
else:
username, password = LocalState.get_credentials()
RemoteHelper.create_user_accounts(username, password, head_node, options.keyname)
acc.set_admin_role(username, "true", cls.ADMIN_CAPABILITIES)
# Wait for machines to finish loading and AppScale Dashboard to be deployed.
RemoteHelper.wait_for_machines_to_finish_loading(head_node, options.keyname)
RemoteHelper.sleep_until_port_is_open(
LocalState.get_login_host(options.keyname), RemoteHelper.APP_DASHBOARD_PORT, options.verbose
)
AppScaleLogger.success("AppScale successfully started!")
AppScaleLogger.success(
"View status information about your AppScale "
+ "deployment at http://{0}:{1}".format(
LocalState.get_login_host(options.keyname), RemoteHelper.APP_DASHBOARD_PORT
)
)
AppScaleLogger.remote_log_tools_state(options, my_id, "finished", APPSCALE_VERSION)