rortel 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -15,7 +15,49 @@ CLI lib for nortel networks devices
15
15
 
16
16
 
17
17
  == INSTALL:
18
-
18
+ sudo gem install rortel
19
+
20
+ == Example:
21
+ require 'rubygems'
22
+ require 'rortel'
23
+ include Rortel
24
+
25
+ msc=Msc.new :ip=>'atcag2', :user=>'user', :password=>'pass'
26
+ web_patch_list=msc.get_web_patch_list 'MSCS0200.PPC4'
27
+ msc.login
28
+ msc.run "prsm;report dest cm"
29
+ patch_list=msc.parse_patch_list
30
+ missing_patch_list=web_patch_list-patch_list
31
+ time=Time.new
32
+ File.open("missing_patch_#{time.to_i}.txt",'w') do |f|
33
+ f.puts missing_patch_list
34
+ end
35
+ pacs=PacsHost.new :ip=>'rnd94', :user=>'davidrua', :password=>TestData::Password
36
+ pacs.login
37
+ pacs.enter_pacs
38
+ missing_patch_list.each do |patch_id|
39
+ pacs.download patch_id
40
+ end
41
+ pacs.logout
42
+ msc.connect_ftp_access('user','pass')
43
+ msc.setup_ftp_access do |f|
44
+ f.site('lrecl 128')
45
+ end
46
+ missing_patch_list.each do |patch_id|
47
+ patch_path='/home/ruan/sshfs/pacs_dir/'+patch_id.downcase+'.ptchppcp'
48
+ if File.exists? patch_path
49
+ msc.upload_patch patch_path
50
+ msc.run "listsf all"
51
+ msc.change_patch "apply", patch_id
52
+ msc.run "prsm;report prsu #{patch_id}"
53
+ msc.delete_patch(patch_id)
54
+ else
55
+ puts "patch file for #{patch_id} is not found in local disk"
56
+ end
57
+ end
58
+ msc.upload_all_patch_in_dir '/home/ruan/sshfs/pacs_dir'
59
+ msc.disconnect_ftp_access
60
+ msc.logout
19
61
 
20
62
  == LICENSE:
21
63
 
data/lib/rortel.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Rortel
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
 
8
8
  require 'rortel/expectical'
@@ -13,4 +13,5 @@ require 'rortel/msc'
13
13
  require 'rortel/unix'
14
14
  require 'rortel/pls_host'
15
15
  require 'rortel/pacs_host'
16
+ require 'rortel/typhoon'
16
17
  require 'test_data'
data/lib/rortel/dms.rb CHANGED
@@ -13,13 +13,18 @@ module Rortel
13
13
  @prompt=/\r\n>/
14
14
  #read(@r,@timeout, @prompt)
15
15
  if @ip =~/atca/
16
- expect_times(/pass|>/,4)
16
+ @atca=true
17
+ #expect_times(/>/,3)
17
18
  else
18
- expect_times(/pass|>/,5)
19
+ @atca=false
20
+ #expect_times(/>/,4)
19
21
  end
22
+ expect_times("CHAR MODE",1)
23
+ expect_times(">",1)
24
+
20
25
  #clear_read_buffer
26
+ @output=[]
21
27
  run(@pw)
22
- read(@r,@timeout, @prompt)
23
28
  end
24
29
 
25
30
  rescue Exception => ee
@@ -10,7 +10,7 @@ module Rortel
10
10
  r.expect(prompt,timeout) do |rec|
11
11
  if rec == nil then
12
12
  @error.push("ERROR: Timeout talking to device")
13
- #close()
13
+ close()
14
14
  return rec
15
15
  else
16
16
  rec=rec.to_s
@@ -25,7 +25,7 @@ module Rortel
25
25
  end
26
26
  def run(cmd,prompt=@prompt)
27
27
  begin
28
- @w.print("#{cmd}\n")
28
+ @w.print("#{cmd}\r")
29
29
  buffer = read(@r,@timeout,prompt)
30
30
  rescue Exception => ee
31
31
  @error.push("ERROR: Exception for host while executing #{cmd}: #{ee.to_s}")
data/lib/rortel/msc.rb CHANGED
@@ -4,6 +4,8 @@ module Rortel
4
4
  class Msc < Base
5
5
  include Dms
6
6
  include FtpAccess
7
+ attr_accessor :atca
8
+ attr_accessor :current_image
7
9
  def parse_prsu_status
8
10
  # 33
9
11
  # 78
@@ -71,5 +73,29 @@ module Rortel
71
73
  end
72
74
  user_list
73
75
  end
76
+ def get_image_list(type)
77
+ image_list=Array.new
78
+ run "diskut;itocci;lbf #{type}"
79
+ @output.last.each do |line|
80
+ # 1 0 0 5 0 0 5
81
+ # 0 07/08/2010 00:56:52 SD01IMAGE1 S100708005401_CM
82
+
83
+ m= /\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d/.match(line)
84
+ image_list<<[line[25,20].strip, line[36,100].strip] if m
85
+ @current_image=image_list.last if line =~ /\*/
86
+ end
87
+ image_list
88
+ end
89
+ def set_image_list(type)
90
+ image_list=get_image_list(type)
91
+ image_list.each_with_index do |e,i|
92
+ puts "#{i} #{e}"
93
+ puts "select one"
94
+ end
95
+ selected=STDIN.gets.strip.to_i
96
+ puts "selected #{image_list[selected].last} on #{image_list[selected].first}"
97
+ run "lf #{image_list[selected].first}"
98
+ run "sa #{type} #{image_list[selected].last}"
99
+ end
74
100
  end
