Skip to content

Commit

Permalink
Merge pull request #1 from ohtarr/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ohtarr authored Feb 6, 2019
2 parents ef017c0 + 067338f commit 201adb1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "ohtarr/ciscoparse",
"type": "library",
"description": "PHP7 library to parse cisco cli to php object",
"keywords": [
"php7",
"cisco"
],
"homepage": "http://github.com/ohtarr/ciscoparse",
"authors": [
{
"name": "ohtarr",
"email": "[email protected]",
"role": "Developer"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=7.0.3",
},
"require-dev": {
},
"autoload": {
"psr-4": {
"ohtarr\\": "src"
}
}
}
24 changes: 17 additions & 7 deletions lib/cisco_parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ class CiscoParse
//public $interfaces = [];
public $output = [];

public function __construct()
public function __construct($array)
{

foreach($array as $key => $value)
{
if(array_key_exists($key,$this->input))
{
$this->input[$key] = $value;
}
$this->update();
}
}

public function __destruct()
Expand Down Expand Up @@ -81,27 +88,30 @@ public function update()
if($this->os == "ios")
{
require_once("cisco_ios_parse.php");
$parser = new \ohtarr\CiscoIosParse();
$parser = new \ohtarr\CiscoIosParse($this->input);
return $parser;
}

if($this->os == "iosxe")
{
require_once("cisco_iosxe_parse.php");
$parser = new \ohtarr\CiscoIosxeParse();
$parser = new \ohtarr\CiscoIosxeParse($this->input);
return $parser;
}

if($this->os == "nxos")
{
require_once("cisco_nxos_parse.php");
$parser = new \ohtarr\CisconxosParse();
$parser = new \ohtarr\CisconxosParse($this->input);
return $parser;
}

if($this->os == "iosxr")
{
//require_once("cisco_iosxr_parse.php");
}

if($this->os)
/* if($this->os)
{
$parser->input_data($this->input['run'],"run");
$parser->input_data($this->input['version'],"version");
Expand All @@ -113,7 +123,7 @@ public function update()
$parser->input_data($this->input['switchport'],"switchport");
//$parser->update();
$this->output = $parser->output;
}
} */
}

public function parse_version_to_os()
Expand Down

0 comments on commit 201adb1

Please sign in to comment.