Example #1
0
def _service_catalog_build(action, product_spec, config=None):
    result = helper.find_build_product(product_spec, config)
    if result['product'] is None:
        raise ValueError('Product was not found in config!')
    product = result['product']
    print(product_spec)
    update_iam_role(product_spec)
    product.add_resources(product_spec)
    if 'roleName' in product_spec:
        product.create_deployer_launch_constraint(
            helper.get_portfolio(config, name=product_spec['portfolio']),
            product_spec['roleName'])
    product.release(action, product_spec['artifact'], product.version)
    if action != 'build':
        product.tidy_versions()
Example #2
0
def delete_portfolio(portfolio_id, config=None):
    """
    Delete a portfolio.

    Args:
        id (str): The id of the portfolio to delete.
    """
    if portfolio_id is None:
        raise ValueError("A portfolio id must be provided")
    print("Deleting portfolio with id: {}".format(portfolio_id))
    portfolio = helper.get_portfolio(config, portfolio_id=portfolio_id)
    for product in portfolio.products:
        print("Disassociating product with id: {}".format(product.product_id))
        product.disassociate(portfolio.portfolio_id)
    portfolio.delete()
    config['portfolios'].remove(portfolio)
Example #3
0
def associate_product_with_portfolio(product_id, portfolio_id, config=None):
    if portfolio_id is None:
        raise ValueError("A portfolio id must be provided")
    if product_id is None:
        raise ValueError("A product id must be provided")

    portfolio = helper.get_portfolio(config, portfolio_id=portfolio_id)
    if portfolio is None:
        raise ValueError(
            "Provided portfolio does not exist in Conduit config!")

    bucket = configure()
    print("Associating product with portfolio...")
    service_catalog.associate(product_id, portfolio_id)
    print("Association successful...")
    print("Finding product by id...")
    product = factory.product_by_id(product_id, bucket)
    print("Reflecting changes in Conduit config...")
    portfolio.products.append(product)
    product.portfolio = portfolio.name
Example #4
0
def update_portfolio(portfolio_id, name=None, description=None, config=None):
    """
    Update a portfolio.

    Args:
        name (str): The name of the portfolio to create.
        description (str): A description of the portfolio to create.

    Return:-
        portfolio: An object handle on the portfolio.
    """
    if portfolio_id is None:
        raise ValueError("A portfolio ID must be provided")
    print("Updating portfolio with id: {}".format(portfolio_id))
    portfolio = helper.get_portfolio(config, portfolio_id=portfolio_id)
    if name is not None:
        portfolio.name = name
    if description is not None:
        portfolio.description = description
    portfolio.update()
    print("Portfolio updated successfully...")
Example #5
0
def new_product(name,
                description,
                cfntype,
                portfolio_name,
                tags=None,
                config=None):
    """
    Create a new product.

    Args:
        name (str): The name of the product to create.
        description (str): A brief description of the product.
        cfntype (str): One of [json, yaml, yml]
        portfolio_name (str): The name of the portfolio to add the product to.

    Return:
        product: An object handle on the new product.
    """
    if name is None or description is None or cfntype is None or portfolio_name is None:
        raise ValueError(
            "name, description, cfntype and portfolio_name must have values")
    if tags is None:
        tags = []
    print("Creating a new product...")
    product = factory.product(name,
                              portfolio_name,
                              product_description=description)
    portfolio = factory.portfolio(portfolio_name)
    portfolio_id = portfolio.get_id()
    support = dict() if 'support' not in config else config['support']
    product.create(support, tags)
    print("Product created...")
    product.add_to_portfolio(portfolio_id)
    print("Product assigned to portfolio: {}".format(portfolio_id))
    portfolio = helper.get_portfolio(config, name=portfolio_name)
    portfolio.products.append(product)
    return product