コード例 #1
0
def update(id, name=None, password=None):
    params = {}
    if password:
        if password.lower() == 'true':
            password = getpass.getpass("New Password: ")
        params['adminPassword'] = password
    if name:
        params['name'] = name
    print getattr(get_server_api().servers, id).PUT(**params)
コード例 #2
0
def create(name, imageId, flavorId, metadata={}, personality=[]):
    mosso = get_server_api()
    response = mosso.servers.POST(
        name=name,
        imageId=int(imageId),
        flavorId=int(flavorId),
        metadata=metadata,
        personality=personality
    )

    result = {"servers": [response['server'], ]}
    detail_output(result=result, title="New Server", key='server')
コード例 #3
0
def list(id, public=False, private=False):
    mosso = getattr(get_server_api().servers, id)

    if public:
        result = mosso.ips.public()
        title = 'Public IPs'
    elif private:
        result = mosso.ips.private()
        title = 'Private IPs'

    if public or private:
        print "%s:" % title
        for address in result[public and 'public' or 'private']:
            print '    %s' % address
    else:
        result = mosso.ips()
        print "IPs:"
        for key, addresses in result['addresses'].items():
            print " - %s" % key.capitalize()
            for address in addresses:
                print "    %s" % address
コード例 #4
0
def delete(id):
    mosso = get_server_api()
    print getattr(mosso.servers, id).DELETE()