Add Create OpenVZ Template to the Proxmox Web GUI

Add Create OpenVZ Template to the Proxmox Web GUI

Get Social!

proxmox logo gradCreating a template from an OpenVZ container is a very manual process. My biggest problem is that you have to have root access to the Proxmox hardware node in order to create a tar from the root of the CT. See How to make a new OpenVZ template for more information on manually creating a template.

proxmox-create-template-context-menu

I created a small code patch for the Proxmox API and web GUI to add a ‘create template’ feature for CTs. The code adds a context menu entry when you right click on a CT in the Proxmox web GUI.

Before using the feature, the CT must be shut down and any network interfaces removed. The feature presents the user with a dialogue box requesting which storage device the template should be saved to, and what it should be called.

Once the storage has been selected and the template has been given a name, a new ‘create template’ task is created which archives the root directory of the selected container and adds it to the cache folder of the selected storage.

proxmox-create-template-dialogue-box

The changes were declined by the Proxmox team on the grounds that creating a template is a technical process and may not result in creating a working, cloned instance. In addition, it is very easy to leave sensitive information in the CT which is the source of the template – all data on the CTs file system will be archived into the template making it available the next time a CT is created. If SSH keys are left on the CT, for example, then they will be available in the new CT also.

Because the feature was not accepted into the main distribution of Proxmox, I will maintain it myself and manually apply the patches to my Proxmox servers after every update. I have created a public repository on my Gitlab server that holds the git patch file which is available for everyone. 

If you accepts the risks mentioned above, and are happy to hack away at your Proxmox binaries, then you are welcome to try the patch for yourself.

You can download the patch and get more information on my public Proxmox Github page.

I should mention that this patch may not always be up to date. In addition, this is changing the actual Proxmox distribution files and as such may have unintended side effects. Please use these patches with caution and only in your development environments.

gitlabDownload

 


14 Comments

Steve

22-Apr-2014 at 7:52 am

Hey!
I tried your patch on a fresh installed Proxmox host:

root@vm1:/usr/share# git apply –check /root/proxmox.patch
root@vm1:/usr/share# git apply /root/proxmox.patch
/root/proxmox.patch:9: trailing whitespace.

/root/proxmox.patch:11: trailing whitespace.
name => ‘createtemplate’,
/root/proxmox.patch:15: trailing whitespace.
permissions => {
/root/proxmox.patch:21: space before tab in indent.
additionalProperties => 0,
/root/proxmox.patch:29: trailing whitespace.
returns => {
warning: squelched 42 whitespace errors
warning: 47 lines add whitespace errors.

Any ideas?
Best wishes
Steve

    james.coyle

    22-Apr-2014 at 10:53 am

    Hi Steve,

    Does the version match, as per the read me?

      Steve

      22-Apr-2014 at 8:13 pm

      damn.. ;-)
      I already have 3.2-1
      Do you plan to adapt it?

        james.coyle

        22-Apr-2014 at 8:36 pm

        Yes, it’s a time thing. It’s on my to-do and I hope to have it completed before the end of the week.

Martin Cleaver

30-Jul-2014 at 12:10 pm

Hey James,

Interesting patch there.

Looks like I can’t run it though.

> pve-manager/3.2-4/e24a91c1 (running kernel: 2.6.32-29-pve)

Also, gitlib looks interesting but you might get more participation on github or bitbucket – e.g. I tend to search those two when looking for code snippets.

Best,
Martin.

    james.coyle

    30-Jul-2014 at 12:52 pm

    Hi Martin, thanks for the note. I use gitlab for my personal stuff too so it’s easier for me to keep everything in one place.

    I have not had the time to update the code to take into account the latest Proxmox version so it will fail on the latest version. A new major release of Proxmox is upcoming so I’ll wait for that to come out before I rebase all my patches.

      Martin Cleaver

      4-Oct-2014 at 10:31 am

      Thanks James,

      Should I assume that you offered your patch into the main code base but the maintainers have refused it?

      Also, are you likely to update this soon?

      Cheers,
      Martin.

        Martin Cleaver

        4-Oct-2014 at 10:42 am

        Okay, now I understand.

        I disagree with their decision to not incorporate it – and have stated that here: http://forum.proxmox.com/threads/19919-Template-from-an-OpenVZ-container-using-the-WebUI?p=101517#post101517

        Cheers, M.

          james.coyle

          4-Oct-2014 at 5:51 pm

          Hi Martin,

          I’ll try and get this updated soon – I have to rebase all the patches as soon as they change the code, which seems to be most releases.

          They rejected the code because templating is quite a complicated subject. They stated that by adding a button to the GUI it would make it look like a template would be created and guaranteed to work. If you don’t know what you’re doing, it’s quite likely that the template would not work when used for a new CT. In addition, things like keys and logs should always be cleared before templating for security reasons which has to be done manually. Again, the ‘button’ might not be able to cover all eventualities.

          My point was that I need to do this quite frequently, and I suspect many other people do too. I’d love this button to be there, and I’d even be happy with a warning every time I click it saying something like ‘This is an advanced feature blah blah blah’.

          I’ll try and get this updated soon and posted.

Thomas

19-May-2015 at 10:34 am

cannot download from http://wwwgit.jamescoyle.net/james.coyle/proxmox-public/tree/master

    james.coyle

    27-May-2015 at 8:46 pm

    I’ve updated the link.

Kaspar Wetsch

10-Jan-2017 at 11:02 am

Hey,

very nice but i can not register on your gitlab page….

I like your patch but i dont know hot to download it

    AM

    22-Jan-2018 at 8:51 am

    Hello,

    I have same issue.

    Is this patch updated or still maintained?

      James Coyle

      22-Jan-2018 at 4:18 pm

      No, unfortunately not.

Leave a Reply

Visit our advertisers

Quick Poll

Which type of virtualisation do you use?
  • Add your answer

Visit our advertisers