Revision 0069a20c snf-cyclades-app/synnefo/api/management/commands/port-create.py

b/snf-cyclades-app/synnefo/api/management/commands/port-create.py
39 39

  
40 40
from synnefo.db.models import Network, NetworkInterface, SecurityGroup
41 41
from synnefo.api import util
42
from synnefo.management.common import get_network, get_vm
42 43
from synnefo.logic import ports
43 44

  
44 45

  
......
55 56
            default=None,
56 57
            help="Name of port"),
57 58
        make_option(
58
            '--owner',
59
            dest='owner',
60
            default=None,
61
            help="The owner of the port"),
62
        make_option(
63 59
            '--network',
64 60
            dest='network',
65 61
            default=None,
......
86 82
        device = options['device_id']
87 83
        #assume giving security groups comma separated
88 84
        security_groups = options['security-groups']
89
        userid = options["owner"]
90 85

  
91 86
        if not name:
92 87
            name=""
......
95 90
            raise CommandError("network is required")
96 91
        if not device:
97 92
            raise CommandError("device is required")
98
        if not userid:
99
            raise CommandError("owner is required")
100 93

  
101 94
        #get the network
102
        network = util.get_network(network, userid, non_deleted=True)
95
        network = get_network(network)
103 96

  
104 97
        #get the vm
105
        vm = util.get_vm(device, userid)
98
        vm = get_vm(device)
106 99

  
107 100
        #validate security groups
108 101
        sg_list = []
......
112 105
                sg = util.get_security_group(int(gid))
113 106
                sg_list.append(sg)
114 107

  
115
        new_port = ports.create(userid, network, vm, security_groups=sg_list)
108
        new_port = ports.create(network, vm, security_groups=sg_list)
116 109
        self.stdout.write("Created port '%s' in DB.\n" % new_port)

Also available in: Unified diff