Delete the created network when subnet creation failed.
761167
def _delete_network(self, request, network):
        """"""
        try:
            api.neutron.network_delete(request, network.id)
            LOG.debug('Delete the created network %s '
                      'due to subnet creation failure.', network.id)
            msg = _('Delete the created network "%s" '
                    'due to subnet creation failure.') % network.name
            redirect = self.get_failure_url()
            messages.info(request, msg)
            raise exceptions.Http302(redirect)
        except Exception as e:
            LOG.info('Failed to delete network %(id)s: %(exc)s',
                     {'id': network.id, 'exc': e})
            msg = _('Failed to delete network "%s"') % network.name
            redirect = self.get_failure_url()
            exceptions.handle(request, msg, redirect=redirect)
146933
def remove_network_from_dhcp_agent(self, dhcp_agent, network_id):
        """"""
        return self.delete((self.agent_path + self.DHCP_NETS + "/%s") % (
            dhcp_agent, network_id))
1024236
def delete_network_interface(
        name=None, network_interface_id=None, region=None, key=None,
        keyid=None, profile=None):
    '''
    
    '''
    if not (name or network_interface_id):
        raise SaltInvocationError(
            'Either name or network_interface_id must be provided.'
        )
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    r = {}
    result = _get_network_interface(conn, name, network_interface_id)
    if 'error' in result:
        return result
    eni = result['result']
    try:
        info = _describe_network_interface(eni)
        network_interface_id = info['id']
    except KeyError:
        r['error'] = {'message': 'ID not found for this network interface.'}
        return r
    try:
        r['result'] = conn.delete_network_interface(network_interface_id)
    except boto.exception.EC2ResponseError as e:
        r['error'] = __utils__['boto.get_error'](e)
    return r
896030
def drop_network_by_id(self, network_id: int) -> None:
        """"""
        network = self.session.query(Network).get(network_id)
        self.drop_network(network)
361130
def delete_os_dummy_rtr_nwk(self, rtr_id, net_id, subnet_id):
        
        subnet_lst = set()
        subnet_lst.add(subnet_id)
        ret = self.os_helper.delete_intf_router(None, None, rtr_id, subnet_lst)
        if not ret:
            return ret
        return self.os_helper.delete_network_all_subnets(net_id)
86496
private function handle_delete_networks() {
		$deleted_networks = array_map( 'absint', filter_input( INPUT_POST, 'deleted_networks', FILTER_FORCE_ARRAY ) );
		$override         = (bool) filter_input( INPUT_POST, 'override' );

		foreach ( $deleted_networks as $deleted_network ) {
			$result = delete_network( $deleted_network, $override );
			if ( is_wp_error( $result ) ) {
				wp_die( esc_html( $result->get_error_message() ) );
			}
		}

		$this->handle_redirect( array(
			'networks_deleted' => '1',
		) );
	}
61051
def delete(self, ids):
        
        url = build_uri_with_ids('api/v3/networkv6/%s/', ids)

        return super(ApiNetworkIPv6, self).delete(url)
551785
private void handleCreate(final NetworkContext context) {
    log.debug(String.format("%s - Network configuration created in cluster: %s", NetworkManager.this, cluster.address()));
    log.debug(String.format("%s - Scheduling network deployment task", NetworkManager.this));
    tasks.runTask(new Handler<Task>() {
      @Override
      public void handle(final Task task) {
        currentContext = context;

        // Any time the network is being reconfigured, unready the network.
        // This will cause components to pause during the reconfiguration.
        unready(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            if (result.failed()) {
              log.error(result.cause());
              task.complete();
            } else {
              deployNetwork(context, new Handler<AsyncResult<NetworkContext>>() {
                @Override
                public void handle(AsyncResult<NetworkContext> result) {
                  task.complete();
                  if (result.failed()) {
                    log.error(result.cause());
                  } else {
                    log.info(String.format("%s - Successfully deployed network", NetworkManager.this));
                  }
                }
              });
            }
          }
        });
      }
    });
  }
