Class: UCSAPI::UCS
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
-
#fabric(opts = {}) ⇒ Object
Logic is simple: * If you give us a dn, return one Fabric * If you provide a text ID, return one Fabric * If you provide nothing, return FabricArray.
- #fabrics(opts = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ UCS
constructor
A new instance of UCS.
- #login ⇒ Object
- #logout ⇒ Object
- #session ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ UCS
Returns a new instance of UCS.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/UCSAPI.rb', line 46 def initialize(opts={}) raise "No parameters" if opts == nil @log = Logger.new(STDOUT) @log.level = Logger::ERROR @log.progname = self.class.to_s @log.info("initialize starting") @api = API.new(opts) @log.info("initialize ending") end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
44 45 46 |
# File 'lib/UCSAPI.rb', line 44 def api @api end |
Instance Method Details
#fabric(opts = {}) ⇒ Object
Logic is simple:
-
If you give us a dn, return one Fabric
-
If you provide a text ID, return one Fabric
-
If you provide nothing, return FabricArray
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/UCSAPI.rb', line 78 def fabric(opts={}) @log.info("fabric started") classId = 'networkElement' if opts[:dn] element = @api.configResolveDn( :dn => opts[:dn]) found = Fabric.create(@api,element) elsif opts[:id] then dn = 'sys/switch-' + opts[:id] element = @api.configResolveDn( :dn => dn ) found = Fabric.create(@api,element) else classId = 'networkElement' elements = @api.configResolveClass( :classId => classId) found = FabricArray.create(@api,elements) end @log.info "fabric ended" found end |
#fabrics(opts = {}) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/UCSAPI.rb', line 99 def fabrics(opts={}) @log.info("fabrics started") found = fabric(opts) @log.info("fabrics ended") found end |
#login ⇒ Object
58 59 60 |
# File 'lib/UCSAPI.rb', line 58 def login @api.login if @api.session. = "" end |
#logout ⇒ Object
70 71 72 |
# File 'lib/UCSAPI.rb', line 70 def logout @api.logout end |
#session ⇒ Object
66 67 68 |
# File 'lib/UCSAPI.rb', line 66 def session @api.session end |