Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik committed Jul 3, 2020
1 parent 72bd2d7 commit 9be3197
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 69 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 2020-06-30 version 0.8.5
### 2020-07-30 version 0.8.5

#### New features and enhancements
* Develop utility function to clone Entity instance ([#967](https://github.com/CiscoDevNet/ydk-gen/issues/967))
Expand All @@ -14,6 +14,9 @@
* YDK fails instantiate some of the generated bundle classes ([#983](https://github.com/CiscoDevNet/ydk-gen/issues/983))
* Python generated bundle class fails instantiate when model contains leaf 'logger' ([#996](https://github.com/CiscoDevNet/ydk-gen/issues/996))
* C++ YList class fails to process key values when its name contains '-' character ([#997](https://github.com/CiscoDevNet/ydk-gen/issues/997))
* create_datanode in Path API returns incorrect object and sets incorrect value ([#1003](https://github.com/CiscoDevNet/ydk-gen/issues/1003))
* create_datanode rejects absolute paths with a leading "/" as defined in RFC 7950 ([#1005](https://github.com/CiscoDevNet/ydk-gen/issues/1005))
* Path API create_datanode rejects valid value ([#1006](https://github.com/CiscoDevNet/ydk-gen/issues/1006))

#### Bundle improvements
* Updated cisco-ios-xe bundle to support Cisco IOS XE 16.9.3 due to bug in Python generated code
Expand Down
9 changes: 4 additions & 5 deletions sdk/cpp/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 2020-06-30 version 0.8.5
### 2020-07-30 version 0.8.5

#### New features and enhancements
* Added Entity class member function to clone entity object
Expand All @@ -10,16 +10,15 @@
* Fixed bug in extracting module name from namespace
* gNMI set RPC fails when JSON payload is formatted string
* C++ YList class fails to process key values when its name contains '-' character ([#997](https://github.com/CiscoDevNet/ydk-gen/issues/997))
* create_datanode in Path API returns incorrect object and sets incorrect value ([#1003](https://github.com/CiscoDevNet/ydk-gen/issues/1003))
* create_datanode rejects absolute paths with a leading "/" as defined in RFC 7950 ([#1005](https://github.com/CiscoDevNet/ydk-gen/issues/1005))
* Path API create_datanode rejects valid value ([#1006](https://github.com/CiscoDevNet/ydk-gen/issues/1006))

#### Bundle improvements
* Updated cisco-ios-xr bundle to support Cisco IOS XR 6.6.3
* Updated openconfig bundle to support YANG models of revision "2019-06-21"


#### Bundle improvements
* Updated cisco-ios-xr bundle to support Cisco IOS XR 6.6.3
* Updated openconfig bundle to support YANG models of revision "2019-06-21"

### 2019-10-15 version 0.8.4

#### New features and enhancements
Expand Down
17 changes: 12 additions & 5 deletions sdk/cpp/core/src/path/data_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//////////////////////////////////////////////////////////////////

// -------------------------------------------------------------
// This file has been modified by Yan Gorelik, YDK Solutions.
// All modifications in original under CiscoDevNet domain
// introduced since October 2019 are copyrighted.
// All rights reserved under Apache License, Version 2.0.
////////////////////////////////////////////////////////////////

#include "path_private.hpp"

Expand Down Expand Up @@ -270,9 +273,13 @@ ydk::path::DataNodeImpl::create_helper(const std::string& path, const std::strin

while(!rdn->get_children().empty() && rdn->m_node != cn)
{
rdn = dynamic_cast<DataNodeImpl*>(rdn->get_children()[0].get());
for (auto child_dn : rdn->get_children())
{
rdn = dynamic_cast<DataNodeImpl*>(child_dn.get());
if (!rdn->get_children().empty() || rdn->m_node == cn)
break;
}
}

return *rdn;
}
else
Expand Down
14 changes: 11 additions & 3 deletions sdk/cpp/core/src/path/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//////////////////////////////////////////////////////////////////

// -------------------------------------------------------------
// This file has been modified by Yan Gorelik, YDK Solutions.
// All modifications in original under CiscoDevNet domain
// introduced since October 2019 are copyrighted.
// All rights reserved under Apache License, Version 2.0.
////////////////////////////////////////////////////////////////

#include <pcre.h>
#include <fstream>
Expand Down Expand Up @@ -101,6 +104,11 @@ std::vector<std::string> ydk::path::segmentalize(const std::string& path)
std::vector<std::string> output;
size_t pos = std::string::npos; // size_t to avoid improbable overflow
std::string data{path};
if (data.at(0) == '/')
{
// Remove starting '/' if present
data = data.substr(1);
}
escape_slashes(data, "'[^\[]+'");
escape_slashes(data, "\"[^\[]+\"");
do
Expand Down
21 changes: 8 additions & 13 deletions sdk/cpp/core/src/path/root_data_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//////////////////////////////////////////////////////////////////

// -------------------------------------------------------------
// This file has been modified by Yan Gorelik, YDK Solutions.
// All modifications in original under CiscoDevNet domain
// introduced since October 2019 are copyrighted.
// All rights reserved under Apache License, Version 2.0.
////////////////////////////////////////////////////////////////

#include "path_private.hpp"
#include "../logger.hpp"
Expand Down Expand Up @@ -75,12 +78,6 @@ ydk::path::RootDataImpl::create_datanode(const std::string& path, const std::str
throw(YInvalidArgumentError{"Path is empty"});
}

//path should not start with /
if(path.at(0) == '/')
{
YLOG_ERROR("Path '{}' should not start with /", path);
throw(YInvalidArgumentError{"Path should not start with /"});
}
std::vector<std::string> segments = segmentalize(path);
if(segments.size()<=0)
{
Expand Down Expand Up @@ -138,13 +135,11 @@ ydk::path::RootDataImpl::create_datanode(const std::string& path, const std::str
remaining_path+=segments[i];
}

rdn = &(rdn->create_datanode(remaining_path));
rdn = &(rdn->create_datanode(remaining_path, value));
}


return *rdn;

}
}

void
ydk::path::RootDataImpl::set_value(const std::string& value)
Expand Down
14 changes: 14 additions & 0 deletions sdk/cpp/tests/test_path_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,3 +694,17 @@ TEST_CASE( "rpc_get_schema_no_decode" )
REQUIRE(!reply.empty());
//cout << reply << endl;
}

TEST_CASE( "test_create_datanode" )
{
auto repo = ydk::path::Repository{TEST_HOME};
std::vector<ydk::path::Capability> empty_caps;
auto root_schema = repo.create_root_schema(empty_caps);

std::string datanode_path = "/ydktest-sanity:runner/two-key-list[first='first-key'][second='2']/property";
std::string datanode_value = "TWO-KEY-LIST PROPERTY";
auto & datanode = root_schema->create_datanode(datanode_path, datanode_value);

REQUIRE(datanode_path == datanode.get_path());
REQUIRE(datanode_value == datanode.get_value());
}
24 changes: 24 additions & 0 deletions sdk/python/core/tests/test_netconf_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,30 @@ def test_delete_leaflist(self):
# DELETE AGAIN WITH ERROR
self.crud.update(self.ncc, runner)

def test_create_gre_tunnel_on_demand(self):
#enable_logging(logging.ERROR)
try:
from ydk.models.ydktest.ydktest_sanity import Native
except ImportError:
# bundle is generated with 'one_class_per_module' flag
from ydk.models.ydktest.ydktest_sanity.native.native import Native

native = Native()

tunnel = native.interface.Tunnel()
tunnel.name = 521
tunnel.description = "test tunnel"

# Configure protocol-over-protocol tunneling
tunnel.tunnel.source = "1.2.3.4"
tunnel.tunnel.destination = "4.3.2.1"
tunnel.tunnel.bandwidth.receive = 100000
tunnel.tunnel.bandwidth.transmit = 100000

native.interface.tunnel.append(tunnel)

self.crud.create(self.ncc, native)


if __name__ == '__main__':
device, non_demand, common_cache, timeout = get_device_info()
Expand Down
56 changes: 14 additions & 42 deletions sdk/python/core/tests/test_sanity_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------
# This file has been modified by Yan Gorelik, YDK Solutions.
# All modifications in original under CiscoDevNet domain
# introduced since October 2019 are copyrighted.
# All rights reserved under Apache License, Version 2.0.
# ------------------------------------------------------------------

from __future__ import absolute_import

Expand Down Expand Up @@ -157,40 +162,6 @@ def test_anyxml(self):
datanode = get_rpc(self.nc_session)
self.assertIsNotNone(datanode)

def test_create_gre_tunnel_on_demand(self):
enable_logging(logging.ERROR)

from ydk.providers import NetconfServiceProvider
from ydk.services import CRUDService
try:
from ydk.models.ydktest.ydktest_sanity import Native
except ImportError:
# bundle is generated with 'one_class_per_module' flag
from ydk.models.ydktest.ydktest_sanity.native.native import Native

provider = NetconfServiceProvider(
"127.0.0.1",
"admin",
"admin",
12022)

native = Native()

tunnel = native.interface.Tunnel()
tunnel.name = 521
tunnel.description = "test tunnel"

# Configure protocol-over-protocol tunneling
tunnel.tunnel.source = "1.2.3.4"
tunnel.tunnel.destination = "4.3.2.1"
tunnel.tunnel.bandwidth.receive = 100000
tunnel.tunnel.bandwidth.transmit = 100000

native.interface.tunnel.append(tunnel)

crud_service = CRUDService();
crud_service.create(provider, native)

def test_anyxml_action(self):
expected='''<data xmlns="http://cisco.com/ns/yang/ydktest-action">
<action-node>
Expand Down Expand Up @@ -236,14 +207,15 @@ def test_rpc_get_schema_no_decode(self):
self.assertTrue(len(reply)>0)
#print(reply)

def enable_logging(level):
log = logging.getLogger('ydk')
log.setLevel(level)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
handler.setFormatter(formatter)
log.addHandler(handler)

def test_create_datanode(self):
datanode_path = "/ydktest-sanity:runner/two-key-list[first='first-key'][second='2']/property"
datanode_value = "TWO-KEY-LIST PROPERTY"
datanode = self.root_schema.create_datanode(datanode_path, datanode_value)

self.assertEqual(datanode_path, datanode.get_path())
self.assertEqual(datanode_value, datanode.get_value())


if __name__ == '__main__':
device, non_demand, common_cache, timeout = get_device_info()

Expand Down

0 comments on commit 9be3197

Please sign in to comment.