1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2001 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 package com.sun.dhcpmgr.cli.pntadm; 27 28 import com.sun.dhcpmgr.data.DhcpClientRecord; 29 import com.sun.dhcpmgr.data.Network; 30 import com.sun.dhcpmgr.bridge.BridgeException; 31 import com.sun.dhcpmgr.bridge.NoTableException; 32 33 import java.lang.IllegalArgumentException; 34 35 /** 36 * The main class for the "remove network table" functionality 37 * of pntadm. 38 */ 39 public class RemoveNetworkTable extends PntAdmFunction { 40 41 /** 42 * The valid options associated with removing a network table. 43 */ 44 static final int supportedOptions[] = { 45 PntAdm.RESOURCE, 46 PntAdm.RESOURCE_CONFIG, 47 PntAdm.PATH 48 }; 49 50 /** 51 * Constructs a RemoveNetworkTable object. 52 */ 53 public RemoveNetworkTable() { 54 55 validOptions = supportedOptions; 56 57 } // constructor 58 59 /** 60 * Returns the option flag for this function. 61 * @returns the option flag for this function. 62 */ 63 public int getFunctionFlag() { 64 return (PntAdm.REMOVE_NETWORK_TABLE); 65 } 66 67 /** 68 * Executes the "remove network table" functionality. 69 * @return PntAdm.SUCCESS, PntAdm.ENOENT, PntAdm.WARNING, or 70 * PntAdm.CRITICAL 71 */ 72 public int execute() 73 throws IllegalArgumentException { 74 75 int returnCode = PntAdm.SUCCESS; 76 77 // Create a Network object. 78 // 79 try { 80 Network network = getNetMgr().getNetwork(networkName); 81 if (network == null) { 82 printErrMessage(getString("network_name_error")); 83 return (PntAdm.WARNING); 84 } 85 86 // Delete the network table. 87 // 88 getNetMgr().deleteNetwork(network.toString(), false, 89 getDhcpDatastore()); 90 } catch (NoTableException e) { 91 printErrMessage(getMessage(e)); 92 returnCode = PntAdm.ENOENT; 93 } catch (Throwable e) { 94 printErrMessage(getMessage(e)); 95 returnCode = PntAdm.WARNING; 96 } 97 98 return (returnCode); 99 100 } // execute 101 102 } // RemoveNetworkTable