From 56d6bd49165ca66c339cbcd2a88a9124aed0f581 Mon Sep 17 00:00:00 2001
From: Gaetan SIMO <gaetan.simo@inria.fr>
Date: Wed, 1 Aug 2012 16:59:33 +0200
Subject: [PATCH] [Rakefile] Adding cacti-play + weathermap gems and they
 corresponding rake task

---
 Gemfile                                       | 12 +++-
 Gemfile.lock                                  | 43 ++++++++++-
 Rakefile                                      | 71 ++++++++-----------
 .../input/sites/grenoble/net-links/aspen.yaml | 16 +++--
 4 files changed, 91 insertions(+), 51 deletions(-)

diff --git a/Gemfile b/Gemfile
index b79d3e8c0f8..c0c2d915aa7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,15 @@
 source :rubygems
 
 gem 'json_pure', '~> 1.5'
-gem 'net-ssh'
 gem 'restfully','1.0.5'
+
+gem "net-admin-common",
+  :git => "ssh://g5kadmin@git.grid5000.fr/srv/git/repos/net-admin-common",
+  :tag => "2.2"
+gem "cacti-play",
+  :git => "ssh://g5kadmin@git.grid5000.fr/srv/git/repos/cacti-play",
+  :tag => "2.4"
+gem "weathermap",
+  :git => "ssh://g5kadmin@git.grid5000.fr/srv/git/repos/weathermap",
+  :tag => "5.5"
+
diff --git a/Gemfile.lock b/Gemfile.lock
index 6c50772b875..2d689c2476f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,13 +1,50 @@
+GIT
+  remote: ssh://g5kadmin@git.grid5000.fr/srv/git/repos/cacti-play
+  revision: 1912fcc73ba790370b62d8b9792a35485bb498f6
+  tag: 2.4
+  specs:
+    cacti-play (2.4)
+      net-admin-common (>= 2.2)
+
+GIT
+  remote: ssh://g5kadmin@git.grid5000.fr/srv/git/repos/net-admin-common
+  revision: a0335cc1d5cb7fcd79b6fc3fb11d5f0bc34bd596
+  tag: 2.2
+  specs:
+    net-admin-common (2.2)
+      net-ssh (>= 2.3.0)
+      net-ssh-multi (>= 1.1)
+      rest-client (>= 1.6.7)
+
+GIT
+  remote: ssh://g5kadmin@git.grid5000.fr/srv/git/repos/weathermap
+  revision: 288a5dd149ba01de7a70207ecc992a0a3ae43ca3
+  tag: 5.5
+  specs:
+    weathermap (5.5)
+      cacti-play (>= 2.3)
+      interpolator (>= 0.15)
+      ipaddress (>= 0.8.0)
+      json (>= 1.7.0)
+      net-admin-common (>= 2.0)
+
 GEM
   remote: http://rubygems.org/
   specs:
     addressable (2.2.8)
     backports (2.5.1)
     bond (0.4.2)
+    interpolator (0.15)
+    ipaddress (0.8.0)
     json (1.7.0)
     json_pure (1.5.1)
     mime-types (1.18)
-    net-ssh (2.1.0)
+    net-ssh (2.5.2)
+    net-ssh-gateway (1.1.0)
+      net-ssh (>= 1.99.1)
+    net-ssh-multi (1.1)
+      net-ssh (>= 2.1.4)
+      net-ssh-gateway (>= 0.99.0)
     rack (1.4.1)
     rack-cache (1.2)
       rack (>= 0.4)
@@ -45,6 +82,8 @@ PLATFORMS
   ruby
 
 DEPENDENCIES
+  cacti-play!
   json_pure (~> 1.5)
-  net-ssh
+  net-admin-common!
   restfully (= 1.0.5)
+  weathermap!
diff --git a/Rakefile b/Rakefile
index d9167689e42..b18a4e93c32 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,18 +8,6 @@ ROOT_DIR = File.expand_path File.dirname(__FILE__)
 LIB_DIR = File.join(ROOT_DIR, "generators", "lib")
 $LOAD_PATH.unshift(LIB_DIR) unless $LOAD_PATH.include?(LIB_DIR)
 
-REFERENCE_REPOSITORY_DIR = File.expand_path(File.dirname(__FILE__))
-
-# Import dependency rake file
-IMPORTED_RAKEFILES = Array.new
-IMPORTED_RAKEFILES.push File.expand_path(__FILE__)
-%w(weathermap).each do |dependency|
-  Dir.glob(File.expand_path(File.join(REFERENCE_REPOSITORY_DIR,"..",dependency,"Rakefile"))).each do |rakefile|
-    import rakefile unless IMPORTED_RAKEFILES.include? rakefile
-  end
-end
-
-
 require 'grid5000'
 
 task :environment do
@@ -230,15 +218,6 @@ namespace :netlinks do
 #    puts command
     sh command
   end
