コード例 #1
0
ファイル: manager.py プロジェクト: akaasjager/vFense
    def get_customers_of_user(user_name=None):

        if not user_name:
            return None

        customers = []

        try:

            if user_name == AdminUser:

                all_customers = actions.db_get_all(
                    Collection.Customers
                )

            else:

                all_customers = actions.get_customers_of_user(
                    user_name=user_name
                )

            for c in all_customers:
                try:
                    customer = Customer(
                        c[CustomerKey.CustomerName],
                        c[CustomerKey.Properties],
                    )

                    customers.append(customer)

                except Exception as e:
                    logger.error('Skipping customer `%s`' % u)
                    logger.exception(e)

        except Exception as e:

            logger.error(
                'Could not get customers of user `%s` .'
                % user_name
            )
            logger.exception(e)

        return customers
コード例 #2
0
ファイル: manager.py プロジェクト: akaasjager/vFense
def get_all_customers():

    customers = []
    try:

        cs = actions.db_get_all(
            collection=Collection.Customers,
        )

        for c in cs:

            customers.append(
                Customer(
                    c[CustomerKey.CustomerName],
                    c[CustomerKey.Properties]
                )
            )

    except Exception as e:

        logger.error("Unable to get all customers")
        logger.exception(e)

    return customers