Return-Path: X-Original-To: apmail-ambari-user-archive@www.apache.org Delivered-To: apmail-ambari-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D5BF410622 for ; Fri, 17 Jan 2014 20:43:03 +0000 (UTC) Received: (qmail 83940 invoked by uid 500); 17 Jan 2014 20:43:03 -0000 Delivered-To: apmail-ambari-user-archive@ambari.apache.org Received: (qmail 83884 invoked by uid 500); 17 Jan 2014 20:43:03 -0000 Mailing-List: contact user-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ambari.apache.org Delivered-To: mailing list user@ambari.apache.org Received: (qmail 83875 invoked by uid 99); 17 Jan 2014 20:43:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jan 2014 20:43:03 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of yusaku@hortonworks.com designates 209.85.215.50 as permitted sender) Received: from [209.85.215.50] (HELO mail-la0-f50.google.com) (209.85.215.50) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jan 2014 20:42:57 +0000 Received: by mail-la0-f50.google.com with SMTP id ec20so3950653lab.23 for ; Fri, 17 Jan 2014 12:42:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=Nb6NN7sGEd3ak/WRril0eCsU7umDQP86DC5a62Q5YD0=; b=f5hNb+k8E33vUV6V+orx1gv+tXDq4uAPyWgejW5KQkRc55CI0iHF6m/sZKPI0Da2ix eb6WT9k1YROO4ll8hYrE1wDJdt9aN7D/fJ56076flhDzmNnrKe1i4cghU27K02BsOeDS qvxcfIDX5yVpmCPgxJwpNV8s/HcdB3W4UI+3besHM26L3xKJuJni3IXII5GI8ododrZ2 jzigggOKLsFWRrkRPMDEcaZb8/9X9gsFJuyZTW+g48YMxwwXbeBylzaH2xOw3girfOQ7 oeOHR9ofhmhzUfysVuLFxQyrrRAiQu7TCQZUrWkocCMUTf0JPZuQuiSifczUGh6VUNyZ nsoQ== X-Gm-Message-State: ALoCoQnQNe0sGeTxcQjXzHTMIuMpicP0R7Mb6ttYpIaL2yg6LmEzyvbnC6i3qyYmpxiF6SyEkWRO9q2emYJ88gs4m0LoOjo5dHGs5I+gN9uNfcuDX1J+QwA= MIME-Version: 1.0 X-Received: by 10.112.190.106 with SMTP id gp10mr2003221lbc.37.1389991356461; Fri, 17 Jan 2014 12:42:36 -0800 (PST) Received: by 10.112.26.135 with HTTP; Fri, 17 Jan 2014 12:42:36 -0800 (PST) In-Reply-To: References: Date: Fri, 17 Jan 2014 12:42:36 -0800 Message-ID: Subject: Re: Ambari Client errors against Ambari Server version 1.4.3-38 From: Yusaku Sako To: user@ambari.apache.org Content-Type: multipart/alternative; boundary=001a11c33eaa0b04fe04f03095eb X-Virus-Checked: Checked by ClamAV on apache.org --001a11c33eaa0b04fe04f03095eb Content-Type: text/plain; charset=US-ASCII Sorry about that. Also filed a JIRA to make it so that the API returns a meaningful error message when the server is expecting this HTTP header: https://issues.apache.org/jira/browse/AMBARI-4338 Yusaku On Fri, Jan 17, 2014 at 12:31 PM, Anoop Rajendra wrote: > Oh!! My!! God!! > > I've been breaking my head over this for 2 weeks now. It works. > > Thanks, > -Anoop > > On Fri, Jan 17, 2014 at 12:26 PM, Yusaku Sako > wrote: > > I think this is due to an API change to prevent CSRFs (Cross-Site Forgery > > Requests). > > Ambari Server now expects an additional HTTP header called > "X-Requested-By" > > for all non-GET calls. The value can be set to anything. > > I suppose this change has not reflected in the ambari-client code yet. > > > > Yusaku > > > > > > On Fri, Jan 17, 2014 at 12:19 PM, Chris Mildebrandt < > chris@woodenrhino.com> > > wrote: > >> > >> I'm having the same issue. I just posted the details I was able to > gather. > >> Does this work for anyone? > >> > >> -Chris > >> > >> > >> On Wed, Jan 15, 2014 at 4:41 PM, Anoop Rajendra < > anoop.rajendra@gmail.com> > >> wrote: > >>> > >>> Hi, > >>> > >>> I'm using Ambari Server version 1.4.3-38 > >>> > >>> I downloaded the Ambari source code from git, and built the > >>> ambari-client package. > >>> > >>> The client API functions correctly on all GET methods. However, > >>> whenever I try to use PUT or POST methods the client fails. For > >>> example, my code below is very simple, > >>> > >>> #!/usr/bin/python > >>> > >>> > >>> import os > >>> import json > >>> import logging > >>> import ambari_client.ambari_api > >>> logging.basicConfig() > >>> > >>> a = ambari_client.ambari_api.AmbariClient('compute-0-0.local') > >>> print > >>> > a.get('stacks2/HDP/versions/2.0.6/operatingSystems/redhat6/repositories/HDP-2.0.6') > >>> > >>> r = > >>> {'Repositories':{'base_url':' > http://10.1.1.1/install/distributions/rocks-dist/x86_64'}} > >>> > >>> > >>> > a.put('stacks2/HDP/versions/2.0.6/operatingSystems/redhat6/repositories/HDP-2.0.6', > >>> json.dumps(r)) > >>> > >>> This always returns an HTTP error 400: Bad request. > >>> > >>> This used to work properly with version 1.4.1-25 of the Ambari Server. > >>> > >>> Any ideas? > >>> > >>> -Anoop > >> > >> > > > > > > CONFIDENTIALITY NOTICE > > NOTICE: This message is intended for the use of the individual or entity > to > > which it is addressed and may contain information that is confidential, > > privileged and exempt from disclosure under applicable law. If the > reader of > > this message is not the intended recipient, you are hereby notified that > any > > printing, copying, dissemination, distribution, disclosure or forwarding > of > > this communication is strictly prohibited. If you have received this > > communication in error, please contact the sender immediately and delete > it > > from your system. Thank You. > -- CONFIDENTIALITY NOTICE NOTICE: This message is intended for the use of the individual or entity to which it is addressed and may contain information that is confidential, privileged and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any printing, copying, dissemination, distribution, disclosure or forwarding of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and delete it from your system. Thank You. --001a11c33eaa0b04fe04f03095eb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Sorry about that.
Also filed a JIRA to make= it so that the API returns a meaningful error message when the server is e= xpecting this HTTP header: https://issues.apache.org/jira/browse/AMBARI-4338

