MCPcopy Index your code
hub / github.com/Juniper/netconf-java / main

Method main

examples/EditConfiguration.java:21–61  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

19
20public class EditConfiguration {
21 public static void main(String[] args) throws IOException,
22 ParserConfigurationException, SAXException {
23
24
25 /*Build the XML configuration
26 *The XML configuration required is:
27 *
28 * <configuration>
29 * <system>
30 * <services>
31 * <ftp/>
32 * </services>
33 * </system>
34 * </configuration>
35 */
36 XMLBuilder builder = new XMLBuilder();
37 XML ftp_config = builder.createNewConfig("system", "services", "ftp");
38
39 Device device = CreateDevice.createDevice();
40 device.connect();
41
42 //Lock the configuration first
43 boolean isLocked = device.lockConfig();
44 if(!isLocked) {
45 System.out.println("Could not lock configuration. Exit now.");
46 return;
47 }
48
49 //Load and commit the configuration
50 try {
51 device.loadXMLConfiguration(ftp_config.toString(), "merge");
52 device.commit();
53 } catch(LoadException | CommitException e) {
54 System.out.println(e.getMessage());
55 return;
56 }
57
58 //Unlock the configuration and close the device.
59 device.unlockConfig();
60 device.close();
61 }
62}

Callers

nothing calls this directly

Calls 9

createNewConfigMethod · 0.95
createDeviceMethod · 0.95
connectMethod · 0.95
lockConfigMethod · 0.95
loadXMLConfigurationMethod · 0.95
toStringMethod · 0.95
commitMethod · 0.95
unlockConfigMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected