def _set_app_per_agent_properties(self, agent, app_id): return { SupportedAppsPerAgentKey.AgentId: agent[AgentKey.AgentId], SupportedAppsPerAgentKey.CustomerName: agent[AgentKey.CustomerName], SupportedAppsPerAgentKey.Status: CommonAppKeys.AVAILABLE, SupportedAppsPerAgentKey.LastModifiedTime: self.last_modified_time, SupportedAppsPerAgentKey.Update: PackageCodes.ThisIsAnUpdate, SupportedAppsPerAgentKey.InstallDate: r.epoch_time(0.0), SupportedAppsPerAgentKey.AppId: app_id, SupportedAppsPerAgentKey.Id: build_agent_app_id(agent[SupportedAppsPerAgentKey.AgentId], app_id), }
def _set_specific_keys_for_agent_app(self, app_dict): necessary_keys = { AppsPerAgentKey.AppId: app_dict[AppsPerAgentKey.AppId], AppsPerAgentKey.InstallDate: app_dict[AppsPerAgentKey.InstallDate], AppsPerAgentKey.AgentId: self.agent_id, AppsPerAgentKey.CustomerName: self.customer_name, AppsPerAgentKey.Status: app_dict[AppsPerAgentKey.Status], AppsPerAgentKey.Dependencies: app_dict.pop(AppsPerAgentKey.Dependencies), AppsPerAgentKey.Update: PackageCodes.ThisIsAnUpdate, AppsPerAgentKey.LastModifiedTime: self.modified_time, AppsPerAgentKey.Id: build_agent_app_id( self.agent_id, app_dict[AppsPerAgentKey.AppId] ) } return necessary_keys
def _set_app_per_agent_properties(self, agent, app_id): return { SupportedAppsPerAgentKey.AgentId: agent[AgentKey.AgentId], SupportedAppsPerAgentKey.CustomerName: agent[AgentKey.CustomerName], SupportedAppsPerAgentKey.Status: CommonAppKeys.AVAILABLE, SupportedAppsPerAgentKey.LastModifiedTime: self.last_modified_time, SupportedAppsPerAgentKey.Update: PackageCodes.ThisIsAnUpdate, SupportedAppsPerAgentKey.InstallDate: r.epoch_time(0.0), SupportedAppsPerAgentKey.AppId: app_id, SupportedAppsPerAgentKey.Id: build_agent_app_id(agent[SupportedAppsPerAgentKey.AgentId], app_id) }
def delete_apps_from_agent_by_name_and_version( agent_id, app_name, app_version, collection=AppCollections.UniqueApplications ): """Delete apps from an agent that contain this name and version. Args: agent_id (str): The 36 character UUID of the agent. app_name (str): Name of the application you are removing from this agent. app_version (str): The exact verision of the application you are removing. Kwargs: collection (str): The name of the collection you are perfoming the delete on. default = 'unique_applications' Basic Usage: >>> from vFense.plugins.patching._db import delete_apps_from_agent_by_name_and_version >>> agent_id = '78211125-3c1e-476a-98b6-ea7f683142b3' >>> app_name = 'libpangoxft-1.0-0' >>> app_version = '1.36.3-1ubuntu1' >>> collection = 'apps_per_agent' >>> delete_apps_from_agent_by_name_and_version(agent_id, name, version, collection) Returns: Boolean >>> True """ completed = False app_id = fetch_app_id_by_name_and_version(app_name, app_version) if app_id: agent_app_id = build_agent_app_id(agent_id, app_id) status_code, count, error, generated_ids = ( delete_data_in_table(agent_app_id, collection) ) if status_code == DbCodes.Deleted: completed = True return completed