cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Meghna Kale <meghna.k...@sungardas.com>
Subject Re: [API] Create/update user issue
Date Mon, 27 Oct 2014 17:24:45 GMT
Thanks Rohit for the reply.
Python script -
I just found it on internet.
       request_type = 'GET'
        params = {
            'command':'updateUser',
            'id':user_id
        }
        if email:   params['email'] = email
        if first_name:  params['firstname'] = first_name
        if last_name:   params['lastname'] = last_name
        if password:    params['password'] = password
        if timezone:    params['timezone'] = timezone
        if user_name:   params['username'] = user_name

            params['response'] = 'json'
            params['apiKey'] = self.api_key

            # build the query string
            query_params = map(lambda (k,v):k+"="+urllib.quote(str(v)),
params.items())
            query_string = "&".join(query_params)

            # build signature
            query_params.sort()
            signature_string = "&".join(query_params).lower()
            signature =
urllib.quote(base64.b64encode(hmac.new(self.secret_key, signature_string,
hashlib.sha1).digest()))

            # final query string...
            url =
self.protocol+"://"+self.host+self.uri+"?"+query_string+"&signature="+signature
            print url
            output = None
            try:
                output = json.loads(urllib2.urlopen(url).read())
Thanks
Meghna.

On Mon, Oct 27, 2014 at 4:02 PM, Rohit Yadav <rohit.yadav@shapeblue.com>
wrote:

> Hi,
>
> > On 27-Oct-2014, at 2:58 pm, Meghna Kale <meghna.kale@sungardas.com>
> wrote:
> >
> > I'm was trying to call Cloudstack create/update user API from a python
> > script.
>
> Can you share the python script? Perhaps it was assume some data?
>
> > But when I add or update timezone it fails with 401 error code. I
> debugged
> > and found that timezone has a special character '/'. I replaced it with
> > '%2F', the API call returns success but it updates the timezone with the
> > '%2F' string in DB.
>
> Url encode when you make API requests. The default timezone is GMT, unless
> you’ve passed timezone arg.
>
> Regards,
> Rohit Yadav
> Software Architect, ShapeBlue
> M. +91 88 262 30892 | rohit.yadav@shapeblue.com
> Blog: bhaisaab.org | Twitter: @_bhaisaab
>
>
>
> 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 – rapid IaaS deployment framework<http://shapeblue.com/csforge/>
> CloudStack Consulting<http://shapeblue.com/cloudstack-consultancy/>
> 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 any 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 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 Blue
> Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in Brasil
> 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.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message