Undeploys a network by configuration.
965635
private void doUndeployNetwork(final NetworkConfig network, final Message<JsonObject> message) {
    // First we need to load the network's context from the cluster.
    final WrappedWatchableMap<String, String> data = new WrappedWatchableMap<String, String>(String.format("%s.%s", cluster, network.getName()), this.data.<String, String>getMap(String.format("%s.%s", cluster, network.getName())), vertx);
    String scontext = data.get(String.format("%s.%s", cluster, network.getName()));
    if (scontext == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "Network is not deployed."));
    } else {
      // Determine whether the network's manager is deployed.
      final NetworkContext tempContext = Contexts.<NetworkContext>deserialize(new JsonObject(scontext));
      if (managers.containsKey(tempContext.address())) {
        // If the network's manager is deployed then unmerge the given
        // configuration from the configuration of the network that's
        // already running. If the resulting configuration is a no-component
        // network then that indicates that the entire network is being undeployed.
        // Otherwise, we simply update the existing configuration and allow the
        // network's manager to handle deployment and undeployment of components.
        NetworkConfig updatedConfig = Configs.unmergeNetworks(tempContext.config(), network);
        final NetworkContext context = ContextBuilder.buildContext(updatedConfig, cluster);

        // If the new configuration has no components then undeploy the entire network.
        if (context.components().isEmpty()) {
          // We need to watch the network's status key to determine when the network's
          // components have been completely undeployed. Once that happens it's okay
          // to then undeploy the network's manager.
          data.watch(context.status(), MapEvent.Type.CHANGE, new Handler<MapEvent<String, String>>() {
            @Override
            public void handle(MapEvent<String, String> event) {
              // When the network's status key is set to an empty string, that indicates
              // that the network's manager has completely undeployed all components and
              // connections within the network. The manager is the only element of the
              // network left running, so we can go ahead and undeploy it.
              if (event.value() != null && event.value().equals("")) {
                // First, stop watching the status key so this handler doesn't accidentally
                // get called again for some reason.
                data.unwatch(context.status(), MapEvent.Type.CHANGE, this, new Handler<AsyncResult<Void>>() {
                  @Override
                  public void handle(AsyncResult<Void> result) {
                    // Now undeploy the manager from the context cluster. Once the manager
                    // has been undeployed the undeployment of the network is complete.
                    platform.undeployVerticle(managers.remove(context.address()), new Handler<AsyncResult<Void>>() {
                      @Override
                      public void handle(AsyncResult<Void> result) {
                        if (result.failed()) {
                          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
                        } else {
                          // We can be nice and unset the status key since the manager was undeployed :-)
                          DefaultNodeManager.this.context.execute(new Action<Void>() {
                            @Override
                            public Void perform() {
                              networks.remove(context.address());
                              data.remove(context.status());
                              return null;
                            }
                          }, new Handler<AsyncResult<Void>>() {
                            @Override
                            public void handle(AsyncResult<Void> result) {
                              message.reply(new JsonObject().putString("status", "ok"));
                            }
                          });
                        }
                      }
                    });
                  }
                });
              }
            }
          }, new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              // Once we've started watching the status key, unset the network's context in
              // the cluster. The network's manager will be notified of the configuration
              // change and will begin undeploying all of its components. Once the components
              // have been undeployed it will reset its status key.
              if (result.failed()) {
                message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
              } else {
                DefaultNodeManager.this.context.run(new Runnable() {
                  @Override
                  public void run() {
                    data.remove(context.address());
                  }
                });
              }
            }
          });
        } else {
          // If only a portion of the running network is being undeployed, we need
          // to watch the network's status key for notification once the configuration
          // change is complete.
          data.watch(context.status(), MapEvent.Type.CHANGE, new Handler<MapEvent<String, String>>() {
            @Override
            public void handle(MapEvent<String, String> event) {
              if (event.value() != null && event.value().equals(context.version())) {
                // The network's configuration has been completely updated. Stop watching
                // the network's status key and call the async handler.
                data.unwatch(context.status(), null, this, new Handler<AsyncResult<Void>>() {
                  @Override
                  public void handle(AsyncResult<Void> result) {
                    message.reply(new JsonObject().putString("status", "ok").putObject("context", Contexts.serialize(context)));
                  }
                });
              }
            }
          }, new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              // Once we've started watching the status key, update the network's context in
              // the cluster. The network's manager will be notified of the configuration
              // change and will begin deploying or undeploying components and connections
              // as necessary.
              if (result.failed()) {
                message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
              } else {
                DefaultNodeManager.this.context.run(new Runnable() {
                  @Override
                  public void run() {
                    data.put(context.address(), Contexts.serialize(context).encode());
                  }
                });
              }
            }
          });
        }
      } else {
        message.reply(new JsonObject().putString("status", "error").putString("message", "Network is not deployed."));
      }
    }
  }
