Revison 8/25/2016
The challenge for developers who work with large volumes of data such as multimedia assets, video game art, and firmware designs, etc, is the ability to get a quick copy of source and build assets. By combining the technologies of Perforce and NetApp, a new Perforce workspace can be created in minutes instead of hours. Perforce in collaboration with NetApp has developed a p4 broker script written in python that allows users to create workspaces quickly using NetApp FlexClone technology.
The P4 flex script is an open-source p4 broker script which is shared to the developer community to refine and customized. Each development environment is unique and may have requirements of security, control, workflow, etc. Thus this script is meant to be only as a starting reference which can be enhanced to support requirements of your specific development environment.
Support for this script is through the developer community forums in which both Perforce and NetApp are members. Questions and issues should be posted there for further guidance.
In order to be able to utilize P4 Flex the following is required:
Currently P4 Flex is only supported for Unix environments and NFS.
To use P4 flex, the following are assumed.
SERVER:
CLIENT:
The p4 flex script is written in python and is run in behalf of the user by the p4broker. The p4 flex consists of the following files:
The setup and install is expected to be run by IT administrators who manages the Perforce and NetApp infrastructure.
Download:
Install.
P4 Python APIs and p4 Broker use yum install or apt-install after repositories are set. For example, RHEL 7:
sudo yum install perforce-p4python-python2.7
sudo yum install perforce-broker
Uzip NetApp Manageability in /usr/local/lib
cd /usr/local/lib
unzip netapp-manageability-sdk-5.3.1.zip
Copy the broker.cfg in the same location as where the Perforce configuration files are usually located (ie. /opt/perforce/servers/p4broker-master or /etc/perforce)
Modify the broker.cfg. The parameters to modify in the broker.cfg include:
Start the p4broker using the broker.cfg as "perforce" or perforce admin user.
If running p4broker as a unix service, modify /etc/perforce/p4dctl.conf.d/p4broker-master.conf to point to the appropriate p4broker config file (broker.cfg).:
sudo p4dctl start p4broker-master
Manually:
p4broker -c /etc/perforce/p4flex/broker.cfg -d
Create a p4 super admin user. The "flex" is a P4 super user and will be running the p4broker commands. Thus as "perforce" or admin user of perforce process do the following:
su - perforce
export P4PORT=1667
export P4USER=perforce
p4 login
p4 user -f flex
p4 passwd flex
p4 protect
Add the following line before super user perforce in protections file:
super user flex * //...
Modify the flex.cfg file with information relating to P4 Flex and NetApp admin. Information on parameters is provided by the Perforce and/or NetApp administrator. The parameters to modify include:
Optional:
Create a mount_base directory that is specified int flex.cfg file for instance "/p4" to mount the root directory of NetApp filer. Modify permissions such that users can access it.
sudo mkdir /p4
sudo chmod 777 /p4
Mount the NetApp filer to mount_base (ie. /p4):
sudo mount -t nfs -o vers=3 192.168.25.19:/ /p4
Modify /etc/sudoers to only provide permissions to perforce admin user to be able to do certain sudo commands. For example, add the following line in /etc/sudoers:
perforce ALL=(ALL) NOPASSWD: ALL
On each user machines who will be using P4 flex, repeat steps 8-9 above which is to create the mount_base and mount the filesystem.
Below is the output of "p4 flex help". For examples of usage, please refer to the Workflow in the next section.
(FlexClone)
flex -- Perforce FlexClone operations
p4 flex volume -s size[M, G] name
p4 flex volume -d name
p4 flex volumes
p4 flex snapshot -V volume [-c client] name
p4 flex snapshot -V volume -d name
p4 flex snapshots
p4 flex clone -V volume -S parent name
p4 flex clone -d name
p4 flex clones [-a]
'p4 flex volume' will create a new volume. The '-d' flag will
delete the volume and associated snapshots.
'p4 flex volumes' will display a list of all volumes.
'p4 flex snapshot' will create a new snapshot. The '-d' flag will
delete the snapshot and associated client.
'p4 flex snapshots' will display a list of all flex snapshots.
'p4 flex clone' will create a new flex clone. The '-d' flag will
delete the flex clone and associated client.
'p4 flex clones' will display a list of all flex clones owned by that
user. The '-a' flag will list all flex clones globally.
For P4 flex commands to work, the following is required:
P4 admin creates a template in which others can clone from which involves the following:
Create a volume
p4 flex volume -s 1G projA
Populate workspace with existing sources checked into Perforce
p4 sync
Build
make
Create a snapshot
p4 flex snapshot -V projA -c test snapA
P4 users can list snapshots/templates available to clone and create a workspace
p4 flex snapshots
P4 users can create a new Perforce writable clone workspace (wsA) from the template/snapshot volume projA and snapA
p4 flex clone -V projA -P snapA wsA
When users are done with the workspace, P4 users can remove the cloned workspace.
p4 flex clone -d wsA
P4 flex admin is the only user allowed to delete the volume template since deleting volume will delete all snapshots/template. This command will fail if there are cloned workspace associated with this volume.
p4 flex volume -d projA
Using P4 Flex to create Perforce workspaces can improve developer productivity; however there are some things to consider and be aware of which include:
p4 flex clone -d
P4Broker
FlexClone - A Thorough Introduction to FlexClone
Deployment and Implementation Guide: Perforce Software on NetApp Clustered Data ONTAP
Data ONTAP Administration Manuals refer to the Documentation section from: