Revision 3d870b05 snf-cyclades-app/synnefo/api/networks.py

b/snf-cyclades-app/synnefo/api/networks.py
112 112
    req = api.utils.get_request_dict(request)
113 113
    log.info('create_network %s', req)
114 114

  
115
    network_dict = api.utils.get_attribute(req, "network")
116
    flavor = api.utils.get_attribute(network_dict, "type")
115
    network_dict = api.utils.get_attribute(req, "network",
116
                                           attr_type=dict)
117
    flavor = api.utils.get_attribute(network_dict, "type",
118
                                     attr_type=basestring)
117 119

  
118 120
    if flavor not in Network.FLAVORS.keys():
119 121
        raise api.faults.BadRequest("Invalid network type '%s'" % flavor)
......
121 123
        raise api.faults.Forbidden("Cannot create network of type '%s'." %
122 124
                                   flavor)
123 125

  
124
    name = api.utils.get_attribute(network_dict, "name", required=False)
126
    name = api.utils.get_attribute(network_dict, "name", attr_type=basestring,
127
                                   required=False)
125 128
    if name is None:
126 129
        name = ""
127 130

  
......
144 147
def update_network(request, network_id):
145 148
    info = api.utils.get_request_dict(request)
146 149

  
147
    network = api.utils.get_attribute(info, "network", required=True)
148
    new_name = api.utils.get_attribute(network, "name")
150
    network = api.utils.get_attribute(info, "network", attr_type=dict,
151
                                      required=True)
152
    new_name = api.utils.get_attribute(network, "name", attr_type=basestring)
149 153

  
150 154
    network = util.get_network(network_id, request.user_uniq, for_update=True)
151 155
    if network.public:

Also available in: Unified diff