Skip navigation
8413 Views 3 Replies Latest reply: Mar 15, 2011 12:42 PM by patbaker82 RSS
Nicholas Henry Newbie 1 posts since
Mar 24, 2010
Currently Being Moderated

Mar 24, 2010 5:37 PM

Issues with xmlrpc when adding a device - newbie

I was able to follow the example for sending an event: http://community.zenoss.org/docs/DOC-3750#technique_sending_an_event and it works find... I am now simply trying to add a device, but I am having issues...

 

import java.net.URL;
import java.util.HashMap;
 
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
 
 
public class AddServer {
 
 
  public static void main(String[] args) throws Exception {
      XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
      String url = "http://monitor.sc.net:8080/zport/dmd/DeviceLoader";
      config.setServerURL(new URL(url));
      config.setBasicUserName("adminUser");
      config.setBasicPassword("adminPassword");
 
 
      XmlRpcClient client = new XmlRpcClient();
      client.setConfig(config);
 
 
      HashMap<String,Object> params = new HashMap<String,Object>();
 
 
      params.put("deviceName", "www.sc.net");
 
      client.execute("loadDevice", new Object[]{params});
  }
}
 

 

When I run this, it does not give me any errors or anything, but it also does not add the server...

 

So I tried with wget:

$ wget -O- 'http://adminUser:adminPassword@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.netadminPassword@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.netadminPassword@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.netadminPassword@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.net'
--2010-03-24 15:28:34--  http://adminUser:*password*@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.net*password*@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.net*password*@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.net*password*@monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.net
Resolving monitor.sc.net... 123.234.234.234
Connecting to monitor.sc.net|123.234.234.234|:8080... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://monitor.sc.net:8080/zport/acl_users/cookieAuthHelper/login_form?came_from=http%3A//monitor.sc.net%3A8080/zport/dmd/DeviceLoader/loadDevice%3FdeviceName%3Dwww.sc.net [following]
--2010-03-24 15:28:34--  http://monitor.sc.net:8080/zport/acl_users/cookieAuthHelper/login_form?came_from=http%3A//monitor.sc.net%3A8080/zport/dmd/DeviceLoader/loadDevice%3FdeviceName%3Dwww.sc.net
Connecting to monitor.sc.net|123.234.234.234|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4131 (4.0K) [text/html]
Saving to: `STDOUT'

 0% [                                                                                                                                                                      ] 0           --.-K/s              <html>
    <head>
        <link rel="shortcut icon" type="image/x-icon" href="/zport/dmd/favicon.ico" />
        <title>Zenoss Login</title>
        <style>
            .inputbox {
                border: medium none;
                background: transparent none;
                width: 180px;
                font-size: 110%;
                color: #444;
                text-align: center;
                position: absolute;
                left: 367px;
                z-index: 100;
            }
            .submitbutton {
                position: absolute;
                z-index: 100;
                background: transparent url('zenoss-login-button.png');
                top: 245px;
                left: 466px;
                width: 90px;
                height: 32px;
                border: medium none;
                cursor: hand; cursor: pointer;
            }
            * { zoom: 1; } /* IE7 compatibility */
            body {
                margin: 0;
                padding: 0;
                background-color: #888;
                position: relative;
                z-index: 0;
            }
            #topbar {
                height: 20%;
                position: relative;
                z-index: 0;
            }
            #middlebar {
                text-align:center;
                height:360px;
                border-width: 2px 0;
                border-style: solid;
                border-color: #444;
                background-color:#f4f4f4;
                position: relative;
                z-index: 1;
            }
            #container {
                width:671px;
                margin: 0 auto;
                height:360px;
                position: relative;
                z-index: 1;
            }
            #loginimg {
                position: absolute;
                height: 360px;
                width: 671px;
                top: 0;
                left: -50px;
                z-index: 2;
            }
            #errorbox {
                width: 300px;
                position: absolute;
                top: 250px;
                left: 210px;
                z-index: 100;
            }
            span.error {
                font-family: sans-serif;
                color: #8B0000;
            }
            #copyright {
                color: #4e7aba;
                font-size: 70%;
                font-family: sans-serif;
                text-align: center;
                width: 300px;
                position: absolute;
                top: 300px;
                left: 265px;
                z-index: 2;
            }
        </style>
    </head>

    <body onload="document.getElementById('username').focus();">
        <div id="topbar"></div>
        <form name="loginform" method="POST"
              action="http://monitor.sc.net:8080/zport/acl_users/cookieAuthHelper/login">
                <input type="hidden" name="came_from"
                       value="http://monitor.sc.net:8080/zport/dmd/DeviceLoader/loadDevice?deviceName=www.sc.net" />
                <input type="hidden" name="submitted" value="true" />
            <div id="middlebar">
                <div id="container">
                    <div id="loginimg" style="background:transparent url(zenoss-login.png)
                        no-repeat">
                    </div>
                    <input id="username" type="text" name="__ac_name" class="inputbox" style="top:160px" />
                    <input type="password" name="__ac_password" class="inputbox" style="top:202px;" />
                    <div id="errorbox">
                        
                            
                        
                    </div>
                    <input type="submit" name="submitbutton" class="submitbutton" value="" />
                    <div id="copyright">
                        <p>Copyright &copy; 2005-2010 Zenoss, Inc. | Version
                        <span>2.5.2</span>
                        </p>
                    </div>
                </div>
            </div>
        </form>
        
    </body>


</html>
100%[=====================================================================================================================================================================>] 4,131       --.-K/s   in 0.001s  

2010-03-24 15:28:34 (3.58 MB/s) - `-' saved [4131/4131]

 

This also doesn't really do much of anything, but if I do copy/paste the url into my web browser, things work correctly...

 

Any advice or suggestions?  (Especially with the Java Portion)

 

Also, does anyone know of any examples that show how to manage users with xmlrpc?

 

Thanks!

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points