Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate code in generated cisco-ios-xe Go bundle #891

Closed
ygorelik opened this issue Mar 13, 2019 · 2 comments
Closed

Duplicate code in generated cisco-ios-xe Go bundle #891

ygorelik opened this issue Mar 13, 2019 · 2 comments
Assignees
Milestone

Comments

@ygorelik
Copy link
Collaborator

The issue has been found by Raman Viswanathan ramanvi@cisco.com

Current Behavior

When tried to use cisco-ios-xe Go bundle the compiler gives syntax errors:

We ran into compilation issues with : https://github.com/CiscoDevNet/ydk-go/blob/master/ydk/models/cisco_ios_xe/native/native.go

There are some redeclared code errors: 

/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571155:6: Native_Interface_Vlan_CiscoIOSXEInterfacesSwitchportConf redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554401:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571185:6: Native_Interface_Vlan_CiscoIOSXEInterfacesSwitchport redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554431:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571211:6: Native_Interface_Vlan_CiscoIOSXEInterfacesStackwiseVirtual redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554457:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571246:6: Native_Interface_Vlan_CiscoIOSXEInterfacesArp redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554492:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571276:6: Native_Interface_Vlan_CiscoIOSXEInterfacesBackup redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554522:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571314:6: Native_Interface_Vlan_CiscoIOSXEInterfacesBackup_Delay redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554560:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571351:6: Native_Interface_Vlan_CiscoIOSXEInterfacesBackup_Delay_Failure redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554597:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571354:139: Native_Interface_Vlan_CiscoIOSXEInterfacesBackup_Delay_Failure_never redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554600:139
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571358:6: Native_Interface_Vlan_CiscoIOSXEInterfacesBackup_Delay_SecondaryDisable redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554604:6
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571361:157: Native_Interface_Vlan_CiscoIOSXEInterfacesBackup_Delay_SecondaryDisable_never redeclared in this block
previous declaration at /root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:554607:157
/root/ydk-go/golang/src/github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native/native.go:571361:157: too many errors

Your Script

package main

import (
	"flag"
	"fmt"

	"github.com/CiscoDevNet/ydk-go/ydk"
	"github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native"
	"github.com/CiscoDevNet/ydk-go/ydk/providers"
	"github.com/CiscoDevNet/ydk-go/ydk/services"
	encoding "github.com/CiscoDevNet/ydk-go/ydk/types/encoding_format"
)

const (
	inputXML = `
	<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
	<utd-mt xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-utd">
	   <utd>
		  <multi-tenancy />
		  <engine>
			 <standard>
				<multi-tenancy>
				   <threat-inspection>
					  <profile>
						 <name>rv-test1</name>
					  </profile>
					  <profile>
						 <name>rv-test2</name>
						 <threat>protection</threat>
						 <policy>security</policy>
					  </profile>
				   </threat-inspection>
				   <policy>
					  <name>rv-utd-test1</name>
					  <all-interfaces />
					  <vrf>
						 <name>global</name>
					  </vrf>
					  <threat-inspection>
						 <profile>rv-test1</profile>
					  </threat-inspection>
				   </policy>
				   <policy>
					  <name>rv-utd-test2</name>
					  <all-interfaces />
					  <vrf>
						 <name>1</name>
					  </vrf>
					  <threat-inspection>
						 <profile>rv-test2</profile>
					  </threat-inspection>
				   </policy>
				</multi-tenancy>
			 </standard>
		  </engine>
	   </utd>
	</utd-mt>
 </native>
`
)

// main executes main program.
func main() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("\nError occured!!\n ", r)
		}
	}()

	vPtr := flag.Bool("v", false, "Enable verbose")
	flag.Parse()

	if *vPtr {
		ydk.EnableLogging(ydk.Info)
	}

	// create codec provider
	jsonProvider := providers.CodecServiceProvider{}
	jsonProvider.Encoding = encoding.JSON
	xmlProvider := providers.CodecServiceProvider{}
	xmlProvider.Encoding = encoding.XML

	fmt.Println("RV Test1")

	// create codec service
	var codec = services.CodecService{}

	fmt.Println("RV Test2")

	var native native.Native
	native = codec.Decode(&xmlProvider, inputXML)

	fmt.Println("RV Test3")

	// encode and print object
	fmt.Println(codec.Encode(&jsonProvider, native))
}

