Ejemplo n.º 1
0
def create_data(numorgs, numsystems, numproducts, singleorg):
    # Setup connection to Katello
    admin = AdminCLI()
    admin.setup_parser()
    admin.opts, admin.args = admin.parser.parse_args([])
    admin.setup_server()
    admin._username = "******"
    admin._password = "******"
    org_names = []
    if (singleorg):
        # If we pass in a single org name
        # we just load all the data into that.
        org_names.append(singleorg)
    else:
        # Otherwise just create fake orgs
        orgapi = OrganizationAPI()
        print "Creating [%s] Orgs" % numorgs
        for i in range(numorgs):
            name = "Org-%s" % randomString()
            org_names.append(name)
            print "[%s] Creating org with name [%s]" % (i, name)
            orgapi.create(name, "description")

    # create envs
    envapi = EnvironmentAPI()

    for i in range(len(org_names)):
        print "[%s] Creating DEV/TEST/STAGE in org: [%s]" % (i, org_names[i])
        libraryId = get_environment(org_names[i], "Library")["id"]
        print "Library ID: %s" % libraryId
        envids = [libraryId]
        for x in range(len(ENVIRONMENTS)):
            existing_env = get_environment(org_names[i], ENVIRONMENTS[x])
            if not existing_env:
                e = envapi.create(org_names[i], ENVIRONMENTS[x], "Desc",
                                  envids[x])
                envids.append(e["id"])
            else:
                envids.append(existing_env["id"])

    ## Create systems
    print "Creating [%s] Systems in each org and assigning to random envs" % numsystems
    for i in range(len(org_names)):
        systemapi = SystemAPI()
        for x in range(numsystems):
            system_name = "System-%s" % randomString()
            randenv = random.choice(ENVIRONMENTS)
            print "Registering system: [%s] in environment: [%s]" % (
                system_name, randenv)
            system = systemapi.register(system_name, org_names[i], randenv, [],
                                        'system')
            print "[%s] Created system: %s" % (x, system["name"])
Ejemplo n.º 2
0
def create_data(numorgs, numsystems, numproducts, singleorg):
    # Setup connection to Katello
    admin = AdminCLI()
    admin.setup_parser()
    admin.opts, admin.args = admin.parser.parse_args([])
    admin.setup_server()
    admin._username = "******"
    admin._password = "******"
    org_names = []
    if (singleorg):
        # If we pass in a single org name 
        # we just load all the data into that.
        org_names.append(singleorg)
    else:
        # Otherwise just create fake orgs
        orgapi = OrganizationAPI()
        print "Creating [%s] Orgs" % numorgs 
        for i in range(numorgs):
            name = "Org-%s"  % randomString()
            org_names.append(name)
            print "[%s] Creating org with name [%s]" % (i, name)
            orgapi.create(name, "description")
        
    # create envs
    envapi = EnvironmentAPI()

    for i in range(len(org_names)):
        print "[%s] Creating DEV/TEST/STAGE in org: [%s]" % (i, org_names[i])
        libraryId = get_environment(org_names[i], "Library")["id"]
        print "Library ID: %s" % libraryId
        envids = [libraryId]
        for x in range(len(ENVIRONMENTS)):
            existing_env = get_environment(org_names[i], ENVIRONMENTS[x])
            if not existing_env:
                e = envapi.create(org_names[i], ENVIRONMENTS[x], "Desc", envids[x])
                envids.append(e["id"])
            else:
                envids.append(existing_env["id"])

    ## Create systems
    print "Creating [%s] Systems in each org and assigning to random envs" % numsystems 
    for i in range(len(org_names)):
        systemapi = SystemAPI()
        for x in range(numsystems):
            system_name = "System-%s" % randomString()
            randenv = random.choice(ENVIRONMENTS)
            print "Registering system: [%s] in environment: [%s]" % (system_name, randenv)
            system = systemapi.register(system_name, org_names[i], randenv, [], 'system')
            print "[%s] Created system: %s" % (x, system["name"])
