You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cloudstack.apache.org by Marco Giovannini <us...@gmail.com> on 2015/07/07 13:06:39 UTC

cloudmonkey - account name with spaces

Hi

I'm using Cloudstack 4.3.X. and  I need to  use cloudmonkey to perform the
task of assigning the vm instance to another user (I did not find a way to
do from the web interface in one step)

I'm using the following command:

assign virtualmachine *account='Part1 Part2 Part3*'
domainid=9f33d216-cd9e-485a-9858-e5805afe8097
virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21
networkids=ff1567f0-0820-4116-98b1-c79a55120356

This command is giving me back the following error


nt/api', 'expires=600',
'secretkey=g_fBs2UpAJQSu0CfL8s5hVhC0wTaEkYfQITT1v81fW87wSXduZvBqOKAgJsq_Y4Q48JXnfUD9Cjn9SerbaoprA',
'timeout=3600', 'password=password']
2015-07-07 10:47:37,578 - requester.py:41 - [DEBUG] ======== START Request
========
2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Requesting
command=assignVirtualMachine, args={'networkids':
'ff1567f0-0820-4116-98b1-c79a55120356',* 'Part3': ''*, 'virtualmachineid':
'96aa0da7-29ca-48a7-b928-b73052933e21', *'account': 'Part1', 'Part2':* '',
'domainid': '9f33d216-cd9e-485a-9858-e5805afe8097'}
2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Request sent:
http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D
2015-07-07 10:47:37,675 - requester.py:41 - [DEBUG] Response received: None
2015-07-07 10:47:37,675 - requester.py:41 -* [DEBUG] Error:
Error:Unauthorized None*

As  you  can see the account name with spaces is messing up the account
name used in the call and this is the reason I get the unauthorized error.

I tried different way to put the account name, with quote  without quote or
substitute the space with %20 but nothing worked.

Is the any known workaround  to get rid of this issue?

Regards,
Marco

Re: cloudmonkey - account name with spaces

Posted by Marco Giovannini <us...@gmail.com>.
Cloning the repo and  installing it the URL seems much better.

Now it is failing for another reason but it seems a step forward :)

2015-07-09 11:08:40,084 - requester.py:49 - [DEBUG] ======== START Request
========
2015-07-09 11:08:40,084 - requester.py:49 - [DEBUG] Requesting
command=assignVirtualMachine, *args={u'account': u'Part 1 Part2 Part3',*
u'domainid': u'9f33d216-cd9e-485a-9858-e5805afe8097', u'networkids':
u'ff1567f0-0820-4116-98b1-c79a55120356', u'virtualmachineid':
u'96aa0da7-29ca-48a7-b928-b73052933e21'}
2015-07-09 11:08:40,093 - connectionpool.py:735 - [INFO] Starting new HTTPS
connection (1): host.domain.com
2015-07-09 11:08:40,194 - connectionpool.py:383 - [DEBUG] "GET
/url1/url2/url3?signatureversion=3&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&expires=2015-07-09T12%3A48%3A40%2B0000&networkids=ff1567f0-0820-4116-98b1-c79a55120356&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&signature=cemsm4BCpNn5u8WrrZhdQXeZYHo%3D&
*account=Part1+Part2+Part3*&response=json HTTP/1.1" 500 0
2015-07-09 11:08:40,195 - requester.py:49 - [DEBUG] Request sent:
https://host.domain.com/url1/url2/url3?signatureversion=3&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&expires=2015-07-09T12%3A48%3A40%2B0000&networkids=ff1567f0-0820-4116-98b1-c79a55120356&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&signature=cemsm4BCpNn5u8WrrZhdQXeZYHo%3D&account=
*Part1+Part2+Part3*&response=json
2015-07-09 11:08:40,195 - requester.py:49 - [DEBUG] Response received:
2015-07-09 11:08:40,195 - requester.py:49 - [DEBUG] Error: 500: None


Regards,
Marco

On Thu, Jul 9, 2015 at 9:44 AM, Marco Giovannini <us...@gmail.com> wrote:

> Hi
>
> I tried the double quote but the issue persist :(.
>
> Currently I'm using cloudmonkey 5.2.0 and I can not change it at the
> moment in the production env so I'm testing  a more recent version in my
> test env but that part of the code did not change so I suppose I will face
> the same issue.
>
> Regards,
> Marco
>
> On Wed, Jul 8, 2015 at 6:09 PM, Rohit Yadav <ro...@shapeblue.com>
> wrote:
>
>>  Hi Marco,
>>
>>  Are you using the latest version, CloudMonkey 5.3.1?
>>
>>  Can you try using double quotes? Like: assign virtualmachine
>> account=โ€œstring1 string2โ€
>> (CloudMonkey using shlex, fyi)
>>
>>  The account parameter for the API should be provided as is (in case you
>> were trying to do wild card search using a star - *).
>>
>>  Hope this helps.
>>
>> On 08-Jul-2015, at 7:34 pm, Marco Giovannini <us...@gmail.com> wrote:
>>
>> Hi
>>
>> after a deeper investigation I think the  issue is in the cloudmonkey.py
>> in the following function as it is using space as delimiter for the
>> options
>> of the command.
>>
>> I will install a cloudmonkey in my test environment and I'll see if I'm
>> right and able to fix it.
>>
>>    def default(self, args):
>>        if self.pipe_runner(args):
>>            return
>>
>>        apiname = args.partition(' ')[0]
>>        verb, subject = splitverbsubject(apiname)
>>
>>        lexp = shlex.shlex(args.strip())
>>        lexp.whitespace = " "
>> *        lexp.whitespace_split = True*
>>
>>        lexp.posix = True
>>        args = []
>>        while True:
>>            next_val = lexp.next()
>>            if next_val is None:
>>                break
>>            args.append(next_val.replace('\x00', ''))
>>
>>        args_dict = dict(map(lambda x: [x.partition("=")[0],
>>                                        x.partition("=")[2]],
>>                             args[1:])[x] for x in range(len(args) - 1))
>>        field_filter = None
>>        if 'filter' in args_dict:
>>            field_filter = filter(lambda x: x is not '',
>>                                  map(lambda x: x.strip(),
>>                                      args_dict.pop('filter').split(',')))
>>
>>        missing = []
>>        if verb in self.apicache and subject in self.apicache[verb]:
>>            missing = filter(lambda x: x not in [key.split('[')[0]
>>                                                 for key in args_dict],
>>
>> self.apicache[verb][subject]['requiredparams'])
>>
>>        if len(missing) > 0:
>>            self.monkeyprint("Missing arguments: ", ' '.join(missing))
>>            return
>>
>>        isasync = False
>>        if 'asyncapis' in self.apicache:
>>            isasync = apiname in self.apicache['asyncapis']
>>
>>        result = self.make_request(apiname, args_dict, isasync)
>>
>>        if result is None:
>>            return
>>        try:
>>            responsekeys = filter(lambda x: 'response' in x, result.keys())
>>            for responsekey in responsekeys:
>>                self.print_result(result[responsekey], field_filter)
>>            print
>>        except Exception as e:
>>            self.monkeyprint("๐Ÿ™ˆ  Error on parsing and printing", e)
>>
>>
>>
>> Regards,
>> Marco
>>
>> On Tue, Jul 7, 2015 at 7:44 PM, Nick Brody <ni...@gmail.com>
>> wrote:
>>
>> thanks mate
>>
>> On Tue, Jul 7, 2015 at 4:06 AM, Marco Giovannini <us...@gmail.com>
>> wrote:
>>
>> Hi
>>
>> I'm using Cloudstack 4.3.X. and  I need to  use cloudmonkey to perform the
>> task of assigning the vm instance to another user (I did not find a way to
>> do from the web interface in one step)
>>
>> I'm using the following command:
>>
>> assign virtualmachine *account='Part1 Part2 Part3*'
>> domainid=9f33d216-cd9e-485a-9858-e5805afe8097
>> virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21
>> networkids=ff1567f0-0820-4116-98b1-c79a55120356
>>
>> This command is giving me back the following error
>>
>>
>> nt/api', 'expires=600',
>>
>>
>> 'secretkey=g_fBs2UpAJQSu0CfL8s5hVhC0wTaEkYfQITT1v81fW87wSXduZvBqOKAgJsq_Y4Q48JXnfUD9Cjn9SerbaoprA',
>> 'timeout=3600', 'password=password']
>> 2015-07-07 10:47:37,578 - requester.py:41 - [DEBUG] ======== START Request
>> ========
>> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Requesting
>> command=assignVirtualMachine, args={'networkids':
>> 'ff1567f0-0820-4116-98b1-c79a55120356',* 'Part3': ''*, 'virtualmachineid':
>> '96aa0da7-29ca-48a7-b928-b73052933e21', *'account': 'Part1', 'Part2':* '',
>> 'domainid': '9f33d216-cd9e-485a-9858-e5805afe8097'}
>> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Request sent:
>>
>> http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?
>> account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D
>> 2015-07-07
>> <
>> http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D2015-07-07
>> >
>> 10:47:37,675 - requester.py:41 - [DEBUG] Response received: None
>> 2015-07-07 10:47:37,675 - requester.py:41 -* [DEBUG] Error:
>> Error:Unauthorized None*
>>
>> As  you  can see the account name with spaces is messing up the account
>> name used in the call and this is the reason I get the unauthorized error.
>>
>> I tried different way to put the account name, with quote  without quote
>> or
>> substitute the space with %20 but nothing worked.
>>
>> Is the any known workaround  to get rid of this issue?
>>
>> Regards,
>> Marco
>>
>>
>>
>>
>> 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 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 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.
>>
>
>

Re: cloudmonkey - account name with spaces

Posted by Marco Giovannini <us...@gmail.com>.
Hi

I tried the double quote but the issue persist :(.

Currently I'm using cloudmonkey 5.2.0 and I can not change it at the moment
in the production env so I'm testing  a more recent version in my test env
but that part of the code did not change so I suppose I will face the same
issue.

Regards,
Marco

On Wed, Jul 8, 2015 at 6:09 PM, Rohit Yadav <ro...@shapeblue.com>
wrote:

>  Hi Marco,
>
>  Are you using the latest version, CloudMonkey 5.3.1?
>
>  Can you try using double quotes? Like: assign virtualmachine
> account=โ€œstring1 string2โ€
> (CloudMonkey using shlex, fyi)
>
>  The account parameter for the API should be provided as is (in case you
> were trying to do wild card search using a star - *).
>
>  Hope this helps.
>
> On 08-Jul-2015, at 7:34 pm, Marco Giovannini <us...@gmail.com> wrote:
>
> Hi
>
> after a deeper investigation I think the  issue is in the cloudmonkey.py
> in the following function as it is using space as delimiter for the options
> of the command.
>
> I will install a cloudmonkey in my test environment and I'll see if I'm
> right and able to fix it.
>
>    def default(self, args):
>        if self.pipe_runner(args):
>            return
>
>        apiname = args.partition(' ')[0]
>        verb, subject = splitverbsubject(apiname)
>
>        lexp = shlex.shlex(args.strip())
>        lexp.whitespace = " "
> *        lexp.whitespace_split = True*
>
>        lexp.posix = True
>        args = []
>        while True:
>            next_val = lexp.next()
>            if next_val is None:
>                break
>            args.append(next_val.replace('\x00', ''))
>
>        args_dict = dict(map(lambda x: [x.partition("=")[0],
>                                        x.partition("=")[2]],
>                             args[1:])[x] for x in range(len(args) - 1))
>        field_filter = None
>        if 'filter' in args_dict:
>            field_filter = filter(lambda x: x is not '',
>                                  map(lambda x: x.strip(),
>                                      args_dict.pop('filter').split(',')))
>
>        missing = []
>        if verb in self.apicache and subject in self.apicache[verb]:
>            missing = filter(lambda x: x not in [key.split('[')[0]
>                                                 for key in args_dict],
>                             self.apicache[verb][subject]['requiredparams'])
>
>        if len(missing) > 0:
>            self.monkeyprint("Missing arguments: ", ' '.join(missing))
>            return
>
>        isasync = False
>        if 'asyncapis' in self.apicache:
>            isasync = apiname in self.apicache['asyncapis']
>
>        result = self.make_request(apiname, args_dict, isasync)
>
>        if result is None:
>            return
>        try:
>            responsekeys = filter(lambda x: 'response' in x, result.keys())
>            for responsekey in responsekeys:
>                self.print_result(result[responsekey], field_filter)
>            print
>        except Exception as e:
>            self.monkeyprint("๐Ÿ™ˆ  Error on parsing and printing", e)
>
>
>
> Regards,
> Marco
>
> On Tue, Jul 7, 2015 at 7:44 PM, Nick Brody <ni...@gmail.com>
> wrote:
>
> thanks mate
>
> On Tue, Jul 7, 2015 at 4:06 AM, Marco Giovannini <us...@gmail.com>
> wrote:
>
> Hi
>
> I'm using Cloudstack 4.3.X. and  I need to  use cloudmonkey to perform the
> task of assigning the vm instance to another user (I did not find a way to
> do from the web interface in one step)
>
> I'm using the following command:
>
> assign virtualmachine *account='Part1 Part2 Part3*'
> domainid=9f33d216-cd9e-485a-9858-e5805afe8097
> virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21
> networkids=ff1567f0-0820-4116-98b1-c79a55120356
>
> This command is giving me back the following error
>
>
> nt/api', 'expires=600',
>
>
> 'secretkey=g_fBs2UpAJQSu0CfL8s5hVhC0wTaEkYfQITT1v81fW87wSXduZvBqOKAgJsq_Y4Q48JXnfUD9Cjn9SerbaoprA',
> 'timeout=3600', 'password=password']
> 2015-07-07 10:47:37,578 - requester.py:41 - [DEBUG] ======== START Request
> ========
> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Requesting
> command=assignVirtualMachine, args={'networkids':
> 'ff1567f0-0820-4116-98b1-c79a55120356',* 'Part3': ''*, 'virtualmachineid':
> '96aa0da7-29ca-48a7-b928-b73052933e21', *'account': 'Part1', 'Part2':* '',
> 'domainid': '9f33d216-cd9e-485a-9858-e5805afe8097'}
> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Request sent:
>
> http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?
> account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D
> 2015-07-07
> <
> http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D2015-07-07
> >
> 10:47:37,675 - requester.py:41 - [DEBUG] Response received: None
> 2015-07-07 10:47:37,675 - requester.py:41 -* [DEBUG] Error:
> Error:Unauthorized None*
>
> As  you  can see the account name with spaces is messing up the account
> name used in the call and this is the reason I get the unauthorized error.
>
> I tried different way to put the account name, with quote  without quote
> or
> substitute the space with %20 but nothing worked.
>
> Is the any known workaround  to get rid of this issue?
>
> Regards,
> Marco
>
>
>
>
> 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 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 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.
>

Re: cloudmonkey - account name with spaces

Posted by Rohit Yadav <ro...@shapeblue.com>.
Hi Marco,

Are you using the latest version, CloudMonkey 5.3.1?

Can you try using double quotes? Like: assign virtualmachine account=โ€œstring1 string2โ€
(CloudMonkey using shlex, fyi)

The account parameter for the API should be provided as is (in case you were trying to do wild card search using a star - *).

Hope this helps.

On 08-Jul-2015, at 7:34 pm, Marco Giovannini <us...@gmail.com>> wrote:

Hi

after a deeper investigation I think the  issue is in the cloudmonkey.py
in the following function as it is using space as delimiter for the options
of the command.

I will install a cloudmonkey in my test environment and I'll see if I'm
right and able to fix it.

   def default(self, args):
       if self.pipe_runner(args):
           return

       apiname = args.partition(' ')[0]
       verb, subject = splitverbsubject(apiname)

       lexp = shlex.shlex(args.strip())
       lexp.whitespace = " "
*        lexp.whitespace_split = True*
       lexp.posix = True
       args = []
       while True:
           next_val = lexp.next()
           if next_val is None:
               break
           args.append(next_val.replace('\x00', ''))

       args_dict = dict(map(lambda x: [x.partition("=")[0],
                                       x.partition("=")[2]],
                            args[1:])[x] for x in range(len(args) - 1))
       field_filter = None
       if 'filter' in args_dict:
           field_filter = filter(lambda x: x is not '',
                                 map(lambda x: x.strip(),
                                     args_dict.pop('filter').split(',')))

       missing = []
       if verb in self.apicache and subject in self.apicache[verb]:
           missing = filter(lambda x: x not in [key.split('[')[0]
                                                for key in args_dict],
                            self.apicache[verb][subject]['requiredparams'])

       if len(missing) > 0:
           self.monkeyprint("Missing arguments: ", ' '.join(missing))
           return

       isasync = False
       if 'asyncapis' in self.apicache:
           isasync = apiname in self.apicache['asyncapis']

       result = self.make_request(apiname, args_dict, isasync)

       if result is None:
           return
       try:
           responsekeys = filter(lambda x: 'response' in x, result.keys())
           for responsekey in responsekeys:
               self.print_result(result[responsekey], field_filter)
           print
       except Exception as e:
           self.monkeyprint("๐Ÿ™ˆ  Error on parsing and printing", e)



Regards,
Marco

On Tue, Jul 7, 2015 at 7:44 PM, Nick Brody <ni...@gmail.com>> wrote:

thanks mate

On Tue, Jul 7, 2015 at 4:06 AM, Marco Giovannini <us...@gmail.com>>
wrote:

Hi

I'm using Cloudstack 4.3.X. and  I need to  use cloudmonkey to perform the
task of assigning the vm instance to another user (I did not find a way to
do from the web interface in one step)

I'm using the following command:

assign virtualmachine *account='Part1 Part2 Part3*'
domainid=9f33d216-cd9e-485a-9858-e5805afe8097
virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21
networkids=ff1567f0-0820-4116-98b1-c79a55120356

This command is giving me back the following error


nt/api', 'expires=600',

'secretkey=g_fBs2UpAJQSu0CfL8s5hVhC0wTaEkYfQITT1v81fW87wSXduZvBqOKAgJsq_Y4Q48JXnfUD9Cjn9SerbaoprA',
'timeout=3600', 'password=password']
2015-07-07 10:47:37,578 - requester.py:41 - [DEBUG] ======== START Request
========
2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Requesting
command=assignVirtualMachine, args={'networkids':
'ff1567f0-0820-4116-98b1-c79a55120356',* 'Part3': ''*, 'virtualmachineid':
'96aa0da7-29ca-48a7-b928-b73052933e21', *'account': 'Part1', 'Part2':* '',
'domainid': '9f33d216-cd9e-485a-9858-e5805afe8097'}
2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Request sent:

http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D
2015-07-07
<http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D2015-07-07>
10:47:37,675 - requester.py:41 - [DEBUG] Response received: None
2015-07-07 10:47:37,675 - requester.py:41 -* [DEBUG] Error:
Error:Unauthorized None*

As  you  can see the account name with spaces is messing up the account
name used in the call and this is the reason I get the unauthorized error.