1290175
def deletelogicalnetwork(check_processor=default_logicalnetwork_delete_check,
                         reorder_dict = default_iterate_dict):
    
    def walker(walk, write, timestamp, parameters_dict):
        for key, parameters in reorder_dict(parameters_dict):
            try:
                value = walk(key)
            except KeyError:
                pass
            else:
                try:
                    logmap = walk(LogicalNetworkMap._network.leftkey(key))
                except KeyError:
                    pass
                else:
                    try:
                        phynet = walk(value.physicalnetwork.getkey())
                    except KeyError:
                        pass
                    else:
                        try:
                            phymap = walk(PhysicalNetworkMap._network.leftkey(phynet))
                        except KeyError:
                            pass
                        else:
                            check_processor(value, logmap, phynet, phymap, walk, write, parameters=parameters)
                            phymap.logicnetworks.dataset().discard(value.create_weakreference())
                            write(phymap.getkey(), phymap)
                            write(key, None)
                            write(logmap.getkey(), None)
                try:
                    logicalnetworkset = walk(LogicalNetworkSet.default_key())
                except KeyError:
                    pass
                else:
                    logicalnetworkset.set.dataset().discard(value.create_weakreference())
                    write(logicalnetworkset.getkey(), logicalnetworkset)
    return walker
1250149
def reset_network(message):
    """"""
    for command in settings.RESTART_NETWORK:
        try:
            subprocess.check_call(command)
        except:
            pass
    print(message)
1208881
def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if not conn:
        return False
    try:
        conn.delete_cache_subnet_group(name)
        msg = 'Deleted ElastiCache subnet group {0}.'.format(name)
        log.info(msg)
        return True
    except boto.exception.BotoServerError as e:
        log.debug(e)
        msg = 'Failed to delete ElastiCache subnet group {0}'.format(name)
        log.error(msg)
        return False
565131
def delete_network_postcommit(self, context):
        """"""
        network = context.current

        log_context("delete_network_postcommit: network", network)

        segments = context.network_segments
        tenant_id = network['project_id']
        self.delete_segments(segments)
        self.delete_network(network)
        self.delete_tenant_if_removed(tenant_id)
237753
private void handleDelete() {
    log.debug(String.format("%s - Network configuration removed from cluster: %s", NetworkManager.this, cluster.address()));
    tasks.runTask(new Handler<Task>() {
      @Override
      public void handle(final Task task) {
        unready(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            if (result.failed()) {
              log.error(result.cause());
            }
            if (currentContext != null) {
              log.info(String.format("%s - Undeploying network", NetworkManager.this));
              undeployNetwork(currentContext, new Handler<AsyncResult<Void>>() {
                @Override
                public void handle(AsyncResult<Void> result) {
                  if (result.failed()) {
                    log.error(result.cause());
                    task.complete();
                  } else {
                    // Once we've finished undeploying all the components of the
                    // network, set the network's status to nothing in order to
                    // indicate that the manager (this) can be undeployed.
                    data.put(currentContext.status(), "", new Handler<AsyncResult<String>>() {
                      @Override
                      public void handle(AsyncResult<String> result) {
                        if (result.failed()) {
                          log.error(result.cause());
                        } else {
                          log.info(String.format("%s - Successfully undeployed all components", NetworkManager.this));
                        }
                        task.complete();
                      }
                    });
                  }
                }
              });
            } else {
              task.complete();
            }
          }
        });
      }
    });
  }
813696
def delete_subnetwork(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The delete_subnet function must be called with -f or --function.'
        )

    if not kwargs or 'name' not in kwargs:
        log.error(
            'Must specify name of subnet.'
        )
        return False

    if 'region' not in kwargs:
        log.error(
            'Must specify region of subnet.'
        )
        return False

    name = kwargs['name']
    region = kwargs['region']
    conn = get_conn()

    __utils__['cloud.fire_event'](
        'event',
        'deleting subnetwork',
        'salt/cloud/subnet/deleting',
        args={
            'name': name,
            'region': region
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    try:
        result = conn.ex_destroy_subnetwork(name, region)
    except ResourceNotFoundError as exc:
        log.error(
            'Subnetwork %s was not found. Exception was: %s',
            name, exc, exc_info_on_loglevel=logging.DEBUG
        )
        return False

    __utils__['cloud.fire_event'](
        'event',
        'deleted subnetwork',
        'salt/cloud/subnet/deleted',
        args={
            'name': name,
            'region': region
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
    return result
410299
def delete_network(self, network):
        """"""
        n_res = MechResource(network['id'], a_const.NETWORK_RESOURCE,
                             a_const.DELETE)
        self.provision_queue.put(n_res)
1152195
def delete_nic(self, instance_id, port_id):
        """"""
        self.client.servers.interface_detach(instance_id, port_id)
        return True
1217852
def create_subnet(self, network, cidr, name=None, ip_version=4):
        '''
        
        '''
        net_id = self._find_network_id(network)
        body = {'cidr': cidr,
                'ip_version': ip_version,
                'network_id': net_id,
                'name': name}
        return self.network_conn.create_subnet(body={'subnet': body})