Return-Path: X-Original-To: apmail-cloudstack-users-cn-archive@www.apache.org Delivered-To: apmail-cloudstack-users-cn-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9BFB910E75 for ; Fri, 28 Aug 2015 09:22:01 +0000 (UTC) Received: (qmail 98941 invoked by uid 500); 28 Aug 2015 09:21:59 -0000 Delivered-To: apmail-cloudstack-users-cn-archive@cloudstack.apache.org Received: (qmail 98796 invoked by uid 500); 28 Aug 2015 09:21:59 -0000 Mailing-List: contact users-cn-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users-cn@cloudstack.apache.org Delivered-To: mailing list users-cn@cloudstack.apache.org Received: (qmail 98760 invoked by uid 99); 28 Aug 2015 09:21:59 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Aug 2015 09:21:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id E554D18222E; Fri, 28 Aug 2015 09:21:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.91 X-Spam-Level: ** X-Spam-Status: No, score=2.91 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id SOkvteWV_W3S; Fri, 28 Aug 2015 09:21:48 +0000 (UTC) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id D29BB21597; Fri, 28 Aug 2015 09:21:47 +0000 (UTC) Received: by lbbsx3 with SMTP id sx3so26627862lbb.0; Fri, 28 Aug 2015 02:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=VTaLXlYwVjZVSoc1HYegKeJ7/vvu4y4u2JdsU6WaXWs=; b=Kec+n/DTVZ8gAzdJeElIb4GY9wCUs1oD/h8cXa8enfySfkAuyX5pNqGLIgaAVILXWn 9UEVtgBhwVgIeZCX0SgdAUpMM/yrdcOedt9+N6a5lpiUCctuWPLJGvqmBzgw3wVvC0xH nsPCK9sZeylFl60RNiqMJ1XbIkgJUeiC2Vkqh/txcxG2aiDZktwiOmpqYwTgBctFrCYT ll0UWFNrBOMpchVnzq5VnoEF+rfxmu8IraMjCyJG6KsuG6iPvZCtqWNkyz4T1vv/NKPx Mbv6sc33/usyOhOW+ZVmGCV+J9QRiXDzU4MGf/uG8eFs1f2wED1DYLYjEJMGvizO7BlD 6PKg== MIME-Version: 1.0 X-Received: by 10.152.5.40 with SMTP id p8mr4679938lap.10.1440753701201; Fri, 28 Aug 2015 02:21:41 -0700 (PDT) Received: by 10.114.99.38 with HTTP; Fri, 28 Aug 2015 02:21:41 -0700 (PDT) In-Reply-To: <55E01E8C.1060509@163.com> References: <55BB56FD.7060004@163.com> <55D300E5.3010701@163.com> <55D30348.3000700@163.com> <55D3EAC1.6050700@163.com> <55DAD7F0.1030207@163.com> <9312E43F-BBB7-4AAC-852A-543CE10BABA3@shapeblue.com> <55DFF933.2060609@163.com> <55E01E8C.1060509@163.com> Date: Fri, 28 Aug 2015 19:21:41 +1000 Message-ID: Subject: Re: How does the parameter startdate/enddate of api listEvents() use new time format like 'yyyy-MM-dd HH:mm:ss' ? From: Santhosh Edukulla To: users@cloudstack.apache.org Cc: users-cn@cloudstack.apache.org, dev@cloudstack.apache.org Content-Type: multipart/alternative; boundary=089e013d116e91af4f051e5b9cbe --089e013d116e91af4f051e5b9cbe Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Cao, Inside "_sort_request" function mentioned at the wiki, change the below line self.params.append(key + '=3D' + urllib.quote_plus(args[key])) to self.params.append( key + '=3D' + str.lower(urllib.quote_plus(args[key])). *replace(**"+", "%20") *) The time stamp parameter "2015-08-28 16:20:00" , you are passing has a space in it, which gets replaced with "+" through quote_plus logic, so replace that "+" with "%20", this is getting passed in calculating signature in later function. Similarly, change it for "_build_post_request" function. Let us know. Regards, Santhosh On Fri, Aug 28, 2015 at 6:40 PM, wrote: > > > My scripts is just from cloudstack website > > https://cwiki.apache.org/confluence/display/CLOUDSTACK/Simple+class+for+m= aking+API+calls%2C+Python > > and I just do some testing like this: > > 1. >>> from SignedAPICall import api > 2. >>> api.listEvents(listall=3D'true', startdate=3D'2015-08-28') > 3. >>> api.listEvents(listall=3D'true', startdate=3D'2015-08-28 16:20:00'= ) > > Line 2 works fine, line 3 failed with error " 'http error', 401, > 'Unauthorized' ". > > I also do some other tests, they also works fine, like api.listHosts() > api.listVirtualMachines(). > > when line 3 failed, management-server.log said this: > > 2015-08-28 16:37:53,619 DEBUG [c.c.a.ApiServlet] > (catalina-exec-15:ctx-4e587804) =3D=3D=3DSTART=3D=3D=3D 10.0.1.99 -- GET > apiKey=3DhjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQI= ZXUVwfaT1vANdDUJs3Vkkg&command=3DlistEvents&listall=3Dtrue&response=3Djson&= startdate=3D2015-08-28+16%3A20%3A00&signature=3Dr7wa861jYWP4QbNMeEjZZ2wNpIc= %3D > 2015-08-28 16:37:53,622 INFO [c.c.a.ApiServer] > (catalina-exec-15:ctx-4e587804 ctx-1f6fddbe) User signature: > r7wa861jYWP4QbNMeEjZZ2wNpIc=3D is not equaled to computed signature: > 4c8Kmn+cbMZAmfSvSISPkWt9WCQ=3D > 2015-08-28 16:37:53,622 DEBUG [c.c.a.ApiServlet] > (catalina-exec-15:ctx-4e587804 ctx-1f6fddbe) =3D=3D=3DEND=3D=3D=3D 10.0.= 1.99 -- GET > apiKey=3DhjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQI= ZXUVwfaT1vANdDUJs3Vkkg&command=3DlistEvents&listall=3Dtrue&response=3Djson&= startdate=3D2015-08-28+16%3A20%3A00&signature=3Dr7wa861jYWP4QbNMeEjZZ2wNpIc= %3D > > following for line 2: > 2015-08-28 16:37:15,900 DEBUG [c.c.a.ApiServlet] > (catalina-exec-13:ctx-f8019189) =3D=3D=3DSTART=3D=3D=3D 10.0.1.99 -- GET > apiKey=3DhjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQI= ZXUVwfaT1vANdDUJs3Vkkg&command=3DlistEvents&listall=3Dtrue&response=3Djson&= startdate=3D2015-08-28&signature=3DKZZIAOaRduzCJlo0byaN9j4uvro%3D > 2015-08-28 16:37:15,939 DEBUG [c.c.a.ApiServlet] > (catalina-exec-13:ctx-f8019189 ctx-c42b8c5e ctx-1ebbe226) =3D=3D=3DEND=3D= =3D=3D > 10.0.1.99 -- GET > apiKey=3DhjZ12EQ4JfFasIHO3RCXBLji-3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQI= ZXUVwfaT1vANdDUJs3Vkkg&command=3DlistEvents&listall=3Dtrue&response=3Djson&= startdate=3D2015-08-28&signature=3DKZZIAOaRduzCJlo0byaN9j4uvro%3D > > > > ----------- > Cao Tong > > > On 08/28/2015 02:09 PM, Abhinandan Prateek wrote: > >> apikey/signature should work and they have same privileges as the >> respective user logged in. >> Are all the api calls failing or just some ? >> Can you share relevant portion of the scripts that you are trying to run= ? >> >> On 28-Aug-2015, at 11:31 am, tony_caotong@163.com wrote: >>> >>> >>> Thanks for all your people's replys. >>> >>> 1. Abhinandan, My ACS manager was not listening on port '8096', >>> >>> 2. As Yipeng said, When I call this api from cloudmonkey, it works >>> fine, like this >>> " cloudmonkey api listEvents listall=3Dtrue startdate=3D'2015-08-28 >>> 00:00:00' " >>> >>> When I call it through my python scripts, I used the >>> apikey/signature pair to work, but it failed. >>> I found that how cloudmonkey works, >>> first it login with username/password, then call the function with >>> this session id. >>> >>> it seems that the apikey/signature pair's privilege is not same with >>> username/password pair's ? >>> >>> >>> @Daan, yes I am a Chinese. I am afraid it's not a preblem about >>> character encodings perhaps. >>> >>> >>> ----------- >>> Cao Tong >>> >>> On 08/27/2015 08:54 PM, Abhinandan Prateek wrote: >>> >>>> Try using the =E2=80=9C8096=E2=80=9D port for testing/checking APIs. >>>> >>>> shapeblue.com> wrote: >>>> >>>>> Yes, as per >>>>> https://cloudstack.apache.org/api/apidocs-4.2/root_admin/listEvents.h= tml >>>>> >>>>> >>>>> On 24-Aug-2015, at 2:08 pm, tony_caotong@163.com wrote: >>>>>> >>>>>> Hello Every. >>>>>> >>>>>> I know this is a very simple question to most of you. but it is >>>>>> really hard for me to continue my work. >>>>>> >>>>>> So could Anyone spend your three minutes to give me some advice, it >>>>>> will be very usefull to me. >>>>>> >>>>>> my question is: >>>>>> >>>>>> How does the parameter startdate/enddate of api listEvents() use >>>>>> new time format like 'yyyy-MM-dd HH:mm:ss' ? >>>>>> >>>>>> >>>>>> Event({'listall':'True', 'startdate':'2015-08-24 00:00:00'}) >>>>>>>>> >>>>>>>> >>>>>> http://10.0.1.100:8080/client/api?apiKey=3DhjZ12EQ4JfFasIHO3RCXBLji-= 3RbBmdC973utGwCL5388WypVKwtaNsDso-JzVQIZXUVwfaT1vANdDUJs3Vkkg&command=3Dlis= tEvents&listall=3DTrue&response=3Djson&startdate=3D2015-08-24+00%3A00%3A00&= signature=3Dz4LQCw7yzGmTK5B7TzAbzl1biXI%3D >>>>>> Traceback (most recent call last): >>>>>> File "", line 1, in >>>>>> File "SignedAPICall.py", line 67, in Event >>>>>> a =3D api.listEvents(request) >>>>>> File "SignedAPICall.py", line 49, in handlerFunction >>>>>> return self._make_request(name, args[0]) >>>>>> File "SignedAPICall.py", line 61, in _make_request >>>>>> data =3D self._http_get(self.value) >>>>>> File "SignedAPICall.py", line 54, in _http_get >>>>>> response =3D urllib.urlopen(url) >>>>>> File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen >>>>>> return opener.open(url) >>>>>> File "/usr/lib64/python2.7/urllib.py", line 208, in open >>>>>> return getattr(self, name)(url) >>>>>> File "/usr/lib64/python2.7/urllib.py", line 359, in open_http >>>>>> return self.http_error(url, fp, errcode, errmsg, headers) >>>>>> File "/usr/lib64/python2.7/urllib.py", line 372, in http_error >>>>>> result =3D method(url, fp, errcode, errmsg, headers) >>>>>> File "/usr/lib64/python2.7/urllib.py", line 683, in http_error_401 >>>>>> errcode, errmsg, headers) >>>>>> File "/usr/lib64/python2.7/urllib.py", line 381, in http_error_defau= lt >>>>>> raise IOError, ('http error', errcode, errmsg, headers) >>>>>> IOError: ('http error', 401, 'Unauthorized', >>>>> instance at 0x7f083da78998>) >>>>>> >>>>>> ----------- >>>>>> Cao Tong >>>>>> >>>>>> On 08/19/2015 10:32 AM, tony_caotong@163.com wrote: >>>>>> >>>>>>> Hi All: >>>>>>> >>>>>>> Does any one have any idea ? Thanks. >>>>>>> >>>>>>> ----------- >>>>>>> Cao Tong >>>>>>> >>>>>>> On 08/18/2015 06:04 PM, tony_caotong@163.com wrote: >>>>>>> >>>>>>>> In ParamProcessWorker::setFieldValue() I found this lins: >>>>>>>> >>>>>>>> case DATE: >>>>>>>> // This piece of code is for maintaining backward >>>>>>>> compatibility >>>>>>>> // and support both the date formats(Bug 9724) >>>>>>>> >>>>>>>> Is it related to my problem? Where can I found the descriptions >>>>>>>> about BUG9724 ? >>>>>>>> >>>>>>>> ----------- >>>>>>>> Cao Tong >>>>>>>> >>>>>>>> On 08/18/2015 05:54 PM, tony_caotong@163.com wrote: >>>>>>>> >>>>>>>>> Hello, >>>>>>>>> >>>>>>>>> When I use timestamp format startdate=3D"2015-07-31", it works fi= nd. >>>>>>>>> When I use it like this startdate=3D"2015-07-31 13:00:00". >>>>>>>>> It return a error >>>>>>>>> IOError: ('http error', 401, 'Unauthorized', >>>>>>>> instance at 0x16dca70>) >>>>>>>>> >>>>>>>>> Could anyone tell me why ? >>>>>>>>> >>>>>>>>> I have read the code >>>>>>>>> "DefaultLoginAPIAuthenticatorCmd::authenticate()" , but I am stil= l not >>>>>>>>> understand what was happening, >>>>>>>>> it seems authenticate failed, but why?? >>>>>>>>> >>>>>>>>> ----------- >>>>>>>>> Cao Tong >>>>>>>>> >>>>>>>>> On 07/31/2015 07:07 PM, tony_caotong@163.com wrote: >>>>>>>>> >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> was this format is enabled in ACS 4.5.1 like /"yyyy-MM-dd >>>>>>>>>> HH:mm:ss" >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> / I found it in 4.5.0 API doc, but it seems not enabled. >>>>>>>>>> >>>>>>>>>> http://cloudstack.apache.org/api/apidocs-4.5/user/listEvents.htm= l >>>>>>>>>> >>>>>>>>>> api.listEvents(startdate=3D"2015-07-31 13:00:00") >>>>>>>>>>>>> >>>>>>>>>>>> Traceback (most recent call last): >>>>>>>>>> File "", line 1, in >>>>>>>>>> File "call.py", line 48, in handlerFunction >>>>>>>>>> return self._make_request(name, kwargs) >>>>>>>>>> File "call.py", line 60, in _make_request >>>>>>>>>> data =3D self._http_get(self.value) >>>>>>>>>> File "call.py", line 53, in _http_get >>>>>>>>>> response =3D urllib.urlopen(url) >>>>>>>>>> File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen >>>>>>>>>> return opener.open(url) >>>>>>>>>> File "/usr/lib64/python2.7/urllib.py", line 208, in open >>>>>>>>>> return getattr(self, name)(url) >>>>>>>>>> File "/usr/lib64/python2.7/urllib.py", line 359, in open_http >>>>>>>>>> return self.http_error(url, fp, errcode, errmsg, headers) >>>>>>>>>> File "/usr/lib64/python2.7/urllib.py", line 372, in http_error >>>>>>>>>> result =3D method(url, fp, errcode, errmsg, headers) >>>>>>>>>> File "/usr/lib64/python2.7/urllib.py", line 683, in http_error_4= 01 >>>>>>>>>> errcode, errmsg, headers) >>>>>>>>>> File "/usr/lib64/python2.7/urllib.py", line 381, in >>>>>>>>>> http_error_default >>>>>>>>>> raise IOError, ('http error', errcode, errmsg, headers) >>>>>>>>>> IOError: ('http error', 401, 'Unauthorized', >>>>>>>>> instance at 0x16dca70>) >>>>>>>>>> >>>>>>>>>> my ACS version: >>>>>>>>>> >>>>>>>>>> [root@cs ~]# rpm -qa |grep cloud >>>>>>>>>> cloudstack-management-4.5.1-shapeblue0.el6.x86_64 >>>>>>>>>> cloudstack-awsapi-4.5.1-shapeblue0.el6.x86_64 >>>>>>>>>> cloudstack-agent-4.5.1-shapeblue0.el6.x86_64 >>>>>>>>>> cloudstack-common-4.5.1-shapeblue0.el6.x86_64 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Find out more about ShapeBlue and our range of CloudStack relate= d >>>>> services >>>>> >>>>> IaaS Cloud Design & Build< >>>>> http://shapeblue.com/iaas-cloud-design-and-build//> >>>>> CSForge =E2=80=93 rapid IaaS deployment framework< >>>>> http://shapeblue.com/csforge/> >>>>> CloudStack Consulting >>>>> CloudStack Software Engineering< >>>>> http://shapeblue.com/cloudstack-software-engineering/> >>>>> CloudStack Infrastructure Support< >>>>> http://shapeblue.com/cloudstack-infrastructure-support/> >>>>> CloudStack Bootcamp Training Courses< >>>>> http://shapeblue.com/cloudstack-training/> >>>>> >>>>> This email and any attachments to it may be confidential and are >>>>> intended solely for the use of the individual to whom it is addressed= . Any >>>>> views or opinions expressed are solely those of the author and do not >>>>> necessarily represent those of Shape Blue Ltd or related companies. I= f you >>>>> are not the intended recipient of this email, you must neither take a= ny >>>>> action based upon its contents, nor copy or show it to anyone. Please >>>>> contact the sender if you believe you have received this email in err= or. >>>>> Shape Blue Ltd is a company incorporated in England & Wales. ShapeBlu= e >>>>> Services India LLP is a company incorporated in India and is operated= under >>>>> license from Shape Blue Ltd. Shape Blue Brasil Consultoria Ltda is a >>>>> company incorporated in Brasil and is operated under license from Sha= pe >>>>> Blue Ltd. ShapeBlue SA Pty Ltd is a company registered by The Republi= c of >>>>> South Africa and is traded under license from Shape Blue Ltd. ShapeBl= ue is >>>>> a registered trademark. >>>>> >>>> Find out more about ShapeBlue and our range of CloudStack related >>>> services >>>> >>>> IaaS Cloud Design & Build< >>>> http://shapeblue.com/iaas-cloud-design-and-build//> >>>> CSForge =E2=80=93 rapid IaaS deployment framework>>> > >>>> CloudStack Consulting >>>> CloudStack Software Engineering< >>>> http://shapeblue.com/cloudstack-software-engineering/> >>>> CloudStack Infrastructure Support< >>>> http://shapeblue.com/cloudstack-infrastructure-support/> >>>> CloudStack Bootcamp Training Courses< >>>> http://shapeblue.com/cloudstack-training/> >>>> >>>> This email and any attachments to it may be confidential and are >>>> intended solely for the use of the individual to whom it is addressed.= Any >>>> views or opinions expressed are solely those of the author and do not >>>> necessarily represent those of Shape Blue Ltd or related companies. If= you >>>> are not the intended recipient of this email, you must neither take an= y >>>> action based upon its contents, nor copy or show it to anyone. Please >>>> contact the sender if you believe you have received this email in erro= r. >>>> Shape Blue Ltd is a company incorporated in England & Wales. ShapeBlue >>>> Services India LLP is a company incorporated in India and is operated = under >>>> license from Shape Blue Ltd. Shape Blue Brasil Consultoria Ltda is a >>>> company incorporated in Brasil and is operated under license from Shap= e >>>> Blue Ltd. ShapeBlue SA Pty Ltd is a company registered by The Republic= of >>>> South Africa and is traded under license from Shape Blue Ltd. ShapeBlu= e is >>>> a registered trademark. >>>> >>> >>> >>> Find out more about ShapeBlue and our range of CloudStack related >> services >> >> IaaS Cloud Design & Build< >> http://shapeblue.com/iaas-cloud-design-and-build//> >> CSForge =E2=80=93 rapid IaaS deployment framework >> CloudStack Consulting >> CloudStack Software Engineering< >> http://shapeblue.com/cloudstack-software-engineering/> >> CloudStack Infrastructure Support< >> http://shapeblue.com/cloudstack-infrastructure-support/> >> CloudStack Bootcamp Training Courses< >> http://shapeblue.com/cloudstack-training/> >> >> This email and any attachments to it may be confidential and are intende= d >> solely for the use of the individual to whom it is addressed. Any views = or >> opinions expressed are solely those of the author and do not necessarily >> represent those of Shape Blue Ltd or related companies. If you are not t= he >> intended recipient of this email, you must neither take any action based >> upon its contents, nor copy or show it to anyone. Please contact the sen= der >> if you believe you have received this email in error. Shape Blue Ltd is = a >> company incorporated in England & Wales. ShapeBlue Services India LLP is= a >> company incorporated in India and is operated under license from Shape B= lue >> Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in Bra= sil >> and is operated under license from Shape Blue Ltd. ShapeBlue SA Pty Ltd = is >> a company registered by The Republic of South Africa and is traded under >> license from Shape Blue Ltd. ShapeBlue is a registered trademark. >> > > > > --089e013d116e91af4f051e5b9cbe--