75
101
  end
data/spec/msc_spec.rb CHANGED
@@ -7,12 +7,12 @@ module Rortel
7
7
  context "starting up" do
8
8
 
9
9
  it "should send the welcome message and the bye message on ATCA" do
10
- msc=Msc.new :ip=>'atcag1', :user=>'davidruan2', :password=>'davidruan2'
10
+ msc=Msc.new :ip=>'atcag2', :user=>'davidruan2', :password=>'davidruan2'
11
11
  msc.login
12
12
  msc.output.last.should =~ /Logged in on /m
13
13
  msc.logout
14
14
  msc.output.last.should =~ /Logged out on /m
15
- #msc.error.should be_empty
15
+ msc.error.should be_empty
16
16
  end
17
17
 
18
18
  it "should send the welcome message and the bye message on XA-Core" do
@@ -21,31 +21,58 @@ module Rortel
21
21
  msc.output.last.should =~ /Logged in on /m
22
22
  msc.logout
23
23
  msc.output.last.should =~ /Logged out on /m
24
- #msc.error.should be_empty
24
+ msc.error.should be_empty
25
25
  end
26
- end
27
-
28
- context "patching" do
29
- it "should parse the report prsu patch status" do
30
- msc=Msc.new :ip=>'atcag1', :user=>'davidruan2', :password=>'davidruan2'
26
+
27
+ it "should get/set the image list on ATCA" do
28
+ msc=Msc.new :ip=>'atcag2', :user=>'davidruan1', :password=>'davidruan1'
31
29
  msc.login
32
30
  msc.output.last.should =~ /Logged in on /m
33
- msc.run "prsm;report prsu rud03p9c"
34
- msc.parse_prsu_status.should_not be_empty
31
+ msc.get_image_list('cm').should_not be_empty
32
+ msc.current_image.should_not be_empty
33
+ msc.set_image_list('cm')
34
+ msc.get_image_list('cm').should_not be_empty
35
+ msc.current_image.should_not be_empty
35
36
  msc.logout
36
- msc.output.last.should =~ /Logged out on /m
37
37
  end
38
38
 
39
- it "should remove the patch and apply the patch" do
40
- msc=Msc.new :ip=>'atcag1', :user=>'davidruan2', :password=>'davidruan2'
39
+ it "should get the image list on XA-Core" do
40
+ msc=Msc.new :ip=>'gsmr', :user=>'davidruan1', :password=>'davidruan1'
41
41
  msc.login
42
42
  msc.output.last.should =~ /Logged in on /m
43
- msc.change_patch "remove", "rud03p9c"
44
- msc.run "prsm;report prsu rud03p9c"
45
- msc.parse_prsu_status.should == "R"
43
+ msc.get_image_list('xa').should_not be_empty
44
+ msc.current_image.should_not be_empty
45
+ msc.get_image_list('ms').should_not be_empty
46
+ msc.current_image.should_not be_empty
47
+ msc.logout
48
+ end
49
+
50
+ end
51
+
52
+ context "patching" do
53
+ before :each do
54
+ @msc=Msc.new :ip=>'atcag1', :user=>'davidruan2', :password=>'davidruan2'
55
+ @msc.login
56
+ @msc.output.last.should =~ /Logged in on /m
57
+ end
46
58
 
47
- msc.connect_ftp_access('admin','admin')
48
- msc.setup_ftp_access do |f|
59
+ after :each do
60
+ @msc.logout
61
+ @msc.output.last.should =~ /Logged out on /m
62
+ end
63
+
64
+ it "should parse the report prsu patch status" do
65
+ @msc.run "prsm;report prsu rud03p9c"
66
+ @msc.parse_prsu_status.should_not be_empty
67
+ end
68
+
69
+ it "should remove the patch and apply the patch" do
70
+ @msc.change_patch "remove", "rud03p9c"
71
+ @msc.run "prsm;report prsu rud03p9c"
72
+ @msc.parse_prsu_status.should == "R"
73
+
74
+ @msc.connect_ftp_access('admin','admin')
75
+ @msc.setup_ftp_access do |f|
49
76
  remote_file_list=f.nlst
50
77
  begin
51
78
  f.delete 'RUD03P9C$PATCH' if remote_file_list.include? 'RUD03P9C$PATCH'
@@ -54,13 +81,14 @@ module Rortel
54
81
  end
55
82
  f.site('lrecl 128')
56
83
  end
57
- msc.upload_patch '/home/ruan/sshfs/rud03p9c.ptchppcp'
58
- msc.disconnect_ftp_access
59
- msc.run "listsf all"
60
- msc.change_patch "apply","rud03p9c"
61
- msc.run "prsm;report prsu rud03p9c"
62
- msc.parse_prsu_status.should == "A"
84
+ @msc.upload_patch '/home/ruan/sshfs/rud03p9c.ptchppcp'
85
+ @msc.disconnect_ftp_access
86
+ @msc.run "listsf all"
87
+ @msc.change_patch "apply","rud03p9c"
88
+ @msc.run "prsm;report prsu rud03p9c"
89
+ @msc.parse_prsu_status.should == "A"
63
90
  end
91
+
64
92
  end
65
93
  end
66
94
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rortel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Ruan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-27 00:00:00 +08:00
18
+ date: 2010-08-03 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency