-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_php.php
75 lines (64 loc) · 1.6 KB
/
api_php.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
function NexApiGet($ip,$ver,$type,$newconfig)
{
global $username;
global $Rpass;
global $Spass;
global $libpath;
$pass ="";
$str="";
if($ver=="iosxe")
$ver="ios";
if($type=="Swtich")
$pass=$Spass;
$data = array("ip"=>$ip, "username"=>$username, "password"=>$pass,"ver"=>$ver,"newconfig"=>$newconfig);
$datajson=json_encode($data);
$str=$libpath."nxos/nxapi.py '".$datajson."' ";
return $str;
}
function NexApiSet($ip,$ver,$type,$newconfig)
{
global $username;
global $Rpass;
global $Spass;
global $libpath;
$pass ="";
$str="";
if($ver=="iosxe")
$ver="ios";
if($type=="Swtich")
$pass=$Spass;
$data = array("ip"=>$ip, "username"=>$username, "password"=>$pass,"ver"=>$ver,"newconfig"=>$newconfig);
$datajson=json_encode($data);
$str=$libpath."nxos/nxapi_set.py '".$datajson."' ";
return $str;
}
$cmd=$_POST['cmd'];
$data =$_POST['data'];
$obj = json_decode($data);
$DevName =$obj->DevName;
$DevIp = $obj->DevIP;
$DevType =$obj->DevType;
$DevVer =$obj->DevVer;
if($cmd=="GetIntnxos")
{
$command = NexApiGet($DevIp,$DevVer,$DevType,"sh int ");
}
elseif($cmd=="GetIntModenxos")
{
$command = NexApiGet($DevIp,$DevVer,$DevType,"show interface switchport");
}elseif($cmd=="GetVernxos")
{
$command = NexApiGet($DevIp,$DevVer,$DevType,"show version ;sh system resources ;sh environment");
}elseif($cmd=="GetnxSn")
{
$command = NexApiGet($DevIp,$DevVer,$DevType,"sh inventory module");
}elseif($cmd=="GetIntSfpPowernxos")
{
$command = NexApiGet($DevIp,$DevVer,$DevType,"show interface transceiver details");
}
elseif($cmd=="GetVlansAllnxos")
{
$command = NexApiGet($DevIp,$DevVer,$DevType,"sh vlan summary ;show vlan");
}
?>