Added a Vagrant directory for building a mininet VM 26/3526/2
authorEd Warnicke <eaw@cisco.com>
Fri, 6 Dec 2013 11:57:13 +0000 (05:57 -0600)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 6 Dec 2013 14:47:27 +0000 (14:47 +0000)
See the README file for details.

Change-Id: I993cb54cd7ce60e67829925c505cef90ec42acfb
Signed-off-by: Ed Warnicke <eaw@cisco.com>
vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/action_provision [new file with mode: 0644]
vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/action_set_name [new file with mode: 0644]
vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/id [new file with mode: 0644]
vagrant/mininet-2.1.0-of-1.3/README [new file with mode: 0644]
vagrant/mininet-2.1.0-of-1.3/Vagrantfile [new file with mode: 0644]
vagrant/mininet-2.1.0-of-1.3/bootstrap.sh [new file with mode: 0644]
vagrant/mininet-2.1.0-of-1.3/node.py.patch [new file with mode: 0644]

diff --git a/vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/action_provision b/vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/action_provision
new file mode 100644 (file)
index 0000000..167448b
--- /dev/null
@@ -0,0 +1 @@
+1386330537
\ No newline at end of file
diff --git a/vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/action_set_name b/vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/action_set_name
new file mode 100644 (file)
index 0000000..167448b
--- /dev/null
@@ -0,0 +1 @@
+1386330537
\ No newline at end of file
diff --git a/vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/id b/vagrant/mininet-2.1.0-of-1.3/.vagrant/machines/default/virtualbox/id
new file mode 100644 (file)
index 0000000..8d03098
--- /dev/null
@@ -0,0 +1 @@
+8e549062-d345-4312-9ddd-20c6cbea79d4
\ No newline at end of file
diff --git a/vagrant/mininet-2.1.0-of-1.3/README b/vagrant/mininet-2.1.0-of-1.3/README
new file mode 100644 (file)
index 0000000..2c134ea
--- /dev/null
@@ -0,0 +1,35 @@
+This directory will allow you to materialize a Virtual Box VM using
+vagrant that has mininet-2.1.0, OVS-2.0, and patched to make
+it easy to use OpenFlow 1.3 with mininet.
+
+To use it:
+
+1)  Install Virtaul Box:
+https://www.virtualbox.org/
+2)  Install Vagrant:
+http://www.vagrantup.com/
+3)  In this directory, run at the command line
+
+vagrant up
+
+This will build and configure the VM and run
+it.
+
+4)  In this directory, run at the command line
+
+vagrant ssh
+
+(This will ssh to the VM you just ran)
+
+5)  You can then run mininet for OF 1.3 using
+
+sudo mn --topo single,3  --controller 'remote,ip=<your controller IP>' --switch ovsk,protocols=OpenFlow13
+
+
+Many thanks to Fred Hsu who turned me onto Vagrant:
+http://fredhsu.wordpress.com/2013/11/04/vagrant-with-opendaylight/
+
+Many thanks to Michal Rehak who did the original underlying work to
+figure out how to get mininet working with OF 1.3 and is the original
+source of the mininet patch:
+https://wiki.opendaylight.org/view/Openflow_Protocol_Library:OpenVirtualSwitch
diff --git a/vagrant/mininet-2.1.0-of-1.3/Vagrantfile b/vagrant/mininet-2.1.0-of-1.3/Vagrantfile
new file mode 100644 (file)
index 0000000..6696972
--- /dev/null
@@ -0,0 +1,120 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  # All Vagrant configuration is done here. The most common configuration
+  # options are documented and commented below. For a complete reference,
+  # please see the online documentation at vagrantup.com.
+
+  # Every Vagrant virtual environment requires a box to build off of.
+  config.vm.box = "mininet-2.1.0-of1.3"
+
+  # The url from where the 'config.vm.box' box will be fetched if it
+  # doesn't already exist on the user's system.
+  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # config.vm.network :forwarded_port, guest: 80, host: 8080
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  # config.vm.network :private_network, ip: "192.168.33.10"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network :public_network
+
+  # If true, then any SSH connections made will enable agent forwarding.
+  # Default value: false
+  config.ssh.forward_agent = true
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  # config.vm.provider :virtualbox do |vb|
+  #   # Don't boot with headless mode
+  #   vb.gui = true
+  #
+  #   # Use VBoxManage to customize the VM. For example to change memory:
+  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
+  # end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
+
+  config.vm.provision :shell, :path => "bootstrap.sh"
+
+  # Enable provisioning with Puppet stand alone.  Puppet manifests
+  # are contained in a directory path relative to this Vagrantfile.
+  # You will need to create the manifests directory and a manifest in
+  # the file base.pp in the manifests_path directory.
+  #
+  # An example Puppet manifest to provision the message of the day:
+  #
+  # # group { "puppet":
+  # #   ensure => "present",
+  # # }
+  # #
+  # # File { owner => 0, group => 0, mode => 0644 }
+  # #
+  # # file { '/etc/motd':
+  # #   content => "Welcome to your Vagrant-built virtual machine!
+  # #               Managed by Puppet.\n"
+  # # }
+  #
+  # config.vm.provision :puppet do |puppet|
+  #   puppet.manifests_path = "manifests"
+  #   puppet.manifest_file  = "site.pp"
+  # end
+
+  # Enable provisioning with chef solo, specifying a cookbooks path, roles
+  # path, and data_bags path (all relative to this Vagrantfile), and adding
+  # some recipes and/or roles.
+  #
+  # config.vm.provision :chef_solo do |chef|
+  #   chef.cookbooks_path = "../my-recipes/cookbooks"
+  #   chef.roles_path = "../my-recipes/roles"
+  #   chef.data_bags_path = "../my-recipes/data_bags"
+  #   chef.add_recipe "mysql"
+  #   chef.add_role "web"
+  #
+  #   # You may also specify custom JSON attributes:
+  #   chef.json = { :mysql_password => "foo" }
+  # end
+
+  # Enable provisioning with chef server, specifying the chef server URL,
+  # and the path to the validation key (relative to this Vagrantfile).
+  #
+  # The Opscode Platform uses HTTPS. Substitute your organization for
+  # ORGNAME in the URL and validation key.
+  #
+  # If you have your own Chef Server, use the appropriate URL, which may be
+  # HTTP instead of HTTPS depending on your configuration. Also change the
+  # validation key to validation.pem.
+  #
+  # config.vm.provision :chef_client do |chef|
+  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+  #   chef.validation_key_path = "ORGNAME-validator.pem"
+  # end
+  #
+  # If you're using the Opscode platform, your validator client is
+  # ORGNAME-validator, replacing ORGNAME with your organization name.
+  #
+  # If you have your own Chef Server, the default validation client name is
+  # chef-validator, unless you changed the configuration.
+  #
+  #   chef.validation_client_name = "ORGNAME-validator"
+end
diff --git a/vagrant/mininet-2.1.0-of-1.3/bootstrap.sh b/vagrant/mininet-2.1.0-of-1.3/bootstrap.sh
new file mode 100644 (file)
index 0000000..ba4f56c
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+#apt-get update
+apt-get install -y mininet
+cd /;patch -p0 < /vagrant/node.py.patch;cd -
+
diff --git a/vagrant/mininet-2.1.0-of-1.3/node.py.patch b/vagrant/mininet-2.1.0-of-1.3/node.py.patch
new file mode 100644 (file)
index 0000000..70bc0f7
--- /dev/null
@@ -0,0 +1,29 @@
+--- /usr/share/pyshared/mininet/node.py        2013-12-06 02:54:41.079577722 +0000
++++ new_node.py        2013-12-06 02:54:20.139578272 +0000
+@@ -952,6 +952,10 @@
+            datapath: userspace or kernel mode (kernel|user)"""
+         Switch.__init__( self, name, **params )
+         self.failMode = failMode
++      protKey = 'protocols'
++      if self.params and protKey in self.params:
++              print 'have protocol params!'
++              self.opts += protKey + '=' + self.params[protKey]
+         self.datapath = datapath
+     @classmethod
+@@ -1024,12 +1028,13 @@
+         # Annoyingly, --if-exists option seems not to work
+         self.cmd( 'ovs-vsctl del-br', self )
+         self.cmd( 'ovs-vsctl add-br', self )
++      print 'OVSswitch opts: ',self.opts
+         if self.datapath == 'user':
+             self.cmd( 'ovs-vsctl set bridge', self,'datapath_type=netdev' )
+         int( self.dpid, 16 ) # DPID must be a hex string
+         self.cmd( 'ovs-vsctl -- set Bridge', self,
+-                  'other_config:datapath-id=' + self.dpid )
+-        self.cmd( 'ovs-vsctl set-fail-mode', self, self.failMode )
++              self.opts+' other_config:datapath-id=' + self.dpid )
++      self.cmd( 'ovs-vsctl set-fail-mode', self, self.failMode )
+         for intf in self.intfList():
+             if not intf.IP():
+                 self.attach( intf )