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
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
Example #4
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)