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 <[email protected]> wrote:

> thanks mate
>
> On Tue, Jul 7, 2015 at 4:06 AM, Marco Giovannini <[email protected]>
> 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
>>
>
>

Reply via email to