System Information

YDK-Go 0.8.1 docker.

@111pontes
Copy link
Collaborator

Is this a dup of #675?

ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Mar 20, 2019
ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Mar 20, 2019
@ygorelik
Copy link
Collaborator Author

Resolved the issue to YDK-0.8.3.

Working script

package main

import (
	"flag"
	"fmt"

	"github.com/CiscoDevNet/ydk-go/ydk"
	"github.com/CiscoDevNet/ydk-go/ydk/models/cisco_ios_xe/native"
	"github.com/CiscoDevNet/ydk-go/ydk/providers"
	"github.com/CiscoDevNet/ydk-go/ydk/services"
	encoding "github.com/CiscoDevNet/ydk-go/ydk/types/encoding_format"
)

const (
	inputXML = `
 <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
	<utd-mt xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-utd">
	   <utd>
		  <multi-tenancy />
		  <engine>
			 <standard>
				<multi-tenancy>
				   <threat-inspection>
					  <profile>
						 <name>rv-test1</name>
					  </profile>
					  <profile>
						 <name>rv-test2</name>
						 <threat>protection</threat>
						 <policy>security</policy>
					  </profile>
				   </threat-inspection>
				   <policy>
					  <name>rv-utd-test1</name>
					  <all-interfaces />
					  <vrf>
						 <name>global</name>
					  </vrf>
					  <threat-inspection>
						 <profile>rv-test1</profile>
					  </threat-inspection>
				   </policy>
				   <policy>
					  <name>rv-utd-test2</name>
					  <all-interfaces />
					  <vrf>
						 <name>1</name>
					  </vrf>
					  <threat-inspection>
						 <profile>rv-test2</profile>
					  </threat-inspection>
				   </policy>
				</multi-tenancy>
			 </standard>
		  </engine>
	   </utd>
	</utd-mt>
 </native>
`
)

// main executes main program.
func main() {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("\nError occured!!\n ", r)
		}
	}()

	vPtr := flag.Bool("v", false, "Enable verbose")
	flag.Parse()

	if *vPtr {
		ydk.EnableLogging(ydk.Info)
	}

	// create codec service
	jsonProvider := providers.CodecServiceProvider{}
	jsonProvider.Encoding = encoding.JSON
	var codec = services.CodecService{}

	fmt.Println("=====> RV Test1. Register Native")
    nt := native.Native{}
    fmt.Println(codec.Encode(&jsonProvider, &nt))

	fmt.Println("=====> RV Test2. Decode XML to Entity")

	xmlProvider := providers.CodecServiceProvider{}
	xmlProvider.Encoding = encoding.XML
	native_entity := codec.Decode(&xmlProvider, inputXML)

	fmt.Println("=====> RV Test3. Encode Entity to JSON")

	// encode and print object
	fmt.Println(codec.Encode(&jsonProvider, native_entity))
}

Running result

yan@ubuntu-yan:~/ydk-workspace/ydk-gen$ go run ./scripts/tests/test_891.go -v
=====> RV Test1. Register Native
{
  "Cisco-IOS-XE-native:native": {
  }
}

=====> RV Test2. Decode XML to Entity
=====> RV Test3. Encode Entity to JSON
{
  "Cisco-IOS-XE-native:native": {
    "Cisco-IOS-XE-utd:utd-mt": {
      "utd": {
        "multi-tenancy": [null],
        "engine": {
          "standard": {
            "multi-tenancy": {
              "threat-inspection": {
                "profile": [
                  {
                    "name": "rv-test1"
                  },
                  {
                    "name": "rv-test2",
                    "threat": "protection",
                    "policy": "security"
                  }
                ]
              },
              "policy": [
                {
                  "name": "rv-utd-test1",
                  "all-interfaces": [null],
                  "vrf": [
                    {
                      "name": "global"
                    }
                  ],
                  "threat-inspection": {
                    "profile": "rv-test1"
                  }
                },
                {
                  "name": "rv-utd-test2",
                  "all-interfaces": [null],
                  "vrf": [
                    {
                      "name": "1"
                    }
                  ],
                  "threat-inspection": {
                    "profile": "rv-test2"
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}

@ghost ghost added this to the 0.8.3 milestone Apr 2, 2019
ghost pushed a commit that referenced this issue May 16, 2019
ghost pushed a commit that referenced this issue May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants