77 */
88package pt .impl ;
99
10+ import com .google .common .util .concurrent .FluentFuture ;
11+ import java .net .UnknownHostException ;
12+ import java .util .Optional ;
13+ import java .util .concurrent .ExecutionException ;
1014import org .opendaylight .mdsal .binding .api .DataBroker ;
15+ import org .opendaylight .mdsal .binding .api .ReadTransaction ;
16+ import org .opendaylight .mdsal .binding .api .WriteTransaction ;
17+ import org .opendaylight .mdsal .common .api .LogicalDatastoreType ;
18+ import org .opendaylight .yang .gen .v1 .urn .opendaylight .params .xml .ns .yang .device .rev250611 .Device ;
19+ import org .opendaylight .yang .gen .v1 .urn .opendaylight .params .xml .ns .yang .device .rev250611 .DeviceBuilder ;
20+ import org .opendaylight .yang .gen .v1 .urn .opendaylight .params .xml .ns .yang .device .rev250611 .Ipv4Address ;
21+ import org .opendaylight .yang .gen .v1 .urn .opendaylight .params .xml .ns .yang .device .rev250611 .MacAddress ;
22+ import org .opendaylight .yangtools .binding .DataObjectIdentifier ;
1123import org .slf4j .Logger ;
1224import org .slf4j .LoggerFactory ;
1325
@@ -24,8 +36,23 @@ public MockBindingProvider(final DataBroker dataBroker) {
2436 /**
2537 * Method called when the blueprint container is created.
2638 */
27- public void init () {
39+ public void init () throws ExecutionException , InterruptedException , UnknownHostException {
2840 LOG .info ("MockBindingProvider Session Initiated" );
41+ Device data = new DeviceBuilder ().setHostname ("Host1" )
42+ .setIpAddress (Ipv4Address .getDefaultInstance ("156.127.13.51" ))
43+ .setMacAddress (MacAddress .getDefaultInstance ("00:1A:2B:3C:4D:5E" ))
44+ .setLocation ("EU" )
45+ .build ();
46+
47+ final WriteTransaction tx = dataBroker .newWriteOnlyTransaction ();
48+ DataObjectIdentifier <Device > identifier = DataObjectIdentifier .builder (Device .class ).build ();
49+ tx .put (LogicalDatastoreType .CONFIGURATION , identifier , data );
50+ tx .commit ().get ();
51+
52+ final ReadTransaction rx = dataBroker .newReadOnlyTransaction ();
53+ FluentFuture <Optional <Device >> future = rx .read (LogicalDatastoreType .CONFIGURATION , identifier );
54+ Device dataOut = future .get ().orElseThrow ();
55+ LOG .info ("Data Out is {}" , dataOut );
2956 }
3057
3158 /**
0 commit comments