Parallels Virtual Machine to VirtualBox Using VMWare Fusion

Recently I found the need to convert a Parallels Virtual Machine to a format in which VirtualBox could use. Surprisingly I couldn’t find a feature in Parallels to do so but found a way that involves using VMWare Fusion as an intermediary.

  1. If you do not have VMWare Fusion you can download it here (you can use the trial version but will be limited to 30 days of usage). Once downloaded install it.

  2. Open VMWare Fusion then from the menu go to File » Import…
    parallels_to_virtualbox_1

  3. Select the Parallels Virtual Machine you want to convert.
    parallels_to_virtualbox_2

  4. Select where you want the VMWare Virtual Machine to be saved and name it (This is not the final Virtual Machine we will import into VirtualBox but an intermediate Virtual Machine).
    parallels_to_virtualbox_3

  5. Once the import of the Parallels Virtual Machine is complete close VMWare Fusion.

  6. Open Terminal and run the following command:

    cd /Applications/VMware\ Fusion.app/Contents/Library/VMware\ OVF\ Tool/
    
  7. Now we are ready to do the conversion by running the following command:

    ./ovftool /Volumes/Data/VMWare/Ubuntu\ Linux.vmwarevm/Ubuntu\ Linux.vmx /Volumes/Data/Virtual\ Machines/Ubuntu\ Linux.ovf
    

    Note: Replace /Volumes/Data/VMWare/Ubuntu\ Linux.vmwarevm/Ubuntu\ Linux.vmx with the path to the Virtual Machine you created in step 4 and replace /Volumes/Data/Virtual\ Machines/Ubuntu\ Linux.ovf with the path where you final the final Virtual Machine to be created.

  8. Now open VirtualBox then in the menu go to File » Import Appliance…
    parallels_to_virtualbox_4

  9. Now click Open Appliance…
    parallels_to_virtualbox_5

  10. Now select the Virtual Machine you made in step 7.
    parallels_to_virtualbox_6

  11. Set the name of the Virtual Machine then click Import.
    parallels_to_virtualbox_7

Now you should have a working VirtualBox Virtual Machine of your initial Parallels Virtual Machine. Thanks for taking the time to read this post and I hope it helped. If you run into any errors during this process please let us know.

SharePoint – The current operation could not be completed. Try again, or contact your system administrator.

If attempting to utilize Site Manager, to COPY an entire site or any particular pages, and receive the following error.

The current operation could not be completed. Try again, or contact your system administrator.

You may re-try the operation, and you may need to clean up the half-created data first before re-trying. If the problem persists, please contact your system administrator.

If you review the logs, and the following is displayed,

System.ArgumentException (0×80070057)

Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder) at Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder) at Microsoft.SharePoint.SPWeb.GetFileOrFolderObject(String strUrl) at Microsoft.SharePoint.Publishing.CommonUtilities.GetFileFromUrl(String url, SPWeb web) at Microsoft.SharePoint.Publishing.PublishingPage.get_Layout() at Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.cachePageInfoForXmlFiltering(PublishingPage publishingPage) at Microsoft.Office.Server.Utilities.ContentIterator.ProcessItem(SPListItem item, Boolean fIncludeFolderItems, MonitoredScopeWrapper monitoredScopeWrapper, ItemProcessor itemProcessor, ItemProcessorErrorCallout errorCallout) at Microsoft.Office.Server.Utilities.ContentIterator.ProcessItems(SPListItemCollection items, Boolean fIncludeFolderItems, Boolean fIterateInReverseOrder, MonitoredScopeWrapper monitoredScopeWrapper, ItemProcessor itemProcessor, ItemProcessorErrorCallout errorCallout) at Microsoft.Office.Server.Utilities.ContentIterator.<>c__DisplayClassc.<ProcessListItems>b__9(SPListItemCollection items) at Microsoft.Office.Server.Utilities.ContentIterator.ProcessListItems(SPList list, SPQuery query, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout) at Microsoft.Office.Server.Utilities.ContentIterator.ProcessListItems(SPList list, String strQuery, UInt32 rowLimit, Boolean fRecursive, SPFolder folder, ItemsProcessor itemsProcessor, ItemsProcessorErrorCallout errorCallout) at Microsoft.Office.Server.Utilities.ContentIterator.ProcessListItems(SPList list, Boolean fIterateInReverseOrder, ItemProcessor itemProcessor, ItemProcessorErrorCallout errorCallout) at Microsoft.Office.Server.Utilities.ContentIterator.ProcessListItems(SPList list, ItemProcessor itemProcessor, ItemProcessorErrorCallout errorCallout) at Microsoft.SharePoint.Publishing.PublishingWeb.IterateOverAllPages(ProcessPublishingPage callToProcessPublishingPage) at Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.configureExportCopyOrMove(String[] sourceSmtObjectIds, SPExportSettings& exportSettings, SPIncludeVersions versionsToInclude) at Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.Copy(String[] sourceSmtObjectIds, String destSmtObjectId) at Microsoft.SharePoint.Publishing.Internal.WebControls.CopyObjects.Copy() at Microsoft.SharePoint.Publishing.Internal.WebControls.CopyObjects.DoWork() at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock

You’ll want to check the pages contained in the page library, and download and view them in a text editor.

You will want to make sure the PublishingPageLayout is correctly matching your source web application, and when it’s corrected, re-upload the pages and you’ll be able to perform the copy operation.

<mso:PublishingPageLayout msdt:dt="string">

SharePoint – Web Service Requests in InfoPath Forms (Classic to Claims)

Without writing code, you can populate User Profile Service (UPS) information into your fields in InfoPath forms. This process is clearly defined in the following blog. However, as this works perfectly, in the classic-based authentication there are several modifications that will need to be made, to fully utilize the forms, as a result of product limitations caused by Claims-based authentication.

Firstly, a Secure Store ID will need to be created in Central Administration (Manage Service Applications), you’ll need to assign the Target Application ID, and add the Target Application Administrators which would ideally need to be a generic ID that never expires, and the members that are mapped to the credentials defined. You’d need to then set the credentials on that domain account for the secure store target application. Lastly, under Central Administration (General Application Settings), and InfoPath Forms Services, the option to ‘Allow user form templates to use authentication information contained in data connection files’ is selected.

To re-mediate any issues with the data connections previously created while in classic (that utilize web services), you will need to download the previously created data connections from their respective data connection libraries, and open them using any text editor. You’ll notice that the UDCX files, are purely XML. Modify the XML, such that the following information is included. What this allows, is for impersonation to allow the user accounts accessing this form, to be able to get the correct data from the web services.

<udc:Authentication>
	<udc:SSO AppId='TheApplicationID' CredentialType='NTLM'/>
</udc:Authentication>	

Once this change is made, simply re-upload and publish your data connection file, into the data connection library associated with your InfoPath Form Library. Once you complete this action then re-open your InfoPath Form template. If you were providing information on a button press, form load, or form submit operation, you’d simply modify your existing actions to include the following details. You would need to add another action to set a field’s value, and when the dialog appears, select the drill-down beside the field textbox.

New Action

Within the next dialog, click the drop-down and select your respective web service. In the image below, the data connection was named GetUserProfileByName, and you will need to select the field AccountName and press OK.

Account Name

and in the value field, simply enter userName(), or add it by the function entry under Users.

Lastly, you’ll need to perform a query using a data connection action, utilizing the data connection associated with the web service request. These two major items need to be before your other field-based actions as it’ll then associate the requests with your ID, and populate your information correctly.

Below is a sample image, which illustrates what the actions should look like, in the correct order, to acquire the First Name of the user. These field values for the individual user profile service attributes, is listed in the blog article talked about above.

Sample Actions

SQL – Locked in Single-User Mode

If you ever want to see what sessions are active in SQL, or if you ever perform a SharePoint Backup through Central Administration, and SQL Server goes into single-user mode and does not remove that state – the following SQL query will return all active user sessions, by ID.

select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid
where d.name = 'db_name'
GO

Once you get this ID, you can just manually kill the session, to the ID, and then disable single-user mode in the respective tables, etc.

Installing RhodeCode on Ubuntu Server 12.04

Preparation

  1. Update Ubuntu

    Execute the following commands:

    sudo apt-get update
    sudo apt-get upgrade
    
  2. Install pip and virtualenv

    Execute the following commands:

    sudo apt-get install python-pip
    sudo pip install virtualenv
    

Installing RabbitMQ

  1. Install RabbitMQ

    Execute the following commands:

    sudo apt-get install rabbitmq-server
    
  2. Create RabbitMQ User

    Execute the following commands:

    sudo rabbitmqctl add_user rhodeuser rhodepass
    sudo rabbitmqctl add_vhost rhodevhost
    sudo rabbitmqctl set_permissions -p rhodevhost rhodeuser ".*" ".*" ".*"
    

