Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Anderson Leeb Blog

Anderson Leeb Blog

Apply patch to ESXi host via SSH

  1. scp update to tmp cache location
  2. scp <update filename> root@<esxi host>:/var/tmp/cache/
  3. SSH to the ESXi host
  4. enter Maintenance mode
  5. run the esxupdate command with your filename
  6. esxupdate --bundle=/var/tmp/cache/<update filename> update
  7. Reboot the host
  8. reboot
  9. Exit maintenance mode

Your host is now be updated.  You can verify by checking the build number on the console, or the vSphere Console.

Apr 26, 2013 08:28 PM

Place ESXi into Maintenance mode through SSH

You can enter maintenance mode via SSH using the following command:

vim-cmd /hostsvc/maintenance_mode_enter
Apr 26, 2013 08:25 PM

Enable SSH on ESXi host

By default, SSH is disabled on ESXi.

  1. Launch the vSphere Client
  2. Select the host in the tree-view on the left hand side
  3. Select the “Configuration” tab
  4. Under the “Software” menu, select “Security Profile”
  5. Click the “Properties” link which will open up the “Services Properties” window (see below)
  6. Select the “Remote Tech Support (SSH)” service and then click the “Options” button
  7. Set the “Startup Policy” to “Start automatically” and click “Start”
  8. Click “OK” and “OK” again
Apr 26, 2013 08:25 PM

small javascript to truncate text on word boundaries

Javascript truncation

String.prototype.trunc = function (n){
    var toLong = this.length>n;
    var s_ = toLong ? this.substr(0,n-1) : this;
    s_ = s_.substr(0,s_.lastIndexOf(' '));
    return toLong ? s_  + '...' : s_;
};

$(".text-to-truncate").each(function(){this.innerHTML = this.innerHTML.trunc(num-of-characters)});
Mar 25, 2013 01:20 AM

See managePortletsFallback without the proper viewlet manager

<rules if-not-path="@@manage-portletsinheader @@manage-portletsabovecontent @@manage-portletsbelowcontent @@manage-portletsfooter @@manage-sitefooterportlets @@search">
<after css:theme-children="#content article" if-content='not(//*[@id="portal-column-two"]) and not(//*[@id="portal-column-one"])' >
<a class="managePortletsFallback" href="{$scheme}://{$host}{$path}/@@manage-portlets">
Manage portlets
</a>
</after>
</rules>
Feb 08, 2013 07:11 PM

Configuring Dovecot and Postfix for virtual hosting

As we enter into the rewarding world of hosting other applications, we were requested to host a mail server. In trying to set this up, I stumbled upon the following post that set me on the right path.

 

http://kingofthemongodb.blogspot.com/2013/01/postfix-dovecot-multiple-domains.html

 

Good write-up on how to do virtual email hosting without the expense of cpanel.

Jan 26, 2013 02:25 AM

Use built in theme parameters in Diazo rules

While building the rules.xml file for a project, I needed to insert the value of some of the built in theme parameters as the value for an attribute to a tag. The synax I'm used to from e.g. TAL expressions:

${context}

is a little different than what is used with a Diazo/plone.app.theming theme:

{$path}

The final rule ended up looking like this:

<after css:theme-children="#content article"
if-content='not(//*[@id="portal-column-two"]) and
not(//*[@id="portal-column-one"])' >
<a class="managePortletsFallback" href="{$scheme}://{$host}{$path}/@@manage-portlets">
Manage portlets
</a>
</after>
Dec 14, 2012 06:20 PM

Compound Conditionals in Diazo

Say for instance that you are using Twitter Bootstrap, and you want to map Plone's three column layout into a Bootstrap row. When all three columns are present, the center column should take up, for instance 6 grid columns, and the left and right columns could take three each in a 12 column grid.

Obviously, this works great if all three columns are present, but if one or both of the left and right columns are absent, you end up with a lot of wasted space. When using diazo, you can conditionally modify the class of an HTML element to change this with:

<before css:theme-children="#content article"
        css:if-content="#portal-column-two">
    <xsl:attribute name="class">span12</xsl:attribute>
</before>

Now, this works fine if you only have one possibility, in this case the presence or absence of column 1. Since we have two columns, we can say that if either one is gone, use 9 columns, if both are gone, use 12. which becomes this:

<before css:theme-children="#content article"
        if-content='not(//*[@id="portal-column-two"]) or
                    not(//*[@id="portal-column-one"])' >
    <xsl:attribute name="class">span9</xsl:attribute>
</before>
		
<before css:theme-children="#content article"
        if-content='not(//*[@id="portal-column-two"]) and
                    not(//*[@id="portal-column-one"])' >
    <xsl:attribute name="class">span12</xsl:attribute>
</before>

This allows to use the logical "or" and "and" operators to take care of both cases. Note that the order matters, the and must come after the or.

Dec 12, 2012 01:55 AM

Create objects in the Plone debugger

Plone 4

(11/19/2012) Note: David Glick was kind enough to point out that there is now a much easier way of handling this, in the plone.recipe.zope2instance. See the examples on pypi.

Plone 3

Initialization code required before trying to create an object in the debugger:

from Testing import makerequest
root = makerequest.makerequest(app)
site = root.Plone

admin = root.acl_users.getUserById('admin')
admin = admin.__of__(site.acl_users)

from AccessControl.SecurityManagement import newSecurityManager
newSecurityManager(None, admin)

from zope.site.hooks import setHooks
from zope.site.hooks import setSite
setHooks()
setSite(site)
site.setupCurrentSkin(site.REQUEST)

After that you should be able to create content, or update a member's properties

site.invokeFactory('Folder', 'test')
folder = site.test
folder.processForm()
Nov 19, 2012 01:45 AM

Skin layer order matters

Order does matter, especially when dealing with skin layers. A client requested a modification to the overlay used when viewing events in Solgema.fullcalendar. This modification was put into the skins directory of the custom theme product. The skins folder was registered to always be right after the custom folder. A new version of Solgema.fullcalendar was installed and the modification disappeared. Why, you may ask? Because the skin layer for the custom product was now not directly below the custom folder; the updated product's skin layer was higher, above the custom theme.

Solutions:

  1. Reinstall the custom theme. Easy enough, but why reinstall if it isn't necessary?
  2. Simple copy & paste. In the ZMI, go to portal_skins, then click the Properties tab. This provides a listing of the skin layers in the order that they are registered. Move the custom theme above the reinstalled product in the default skin layer.

 

Sep 28, 2012 01:36 AM

Document Actions