I tried different way to put the account name, with quote  without quote
or
substitute the space with %20 but nothing worked.

Is the any known workaround  to get rid of this issue?

Regards,
Marco




Regards,
Rohit Yadav
Software Architect, ShapeBlue


[cid:9DD97B41-04C5-45F0-92A7-951F3E962F7A]


M. +91 88 262 30892 | rohit.yadav@shapeblue.com<ma...@shapeblue.com>
Blog: bhaisaab.org<http://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 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 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.

Re: cloudmonkey - account name with spaces

Posted by Marco Giovannini <us...@gmail.com>.
Hi

after a deeper investigation I think the  issue is in the cloudmonkey.py
in the following function as it is using space as delimiter for the options
of the command.

I will install a cloudmonkey in my test environment and I'll see if I'm
right and able to fix it.

    def default(self, args):
        if self.pipe_runner(args):
            return

        apiname = args.partition(' ')[0]
        verb, subject = splitverbsubject(apiname)

        lexp = shlex.shlex(args.strip())
        lexp.whitespace = " "
*        lexp.whitespace_split = True*
        lexp.posix = True
        args = []
        while True:
            next_val = lexp.next()
            if next_val is None:
                break
            args.append(next_val.replace('\x00', ''))

        args_dict = dict(map(lambda x: [x.partition("=")[0],
                                        x.partition("=")[2]],
                             args[1:])[x] for x in range(len(args) - 1))
        field_filter = None
        if 'filter' in args_dict:
            field_filter = filter(lambda x: x is not '',
                                  map(lambda x: x.strip(),
                                      args_dict.pop('filter').split(',')))

        missing = []
        if verb in self.apicache and subject in self.apicache[verb]:
            missing = filter(lambda x: x not in [key.split('[')[0]
                                                 for key in args_dict],
                             self.apicache[verb][subject]['requiredparams'])

        if len(missing) > 0:
            self.monkeyprint("Missing arguments: ", ' '.join(missing))
            return

        isasync = False
        if 'asyncapis' in self.apicache:
            isasync = apiname in self.apicache['asyncapis']

        result = self.make_request(apiname, args_dict, isasync)

        if result is None:
            return
        try:
            responsekeys = filter(lambda x: 'response' in x, result.keys())
            for responsekey in responsekeys:
                self.print_result(result[responsekey], field_filter)
            print
        except Exception as e:
            self.monkeyprint("๐Ÿ™ˆ  Error on parsing and printing", e)



Regards,
Marco

On Tue, Jul 7, 2015 at 7:44 PM, Nick Brody <ni...@gmail.com> wrote:

> thanks mate
>
> On Tue, Jul 7, 2015 at 4:06 AM, Marco Giovannini <us...@gmail.com>
> wrote:
>
>> Hi
>>
>> I'm using Cloudstack 4.3.X. and  I need to  use cloudmonkey to perform the
>> task of assigning the vm instance to another user (I did not find a way to
>> do from the web interface in one step)
>>
>> I'm using the following command:
>>
>> assign virtualmachine *account='Part1 Part2 Part3*'
>> domainid=9f33d216-cd9e-485a-9858-e5805afe8097
>> virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21
>> networkids=ff1567f0-0820-4116-98b1-c79a55120356
>>
>> This command is giving me back the following error
>>
>>
>> nt/api', 'expires=600',
>>
>> 'secretkey=g_fBs2UpAJQSu0CfL8s5hVhC0wTaEkYfQITT1v81fW87wSXduZvBqOKAgJsq_Y4Q48JXnfUD9Cjn9SerbaoprA',
>> 'timeout=3600', 'password=password']
>> 2015-07-07 10:47:37,578 - requester.py:41 - [DEBUG] ======== START Request
>> ========
>> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Requesting
>> command=assignVirtualMachine, args={'networkids':
>> 'ff1567f0-0820-4116-98b1-c79a55120356',* 'Part3': ''*, 'virtualmachineid':
>> '96aa0da7-29ca-48a7-b928-b73052933e21', *'account': 'Part1', 'Part2':* '',
>> 'domainid': '9f33d216-cd9e-485a-9858-e5805afe8097'}
>> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Request sent:
>>
>> http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D
>> 2015-07-07
>> <http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D2015-07-07>
>> 10:47:37,675 - requester.py:41 - [DEBUG] Response received: None
>> 2015-07-07 10:47:37,675 - requester.py:41 -* [DEBUG] Error:
>> Error:Unauthorized None*
>>
>> As  you  can see the account name with spaces is messing up the account
>> name used in the call and this is the reason I get the unauthorized error.
>>
>> I tried different way to put the account name, with quote  without quote
>> or
>> substitute the space with %20 but nothing worked.
>>
>> Is the any known workaround  to get rid of this issue?
>>
>> Regards,
>> Marco
>>
>
>

