Example #1
0
def add_supported_app_to_agents(username, customer_name, uri, method, agent_id=None):

    if agent_id:
        agent_info = get_agent_info(agent_id)
        apps_info = (
            fetch_apps_data_by_os_code(
                agent_info[AgentKey.OsCode],
                customer_name,
                collection=AppCollections.SupportedApps,
            )
        )
        if len(apps_info) > 0:
            for app_info in apps_info:
                app_id = app_info.get(SupportedAppsKey.AppId)
                file_data = fetch_file_data(app_id)
                add_file_data(
                    app_id, file_data, agent_id
                )
                agent_info_to_insert = (
                    {
                        SupportedAppsPerAgentKey.AgentId: agent_id,
                        SupportedAppsPerAgentKey.AppId: app_id,
                        SupportedAppsPerAgentKey.Status: AVAILABLE,
                        SupportedAppsPerAgentKey.CustomerName: customer_name,
                        SupportedAppsPerAgentKey.InstallDate: r.epoch_time(0.0)
                    }
                )
                insert_app_data(
                    agent_info_to_insert,
                    collection=AppCollections.SupportedAppsPerAgent
                )
Example #2
0
def add_supported_app_to_agents(username,
                                customer_name,
                                uri,
                                method,
                                agent_id=None):

    if agent_id:
        agent_info = get_agent_info(agent_id)
        apps_info = (fetch_apps_data_by_os_code(
            agent_info[AgentKey.OsCode],
            customer_name,
            collection=AppCollections.SupportedApps,
        ))
        if len(apps_info) > 0:
            for app_info in apps_info:
                app_id = app_info.get(SupportedAppsKey.AppId)
                file_data = fetch_file_data(app_id)
                add_file_data(app_id, file_data, agent_id)
                agent_info_to_insert = ({
                    SupportedAppsPerAgentKey.AgentId:
                    agent_id,
                    SupportedAppsPerAgentKey.AppId:
                    app_id,
                    SupportedAppsPerAgentKey.Status:
                    AVAILABLE,
                    SupportedAppsPerAgentKey.CustomerName:
                    customer_name,
                    SupportedAppsPerAgentKey.InstallDate:
                    r.epoch_time(0.0)
                })
                insert_app_data(
                    agent_info_to_insert,
                    collection=AppCollections.SupportedAppsPerAgent)
Example #3
0
def get_all_supported_apps_for_agent(agent_id):
    agent = get_agent_info(agent_id)
    apps = fetch_apps_data_by_os_code(agent[AgentKey.OsCode], collection=DownloadCollections.LatestDownloadedSupported)

    if apps:
        try:
            update_apps = IncomingSupportedApps()
            update_apps.update_agents_with_supported(apps, [agent])
        except Exception as e:
            logger.exception(e)
Example #4
0
def add_custom_app_to_agents(username,
                             customer_name,
                             uri,
                             method,
                             file_data,
                             agent_id=None,
                             app_id=None):

    if app_id and not agent_id:
        app_info = (fetch_app_data(app_id,
                                   collection=AppCollections.CustomApps))

        agent_ids = get_all_agent_ids(customer_name,
                                      agent_os=app_info[AgentKey.OsCode])
        if len(agent_ids) > 0:
            for agentid in agent_ids:
                add_file_data(app_id, file_data, agent_id)
                agent_info_to_insert = ({
                    CustomAppsPerAgentKey.AgentId:
                    agentid,
                    CustomAppsPerAgentKey.AppId:
                    app_id,
                    CustomAppsPerAgentKey.Status:
                    CommonAppKeys.AVAILABLE,
                    CustomAppsPerAgentKey.CustomerName:
                    customer_name,
                    CustomAppsPerAgentKey.InstallDate:
                    r.epoch_time(0.0)
                })
                insert_app_data(agent_info_to_insert,
                                collection=AppCollections.CustomAppsPerAgent)

    if agent_id and not app_id:
        agent_info = get_agent_info(agent_id)
        apps_info = fetch_apps_data_by_os_code(
            agent_info[AgentKey.OsCode],
            customer_name,
            collection=AppCollections.CustomApps)

        for app_info in apps_info:
            app_id = app_info.get(CustomAppsKey.AppId)
            file_data = fetch_file_data(app_id)
            add_file_data(app_id, file_data, agent_id)

            agent_info_to_insert = {
                CustomAppsPerAgentKey.AgentId: agent_id,
                CustomAppsPerAgentKey.AppId: app_id,
                CustomAppsPerAgentKey.Status: CommonAppKeys.AVAILABLE,
                CustomAppsPerAgentKey.CustomerName: customer_name,
                CustomAppsPerAgentKey.InstallDate: r.epoch_time(0.0)
            }

            insert_app_data(agent_info_to_insert,
                            collection=AppCollections.CustomAppsPerAgent)
Example #5
0
def get_all_supported_apps_for_agent(agent_id):
    agent = get_agent_info(agent_id)
    apps = fetch_apps_data_by_os_code(
        agent[AgentKey.OsCode],
        collection=DownloadCollections.LatestDownloadedSupported)

    if apps:
        try:
            update_apps = IncomingSupportedApps()
            update_apps.update_agents_with_supported(apps, [agent])
        except Exception as e:
            logger.exception(e)
Example #6
0
def add_custom_app_to_agents(username, customer_name, uri, method,
                             file_data, agent_id=None, app_id=None):

    if app_id and not agent_id:
        app_info = (
            fetch_app_data(
                app_id, collection=AppCollections.CustomApps
            )
        )

        agent_ids = get_all_agent_ids(customer_name, agent_os=app_info[AgentKey.OsCode])
        if len(agent_ids) > 0:
            for agentid in agent_ids:
                add_file_data(app_id, file_data, agent_id)
                agent_info_to_insert = (
                    {
                        CustomAppsPerAgentKey.AgentId: agentid,
                        CustomAppsPerAgentKey.AppId: app_id,
                        CustomAppsPerAgentKey.Status: CommonAppKeys.AVAILABLE,
                        CustomAppsPerAgentKey.CustomerName: customer_name,
                        CustomAppsPerAgentKey.InstallDate: r.epoch_time(0.0)
                    }
                )
                insert_app_data(
                    agent_info_to_insert,
                    collection=AppCollections.CustomAppsPerAgent
                )

    if agent_id and not app_id:
        agent_info = get_agent_info(agent_id)
        apps_info = fetch_apps_data_by_os_code(
            agent_info[AgentKey.OsCode], customer_name,
            collection=AppCollections.CustomApps
        )

        for app_info in apps_info:
            app_id = app_info.get(CustomAppsKey.AppId)
            file_data = fetch_file_data(app_id)
            add_file_data(app_id, file_data, agent_id)

            agent_info_to_insert = {
                CustomAppsPerAgentKey.AgentId: agent_id,
                CustomAppsPerAgentKey.AppId: app_id,
                CustomAppsPerAgentKey.Status: CommonAppKeys.AVAILABLE,
                CustomAppsPerAgentKey.CustomerName: customer_name,
                CustomAppsPerAgentKey.InstallDate: r.epoch_time(0.0)
            }

            insert_app_data(
                agent_info_to_insert, collection=AppCollections.CustomAppsPerAgent
            )