RE: [OpenVMPS-devel] External program: answer not being accepted
Brought to you by:
dori_seliskar
From: David S. <dav...@me...> - 2005-11-22 12:39:33
|
What I have is based differently. Can you try changing your application? $fd = fopen("php://stdin", "r"); while (true) { $line=rtrim( fgets($fd, 1024) ); if (strlen($line) > 0) { list($domain, $switch, $port, $lastvlan, $mac)=explode(" ", $line); echo("ALLOW $lastvlan\n"); flush(); // don't know if this needed, but doesn't seem to matter } } fclose($fd); The program will block on the read string until it gets passed something. The external application starts at the same time as vmpsd, or at least the first time it's used. The flush is required, maybe needing to specify stdout?? Dave System Administrator m/v Africa Mercy Mercy Ships tel: 0191 483 8413 ex 108 fax: 0870 460 0764 > -----Original Message----- > From: vmp...@li... > [mailto:vmp...@li...] On Behalf Of > Sean Boran > Sent: 04 November 2005 15:27 > To: vmp...@li... > Subject: [OpenVMPS-devel] External program: answer not being accepted > > > Hi, > > I've having problems getting a basic external plug-in to work. > > I have a simple PHP script: > > while (true) { > $fd = fopen("php://stdin", "r"); > > $line=rtrim( fgets($fd, 1024) ); > if (strlen($line) > 0) { > list($domain, $switch, $port, $lastvlan, > $mac)=explode(" ", $line); > echo("ALLOW $lastvlan\n"); > flush(); // don't know if this needed, but doesn't > seem to matter > } > fclose($fd); > sleep(1); # wait 1 secs, before retrying > } > > The data arrives OK, but what I send back never seems to be > sent by vmpsd, > I've tried > echo("ALLOW $lastvlan\n\n"); > echo("ALLOW $lastvlan\n"); > echo("ALLOW $lastvlan"); > > but no luck. > > IN vmpsd's external.c is seems to happen around here: > write(tocli[1], str, strlen(str)); > n = readline(fromcli[0], buf, 255); > The first line seems to work fine, the second never comes back. > I added in > vmps_log(VQP|DEBUG, ">>>> Sending: %s ", str); > before the "write" line and this works. > > When I look at the code for readline() it seems to read char > by char until > it hits 255 or \n. So it should work. > > In syslog I see: > > Nov 3 23:04:37 INOCESvmps1 vmpsd: ================================== > Nov 3 23:04:37 INOCESvmps1 vmpsd: VQP Request > Nov 3 23:04:37 INOCESvmps1 vmpsd: Unknown: 1 > Nov 3 23:04:37 INOCESvmps1 vmpsd: Request Type: 1 > Nov 3 23:04:37 INOCESvmps1 vmpsd: Response: 0 > Nov 3 23:04:37 INOCESvmps1 vmpsd: No. Data Items: 6 > Nov 3 23:04:37 INOCESvmps1 vmpsd: Sequence No.: 4660 > Nov 3 23:04:37 INOCESvmps1 vmpsd: Client IP address: 193.111.222.1 > Nov 3 23:04:37 INOCESvmps1 vmpsd: Port name: Fa0/17 > Nov 3 23:04:37 INOCESvmps1 vmpsd: Vlan name: test > Nov 3 23:04:37 INOCESvmps1 vmpsd: Domain name: Domain > Nov 3 23:04:37 INOCESvmps1 vmpsd: MAC address: 080020b0cb95 > Nov 3 23:04:37 INOCESvmps1 vmpsd: >>>> Sending: Domain > 193.111.222.1 Fa0/17 > switch1 0800.20b0.cb95 > > My external sends back: "ALLOW test", but vmpsd never sees it > arriving and > vmpsd just sits there waiting. > > Any sugsestions /tips? > > Thanks, > > Sean > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App > Server. Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Vmps-devel mailing list > Vmp...@li... > https://lists.sourceforge.net/lists/listinfo/vmps-devel > |