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
#
# Copyright 2019, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#

Function Confirm-NSXTFabricVirtualMachines {

    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )

    #Check if it looks like an Fabric Virtual Machines element

    if ( -not ( $argument | get-member -name host_id -Membertype Properties)) {
        throw "Element specified does not contain a host_id property."
    }
    if ( -not ( $argument | get-member -name external_id -Membertype Properties)) {
        throw "Element specified does not contain an external_id property."
    }
    if ( -not ( $argument | get-member -name resource_type -Membertype Properties)) {
        throw "Element specified does not contain a resource_type property."
    }
    if ( -not ( $argument | get-member -name display_name -Membertype Properties)) {
        throw "Element specified does not contain a display_name property."
    }
    $true

}

Function Confirm-NSXTSegments {

    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )

    #Check if it looks like a Segment element

    if ( -not ( $argument | get-member -name type -Membertype Properties)) {
        throw "Element specified does not contain a type property."
    }
    if ( -not ( $argument | get-member -name vlan_ids -Membertype Properties)) {
        throw "Element specified does not contain an vlan_ids property."
    }
    if ( -not ( $argument | get-member -name transport_zone_path -Membertype Properties)) {
        throw "Element specified does not contain a transport_zone_path property."
    }
    if ( -not ( $argument | get-member -name resource_type -Membertype Properties)) {
        throw "Element specified does not contain a resource_type property."
    }
    if ( -not ( $argument | get-member -name id -Membertype Properties)) {
        throw "Element specified does not contain a id property."
    }
    if ( -not ( $argument | get-member -name display_name -Membertype Properties)) {
        throw "Element specified does not contain a display_name property."
    }
    if ( -not ( $argument | get-member -name path -Membertype Properties)) {
        throw "Element specified does not contain a path property."
    }
    if ( -not ( $argument | get-member -name relative_path -Membertype Properties)) {
        throw "Element specified does not contain a relative_path property."
    }
    if ( -not ( $argument | get-member -name parent_path -Membertype Properties)) {
        throw "Element specified does not contain a parent_path property."
    }
    if ( -not ( $argument | get-member -name marked_for_delete -Membertype Properties)) {
        throw "Element specified does not contain a marked_for_delete property."
    }
    $true

}

Function Confirm-NSXTTransportZones {

    Param (
        [Parameter (Mandatory = $true)]
        [object]$argument
    )

    #Check if it looks like an Transport Zones element

    if ( -not ( $argument | get-member -name transport_type -Membertype Properties)) {
        throw "Element specified does not contain a transport_type property."
    }
    if ( -not ( $argument | get-member -name host_switch_name -Membertype Properties)) {
        throw "Element specified does not contain an host_switch_name property."
    }
    if ( -not ( $argument | get-member -name host_switch_id -Membertype Properties)) {
        throw "Element specified does not contain a host_switch_id property."
    }
    if ( -not ( $argument | get-member -name host_switch_mode -Membertype Properties)) {
        throw "Element specified does not contain a host_switch_mode property."
    }
    if ( -not ( $argument | get-member -name nested_nsx -Membertype Properties)) {
        throw "Element specified does not contain a nested_nsx property."
    }
    if ( -not ( $argument | get-member -name is_default -Membertype Properties)) {
        throw "Element specified does not contain a is_default property."
    }
    if ( -not ( $argument | get-member -name resource_type -Membertype Properties)) {
        throw "Element specified does not contain a resource_type property."
    }
    if ( -not ( $argument | get-member -name id -Membertype Properties)) {
        throw "Element specified does not contain a id property."
    }
    if ( -not ( $argument | get-member -name display_name -Membertype Properties)) {
        throw "Element specified does not contain a display_name property."
    }
    $true

}