Installing RhodeCode

  1. Install Python Sources

    Execute the following commands:

    sudo apt-get install python-dev
    
  2. Create Base Directory and Give Yourself Ownership

    Execute the following commands:

    sudo mkdir /rhode
    sudo chown myusername /rhode
    
  3. Create Data Directory and Virtual Environment

    Execute the following commands:

    virtualenv --no-site-packages /rhode/venv
    source /rhode/venv/bin/activate
    

    Now you should be in the virtual environment and see (venv) in your shell.
    Screen Shot 2012-12-20 at 10.15.28 AM
    While in the virtual environment, execute the following commands:

    pip install pastescript
    pip install rhodecode
    deactivate
    
  4. Create Directories and Production Configuration

    Execute the following commands:

    mkdir /rhode/repos
    mkdir /rhode/data
    cd /rhode/data
    

    Go back into the virtual environment by executing the following command:

    source /rhode/venv/bin/activate
    

    While in the virtual environment, execute the following command:

    paster make-config RhodeCode production.ini
    
  5. Edit production.ini

    Make sure the following settings are set as shown here:

    [server:main]
    host = 0.0.0.0
    
    [app:main]
    use_celery = true
    broker.vhost = rhodevhost
    broker.user = rhodeuser
    broker.password = rhodepass
    
  6. Generate RhodeCode Database and Create Initial Admin Account

    In your virtual environment, execute the following command:

    paster setup-rhodecode production.ini
    

    When prompted to destroy old database choose Yes, when asked for repository path type ‘/rhode/repos’, and for the user/password choose whatever you want for your initial administrator account.

  7. Test RhodeCode

    In your virtual environment, execute the following command:

    paster celeryd production.ini & paster serve production.ini
    

    Now you should be able to go to http://127.0.0.1:5000/ in your browser on the Ubuntu Server machine and see the RhodeCode web frontend. Or you can go to http://:5000 from another machine on the same network.

Starting RhodeCode on system boot

  1. Create RhodeCode User for Running RhodeCode Daemons

    Execute the following command:

    sudo adduser --no-create-home --disabled-login --disabled-password --system --group rhodecode
    
  2. Give RhodeCode User Ownership of the RhodeCode Directory

    Execute the following command:

    sudo chown -R rhodecode:rhodecode /rhode
    
  3. Download init.d Script and Modify USER, VENV_DIR, and DATA_DIR as Neccessary

    Execute the following commands:

    cd ~
    wget http://raw.github.com/gist/2866413/rhodecode-init.d.sh
    ./rhodecode-init.d.sh
    

    Note: You only need to modify USER, VENV_DIR, and DATA_DIR if you change ‘rhodeuser’, ‘rhodepass’, or the ‘/rhode/data’ directory to something else.

  4. Test the Script

    Execute the following commands:

    chmod +x ./rhodecode-init.d.sh
    sudo ./rhodecode-init.d.sh start
    

    Access RhodeCode via web browser
    Execute the following command:

    sudo ./rhodecode-init.d.sh stop
    

    Verify that the Python processes have stopped
    [/code]

  5. Install the Script

    Execute the following commands:

    sudo cp ./rhodecode-init.d.sh /etc/init.d/rhodecode
    cd /etc/init.d
    sudo update-rc.d rhodecode defaults
    
  6. Test the Script Again

    Execute the following command:

    sudo service rhodecode start
    

    Verify the RhodeCode web frontend is up via a web browser
    Execute the following command:

    sudo service rhodecode stop
    

Now RhodeCode should be installed on your Ubuntu Server and should run automatically on boot. Thank you for taking the time to read this tutorial.

Tutorial based off of: https://gist.github.com/2866413

Setting Up Ruby on Rails and MySQL on OS X Mountain Lion

This article explains how to setup a Ruby on Rails development environment on OS X Mountain Lion with MySQL.

Setting up Ruby on Rails

Install Xcode

First you need to install Xcode from the App Store.

Once Xcode is installed open it.

Now in the ‘Xcode’ menu go to ‘Preferences’
Screen Shot 2012-12-17 at 12.29.55 PM

Click on the ‘Downloads’ tab.
Screen Shot 2012-12-17 at 12.46.34 PM

