Revision 89a1c636 kamaki/cli/commands/cyclades.py

b/kamaki/cli/commands/cyclades.py
449 449
            'If neither --network or --no-network are used, the default '
450 450
            'network policy is applied. These policies are set on the cloud, '
451 451
            'so kamaki is oblivious to them',
452
            '--no-network')
452
            '--no-network'),
453
        project=ValueArgument('Assign the server to project', '--project'),
453 454
    )
454 455
    required = ('server_name', 'flavor_id', 'image_id')
455 456

  
456 457
    @errors.cyclades.cluster_size
457
    def _create_cluster(self, prefix, flavor_id, image_id, size):
458
    def _create_cluster(self, prefix, flavor_id, image_id, size, project=None):
458 459
        networks = self['network_configuration'] or (
459 460
            [] if self['no_network'] else None)
460 461
        servers = [dict(
461 462
            name='%s%s' % (prefix, i if size > 1 else ''),
462 463
            flavor_id=flavor_id,
463 464
            image_id=image_id,
465
            project=project,
464 466
            personality=self['personality'],
465 467
            networks=networks) for i in range(1, 1 + size)]
466 468
        if size == 1:
......
493 495
    @errors.cyclades.flavor_id
494 496
    def _run(self, name, flavor_id, image_id):
495 497
        for r in self._create_cluster(
496
                name, flavor_id, image_id, size=self['cluster_size'] or 1):
498
                name, flavor_id, image_id, size=self['cluster_size'] or 1,
499
                project=self['project']):
497 500
            if not r:
498 501
                self.error('Create %s: server response was %s' % (name, r))
499 502
                continue
......
586 589

  
587 590

  
588 591
@command(server_cmds)
592
class server_reassign(_init_cyclades, _optional_json):
593
    """Assign a VM to a different project
594
    """
595

  
596
    @errors.generic.all
597
    @errors.cyclades.connection
598
    @errors.cyclades.server_id
599
    def _run(self, server_id, project):
600
        self.client.reassign_server(server_id, project)
601

  
602
    def main(self, server_id, project):
603
        super(self.__class__, self)._run()
604
        self._run(server_id=server_id, project=project)
605

  
606

  
607
@command(server_cmds)
589 608
class server_delete(_init_cyclades, _optional_output_cmd, _server_wait):
590 609
    """Delete a virtual server"""
591 610

  

Also available in: Unified diff