Skip to content

Commit

Permalink
add hex-string-prefixed typedef (#1014)
Browse files Browse the repository at this point in the history
* add hex-string-colon typedef
* deprecate hex-string
* Update openconfig-keychain.yang
  • Loading branch information
dplore authored Jul 26, 2024
1 parent 4e238f6 commit 72d3b67
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 13 deletions.
13 changes: 13 additions & 0 deletions regexp-tests/openconfig-yang-types-test.yang
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ module openconfig-yang-types-test {
import pattern-test { prefix "pt"; }
import openconfig-yang-types { prefix "oc-yang"; }

leaf hex-string-prefixed {
type oc-yang:hex-string-prefixed;
pt:pattern-test-pass "0x0000";
pt:pattern-test-pass "0xffff";
pt:pattern-test-pass "0xFFFF";
pt:pattern-test-pass "0x0123456789abcdefABCDEF";
pt:pattern-test-pass "0xFEDCBAfedcba9876543210";
pt:pattern-test-fail "0xg";
pt:pattern-test-fail "0xG";
pt:pattern-test-fail "0x0123456789abcdefABCDEFG";
pt:pattern-test-fail "0xFED0xba9876543210";
}

leaf hex-string {
type oc-yang:hex-string;
pt:pattern-test-pass "00000";
Expand Down
17 changes: 13 additions & 4 deletions release/models/keychain/openconfig-keychain.yang
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ module openconfig-keychain {
which may be then referenced by other models such as routing protocol
management.";

oc-ext:openconfig-version "0.4.0";
oc-ext:openconfig-version "0.5.0";

revision "2024-05-30" {
description
"Update key-id to a union of hex-string-prefixed and uint64.";
reference "0.5.0";
}

revision "2022-11-05" {
description
Expand Down Expand Up @@ -194,13 +200,16 @@ module openconfig-keychain {

leaf key-id {
type union {
type oc-yang:hex-string {
length "1..64";
type oc-yang:hex-string-prefixed {
length "3..66";
}
type uint64;
}
description
"Identifier for the key within the keychain.";
"Identifier for the key within the keychain. Note that the
hex-string type is deprecated and will be removed from a future
version of this model. Implementations should transition to using
the hex-string-prefixed type.";
}

leaf secret-key {
Expand Down
25 changes: 18 additions & 7 deletions release/models/policy/openconfig-policy-types.yang
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module openconfig-policy-types {
// import some basic types
import ietf-yang-types { prefix yang; }
import openconfig-extensions { prefix oc-ext; }
import openconfig-yang-types { prefix oc-yang; }

// meta
organization
Expand All @@ -24,9 +25,15 @@ module openconfig-policy-types {
policy. It can be imported by modules that contain protocol-
specific policy conditions and actions.";

oc-ext:openconfig-version "3.2.3";
oc-ext:openconfig-version "3.3.0";

revision "2022-11-08" {
revision "2024-05-14" {
description
"Add hex-string-prefixed to typedef tag-type.";
reference "3.3.0";
}

revision "2022-11-08" {
description
"Add INSTALL_PROTOCOL_TYPE local.";
reference "3.2.3";
Expand Down Expand Up @@ -165,14 +172,18 @@ module openconfig-policy-types {
type union {
type uint32;
type yang:hex-string;
type oc-yang:hex-string-prefixed {
length "3..18";
}
}
description "type for expressing route tags on a local system,
including IS-IS and OSPF; may be expressed as either decimal or
hexidecimal integer";
description
"Type for expressing route tags on a local system, including IS-IS
and OSPF; This may be expressed as either decimal or hexidecimal
integer.";
reference
"RFC 2178 OSPF Version 2
"RFC 2178 OSPF Version 2 specifies a 32 bit value
RFC 5130 A Policy Control Mechanism in IS-IS Using
Administrative Tags";
Administrative Tags specifies 32 bit and 64 bit values.";
}

identity INSTALL_PROTOCOL_TYPE {
Expand Down
24 changes: 22 additions & 2 deletions release/models/types/openconfig-yang-types.yang
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ module openconfig-yang-types {
Section 4.c of the IETF Trust's Legal Provisions Relating
to IETF Documents (http://trustee.ietf.org/license-info).";

oc-ext:openconfig-version "0.3.1";
oc-ext:openconfig-version "1.0.0";

revision "2024-05-30" {
description
"Add hex-string-prefixed typedef";
reference "1.0.0";
}

revision "2021-07-14" {
description
Expand Down Expand Up @@ -109,12 +115,26 @@ module openconfig-yang-types {
}

typedef hex-string {
status deprecated;
type string {
pattern '[0-9a-fA-F]*';
oc-ext:posix-pattern '^[0-9a-fA-F]*$';
}
description
"A string consisting of a hexadecimal characters.";
"A string consisting of a hexadecimal characters. This leaf is
deprecated and will removed in a future version of this model.
The type hex-string-prefixed should be used instead.";
}

typedef hex-string-prefixed {
type string {
pattern '(0x)([0-9a-fA-F]{2})*';
oc-ext:posix-pattern '^(0x)([0-9a-fA-F]{2})*$';
length "3..max";
}
description
"A string encoding a hexadecimal number with a prefix of '0x' followed
by a list of bytes.";
}

typedef counter32 {
Expand Down

0 comments on commit 72d3b67

Please sign in to comment.