def get_snapshot(id):
    manager = get_manager()
    server = data.get_server_provider_id(id)
    droplet = manager.get_droplet(id)
    snapshots = droplet.get_data("https://api.digitalocean.com/v2/droplets/%s/snapshots?page=1&per_page=1" % str(id))
    for snapshot in snapshots['snapshots']:
        data.make_do_snapshot(str(server[0]['_id']), snapshot['id'], snapshot['name'], snapshot['min_disk_size'])
def import_linodes():
    linodes = get_linodes()
    try:
        for linode in linodes:
            linode_id = linode['LINODEID']
            server = data.get_server_provider_id(int(linode_id))
            if server.count() == 0:
                if linode['STATUS'] == 1:
                    state = 1
                elif linode['STATUS'] == 2:
                    state = 0
                else:
                    state = 2
                linode_ip = get_linode_ip(int(linode['LINODEID']))
                plan = data.get_linode_plan_id(linode['PLANID'])
                server_id = data.make_server(linode['LABEL'],
                                             plan[0]['disk'],
                                             linode['DISTRIBUTIONVENDOR'],
                                             linode['TOTALRAM'],
                                             plan[0]['cores'],
                                             type="linode",
                                             id=int(linode['LINODEID']),
                                             ip=linode_ip['IPADDRESS'],
                                             state=state)
    except:
        pass
Exemple #3
0
def get_snapshot(id):
    manager = get_manager()
    server = data.get_server_provider_id(id)
    droplet = manager.get_droplet(id)
    snapshots = droplet.get_data(
        "https://api.digitalocean.com/v2/droplets/%s/snapshots?page=1&per_page=1"
        % str(id))
    for snapshot in snapshots['snapshots']:
        data.make_do_snapshot(str(server[0]['_id']), snapshot['id'],
                              snapshot['name'], snapshot['min_disk_size'])
def import_droplets():
    droplets = get_droplets()
    for droplet in droplets:
        droplet_id = str(droplet).split(" ")[0]
        server = data.get_server_provider_id(int(droplet_id))
        print server.count()
        if server.count() == 0:
            droplet_obj = get_droplet(droplet_id)
            if droplet.status == "active":
                state = 1
            elif droplet.status == "off":
                state = 0
            else:
                state = 2
            server_id = data.make_server(droplet.name, droplet.disk, droplet.image[
                                         'slug'], droplet.memory, droplet.vcpus, type="do", id=int(droplet.id), ip=droplet.ip_address, state=state)
def import_linodes():
    linodes = get_linodes()
    try:
        for linode in linodes:
            linode_id = linode['LINODEID']
            server = data.get_server_provider_id(int(linode_id))
            if server.count() == 0:
                if linode['STATUS'] == 1:
                    state = 1
                elif linode['STATUS'] == 2:
                    state = 0
                else:
                    state = 2
                linode_ip = get_linode_ip(int(linode['LINODEID']))
                plan = data.get_linode_plan_id(linode['PLANID'])
                server_id = data.make_server(linode['LABEL'], plan[0]['disk'], linode['DISTRIBUTIONVENDOR'], linode[
                                             'TOTALRAM'], plan[0]['cores'], type="linode", id=int(linode['LINODEID']), ip=linode_ip['IPADDRESS'], state=state)
    except:
        pass
Exemple #6
0
def import_droplets():
    droplets = get_droplets()
    for droplet in droplets:
        droplet_id = str(droplet).split(" ")[0]
        server = data.get_server_provider_id(int(droplet_id))
        print server.count()
        if server.count() == 0:
            droplet_obj = get_droplet(droplet_id)
            if droplet.status == "active":
                state = 1
            elif droplet.status == "off":
                state = 0
            else:
                state = 2
            server_id = data.make_server(droplet.name,
                                         droplet.disk,
                                         droplet.image['slug'],
                                         droplet.memory,
                                         droplet.vcpus,
                                         type="do",
                                         id=int(droplet.id),
                                         ip=droplet.ip_address,
                                         state=state)