Ejemplo n.º 1
0
        public void Load(string host, int port, string user, string password)
        {
            using (var client = new NetConfClient(host, port, user, password))
            {
                client.AutomaticMessageIdHandling = false;
                client.OperationTimeout           = new TimeSpan(0, 0, 60);

                client.Connect();

                var nsManager = Ns.CreateManager();
                var rpc       = new XmlDocument();

                //
                // Security Zones
                rpc.LoadXml("<rpc><get-config><source><running /></source><filter>" + FilterSecurityZones + "</filter></get-config></rpc>");

                XmlDocument result   = client.SendReceiveRpc(rpc);
                XDocument   xmlZones = XDocument.Parse(result.OuterXml);

                this.Zones = xmlZones.Root.XPathSelectElements("./nc:data/xnm:configuration/xnm:security/xnm:zones/xnm:security-zone", nsManager).Select(SecurityZone.Parse).ToList();

                //
                // Security Policy Groups
                rpc.LoadXml("<rpc><get-config><source><running /></source><filter>" + FilterGroups + "</filter></get-config></rpc>");

                result = client.SendReceiveRpc(rpc);
                XDocument xmlGroups = XDocument.Parse(result.OuterXml);

                this.Groups = xmlGroups.Root.Descendants(Ns.Xnm + "groups")
                              .Where(x => x.Descendants(Ns.Xnm + "security").SelectMany(y => y.Descendants(Ns.Xnm + "policies")).Any())
                              .Select(SecurityPoliciesGroup.Parse)
                              .ToList();

                //
                // Security Policies
                rpc.LoadXml("<rpc><get-config><source><running /></source><filter>" + FilterSecurityPolicies + "</filter></get-config></rpc>");

                result = client.SendReceiveRpc(rpc);
                XDocument xmlPolicies = XDocument.Parse(result.OuterXml);

                this.Policies = xmlPolicies.Root.XPathSelectElements("./nc:data/xnm:configuration/xnm:security/xnm:policies/xnm:policy", nsManager)
                                .Select(xml => SecurityPolicyContainer.Parse(xml, s => this.Groups.FirstOrDefault(g => g.Name == s) ?? new SecurityPoliciesGroup {
                    Name = s
                })).ToList();

                // Close
                client.SendCloseRpc();
            }
        }
Ejemplo n.º 2
0
        [Ignore] // placeholder for actual test
        public void SendReceiveRpcTest1()
        {
            ConnectionInfo connectionInfo = null;                              // TODO: Initialize to an appropriate value
            NetConfClient  target         = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
            XmlDocument    rpc            = null;                              // TODO: Initialize to an appropriate value
            XmlDocument    expected       = null;                              // TODO: Initialize to an appropriate value
            XmlDocument    actual;

            actual = target.SendReceiveRpc(rpc);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 3
0
 [Ignore] // placeholder for actual test
 public void SendReceiveRpcTest()
 {
     ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
     NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
     string xml = string.Empty; // TODO: Initialize to an appropriate value
     XmlDocument expected = null; // TODO: Initialize to an appropriate value
     XmlDocument actual;
     actual = target.SendReceiveRpc(xml);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }