예제 #1
0
func (d *Driver) getClient() *xmlrpc.Client {
	rpc, err := xmlrpc.NewClient(d.Url, nil)
	if err != nil {
		return nil
	}
	return rpc
}
예제 #2
0
func NewClient() *Client {
	client, _ := xmlrpc.NewClient(OpenSubtitlesAPI, nil)

	return &Client{
		NewUnauthenticatedClientState(*client),
	}
}
예제 #3
0
func (self *Client) Call(serviceMethod string, args []interface{}, reply interface{}) error {
	rpc, err := xmlrpc.NewClient(self.Url, nil)
	if err != nil {
		return err
	}
	return rpc.Call(serviceMethod, args, reply)
}
예제 #4
0
파일: goca.go 프로젝트: pkdevbox/machine
func SetClient(args ...string) error {
	var auth_token string
	var one_auth_path string

	if len(args) == 1 {
		auth_token = args[0]
	} else {
		one_auth_path = os.Getenv("ONE_AUTH")
		if one_auth_path == "" {
			one_auth_path = os.Getenv("HOME") + "/.one/one_auth"
		}

		token, err := ioutil.ReadFile(one_auth_path)
		if err == nil {
			auth_token = strings.TrimSpace(string(token))
		} else {
			auth_token = ""
		}
	}

	one_xmlrpc := os.Getenv("ONE_XMLRPC")
	if one_xmlrpc == "" {
		one_xmlrpc = "http://localhost:2633/RPC2"
	}

	xmlrpcClient, xmlrpcClientError := xmlrpc.NewClient(one_xmlrpc, nil)

	client = &oneClient{
		token:             auth_token,
		xmlrpcClient:      xmlrpcClient,
		xmlrpcClientError: xmlrpcClientError,
	}

	return nil
}
예제 #5
0
func (si *supervisorInstance) run() {
	client, err := xmlrpc.NewClient(fmt.Sprintf("http://%s/RPC2", si.host), nil)
	if err != nil {
		si.err = err
		log.Printf("%s: client error: %v", si.host, err)
		return
	}
	waitTime := sleepTime
	if *signal {
		err = client.Call("supervisor.signalProcess", []interface{}{*program, *signalName}, nil)
		log.Printf("%s: signalProcess. err=%v", si.host, err)
		waitTime = shortSleepTime
	}
	if *stop {
		err = client.Call("supervisor.stopProcess", []interface{}{*program, true}, nil)
		log.Printf("%s: stopProcess. err=%v", si.host, err)
		waitTime = shortSleepTime
	}

	for {
		si.err = client.Call("supervisor.getProcessInfo", *program, &si.info)
		if si.err != nil {
			log.Printf("%s: call error: %v", si.host, err)
			break
		}
		log.Printf("%s: %s", si.host, si.info.StateName)

		if si.info.State != 20 { /* 20=RUNNING */
			break
		}

		time.Sleep(waitTime)
	}
}
예제 #6
0
// Get a new client suitable for communicating with a supervisord.
// url must contain a real url to a supervisord RPC-service.
//
// Url for local supervisord should be http://127.0.0.1:9001/RPC2 by default.
func NewClient(url string) (*Client, error) {
	rpc, err := xmlrpc.NewClient(url, nil)
	if err != nil {
		return nil, err
	}

	return &Client{rpc}, nil
}
예제 #7
0
// NewClient authenticates with Pulse server for a user session, creating
// a RPC client.
func NewClient(url, user, pass string) (Client, error) {
	c, err := &client{d: 15 * time.Second}, (error)(nil)
	if c.rpc, err = xmlrpc.NewClient(url, nil); err != nil {
		return nil, err
	}
	if err = c.rpc.Call("RemoteApi.login", []interface{}{user, pass}, &c.tok); err != nil {
		return nil, err
	}
	return c, nil
}
예제 #8
0
파일: client.go 프로젝트: abourget/ldtp
// New creates a Client, provided with a "host:port" string
func New(hostPort string) *Client {
	rpcClient, err := xmlrpc.NewClient(fmt.Sprintf("http://%s/RPC2", hostPort), nil)
	if err != nil {
		log.Fatalln("Couldn't create XML-RPC client:", err)
	}

	return &Client{
		rpcClient: rpcClient,
	}
}
예제 #9
0
파일: goca.go 프로젝트: OpenNebula/goca
func SetClient(conf OneConfig) error {

	xmlrpcClient, xmlrpcClientError := xmlrpc.NewClient(conf.XmlrpcUrl, nil)

	client = &oneClient{
		token:             conf.Token,
		xmlrpcClient:      xmlrpcClient,
		xmlrpcClientError: xmlrpcClientError,
	}

	return nil
}
예제 #10
0
파일: client.go 프로젝트: xfanity/pulsar
func NewClient() (*Client, error) {
	rpc, err := xmlrpc.NewClient(DefaultOSDBServer, nil)
	if err != nil {
		return nil, err
	}

	c := &Client{
		UserAgent: DefaultUserAgent,
		Client:    rpc, // xmlrpc.Client
	}

	return c, nil
}
예제 #11
0
파일: xapi.go 프로젝트: softlayer/xapi-go
// NewClient stand up a new XapiClient. Version should probably be "1.2" unless you know what you are doing.
func NewClient(uri, username, password, version string) (client Client) {
	client.URI = uri
	client.Username = username
	client.Password = password
	client.Version = version
	client.rpc, _ = xmlrpc.NewClient(
		client.URI,
		&http.Transport{
			Dial: TimeoutDialer(),
		})

	return
}
예제 #12
0
파일: api.go 프로젝트: morpheyesh/goca
/**
 *
 * Creates an RPCClient with endpoint and returns it
 *
 **/
func NewRPCClient(endpoint string, username string, password string) (*Rpc, error) {
	log.Debugf(cmd.Colorfy("  > [one-go] connecting", "blue", "", "bold"))

	RPCclient, err := xmlrpc.NewClient(endpoint, nil)

	if err != nil {
		//TO-DO: trap and send connRefused error.
		return nil, err
	}
	log.Debugf(cmd.Colorfy("  > [one-go] connected", "blue", "", "bold")+" %s", endpoint)

	return &Rpc{
		RPCClient: *RPCclient,
		Key:       username + ":" + password}, nil
}
예제 #13
0
파일: rpc.go 프로젝트: janqii/go-supervisor
// NewClient creates a new supervisor RPC client.
func NewClient(url string) (client Client, err error) {
	var rpc *xmlrpc.Client
	if rpc, err = xmlrpc.NewClient(url, nil); err != nil {
		return
	}

	version := ""
	if err = rpc.Call("supervisor.getAPIVersion", nil, &version); err != nil {
		return
	}
	if version != apiVersion {
		err = errors.New(fmt.Sprintf("want Supervisor API version %s, got %s instead", apiVersion, version))
		return
	}
	client = Client{rpc, version}
	return
}
예제 #14
0
func NewClient(config map[string]string) (*Rpc, error) {
	log.Debugf(cmd.Colorfy("  > [one-go] connecting", "blue", "", "bold"))

	if !satisfied(config) {
		return nil, ErrArgsNotSatisfied
	}

	client, err := xmlrpc.NewClient(config[ENDPOINT], nil)
	if err != nil {
		return nil, err
	}
	//log.Debugf(cmd.Colorfy("  > [one-go] connection response", "blue", "", "bold")+"%#v",client)
	log.Debugf(cmd.Colorfy("  > [one-go] connected", "blue", "", "bold")+" %s", config[ENDPOINT])

	return &Rpc{
		Client: *client,
		Key:    config[USERID] + ":" + config[PASSWORD]}, nil
}
예제 #15
0
func newBugzillaClient(url string, username string, password string) (*BugzillaClient, error) {
	transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
	client, err := xmlrpc.NewClient(url, transport)
	if err != nil {
		return nil, err
	}

	// Get authentication token
	var resp struct {
		ID    int    `xmlrpc:"id"`
		Token string `xmlrpc:"token"`
	}
	if err = client.Call("User.login", params{"login": username, "password": password}, &resp); err != nil {
		return nil, err
	}

	return &BugzillaClient{
		client: client,
		token:  resp.Token,
	}, nil
}
예제 #16
0
func NewSupervisordCollector() (Collector, error) {
	client, err := xmlrpc.NewClient(*supervisordURL, nil)
	if err != nil {
		return nil, err
	}

	var (
		subsystem  = "supervisord"
		labelNames = []string{"name", "group"}
	)
	return &supervisordCollector{
		client: client,
		upDesc: prometheus.NewDesc(
			prometheus.BuildFQName(Namespace, subsystem, "up"),
			"Process Up",
			labelNames,
			nil,
		),
		stateDesc: prometheus.NewDesc(
			prometheus.BuildFQName(Namespace, subsystem, "state"),
			"Process State",
			labelNames,
			nil,
		),
		exitStatusDesc: prometheus.NewDesc(
			prometheus.BuildFQName(Namespace, subsystem, "exit_status"),
			"Process Exit Status",
			labelNames,
			nil,
		),
		uptimeDesc: prometheus.NewDesc(
			prometheus.BuildFQName(Namespace, subsystem, "uptime"),
			"Process Uptime",
			labelNames,
			nil,
		),
	}, nil
}
예제 #17
0
func NewClient() (*Client, error) {
	xmlClient, err := xmlrpc.NewClient("https://pypi.python.org/pypi", nil)
	return &Client{client: xmlClient}, err
}
예제 #18
0
func rpcClient() (*xmlrpc.Client, error) {
	return xmlrpc.NewClient("http://d.hatena.ne.jp/xmlrpc", nil)
}