def get_repo(orgName, repoName, prodName=None, prodLabel=None, prodId=None, envName=None, includeDisabled=False, viewName=None, viewLabel=None, viewId=None): repo_api = RepoAPI() env = get_environment(orgName, envName) prod = get_product(orgName, prodName, prodLabel, prodId) view = None resultViewId = None if viewName or viewLabel or viewId: view = get_content_view(orgName, viewLabel, viewName, viewId) resultViewId = view["id"] repos = repo_api.repos_by_env_product(env["id"], prod["id"], repoName, includeDisabled, resultViewId) if len(repos) > 0: #repo by id call provides more information return repo_api.repo(repos[0]["id"]) if view: error = _("Could not find repository [ %(repoName)s ] within organization [ %(orgName)s ], " \ "product [ %(prodName)s ], content view [ %(viewName)s ], and environment "\ "[ %(env_name)s ]") % {'repoName':repoName, 'orgName':orgName, 'prodName':prod["name"], 'viewName':view["name"], 'env_name':env["name"]} else: error = _("Could not find repository [ %(repoName)s ] within organization [ %(orgName)s ], " \ "product [ %(prodName)s ] and environment [ %(env_name)s ]") % \ {'repoName':repoName, 'orgName':orgName, 'prodName':prod["name"], 'env_name':env["name"]} raise ApiDataError(error)
def get_repo(orgName, prodName, prodLabel, prodId, repoName, envName=None, includeDisabled=False): repo_api = RepoAPI() env = get_environment(orgName, envName) prod = get_product(orgName, prodName, prodLabel, prodId) repos = repo_api.repos_by_env_product(env["id"], prod["id"], repoName, includeDisabled) if len(repos) > 0: #repo by id call provides more information return repo_api.repo(repos[0]["id"]) raise ApiDataError(_("Could not find repository [ %(repoName)s ] within organization [ %(orgName)s ], " \ "product [ %(prodName)s ] and environment [ %(env_name)s ]") % {'repoName':repoName, 'orgName':orgName, 'prodName':prod["name"], 'env_name':env["name"]})
def get_repo(orgName, prodName, repoName, envName=None, includeDisabled=False): repo_api = RepoAPI() env = get_environment(orgName, envName) prod = get_product(orgName, prodName) repos = repo_api.repos_by_env_product(env["id"], prod["id"], repoName, includeDisabled) if len(repos) > 0: #repo by id call provides more information return repo_api.repo(repos[0]["id"]) raise ApiDataError(_("Could not find repository [ %s ] within organization [ %s ], " \ "product [ %s ] and environment [ %s ]") % (repoName, orgName, prodName, env["name"]))
def get_repo(orgName, prodName, repoName, envName=None, includeDisabled=False): repo_api = RepoAPI() env = get_environment(orgName, envName) if env == None: return None prod = get_product(orgName, prodName) if prod == None: return None repos = repo_api.repos_by_env_product(env["id"], prod["id"], repoName, includeDisabled) if len(repos) > 0: #repo by id call provides more information return repo_api.repo(repos[0]["id"]) print >> sys.stderr, _("Could not find repository [ %s ] within organization [ %s ], product [ %s ] and environment [ %s ]") % (repoName, orgName, prodName, env["name"]) return None
class Repository(): api = RepoAPI() def create_repository(self, org, prd, url, name=None, label=None, unprotected=True, gpgkey=None, nogpgkey=None): if name is None: name = generate_name(8) if label is None: label = "label-%s" % name.lower() return self.api.create(org['label'], prd['id'], name, label, url, unprotected, gpgkey, nogpgkey) def delete_repository(self, rId): return self.api.delete(rId) def repository(self, rId): return self.api.repo(rId) def repositories_by_product(self, org, prd, includeDisabled=False): return self.api.repositories_by_repo(org['label'], prd['id'], includeDisabled)
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"])
def __init__(self): super(PackageGroupAction, self).__init__() self.api = RepoAPI()
def __init__(self): super(ProductAction, self).__init__() self.api = ProductAPI() self.repoapi = RepoAPI() self.csapi = ChangesetAPI()
def __init__(self): super(RepoAction, self).__init__() self.api = RepoAPI()
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"])