-  desc "Display network links description amongst network equipments."
-  task :display do
-    host=ENV["HOST"]
-    abort "You must provide the HOST=" if host.nil?
-    cmd = File.join(WEATHERMAP_DIR,"bin","weathermap-app.rb")
-    cmd += " --host '#{host}' --action display"
-    sh cmd
-  end
-
 end
 namespace :env do
   desc "Generates environment JSON files .\nUse DRY=yes to simulate the execution. "
@@ -253,27 +232,33 @@ namespace :env do
     sh command
   end
 end
-
-=begin
-task :mm => [:environment,:hosts] do
-  host,site = @host.scan(/(\S+)\.(\S+)/).flatten
-  root_dir_input = "#{ROOT_DIR}/generators/input"
-  Dir.glob("#{root_dir_input}/#{site}*").each do |file|
-    filename = File.basename(file)
-    if ((scan = filename.scan(/(\S+)-(\S+)\.(rb|yaml)/)).size > 0)
-      site,cluster = scan.flatten
-      cmd = "mkdir -p #{root_dir_input}/#{site}/clusters"
-      cmd += " && mv #{file} #{root_dir_input}/#{site}/clusters/#{cluster}#{File.extname(filename)}"
-      sh cmd
-#      puts cmd
-    elsif ((scan = filename.scan(/(\S+)\.rb/)).size > 0)
-      site = scan.first.first
-      cmd = "mkdir -p #{root_dir_input}/#{site}/clusters"
-      cmd += " && mv #{file} #{root_dir_input}/#{site}/#{site}.rb"
-      sh cmd
-    end
-
+namespace :weathermap do
+  @weathermap_options = ""
+  task :hosts do
+    @weathermap_site = ENV['SITE']
+    @weathermap_host = ENV['HOST']
+    abort "You must provide the SITE= " if @weathermap_site.nil?
+    abort "You must provide the HOST= name (uid) in its site " if @weathermap_host.nil? or @weathermap_host.match(/\.grid5000\.fr/) != nil
+  end
+  task :execute => ["weathermap:hosts"]  do
+    cmd = "bundle exec weathermap"
+    cmd += " --site '#{@weathermap_site}' --host '#{@weathermap_host}' --api-path #{ROOT_DIR} #{@weathermap_options}"
+    sh cmd
+  end
+  desc "Create weathermaps for host HOST without data."
+  task :testing => ["weathermap:hosts"]  do
+    @weathermap_options.replace("--action write --use-cacti no")
+    Rake::Task['weathermap:execute'].invoke
+  end
+  desc "Create weathermaps for host HOST with RRD from cacti."
+  task :production => ["weathermap:hosts"]  do
+    @weathermap_options.replace("--action write --use-cacti yes")
+    Rake::Task['weathermap:execute'].invoke
+  end
+  desc "Display network links description amongst network equipments."
+  task :display do
+    @weathermap_options.replace("--action display")
+    Rake::Task['weathermap:execute'].invoke
   end
-
 end
-=end
+
diff --git a/generators/input/sites/grenoble/net-links/aspen.yaml b/generators/input/sites/grenoble/net-links/aspen.yaml
index 904e5387aa0..366a58b5443 100644
--- a/generators/input/sites/grenoble/net-links/aspen.yaml
+++ b/generators/input/sites/grenoble/net-links/aspen.yaml
@@ -15,7 +15,7 @@ aspen:
   linecards: 
     2: 
       naming_pattern: "%LINECARD%:%PORT%"
-      kind: node
+      kind: switch
       rate: 1000000000
       ports: 
         1:
@@ -56,33 +56,37 @@ aspen:
           port: 0/3
         23:
           uid: voltaire-1
-          kind: switch
         24:
           uid: voltaire-2
-          kind: switch
         32:
           uid: grimage-9
           port: bmc
+          kind: node
         33:
           uid: grimage-10
           port: bmc
+          kind: node
     3: 
       naming_pattern: "%LINECARD%:%PORT%"
-      kind: other
+      kind: node
       rate: 1000000000
       ports: 
         1:
           uid: digmgt
           port: eth0
+          kin: other
         2:
           uid: digmgt
           port: eth1
+          kin: other
         3:
           uid: digmgt
           port: eth2
+          kin: other
         4:
           uid: digmgt
           port: eth3
+          kin: other
         5:
           uid: grimage-9
           port: eth0
@@ -181,7 +185,7 @@ aspen:
           port: eth1
     4: 
       naming_pattern: "%LINECARD%:%PORT%"
-      kind: other
+      kind: node
       rate: 1000000000
       ports: 
         1: 
@@ -244,9 +248,11 @@ aspen:
         23:
           uid: digmgt
           port: eth4
+          kin: other
         24: 
           uid: alpes
           port: eth0
+          kin: other
         25: 
           uid: grimage-1
           port: eth0
-- 
GitLab