示例#1
0
def container_list(username, project_name, service_name):
    name_list = database_update.container_list(username, project_name, service_name)

    if name_list is None:
        return None

    data = []
    for container_name in name_list:
        data.append(get_container(username, project_name, service_name, container_name[0]))

    return data
示例#2
0
def service_monitor(username, project_name, service_name):
    containers = database_update.container_list(username, project_name, service_name)

    if containers is None:
        return None

    rel = []
    for container_name in containers:
        con_monitor = container_monitor(username, project_name, service_name, container_name[0])
        if con_monitor is None:
            continue
        rel.append({'container_name': container_name[0], 'list': con_monitor})

    return rel
示例#3
0
文件: service.py 项目: monkey-H/nap
    def get_service_by_name(cls, username, project_name, service_name):
        service = Service(service_name, project_name, username)

        container_list = database_update.container_list(username, project_name, service_name)

        print 'container_list'
        print container_list

        for container_name in container_list:
            full_name = container_name[0] + config.split_mark + project_name + config.split_mark + username
            ip = database_update.container_ip(username, project_name, service_name, container_name[0])
            client = Client(ip, config.c_version)
            cont = Container.get_container_by_name(client, full_name)
            service.containers.append(cont)

        return service
示例#4
0
def project_monitor(username, project_name):
    services = database_update.service_list(username, project_name)
    rel = []
    for service in services:
        print service[0]
        container_ll = database_update.container_list(username, project_name, service[0])
        if container_ll is None:
            continue
        for container in container_ll:
            if container is None:
                continue
            con_monitor = container_monitor(username, project_name, service[0], container[0])
            if con_monitor is None:
                continue
            rel.append({'container_name': container[0], 'list': con_monitor})

    return rel
示例#5
0
    def get_service_by_name(cls, username, project_name, service_name):
        service = Service(service_name, project_name, username)

        container_list = database_update.container_list(
            username, project_name, service_name)

        print 'container_list'
        print container_list

        for container_name in container_list:
            full_name = container_name[
                0] + config.split_mark + project_name + config.split_mark + username
            ip = database_update.container_ip(username, project_name,
                                              service_name, container_name[0])
            client = Client(ip, config.c_version)
            cont = Container.get_container_by_name(client, full_name)
            service.containers.append(cont)

        return service
示例#6
0
config = {'name': 'hello', 'scale': 2}
# if __name__ == '__main__':
# ip_list = ['114.212.189.147:2376', '114.212.189.140:2376']
# database_update.create_machine(ip_list)
# database_update.create_user('test', '*****@*****.**')
# database_update.create_project()
database_update.create_project('test', 'project', '*****@*****.**')
# print database_update.get_machine()
print database_update.project_list('test', 0, 2)
print database_update.project_exists('test', 'project')
print database_update.project_exists('test', 'projects')
database_update.create_service('test', 'project', 'service', config, 2)
print database_update.service_list('test', 'project')
database_update.create_container('test', 'project', 'service', 'service0',
                                 '114.212.189.147:2376')
print database_update.container_list('test', 'project', 'service')
print database_update.container_ip('test', 'project', 'service', 'service0')
# print database_update.delete_container_by_name('test', 'project', 'service', 'service0')
print database_update.container_list('test', 'project', 'service')
# print database_update.service_list('test', 'project')
# print database_update.project_list('test', 0, 2)
# database_update.delete_project('test', 'project')
print database_update.project_list('test', 0, 10)

# db = MySQLdb.connect(config.database_url, config.database_user, config.database_passwd, config.database)
# cursor = db.cursor()
# cursor.execute("select name from user")
#
# data = cursor.fetchall()
# for item in data:
#     print item[0]
示例#7
0
config = {'name': 'hello', 'scale': 2}
# if __name__ == '__main__':
    # ip_list = ['114.212.189.147:2376', '114.212.189.140:2376']
    # database_update.create_machine(ip_list)
    # database_update.create_user('test', '*****@*****.**')
    # database_update.create_project()
database_update.create_project('test', 'project', '*****@*****.**')
    # print database_update.get_machine()
print database_update.project_list('test', 0, 2)
print database_update.project_exists('test', 'project')
print database_update.project_exists('test', 'projects')
database_update.create_service('test', 'project', 'service', config, 2)
print database_update.service_list('test', 'project')
database_update.create_container('test', 'project', 'service', 'service0', '114.212.189.147:2376')
print database_update.container_list('test', 'project', 'service')
print database_update.container_ip('test', 'project', 'service', 'service0')
# print database_update.delete_container_by_name('test', 'project', 'service', 'service0')
print database_update.container_list('test', 'project', 'service')
    # print database_update.service_list('test', 'project')
    # print database_update.project_list('test', 0, 2)
# database_update.delete_project('test', 'project')
print database_update.project_list('test', 0, 10)

# db = MySQLdb.connect(config.database_url, config.database_user, config.database_passwd, config.database)
# cursor = db.cursor()
# cursor.execute("select name from user")
#
# data = cursor.fetchall()
# for item in data:
#     print item[0]