Re: cloudmonkey - account name with spaces

Posted by Nick Brody <ni...@gmail.com>.
thanks mate

On Tue, Jul 7, 2015 at 4:06 AM, Marco Giovannini <us...@gmail.com> wrote:

> Hi
>
> I'm using Cloudstack 4.3.X. and  I need to  use cloudmonkey to perform the
> task of assigning the vm instance to another user (I did not find a way to
> do from the web interface in one step)
>
> I'm using the following command:
>
> assign virtualmachine *account='Part1 Part2 Part3*'
> domainid=9f33d216-cd9e-485a-9858-e5805afe8097
> virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21
> networkids=ff1567f0-0820-4116-98b1-c79a55120356
>
> This command is giving me back the following error
>
>
> nt/api', 'expires=600',
>
> 'secretkey=g_fBs2UpAJQSu0CfL8s5hVhC0wTaEkYfQITT1v81fW87wSXduZvBqOKAgJsq_Y4Q48JXnfUD9Cjn9SerbaoprA',
> 'timeout=3600', 'password=password']
> 2015-07-07 10:47:37,578 - requester.py:41 - [DEBUG] ======== START Request
> ========
> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Requesting
> command=assignVirtualMachine, args={'networkids':
> 'ff1567f0-0820-4116-98b1-c79a55120356',* 'Part3': ''*, 'virtualmachineid':
> '96aa0da7-29ca-48a7-b928-b73052933e21', *'account': 'Part1', 'Part2':* '',
> 'domainid': '9f33d216-cd9e-485a-9858-e5805afe8097'}
> 2015-07-07 10:47:37,579 - requester.py:41 - [DEBUG] Request sent:
>
> http://inth1-vdc-pcpman2.pargar.cp.vdc:8080/client/api?account=Interoute&apiKey=YpMzLF_JyICbhmHKTlhW16B0NntlX210T5XAZlILM8L85qYDaNaRKdNBIQp-hniVPFkMjeQuLQxjynrUplBp8Q&command=assignVirtualMachine&domainid=9f33d216-cd9e-485a-9858-e5805afe8097&expires=2015-07-07T10%3A57%3A37%2B0000&Management=&networkids=ff1567f0-0820-4116-98b1-c79a55120356&response=json&signatureversion=3&VDC=&virtualmachineid=96aa0da7-29ca-48a7-b928-b73052933e21&signature=el38MIugRpFdSatTT9FU93rfrr8%3D
> 2015-07-07 10:47:37,675 - requester.py:41 - [DEBUG] Response received:
> None
> 2015-07-07 10:47:37,675 - requester.py:41 -* [DEBUG] Error:
> Error:Unauthorized None*
>
> As  you  can see the account name with spaces is messing up the account
> name used in the call and this is the reason I get the unauthorized error.
>
> I tried different way to put the account name, with quote  without quote or
> substitute the space with %20 but nothing worked.
>
> Is the any known workaround  to get rid of this issue?
>
> Regards,
> Marco
>