## p4get-replicationstate ## aaron bockelie function p4get-replicationstate {param($clusterMember) function getReplState #internal function to pull replication state and fix timedate stamp in resultant data { $object = p4get "pull -l -j" $object.replicaTime = convertUnixTime $object.replicaTime $object.replicaStatefileModified = convertUnixTime $object.replicaStatefileModified $object } if (!$env:depotsxml) #look for depots.xml, it's key to repl topology { write-error "Could not locate depots.xml configuration file." break } $originalServer = $env:p4server #store original server in case we're logged into a master server (can't pull repl state from master) $servercheck = p4get-server #get state of logged in if ($servercheck.pingsuccess.equals($true)) #if we're valid login { $static = ([xml](gc $env:depotsxml)) #parse xml object if ($clusterMember) #if the clustermember switch is specified, query that specific server. { try { $null = p4sudo $clusterMember 2>&1 #sign into target getReplState #get state $null = p4sudo $originalserver 2>&1 #return to original server signin } catch { write-error $error[0] #error catchall } } else { $replTopology = p4get-replicationTopology -clusterName ($static.perforce.depot | ?{$_.name -eq $env:p4server} | %{$_.clusterName}) #no server specified? return immediate. BUT check to see if we're on a master. if (!($servercheck.server -match $replTopology.parent.hostname)) #if the master in the topology does not match this server return state { getReplState } else { #if the server master matches logged in server, throw a warning and find an appropriate server to at least return something useful. write-warning "Cannot pull replication state on master server. Selecting nearest checkpoint replica to report state." $null = p4sudo ($replTopology.parent.children | ?{$_.checkpointTarget -eq "true"} | %{$_.hostname}) 2>&1 getReplState $null = p4sudo $originalserver 2>&1 } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 8423 | Aaron Bockelie |
Fixes and changes. Ported from a private depot, not listing specific changes at this point. |
||
#1 | 8410 | Aaron Bockelie |
Root checkin, Perforce Powershell wrapper. Still lots of work to be done, namely documentation and deployment tools, for instance, get-help needs work on the majority of these tools. Additionally, the /lib structure needs a little bit of condensation, probably into major groups (depot, userspec, clientspec, group management, and so on) that way function family can exist under each resource. |