861972
private void undeployModule(final InstanceContext instance, final CountingCompletionHandler<Void> counter) {
    deploymentIDs.remove(instance.address(), new Handler<AsyncResult<String>>() {
      @Override
      public void handle(AsyncResult<String> result) {
        if (result.failed()) {
          counter.fail(result.cause());
        } else if (result.result() != null) {
          cluster.undeployModule(result.result(), new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              unwatchInstance(instance, counter);
            }
          });
        } else {
          unwatchInstance(instance, counter);
        }
      }
    });
  }
805313
@Override
  public Deployment undeployJob(final String host, final JobId jobId, final String token)
      throws HostNotFoundException, JobNotDeployedException, TokenVerificationException {
    log.info("undeploying {}: {}", jobId, host);
    final ZooKeeperClient client = provider.get("undeployJob");

    assertHostExists(client, host);

    final Deployment deployment = getDeployment(host, jobId);
    if (deployment == null) {
      throw new JobNotDeployedException(host, jobId);
    }

    final Job job = getJob(client, jobId);
    verifyToken(token, job);
    final String configHostJobPath = Paths.configHostJob(host, jobId);

    try {
      // use listRecursive to remove both job node and its child creation node
      final List<String> nodes = newArrayList(reverse(client.listRecursive(configHostJobPath)));
      nodes.add(Paths.configJobHost(jobId, host));

      final List<Integer> staticPorts = staticPorts(job);
      for (final int port : staticPorts) {
        nodes.add(Paths.configHostPort(host, port));
      }

      client.transaction(delete(nodes));

    } catch (NoNodeException e) {
      // This method is racy since it's possible someone undeployed the job after we called
      // getDeployment and checked the job exists. If we now discover the job is undeployed,
      // throw an exception and handle it the same as if we discovered this earlier.
      throw new JobNotDeployedException(host, jobId);
    } catch (KeeperException e) {
      throw new HeliosRuntimeException("Removing deployment failed", e);
    }
    return deployment;
  }
1261696
def updateNetwork(self,
                      dhcp='dhcp',
                      ipaddress=None,
                      netmask=None,
                      gateway=None,
                      dns=None):
        """"""
        return self.__post('/api/updateNetwork',
                           data={
                               'dhcp': dhcp,
                               'ipaddress': ipaddress,
                               'netmask': netmask,
                               'gateway': gateway,
                               'dns': json.dumps(dns)
                           })
896030
def drop_network_by_id(self, network_id: int) -> None:
        """"""
        network = self.session.query(Network).get(network_id)
        self.drop_network(network)
1333929
public void undeployAll( String applicationName, String instancePath )
	throws ApplicationWsException {

		this.logger.finer( "Undeploying instances in " + applicationName + " from instance = " + instancePath  );

		WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "undeploy-all" );
		if( instancePath != null )
			path = path.queryParam( "instance-path", instancePath );

		ClientResponse response = this.wsClient.createBuilder( path )
						.accept( MediaType.APPLICATION_JSON )
						.post( ClientResponse.class );

		handleResponse( response );
		this.logger.finer( String.valueOf( response.getStatusInfo()));
	}