Ejemplo n.º 3
0
def create_data(numorgs, numsystems, numproviders, numproducts, numrepos,
                singleorg):
    # Setup connection to Katello
    admin = AdminCLI()
    admin.setup_parser()
    admin.opts, admin.args = admin.parser.parse_args([])
    admin.setup_server()
    admin._username = "******"
    admin._password = "******"
    org_names = []
    if (singleorg):
        # If we pass in a single org name
        # we just load all the data into that.
        org_names.append(singleorg)
    else:
        # Otherwise just create fake orgs
        orgapi = OrganizationAPI()
        print "Creating [%s] Orgs" % numorgs
        for i in range(numorgs):
            name = "Org-%s" % randomString()
            org_names.append(name)
            print "[%s] Creating org with name [%s]" % (i, name)
            orgapi.create(name, "description")

    # create envs
    envapi = EnvironmentAPI()

    for i in range(len(org_names)):
        print "[%s] Creating DEV/TEST/STAGE in org: [%s]" % (i, org_names[i])
        libraryId = get_environment(org_names[i], "Library")["id"]
        print "Library ID: %s" % libraryId
        envids = [libraryId]
        for x in range(len(ENVIRONMENTS)):
            existing_env = get_environment(org_names[i], ENVIRONMENTS[x])
            if not existing_env:
                e = envapi.create(org_names[i], ENVIRONMENTS[x], "Desc",
                                  envids[x])
                envids.append(e["id"])
            else:
                envids.append(existing_env["id"])

    ## create providers, products and repos
    print "Creating [%s] providers in each org" % numproviders
    for i in range(len(org_names)):
        for y in range(numproviders):
            provider_name = "Provider-%s" % randomString()
            print "[%s] Creating Provider with name: [%s] in org: [%s] and products + repos" % (
                y, provider_name, org_names[i])
            providerapi = ProviderAPI()
            provider = providerapi.create(provider_name, org_names[i], "Desc",
                                          "Custom", None)
            print "  Creating [%s] Products in each provider" % numproducts
            for z in range(numproducts):
                product_name = "P-%s" % randomString()
                print "  [%s] Creating product with name: [%s]" % (
                    z, product_name)
                productapi = ProductAPI()
                product = productapi.create(provider["id"], product_name,
                                            "Desc", None)
                print "    Creating [%s] Products in each product" % numproducts
                for x in range(numrepos):
                    repo_name = "Repo-%s" % randomString()
                    print "    [%s] Creating repo with name: [%s]" % (
                        x, repo_name)
                    repoapi = RepoAPI()
                    url = "http://repos.example.com/%s" % repo_name
                    repoapi.create(org_names[i], product["id"], repo_name, url,
                                   None, True)
    ## Create systems
    print "Creating [%s] Systems in each org and assigning to random envs" % numsystems
    for i in range(len(org_names)):
        systemapi = SystemAPI()
        for x in range(numsystems):
            system_name = "System-%s" % randomString()
            randenv = random.choice(ENVIRONMENTS)
            print "Registering system: [%s] in environment: [%s]" % (
                system_name, randenv)
            system = systemapi.register(system_name, org_names[i], randenv, [],
                                        'system')
            print "[%s] Created system: %s" % (x, system["name"])
Ejemplo n.º 4
0
def create_data(numorgs, numsystems, numproviders, numproducts, numrepos, singleorg):
    # Setup connection to Katello
    admin = AdminCLI()
    admin.setup_parser()
    admin.opts, admin.args = admin.parser.parse_args([])
    admin.setup_server()
    admin._username = "******"
    admin._password = "******"
    org_names = []
    if (singleorg):
        # If we pass in a single org name 
        # we just load all the data into that.
        org_names.append(singleorg)
    else:
        # Otherwise just create fake orgs
        orgapi = OrganizationAPI()
        print "Creating [%s] Orgs" % numorgs 
        for i in range(numorgs):
            name = "Org-%s"  % randomString()
            org_names.append(name)
            print "[%s] Creating org with name [%s]" % (i, name)
            orgapi.create(name, "description")
        
    # create envs
    envapi = EnvironmentAPI()

    for i in range(len(org_names)):
        print "[%s] Creating DEV/TEST/STAGE in org: [%s]" % (i, org_names[i])
        libraryId = get_environment(org_names[i], "Library")["id"]
        print "Library ID: %s" % libraryId
        envids = [libraryId]
        for x in range(len(ENVIRONMENTS)):
            existing_env = get_environment(org_names[i], ENVIRONMENTS[x])
            if not existing_env:
                e = envapi.create(org_names[i], ENVIRONMENTS[x], "Desc", envids[x])
                envids.append(e["id"])
            else:
                envids.append(existing_env["id"])

    ## create providers, products and repos
    print "Creating [%s] providers in each org" % numproviders 
    for i in range(len(org_names)):
        for y in range(numproviders):
            provider_name = "Provider-%s" % randomString()
            print "[%s] Creating Provider with name: [%s] in org: [%s] and products + repos" % (y, provider_name, org_names[i])
            providerapi = ProviderAPI()
            provider = providerapi.create(provider_name, org_names[i], "Desc", "Custom", None)
            print "  Creating [%s] Products in each provider" % numproducts 
            for z in range(numproducts):
                product_name = "P-%s" % randomString()
                print "  [%s] Creating product with name: [%s]" % (z, product_name)
                productapi = ProductAPI()
                product = productapi.create(provider["id"], product_name, "Desc", None)
                print "    Creating [%s] Products in each product" % numproducts 
                for x in range(numrepos):
                    repo_name = "Repo-%s" % randomString()
                    print "    [%s] Creating repo with name: [%s]" % (x, repo_name)
                    repoapi = RepoAPI()
                    url = "http://repos.example.com/%s" % repo_name
                    repoapi.create(org_names[i], product["id"], repo_name, url, None, True)
    ## Create systems
    print "Creating [%s] Systems in each org and assigning to random envs" % numsystems 
    for i in range(len(org_names)):
        systemapi = SystemAPI()
        for x in range(numsystems):
            system_name = "System-%s" % randomString()
            randenv = random.choice(ENVIRONMENTS)
            print "Registering system: [%s] in environment: [%s]" % (system_name, randenv)
            system = systemapi.register(system_name, org_names[i], randenv, [], 'system')
            print "[%s] Created system: %s" % (x, system["name"])