Automatic package server assignment aims to assign packages to sites as required in order to distribute the package to all parties which are assigned the package to download. It also adds support to have these assignments removed automatically after they have not been used for a specified number of days.
Automatic package server assignment is an option in the package servers tab of a package. The user can manually select sites that contain the package servers to assign the package to but an additional set of sites determined from automatic package server assignment will be added to it. These two sets, manually assigned and automatically assigned are treated separately to allow the un-setting of manual assignments to sites. Automatic assignments to sites are only ever unset by the automatic un-assignment schedule.
The current set of automatic assignments is the collection of sites that contain computers that are set to receive the package. This is determined in a series of steps.
These resource targets contain the computers which are set to receive the package. This set of computers then has their IP addresses retrieved and the set of sites that are the closest encompassing sites for any of the IP addresses in the collection is created. This set of sites contains the sites which are to be automatically assigned. This process takes place in SWDSupport.SetPackageServerAssignment.
Specifically, if any of the computers are in a resource target assigned to a site or site server, then that site or the site which contains that site server is used instead of the site which contains the computer's IP address. Resource target assignment to an internet site does not override the IP address behavior of a computer when it is not on the internet site.
Every package is always assigned to any sites which contain the SMP server.
Every package is always assigned to Default Internet Site.
In case no sites are defined (except Default Internet Site) every package is always assigned to ALL package servers
The database stored procedure spSetPackageServers stored procedure takes care of updating the database to match the package server assignment. It receives both the set of automatic assignments chosen and the manually assigned sites. Sites that have previously been automatically assigned are added to the automatic assignments group passed to the stored procedure. This allows the addition of 'manual' automatic assignments.
The stored procedure first removes all manually assigned sites from the list of automatically assigned sites. This gives manually assigned sites precedence. Then all sites which have been previously automatically assigned are removed from the list to be automatically assigned. This is done by checking the package site activity log which has an entry added to it when an assignment first occurs, and when subsequent requests come in from agents in a site requesting a package. All package site assignments which were manually assigned for the current package are then removed. The new manual assignments are then added back in, except for ones that already have a corresponding pre-existing automatic assignment. The new automatic assignments are then added in unless there is already a manual assignment.
All new automatic assignments then have initial entries added to the package site activity log where there are currently no entries at all. Once that is completed the process of determining package servers that receive packages is the same as for the manual assignment to sites case. The distinct set of package servers associated with all assigned sites is obtained and all of those package servers are assigned as if an individual assignment was selected.
In addition to the standard automatic assignment process, there is automatic assignment as required. This is triggered when a request comes into GetPackageInfo which receives no download locations. If there are no download locations and the package has an automatic assignment set then an automatic assignment between the client's closest sites and the package is added. This assignment is forced, that is it is added even if there are entries in the package site activity log. This allows automatic package assignment after automatic un-assignment has occurred. Once added to the SWDPackageSite table the standard assignment process is followed. This takes place within the spForceAutoAssignPackageSite stored procedure.
Automatic un-assignment is the process of removing package site assignments when they have not been used for some time. This is performed on a schedule that runs daily. The package site activity log is checked for each package assigned to a site and for each site where there has been no activity in greater than N days, automatic assignments to the site are removed. The activity log is unchanged by this, which stops automatic assignment from automatically re-assigning the package the next time assignments are updated. The assignment can still be recreated, but only by the assignment as required which bypasses the activity log check.