def create_network(network): rc = create_rc_by_network(network) network_params = {'name': "network-%s" % network.id, "admin_state_up": True} LOG.info("Start to create network, id:[%s], name[%s]", network.id, network.name) begin = datetime.datetime.now() try: net = neutron.network_create(rc, **network_params) end = datetime.datetime.now() LOG.info("Create network api apply [%s] seconds", \ (end-begin).seconds) network.network_id = net.id network.status = NETWORK_STATE_ACTIVE network.save() except Exception as ex: end = datetime.datetime.now() LOG.info("Create network api apply [%s] seconds", \ (end-begin).seconds) network.status = NETWORK_STATE_ERROR network.save() LOG.exception("Failed to create network, id:[%s], name[%s], " "exception:[%s]", network.id, network.name, ex) raise ex return network
def network_delete_task(network=None): rc = create_rc_by_network(network) LOG.info("delete network,id:[%s],name[%s]" % (network.id, network.name)) try: net = neutron.network_delete(rc, network.network_id) network.network_id = None network.deleted = True network.save() except Exception as ex: network.status = NETWORK_STATE_ERROR network.save() LOG.info("delete network error,id:[%s],name[%s]" % (network.id, network.name)) raise ex return network
def network_create_task(network): rc = create_rc_by_network(network) network_params = {'name': "network-%s" % network.id, "admin_state_up": True} LOG.info("start create network,id:[%s],name[%s]" % (network.id, network.name)) try: net = neutron.network_create(rc, **network_params) network.network_id = net.id network.status = NETWORK_STATE_ACTIVE network.save() except Exception as ex: network.status = NETWORK_STATE_ERROR network.save() LOG.info("create network error,id:[%s],name[%s],msg:[%s]" % (network.id, network.name, ex)) raise ex return network
def create_network(network): rc = create_rc_by_network(network) network_params = {'name': "network-%s" % network.id, "admin_state_up": True} LOG.info("Start to create network, id:[%s], name[%s]", network.id, network.name) try: net = neutron.network_create(rc, **network_params) network.network_id = net.id network.status = NETWORK_STATE_ACTIVE network.save() except Exception as ex: network.status = NETWORK_STATE_ERROR network.save() LOG.exception("Failed to create network, id:[%s], name[%s], " "exception:[%s]", network.id, network.name, ex) raise ex return network
def network_delete_task(network): rc = create_rc_by_network(network) LOG.info("delete network,id:[%s],name[%s]" % (network.id, network.name)) try: # delete all subnet LOG.info("delete all subnet, network id [%s] name[%s]" % (network.id, network.name)) subnet_set = Subnet.objects.filter(network_id=network.id, deleted=False) for subnet in subnet_set: subnet_delete_task(subnet) # delete network net = neutron.network_delete(rc, network.network_id) network.network_id = None network.deleted = True network.save() except Exception as ex: network.status = NETWORK_STATE_ERROR network.save() LOG.info("delete network error,id:[%s],name[%s],msg:[%s]" % (network.id, network.name, ex)) raise ex return network
def delete_network(network): rc = create_rc_by_network(network) LOG.info("Start to delete network, id:[%s], name[%s]", network.id, network.name) try: subnet_set = Subnet.objects.filter(network_id=network.id, deleted=False) for subnet in subnet_set: delete_subnet(subnet) neutron.network_delete(rc, network.network_id) network.network_id = None network.deleted = True network.save() except Exception as ex: network.status = NETWORK_STATE_ERROR network.save() LOG.exception("Failed to delete network, id:[%s], name[%s], msg:[%s]", network.id, network.name, ex) raise ex return network
def create_network(network): rc = create_rc_by_network(network) network_params = { 'name': "network-%s" % network.id, "admin_state_up": True } LOG.info("Start to create network, id:[%s], name[%s]", network.id, network.name) try: net = neutron.network_create(rc, **network_params) network.network_id = net.id network.status = NETWORK_STATE_ACTIVE network.save() except Exception as ex: network.status = NETWORK_STATE_ERROR network.save() LOG.exception( "Failed to create network, id:[%s], name[%s], " "exception:[%s]", network.id, network.name, ex) raise ex return network