Ejemplo n.º 1
0
def add_server(component_names=None,
               certification_ids=None,
               name="",
               vendor="",
               comments="",
               specification_url=None,
               availability=None):
    with db_session:
        components = None
        certifications = None

        if component_names is not None:
            components = select(c for c in Component
                                if c.name in component_names)[:]

        if certification_ids is not None:
            certifications = select(c for c in Certification
                                    if c.id in certification_ids)[:]

        server = Server(vendor=vendor, name=name, comments=comments)

        if specification_url is not None:
            server.specification_url = specification_url

        if availability is not None:
            server.availability = availability

        if components is not None:
            for c in components:
                server.components.add(c)

        if certifications is not None:
            for c in certifications:
                server.certifications.add(c)

    return server