Revision a6e6fe48 snf-cyclades-app/synnefo/logic/management/commands/network-modify.py

b/snf-cyclades-app/synnefo/logic/management/commands/network-modify.py
1
# Copyright 2012-2013 GRNET S.A. All rights reserved.
1
# Copyright 2012-2014 GRNET S.A. All rights reserved.
2 2
#
3 3
# Redistribution and use in source and binary forms, with or
4 4
# without modification, are permitted provided that the following
......
36 36
from django.core.management.base import BaseCommand, CommandError
37 37

  
38 38
from synnefo.db.models import Backend
39
from synnefo.management.common import (get_network, get_backend)
39
from synnefo.management.common import get_resource
40 40
from snf_django.management.utils import parse_bool
41 41
from synnefo.logic import networks, backend as backend_mod
42 42
from django.db import transaction
......
95 95
        if len(args) != 1:
96 96
            raise CommandError("Please provide a network ID")
97 97

  
98
        network = get_network(args[0])
98
        network = get_resource("network", args[0])
99 99

  
100 100
        new_name = options.get("name")
101 101
        if new_name is not None:
......
159 159

  
160 160
        add_to_backend = options["add_to_backend"]
161 161
        if add_to_backend is not None:
162
            backend = get_backend(add_to_backend)
162
            backend = get_resource("backend", add_to_backend)
163 163
            bnet, jobs = backend_mod.ensure_network_is_active(backend,
164 164
                                                              network.id)
165 165
            if jobs:
......
168 168

  
169 169
        remove_from_backend = options["remove_from_backend"]
170 170
        if remove_from_backend is not None:
171
            backend = get_backend(remove_from_backend)
171
            backend = get_resource("backend", remove_from_backend)
172 172
            if network.nics.filter(machine__backend=backend,
173 173
                                   machine__deleted=False).exists():
174 174
                msg = "Cannot remove. There are still connected VMs to this"\

Also available in: Unified diff