Class: Oc::Run::Domain

Inherits:
Base
  • Object
show all
Defined in:
lib/system/run/commands/domain.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #options

Instance Method Summary collapse

Methods inherited from Base

description, example, get_object_name, meta, method_added, option, options, summary, syntax

Instance Method Details

#create(*args) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/system/run/commands/domain.rb', line 77

def create(*args)
  name = args[0]
  type = args[1]
  data = args[2]
  if data.nil? or type.nil? or data.nil?
    puts "Argument Error".red
    puts "Usage".yellow
    puts "$ oc domain create [DOMAIN_NAME] [TYPE] [IP]".yellow
  else
    result = barge.domain.create_record(name.to_s, {:type => name.to_s, :data => data.to_s})
    if !result.success?
      puts "#{result.message}".red
    else
      puts "Domain created".green
    end
  end
end

#destroy(*args) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/system/run/commands/domain.rb', line 59

def destroy(*args)
  domain = args[0]
  if domain.nil?
    puts "Argument Error".red
    puts "Usage".yellow
    puts "$ oc domain destroy [DOMAIN_NAME]".yellow
  else
    result = barge.domain.destroy(domain.to_s)
    if !result.success?
      puts "#{result.message}".red
    else
      puts "Domain destroyed".green
    end
  end
end

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/system/run/commands/domain.rb', line 6

def run
  result = barge.domain.all
  if !result.success?
    puts "#{result.error}".red
  else
    puts "Domains".yellow
    rows = []
    rows << [
      'Name',
      'TTL'
    ]
    result.domains.each do |domain|
      rows << [
        domain.name.to_s.red,
        domain.ttl
      ]
    end
    table = Terminal::Table.new :rows => rows
    puts table
  end
end

#show(*args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/system/run/commands/domain.rb', line 30

def show(*args)
  domain = args[0]
  if domain.nil?
    puts "Argument Error".red
    puts "Usage".yellow
    puts "$ oc domain show [DOMAIN_NAME]".yellow
  else
    result = barge.domain.show(domain.to_s)
    if !result.success?
      puts "#{result.message}".red
    else
      puts "Domain Information - #{domain}".yellow
      rows = []
      rows << [
        'Name',
        'TTL'
      ]
      rows << [
        result.domain.name.to_s.red,
        result.domain.ttl
      ]
      table = Terminal::Table.new :rows => rows
      puts table
    end
  end
end