Private/Confirm.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#
# Copyright 2020, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#

function Confirm-ArubaCXInterfaces {

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")]
    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )
    #Check if it looks like an Interface element

    if ( -not ( $argument | get-member -name name -Membertype Properties)) {
        throw "Element specified does not contain a name property."
    }
    if ( -not ( $argument | get-member -name admin -Membertype Properties)) {
        throw "Element specified does not contain an admin_state property."
    }
    if ( -not ( $argument | get-member -name routing -Membertype Properties)) {
        throw "Element specified does not contain a routing property."
    }
    if ( -not ( $argument | get-member -name vrf -Membertype Properties)) {
        throw "Element specified does not contain a vrf property."
    }
    if ( -not ( $argument | get-member -name vlan_mode -Membertype Properties)) {
        throw "Element specified does not contain a vlan_mode property."
    }
    $true

}
function Confirm-ArubaCXSystem {

    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )
    #Check if it looks like an System element

    if ( -not ( $argument | get-member -name hostname -Membertype Properties)) {
        throw "Element specified does not contain a hostname property."
    }
    if ( -not ( $argument | get-member -name other_config -Membertype Properties)) {
        throw "Element specified does not contain an other_config property."
    }
    if ( -not ( $argument | get-member -name timezone -Membertype Properties)) {
        throw "Element specified does not contain a timezone property."
    }
    if ( -not ( $argument | get-member -name rest_api -Membertype Properties)) {
        throw "Element specified does not contain a rest_api property."
    }
    if ( -not ( $argument | get-member -name mgmt_intf -Membertype Properties)) {
        throw "Element specified does not contain a mgmt_intf property."
    }
    if ( -not ( $argument | get-member -name aaa -Membertype Properties)) {
        throw "Element specified does not contain an aaa property."
    }
    $true

}

function Confirm-ArubaCXVlans {

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")]
    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )
    #Check if it looks like an Vlan element

    if ( -not ( $argument | get-member -name id -Membertype Properties)) {
        throw "Element specified does not contain a id property."
    }
    if ( -not ( $argument | get-member -name name -Membertype Properties)) {
        throw "Element specified does not contain an name property."
    }
    if ( -not ( $argument | get-member -name admin -Membertype Properties)) {
        throw "Element specified does not contain a admin property."
    }
    if ( -not ( $argument | get-member -name voice -Membertype Properties)) {
        throw "Element specified does not contain a voice property."
    }
    if ( -not ( $argument | get-member -name type -Membertype Properties)) {
        throw "Element specified does not contain a type property."
    }
    if ( -not ( $argument | get-member -name description -Membertype Properties)) {
        throw "Element specified does not contain a description property."
    }
    $true
}

function Confirm-ArubaCXVrfs {

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")]
    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )
    #Check if it looks like an VRF element

    if ( -not ( $argument | get-member -name rd -Membertype Properties)) {
        throw "Element specified does not contain a rd property."
    }
    if ( -not ( $argument | get-member -name https_server -Membertype Properties)) {
        throw "Element specified does not contain a https_server property."
    }
    if ( -not ( $argument | get-member -name snmp_enable -Membertype Properties)) {
        throw "Element specified does not contain a snmp_enable property."
    }
    if ( -not ( $argument | get-member -name source_interface -Membertype Properties)) {
        throw "Element specified does not contain a source_interface property."
    }
    if ( -not ( $argument | get-member -name source_ip -Membertype Properties)) {
        throw "Element specified does not contain a source_ip property."
    }
    if ( -not ( $argument | get-member -name ssh_enable -Membertype Properties)) {
        throw "Element specified does not contain a ssh_enable property."
    }
    $true
}