示例#1
0
def shutdown_instance(instance, backend_client, stream):
    instance_name = instance['name']
    if instance['status'] != 'ADMIN_down':
        stream.write("Instance is not down. Shutting down instance...\n")
        jobid = backend_client.ShutdownInstance(instance_name)
        (status, error) = wait_for_job(backend_client, jobid)
        if status != 'success':
            raise CommandError("Cannot shutdown instance: %s" % error)
示例#2
0
def rename_instance(old_name, new_name, backend_client, stream=sys.stdout):
    stream.write("Renaming instance to %s\n" % new_name)

    jobid = backend_client.RenameInstance(old_name, new_name,
                                          ip_check=False, name_check=False)
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot rename instance: %s" % error)
示例#3
0
def shutdown_instance(instance, backend_client, stream=sys.stdout):
    instance_name = instance['name']
    if instance['status'] != 'ADMIN_down':
        stream.write("Instance is not down. Shutting down instance...\n")
        jobid = backend_client.ShutdownInstance(instance_name)
        (status, error) = wait_for_job(backend_client, jobid)
        if status != 'success':
            raise CommandError("Cannot shutdown instance: %s" % error)
示例#4
0
def rename_instance(old_name, new_name, backend_client, stream):
    stream.write("Renaming instance to %s\n" % new_name)

    jobid = backend_client.RenameInstance(old_name,
                                          new_name,
                                          ip_check=False,
                                          name_check=False)
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot rename instance: %s" % error)
示例#5
0
def remove_instance_nics(instance, backend_client, stream):
    instance_name = instance['name']
    ips = instance['nic.ips']
    nic_indexes = xrange(0, len(ips))
    op = map(lambda x: ('remove', x, {}), nic_indexes)
    stream.write("Removing instance nics\n")
    op.reverse()
    jobid = backend_client.ModifyInstance(instance_name, nics=op)
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot remove instance NICs: %s" % error)
示例#6
0
def remove_instance_nics(instance, backend_client, stream=sys.stdout):
    instance_name = instance['name']
    ips = instance['nic.ips']
    nic_indexes = xrange(0, len(ips))
    op = map(lambda x: ('remove', x, {}), nic_indexes)
    stream.write("Removing instance nics\n")
    op.reverse()
    jobid = backend_client.ModifyInstance(instance_name, nics=op)
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot remove instance NICs: %s" % error)
示例#7
0
def wait_server_job(server):
    jobID = server.task_job_id
    client = server.get_client()
    status, error = backend.wait_for_job(client, jobID)
    if status != "success":
        raise ValueError(error)
示例#8
0
def startup_instance(name, backend_client, stream):
    stream.write("Starting instance %s\n" % name)
    jobid = backend_client.StartupInstance(name)
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot rename instance: %s" % error)
示例#9
0
def add_public_nic(instance_name, nic, backend_client, stream):
    stream.write("Adding public NIC %s\n" % nic)
    jobid = backend_client.ModifyInstance(instance_name, nics=[('add', nic)])
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot rename instance: %s" % error)
示例#10
0
文件: common.py 项目: AthinaB/synnefo
def wait_ganeti_job(client, jobID, stdout):
    status, error = backend_mod.wait_for_job(client, jobID)
    if status == "success":
        stdout.write("Job finished successfully.\n")
    else:
        raise CommandError("Job failed! Error: %s\n" % error)
示例#11
0
def wait_ganeti_job(client, jobID, stdout):
    status, error = backend_mod.wait_for_job(client, jobID)
    if status == "success":
        stdout.write("Job finished successfully.\n")
    else:
        raise CommandError("Job failed! Error: %s\n" % error)
示例#12
0
def startup_instance(name, backend_client, stream=sys.stdout):
    stream.write("Starting instance %s\n" % name)
    jobid = backend_client.StartupInstance(name)
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot rename instance: %s" % error)
示例#13
0
def add_public_nic(instance_name, nic, backend_client, stream=sys.stdout):
    stream.write("Adding public NIC %s\n" % nic)
    jobid = backend_client.ModifyInstance(instance_name, nics=[('add', nic)])
    (status, error) = wait_for_job(backend_client, jobid)
    if status != 'success':
        raise CommandError("Cannot rename instance: %s" % error)