Yusaku


On Fri, Jan 17, 2014 at 12:31 PM, Anoop Rajendra <= span dir=3D"ltr"><anoop.rajendra@gmail.com> wrote:
Oh!! My!! God!!

I've been breaking my head over this for 2 weeks now. It works.

Thanks,
-Anoop

On Fri, Jan 17, 2014 at 12:26 PM, Yusaku Sako <yusaku@hortonworks.com> wrote:
> I think this is due to a= n API change to prevent CSRFs (Cross-Site Forgery
> Requests).
> Ambari Server now expects an additional HTTP header called "X-Req= uested-By"
> for all non-GET calls. =A0The value can be set to anything.
> I suppose this change has not reflected in the ambari-client code yet.=
>
> Yusaku
>
>
> On Fri, Jan 17, 2014 at 12:19 PM, Chris Mildebrandt <chris@woodenrhino.com>
> wrote:
>>
>> I'm having the same issue. I just posted the details I was abl= e to gather.
>> Does this work for anyone?
>>
>> -Chris
>>
>>
>> On Wed, Jan 15, 2014 at 4:41 PM, Anoop Rajendra <anoop.rajendra@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I'm using Ambari Server version 1.4.3-38
>>>
>>> I downloaded the Ambari source code from git, and built the >>> ambari-client package.
>>>
>>> The client API functions correctly on all GET methods. However= ,
>>> whenever I try to use PUT or POST methods the client fails. Fo= r
>>> example, my code below is very simple,
>>>
>>> #!/usr/bin/python
>>>
>>>
>>> import os
>>> import json
>>> import logging
>>> import ambari_client.ambari_api
>>> logging.basicConfig()
>>>
>>> a =3D ambari_client.ambari_api.AmbariClient('compute-0-0.l= ocal')
>>> print
>>> a.get('stacks2/HDP/versions/2.0.6/operatingSystems/redhat6= /repositories/HDP-2.0.6')
>>>
>>> r =3D
>>> {'Repositories':{'base_url':'http://10.1.1.1/install/distributions/rocks-dist/x86_64'}}
>>>
>>>
>>> a.put('stacks2/HDP/versions/2.0.6/operatingSystems/redhat6= /repositories/HDP-2.0.6',
>>> json.dumps(r))
>>>
>>> This always returns an HTTP error 400: Bad request.
>>>
>>> This used to work properly with version 1.4.1-25 of the Ambari= Server.
>>>
>>> Any ideas?
>>>
>>> -Anoop
>>
>>
>
>
> CONFIDENTIALITY NO= TICE
> NOTICE: This message is intended for the use of the individual or enti= ty to
> which it is addressed and may contain information that is confidential= ,
> privileged and exempt from disclosure under applicable law. If the rea= der of
> this message is not the intended recipient, you are hereby notified th= at any
> printing, copying, dissemination, distribution, disclosure or forwardi= ng of
> this communication is strictly prohibited. If you have received this > communication in error, please contact the sender immediately and dele= te it
> from your system. Thank You.


CONFIDENTIALITY NOTICE
NOTICE: This message is = intended for the use of the individual or entity to which it is addressed a= nd may contain information that is confidential, privileged and exempt from= disclosure under applicable law. If the reader of this message is not the = intended recipient, you are hereby notified that any printing, copying, dis= semination, distribution, disclosure or forwarding of this communication is= strictly prohibited. If you have received this communication in error, ple= ase contact the sender immediately and delete it from your system. Thank Yo= u. --001a11c33eaa0b04fe04f03095eb--