736368
private void doUndeployNetwork(final Message<JsonObject> message) {
    Object network = message.body().getValue("network");
    if (network != null) {
      // When undeploying a network from the cluster, we first determine
      // the node to which the network belongs by selecting a node.
      // The node that is selected for the network is always the node
      // that controls the network.
      String key;
      if (network instanceof String) {
        key = (String) network;
      } else if (network instanceof JsonObject) {
        try {
          key = serializer.deserializeObject((JsonObject) network, NetworkConfig.class).getName();
        } catch (SerializationException e) {
          message.reply(new JsonObject().putString("status", "error").putString("message", e.getMessage()));
          return;
        }
      } else {
        message.reply(new JsonObject().putString("status", "error").putString("message", "Invalid network configuration."));
        return;
      }

      selectNode(key, new Handler<AsyncResult<String>>() {
        @Override
        public void handle(AsyncResult<String> result) {
          if (result.failed()) {
            message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
          } else if (result.result() == null) {
            message.reply(new JsonObject().putString("status", "error").putString("message", "No nodes available."));
          } else {
            vertx.eventBus().sendWithTimeout(result.result(), message.body(), 120000, new Handler<AsyncResult<Message<JsonObject>>>() {
              @Override
              public void handle(AsyncResult<Message<JsonObject>> result) {
                if (result.failed()) {
                  message.reply(new JsonObject().putString("status", "error").putString("message", "Failed to reach node."));
                } else {
                  message.reply(result.result().body());
                }
              }
            });
          }
        }
      });
    } else {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No network specified."));
    }
  }
508245
private void doDeployModule(final Message<JsonObject> message) {
    String moduleName = message.body().getString("module");
    if (moduleName == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No module name specified."));
      return;
    }

    JsonObject config = message.body().getObject("config");
    if (config == null) {
      config = new JsonObject();
    }
    int instances = message.body().getInteger("instances", 1);
    platform.deployModule(moduleName, config, instances, createDeploymentHandler(message));
  }
436089
public void undeployVM(String vrpId, VirtualMachine vm, ClusterComputeResource cluster) throws InvalidState, NotFound, RuntimeFault, RemoteException {
        getVimService().undeployVM(getMOR(), vrpId, vm.getMOR(), cluster.getMOR());
    }
877757
def clear_to_reset(self, config_vars):
        """"""

        super(RemoteBridgeState, self).clear_to_reset(config_vars)
        self.status = BRIDGE_STATUS.IDLE
        self.error = 0
54725
function undeploy(mode, target, system, containerDef, container, out, cb) {
    logger.info('undeploying');
    out.stdout('undeploying');
    cb();
  }
654497
public void undeployManaged(@Observes UnDeployManagedDeployments event) throws Exception {
        forEachDeployedDeployment(new Operation<Container, Deployment>() {
            @Inject
            private Event<DeploymentEvent> event;

            @Override
            public void perform(Container container, Deployment deployment) throws Exception {
                if (container.getState().equals(Container.State.STARTED) && deployment.isDeployed()) {
                    event.fire(new UnDeployDeployment(container, deployment));
                }
            }
        });
    }
961599
def discard_config(self):
        """"""
        if self.config_session is not None:
            commands = []
            commands.append('configure session {}'.format(self.config_session))
            commands.append('abort')
            self.device.run_commands(commands)
            self.config_session = None
1028079
def _remove_network(network):
    '''
    
    '''
    ret = {'name': network['Name'],
           'changes': {},
           'result': False,
           'comment': ''}

    errors = []
    for cid in network['Containers']:
        try:
            cinfo = __salt__['docker.inspect_container'](cid)
        except CommandExecutionError:
            # Fall back to container ID
            cname = cid
        else:
            cname = cinfo.get('Name', '').lstrip('/')

        try:
            __salt__['docker.disconnect_container_from_network'](cid, network['Name'])
        except CommandExecutionError as exc:
            errors = \
                'Failed to disconnect container \'{0}\' : {1}'.format(
                    cname, exc
                )
        else:
            ret['changes'].setdefault('disconnected', []).append(cname)

    if errors:
        ret['comment'] = '\n'.join(errors)
        return ret

    try:
        __salt__['docker.remove_network'](network['Name'])
    except CommandExecutionError as exc:
        ret['comment'] = 'Failed to remove network: {0}'.format(exc)
    else:
        ret['changes']['removed'] = True
        ret['result'] = True
        ret['comment'] = 'Removed network \'{0}\''.format(network['Name'])

    return ret
742199
def drop_networks(self) -> None:
        """"""
        for network in self.session.query(Network).all():
            self.drop_network(network)
1250149
def reset_network(message):
    """"""
    for command in settings.RESTART_NETWORK:
        try:
            subprocess.check_call(command)
        except:
            pass
    print(message)
673165
public static base_response unset(nitro_service client, String network, String args[]) throws Exception {
		route6 unsetresource = new route6();
		unsetresource.network = network;
		return unsetresource.unset_resource(client, args);
	}