Now click ‘Install’ for the ‘Command Line Tools’.

Install Homebrew

Run the following commands:

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew doctor
brew tap homebrew/dupes

Install RVM (Ruby Version Manager) and the Latest Version of Ruby

Run the following commands (Note: in the 2nd command change ‘mintrus’ to your username):

curl -L https://get.rvm.io | bash -s stable --ruby
source /Users/mintrus/.rvm/scripts/rvm

Install GCC so gems such as JSON will successfully install)

Run the following commands:

brew install apple-gcc42
sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

Setting up MySQL

Download MySQL from here. After installing MySQL make sure to install the preference pane component so you can easily start and stop your MySQL instance from within System Preferences.

Run the following command so that the mysql2 gem will work successfully:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

If you would like a nice GUI for managing your databases download and install MySQL Workbench.

Enjoy!

Now you should have a fully functioning Ruby on Rails environment on OS X Mountain Lion. Happy programming!

Create Browser Specific CSS Files in Ruby on Rails

If you would like to add browser specific CSS to your Ruby on Rails application this is a quick tutorial is for you.

First you need to add the following to your ApplicationController (app/controllers/application_controller.rb):

class ApplicationController < ActionController::Base

  before_filter :browser
  
private

  def browser
    @user_agent = request.env['HTTP_USER_AGENT'].downcase
    if @user_agent =~ /msie/i
      @browser = "Internet Explorer"
    elsif @user_agent =~ /konqueror/i
      @browser = "Konqueror"
    elsif @user_agent =~ /webkit/i
      @browser = "Webkit"
    elsif @user_agent =~ /gecko/i
      @browser = "Mozilla"
    elsif @user_agent =~ /opera/i
      @browser = "Opera" 
    else
      @browser = "Unknown"
    end
  end

end

Next you need to add the following to your layout file (app/views/layouts/application.html.erb):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>Site Name</title>

  <%= stylesheet_link_tag 'application' %>
  <%= stylesheet_link_tag 'msie' if @browser == 'Internet Explorer' %>
  <%= stylesheet_link_tag 'opera' if @browser == 'Opera' %>
  <%= stylesheet_link_tag 'mozilla' if @browser == 'Mozilla' %>
  <%= stylesheet_link_tag 'webkit' if @browser == 'Webkit' %>

  <%= javascript_include_tag 'application' %>
  <%= csrf_meta_tags %>
</head>
<body>
  <%= yield %>
</body>
</html>

Now in your stylesheets directory (app/assets/stylesheets/) create the following CSS files:

  1. msie.css
  2. opera.css
  3. mozilla.css
  4. webkit.css

Now any CSS code you put in msie.css will only be presented to Internet Explorer, opera.css to Opera, mozilla.css to Firefox and other Mozilla based browsers, and webkit to Chrome and Safari.

SharePoint 2010 – Remove / Disable Themes

If you’ve ever encountered the need the disable themes on a site collection, there are a few options you may have available.

Firstly, there are policies in Central Administration to remove the ability to change the themes across the entire web application, which can be done by the following:

  1.    Visit Central Administration > Application Management > Web Applications > Manage Web Applications.
  2.    Select the Web Application that you want to restrict the themes on.
  3.    Click on “Permission Policy Level” on the Ribbon.
  4.    Name the policy, and find the permission “Apply Themes and Borders” and toggle the “Deny” check box.
  5.    Click save.
  6.    Click on “User Policy” on the Ribbon.
  7.    Add the users and groups you want to restrict, and then apply the policy you just created.

Alternatively, if you want to manually remove the themes, you can update the theme entries, in a file called:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Layouts\1033\SPTHEME.XML. There, you can remove all themes with the exception of default – the sections you would want to delete are the <templates> nodes. Noted, I take no responsibility for any issues caused by this method. I would expect you to make a backup of this file.

If you can’t do either of the above options, and utilizing a managed environment. You could take a third approach, which involves removing the available themes, resetting your themes to default, and disabling the ‘Enhanced Theming’ hidden feature.

You can remove all the managed themes, via the following code in a site-scoped feature receiver, on feature activation.

if (properties != null)
{
     using (SPSite _SPSite = properties.Feature.Parent as SPSite)
     {
         using (SPWeb web = _SPSite.RootWeb)
         {
             ReadOnlyCollection ManagedThemes = null;
             ManagedThemes = ThmxTheme.GetManagedThemes(web.Site);
             SPFile file = null;
             foreach (ThmxTheme themes in ManagedThemes)
             {
                 file = web.GetFile(themes.ServerRelativeUrl);
                 file.Delete();
             }
         }
     }
 }

and then also disabled the following feature through feature stapling,


'Enhanced Theming' - GUID: 068bc832-4951-11dc-8314-0800200c9a66

Also, to reset your theme, in some site scoped feature stapler, you could also reset the theme to default.


ThmxTheme.RemoveThemeFromWeb(_SPWeb, false);

Adding SQL Constraints to Migrations

If you desire to have your migrations create SQL constraints then this tutorial is for you.

Note: Before reading this entire tutorial please know that the constraints shown are in use with MySQL and may or may not work with other database management systems such as MSSQL or PostgreSQL.

In the lib folder of your Ruby on Rails project add a file called advanced_migration.rb.

Add the following Ruby on Rails code to the file you just created:

module AdvancedMigration

  def add_check_constraint(table, column1, column2)

    execute %{ALTER TABLE #{table}
            ADD CONSTRAINT chk_#{column1}_#{column2}
            CHECK (#{column1} IS NOT NULL OR #{column2} IS NOT NULL)}

  end

  def add_foreign_key(from_table, from_column, to_table, to_column = :id)

    constraint_name = "fk_#{from_table}_#{from_column}"

    execute %{ALTER TABLE #{from_table}
            ADD CONSTRAINT #{constraint_name}
            FOREIGN KEY (#{from_column})
            REFERENCES #{to_table} (#{to_column})}

  end

  def remove_check_constraint(table, column1, column2)

    execute %{ALTER TABLE #{table}
            DROP CONSTRAINT chk_#{column1}_#{column2}}

  end

  def remove_foreign_key(from_table, from_column)

    constraint_name = "fk_#{from_table}_#{from_column}"

    execute %{ALTER TABLE #{from_table}
            DROP FOREIGN KEY #{constraint_name}}

  end

end

This will create new methods for you to use in your migrations for adding constraints.

Now to use this in a migration you must include the AdvancedMigration lib like so:

require 'advanced_migration'

And include it in your migration class like so:

include AdvancedMigration

Now you can add a foreign key constraint like so:

add_foreign_key(:users, :company_id, :company, :id)

This adds a foreign key, fk_users_company_id, to the table users on the attribute company_id and references the attribute id on the table company.
Note: the fourth parameter of this method will default to id if you do not provide it.
The following would work the same as above:

add_foreign_key(:users, :company_id, :company)

If you want to remove a foreign key in your migration you can do the following:

remove_foreign_key(:users, :company_id)

This will remove the foreign key we created above, fk_users_company_id.

Another type of constraint you may want to add is a check constraint that makes sure one of two attributes is not null. Below is an example of adding a check constraint:

add_check_constraint(:users, :email, :phone)

This adds a constraint, chk_email_phone, that ensures either the attribute email or the attribute phone is not null for the table users.

In order to remove this constraint you would do the following:

remove_check_constraint(:users, :email, :phone)

Below is an example migration that utilizes these new constraint methods:

require 'advanced_migration'

class Users < ActiveRecord::Migration

  include AdvancedMigration

  def up

    create_table :users do |t|
      t.string      :first_name,    :null => false
      t.string      :last_name,     :null => false
      t.string      :email
      t.string      :phone
      t.references  :company,       :null => true
      t.timestamps
    end

    add_foreign_key(:users, :company_id, :company)
    add_check_constraint(:users, :email, :phone)

  end

  def down
    remove_foreign_key(:users, :company_id)
    remove_check_constraint(:users, :email, :phone)
    drop_table :users
  end

end

SharePoint 2010 – Cannot access the local farm.

Issue:

If you’re encountering the following error, when trying to run a powershell script, you may not have sufficient permissions on the database.

Get-SPWeb : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permission to access the database before trying again.

The issue can be remedied with a few quick powershell commands.

Workaround:

Perform the following script in the SharePoint Management Shell, as a farm administrator and it will remove the error.

Get-SPDatabase | Add-SPShellAdmin SomeDomain\SomeUserName

This will grant the user both access to the configuration database as well as the content database.
Alternatively, you can revoke that granted access with the opposite command.

Get-SPDatabase | Remove-SPShellAdmin SomeDomain\SomeUserName

Social Widgets powered by AB-WebLog.com.