Class: VCenterDriver::DatacenterFolder

Inherits:
Object
  • Object
show all
Defined in:
lib/datacenter.rb

Overview

Class DatacenterFolder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vi_client) ⇒ DatacenterFolder

Returns a new instance of DatacenterFolder.



32
33
34
35
# File 'lib/datacenter.rb', line 32

def initialize(vi_client)
    @vi_client = vi_client
    @items = {}
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



30
31
32
# File 'lib/datacenter.rb', line 30

def items
  @items
end

Instance Method Details

#cluster_networks(one_host) ⇒ Object



481
482
483
484
485
486
487
488
489
# File 'lib/datacenter.rb', line 481

def cluster_networks(one_host)
    ccr_ref = one_host['TEMPLATE/VCENTER_CCR_REF']
    cluster = VCenterDriver::ClusterComputeResource
              .new_from_ref(ccr_ref, @vi_client)
    # cluster = cluster_mob(one_host)
    raise "Cluster with ref: #{ccr_ref} not found" if cluster.nil?

    cluster.item.network
end

#exclude_network?(vc_network, one_host, args, vc_network_hash) ⇒ Boolean

Determine if a network must be excluded from the list

Returns:

  • (Boolean)


503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/datacenter.rb', line 503

def exclude_network?(vc_network, one_host, args, vc_network_hash)
    vc_network_name = vc_network_hash[:vc_network_name]
    vc_network_host = vc_network_hash[:vc_network_host]
    vc_network_tag = vc_network_hash[:vc_network_tag]

    # Exclude some networks if filter = true
    if args[:filter]
        if one_host && one_host['TEMPLATE/NSX_PASSWORD'].nil?
            network_types = [
                VCenterDriver::Network::NETWORK_TYPE_NSXT,
                VCenterDriver::Network::NETWORK_TYPE_NSXV
            ]

            # Only NSX-V and NSX-T can be excluded
            network_type = VCenterDriver::Network
                           .get_network_type(
                               vc_network,
                               vc_network_name
                           )

            return true if network_types.include? network_type
        end
        # Exclude networks without hosts
        if vc_network_host.empty?
            return true
        end

        # Exclude DVS uplinks
        if !vc_network_tag.empty? &&
           vc_network_tag[0][:key] == 'SYSTEM/DVS.UPLINKPG'
            return true
        end
        # Exclude portgroup used for VXLAN communication in NSX
        if vc_network['name'].match(/^vxw-vmknicPg-dvs-(.*)/)
            return true
        end

        return false
    end
    false
end

#fetch!Hash

Builds a hash with Datacenter-Ref / Datacenter to be used as a cache

Returns:

  • (Hash)

    in the form { dc_ref [Symbol] => Datacenter object }



42
43
44
45
46
47
48
49
50
51
# File 'lib/datacenter.rb', line 42

def fetch!
    VIClient
        .get_entities(
            @vi_client.vim.root,
            'Datacenter'
        ).each do |item|
        item_name = item._ref
        @items[item_name.to_sym] = Datacenter.new(item)
    end
end

#get(ref) ⇒ Object

Returns a Datacenter. Uses the cache if available.

Parameters:

  • ref (Symbol)

    the vcenter ref

Returns:

  • Datacenter



58
59
60
61
62
63
64
65
# File 'lib/datacenter.rb', line 58

def get(ref)
    if !@items[ref.to_sym]
        rbvmomi_dc = RbVmomi::VIM::Datacenter.new(@vi_client.vim, ref)
        @items[ref.to_sym] = Datacenter.new(rbvmomi_dc)
    end

    @items[ref.to_sym]
end

#get_unimported_datastores(dpool, vcenter_instance_name, hpool) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/datacenter.rb', line 162

def get_unimported_datastores(dpool, vcenter_instance_name, hpool)
    import_id = 0
    ds_objects = {}
    vcenter_uuid = vcenter_instance_uuid

    # Get datacenters
    fetch! if @items.empty?

    @items.values.each do |dc|
        clusters_in_ds = {}
        dc_name = dc.item.name
        dc_ref  = dc.item._ref

        datastore_folder = dc.datastore_folder
        datastore_folder.fetch!

        datastore_folder.items.values.each do |ds|
            name, capacity, free_space =
                ds
                .item
                .collect(
                    'name',
                    'summary.capacity',
                    'summary.freeSpace'
                )

            ds_name     = name.to_s
            ds_total_mb = ((capacity.to_i / 1024) / 1024)
            ds_free_mb  = ((free_space.to_i / 1024) / 1024)
            ds_ref      = ds['_ref']

            ds_objects[ds_ref] = {}
            ds_objects[ds_ref][:ref]         = ds_ref
            ds_objects[ds_ref][:import_id]   = import_id
            ds_objects[ds_ref][:datacenter]  = dc_name
            ds_objects[ds_ref][:simple_name] = ds_name.to_s
            ds_objects[ds_ref][:total_mb]    = ds_total_mb
            ds_objects[ds_ref][:free_mb]     = ds_free_mb
            ds_objects[ds_ref][:ds]          = []
            ds_objects[ds_ref][:cluster]     = []

            if ds.instance_of? VCenterDriver::Datastore
                hosts = ds['host']
                hosts.each do |host|
                    cluster_ref = host.key.parent._ref
                    if !clusters_in_ds.key?(cluster_ref)
                        clusters_in_ds[cluster_ref] = nil

                        # Try to locate cluster ref in host's pool
                        one_cluster =
                            VCenterDriver::VIHelper
                            .find_by_ref(
                                OpenNebula::HostPool,
                                'TEMPLATE/VCENTER_CCR_REF',
                                cluster_ref,
                                vcenter_uuid,
                                hpool
                            )
                        if one_cluster
                            ds_objects[ds_ref][:cluster] <<
                                one_cluster['CLUSTER_ID'].to_i
                            clusters_in_ds[cluster_ref] =
                                one_cluster['CLUSTER_ID'].to_i
                        end
                    else
                        if clusters_in_ds[cluster_ref] &&
                           !ds_objects[ds_ref][:cluster]
                           .include?(
                               clusters_in_ds[cluster_ref]
                           )
                            ds_objects[ds_ref][:cluster] <<
                                clusters_in_ds[cluster_ref]
                        end
                    end
                end

                already_image_ds = VCenterDriver::Storage
                                   .exists_one_by_ref_dc_and_type?(
                                       ds_ref,
                                       dc_ref,
                                       vcenter_uuid,
                                       'IMAGE_DS',
                                       dpool
                                   )

                key = ds_ref+vcenter_uuid
                if !already_image_ds
                    ds_objects[ds_ref][:name] =
                        VCenterDriver::VIHelper
                        .one_name(
                            OpenNebula::DatastorePool,
                            "#{ds_name}(IMG)",
                            key
                        )
                    object =
                        ds
                        .to_one_template(
                            ds_objects[ds_ref],
                            vcenter_uuid,
                            dc_name,
                            dc_ref,
                            'IMAGE_DS'
                        )
                    ds_objects[ds_ref][:ds] << object unless object.nil?
                end

                already_system_ds =
                    VCenterDriver::Storage
                    .exists_one_by_ref_dc_and_type?(
                        ds_ref,
                        dc_ref,
                        vcenter_uuid,
                        'SYSTEM_DS',
                        dpool
                    )

                if !already_system_ds
                    ds_objects[ds_ref][:name] =
                        VCenterDriver::VIHelper
                        .one_name(
                            OpenNebula::DatastorePool,
                            "#{ds_name}(SYS)",
                            key
                        )
                    object = ds
                             .to_one_template(
                                 ds_objects[ds_ref],
                                 vcenter_uuid,
                                 dc_name,
                                 dc_ref,
                                 'SYSTEM_DS'
                             )
                    ds_objects[ds_ref][:ds] << object unless object.nil?
                end

                ds_objects[ds_ref][:name] = ds_name.to_s
            elsif ds.instance_of? VCenterDriver::StoragePod
                ds['children'].each do |sp_ds|
                    hosts = sp_ds.host
                    hosts.each do |host|
                        cluster_ref = host.key.parent._ref
                        if !clusters_in_ds.include?(cluster_ref)
                            clusters_in_ds[cluster_ref] = nil
                            # Try to locate cluster
                            # ref in cluster's pool
                            one_cluster =
                                VCenterDriver::VIHelper
                                .find_by_ref(
                                    OpenNebula::HostPool,
                                    'TEMPLATE/VCENTER_CCR_REF',
                                    cluster_ref,
                                    vcenter_uuid,
                                    hpool
                                )
                            if one_cluster
                                ds_objects[ds_ref][:cluster] <<
                                    one_cluster['CLUSTER_ID'].to_i
                                clusters_in_ds[cluster_ref] =
                                    one_cluster['CLUSTER_ID'].to_i
                            end
                        else
                            if clusters_in_ds[cluster_ref] &&
                               !ds_objects[ds_ref][:cluster]
                               .include?(
                                   clusters_in_ds[cluster_ref]
                               )
                                ds_objects[ds_ref][:cluster] <<
                                    clusters_in_ds[cluster_ref]
                            end
                        end
                    end
                end

                already_system_ds = VCenterDriver::Storage
                                    .exists_one_by_ref_dc_and_type?(
                                        ds_ref,
                                        dc_ref,
                                        vcenter_uuid,
                                        'SYSTEM_DS',
                                        dpool
                                    )

                if !already_system_ds
                    ds_objects[ds_ref][:name] = "#{ds_name} \
                    [#{vcenter_instance_name} - #{dc_name}] (StorDRS)"
                    object = ds.to_one_template(
                        ds_objects[ds_ref],
                        vcenter_uuid,
                        dc_name,
                        dc_ref,
                        'SYSTEM_DS'
                    )
                    ds_objects[ds_ref][:ds] << object unless object.nil?
                end
            end

            if ds_objects[ds_ref][:ds].empty?
                ds_objects.delete(ds_ref)
            else
                import_id += 1
            end
        end
    end

    { vcenter_instance_name => ds_objects }
end

#get_unimported_hosts(hpool, _vcenter_instance_name) ⇒ Object



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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/datacenter.rb', line 75

def get_unimported_hosts(hpool, _vcenter_instance_name)
    host_objects = {}

    vcenter_uuid = vcenter_instance_uuid
    vcenter_version = vcenter_api_version

    fetch! if @items.empty? # Get datacenters

    # Loop through datacenters
    @items.values.each do |dc|
        dc_name = dc.item.name
        host_objects[dc_name] = []

        # Get clusters inside a datacenter
        host_folder = dc.host_folder
        host_folder.fetch_clusters!
        host_folder.items.values.each do |ccr|
            # Check if the cluster is a host in OpenNebula's pool
            one_host =
                VCenterDriver::VIHelper
                .find_by_ref(
                    OpenNebula::HostPool,
                    'TEMPLATE/VCENTER_CCR_REF',
                    ccr['_ref'],
                    vcenter_uuid,
                    hpool
                )
            next if one_host

            # Get a ClusterComputeResource object
            cluster =
                VCenterDriver::ClusterComputeResource
                .new_from_ref(
                    ccr['_ref'],
                    @vi_client
                )

            # Obtain a list of resource pools found in the cluster
            rpools =
                cluster
                .get_resource_pool_list
                .reject {|rp| rp[:name].empty? }

            # Determine a host location (folder and subfolders)
            item = cluster.item
            folders = []
            until item.instance_of? RbVmomi::VIM::Datacenter
                item = item.parent
                if !item.instance_of?(RbVmomi::VIM::Datacenter) &&
                   item.name != 'host'
                    folders << item.name
                end
                raise "Could not find the host's location" if item.nil?
            end
            location   = folders.reverse.join('/')
            location = '/' if location.empty?

            # Setting host import name and
            # replace spaces and weird characters
            cluster_name = (ccr['name']).to_s.tr(' ', '_')
            cluster_name =
                VCenterDriver::VIHelper
                .one_name(
                    OpenNebula::HostPool,
                    cluster_name,
                    ccr['_ref']+vcenter_uuid,
                    hpool
                )

            # Prepare hash for import tool
            host_info = {}
            host_info[:simple_name]      = ccr['name']
            host_info[:cluster_name]     = cluster_name
            host_info[:cluster_ref]      = ccr['_ref']
            host_info[:cluster_location] = location
            host_info[:vcenter_uuid]     = vcenter_uuid
            host_info[:vcenter_version]  = vcenter_version
            host_info[:rp_list]          = rpools

            # Add the hash to current datacenter
            host_objects[dc_name] << host_info
        end
    end

    host_objects
end

#get_unimported_networks(npool, vcenter_instance_name, hpool, args) ⇒ Object

rubocop:disable Style/GlobalVars



713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/datacenter.rb', line 713

def get_unimported_networks(npool, vcenter_instance_name, hpool, args)
    vcenter_uuid = vcenter_instance_uuid
    networks = {}

    # Selected host in OpenNebula
    if $conf.nil?
        one_client = OpenNebula::Client.new
    else
        one_client = OpenNebula::Client.new(
            nil,
            $conf[:one_xmlrpc]
        )
    end

    one_host = OpenNebula::Host.new_with_id(args[:host], one_client)
    rc = one_host.info
    raise rc.message if OpenNebula.is_error? rc

    # Get all networks in vcenter cluster (one_host)
    vc_cluster_networks = cluster_networks(one_host)

    # Iterate over vcenter networks
    vc_cluster_networks.each do |vc_cluster_network|
        exist = VCenterDriver::VIHelper
                .find_by_ref(OpenNebula::VirtualNetworkPool,
                             'TEMPLATE/VCENTER_NET_REF',
                             vc_cluster_network._ref,
                             vcenter_uuid,
                             npool)

        next if exist

        params = {}

        params[:vc_network]= vc_cluster_network
        params[:vcenter_instance_name]= vcenter_instance_name
        params[:vcenter_uuid]= vcenter_uuid
        params[:_hpool]= hpool
        params[:one_host]= one_host
        params[:args] = args

        network = process_network(params)

        networks.merge!(network) unless network.nil?
    end
    # Added import id
    imid = -1
    networks.map {|_k, v| v[:import_id] = imid += 1 }
    { vcenter_instance_name => networks }
end

#get_unimported_templates(vi_client, tpool) ⇒ Object



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/datacenter.rb', line 369

def get_unimported_templates(vi_client, tpool)
    template_objects = {}
    import_id = 0
    vcenter_uuid = vcenter_instance_uuid

    vcenter_instance_name = vi_client.vim.host

    fetch! if @items.empty? # Get datacenters

    @items.values.each do |dc|
        rp_cache = {}
        dc_name = dc.item.name

        view = vi_client
               .vim
               .serviceContent
               .viewManager
               .CreateContainerView(
                   {
                       :container => dc.item.vmFolder,
                       :type => ['VirtualMachine'],
                       :recursive => true
                   }
               )

        pc = vi_client.vim.serviceContent.propertyCollector

        filter_spec = RbVmomi::VIM.PropertyFilterSpec(
            :objectSet => [
                {
                    :obj => view,
                    :skip => true,
                    :selectSet => [
                        RbVmomi::VIM.TraversalSpec(
                            :name => 'traverseEntities',
                            :type => 'ContainerView',
                            :path => 'view',
                            :skip => false
                        )
                    ]
                }
            ],
            :propSet => [
                {
                    :type => 'VirtualMachine',
                    :pathSet => ['config.template']
                }
            ]
        )

        result = pc.RetrieveProperties(
            :specSet => [filter_spec]
        )

        vms = {}
        result.each do |r|
            if r.obj.is_a?(RbVmomi::VIM::VirtualMachine)
                vms[r.obj._ref] = r.to_hash
            end
        end
        templates = []
        vms.each do |ref, value|
            next unless value['config.template']

            templates << VCenterDriver::Template
                         .new_from_ref(
                             ref,
                             vi_client
                         )
        end

        view.DestroyView # Destroy the view

        templates.each do |template|
            tref = template['_ref']
            next if template_objects[tref]

            one_template = VCenterDriver::VIHelper
                           .find_by_ref(
                               OpenNebula::TemplatePool,
                               'TEMPLATE/VCENTER_TEMPLATE_REF',
                               tref,
                               vcenter_uuid,
                               tpool
                           )

            # If the template has been already imported
            next if one_template

            one_template = VCenterDriver::Template
                           .get_xml_template(
                               template,
                               vcenter_uuid,
                               vi_client,
                               dc_name,
                               rp_cache
                           )

            next if one_template.nil?

            one_template[:import_id] = import_id
            one_template[:vcenter] = vcenter_instance_name
            import_id += 1
            template_objects[tref] = one_template
        end
    end

    {
        vcenter_instance_name => template_objects
    }
end

#one_cluster_id(one_host) ⇒ Object

Return ONE cluster ID



492
493
494
495
496
497
498
499
500
# File 'lib/datacenter.rb', line 492

def one_cluster_id(one_host)
    if !one_host || !one_host['CLUSTER_ID']
        cluster_id = -1
    else
        cluster_id = one_host['CLUSTER_ID']
    end

    cluster_id.to_i
end

#process_network(params) ⇒ Object

Proccess each network



546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
# File 'lib/datacenter.rb', line 546

def process_network(params)
    vc_network = params[:vc_network]
    vcenter_instance_name = params[:vcenter_instance_name]
    vcenter_uuid = params[:vcenter_uuid]
    _hpool = params[:_hpool]
    one_host = params[:one_host]
    args = params[:args]

    full_process = !args[:short]

    vc_network_ref = vc_network._ref
    vc_network_name = VCenterDriver::VcImporter.sanitize(
        vc_network.name
    )
    vc_network_host = vc_network['host']
    vc_network_tag = vc_network['tag']

    vc_network_hash = {}
    vc_network_hash[:vc_network_ref] = vc_network_ref
    vc_network_hash[:vc_network_name] = vc_network_name
    vc_network_hash[:vc_network_host] = vc_network_host
    vc_network_hash[:vc_network_tag] = vc_network_tag

    # Initialize network hash
    network = {}
    # Add name to network hash
    network[vc_network_ref] = { 'name' => vc_network_name }
    # By default no network is excluded
    network[vc_network_ref][:excluded] = false

    # Initialize opts hash used to inject data into one template
    opts = {}

    # Add network type to network hash
    network_type = \
        VCenterDriver::Network.get_network_type(
            vc_network,
            vc_network_name
        )
    network[vc_network_ref][:network_type] = network_type
    network[vc_network_ref][:type] = network_type

    # Determine if the network must be excluded
    network[vc_network_ref][:excluded] = exclude_network?(
        vc_network,
        one_host,
        args,
        vc_network_hash
    )

    return if network[vc_network_ref][:excluded] == true

    if full_process
        case network[vc_network_ref][:network_type]
        # Distributed PortGroups
        when VCenterDriver::Network::NETWORK_TYPE_DPG
            network[vc_network_ref][:sw_name] = \
                vc_network.config.distributedVirtualSwitch.name
            # For DistributedVirtualPortgroups there
            # is networks and uplinks
            network[vc_network_ref][:uplink] = \
                vc_network.config.uplink
        # network[vc_network_ref][:uplink] = false
        # NSX-V PortGroups
        when VCenterDriver::Network::NETWORK_TYPE_NSXV
            network[vc_network_ref][:sw_name] = \
                vc_network.config.distributedVirtualSwitch.name
            # For NSX-V ( is the same as DistributedVirtualPortgroups )
            # there is networks and uplinks
            network[vc_network_ref][:uplink] = \
                vc_network.config.uplink
            network[vc_network_ref][:uplink] = false
        # Standard PortGroups
        when VCenterDriver::Network::NETWORK_TYPE_PG
            # There is no uplinks for standard portgroups,
            # so all Standard
            # PortGroups are networks and no uplinks
            network[vc_network_ref][:uplink] = false
            network[vc_network_ref][:sw_name] =
                VCenterDriver::Network
                .virtual_switch(
                    vc_network
                )
        # NSX-T PortGroups
        when VCenterDriver::Network::NETWORK_TYPE_NSXT
            network[vc_network_ref][:sw_name] = \
                vc_network.summary.opaqueNetworkType
            # There is no uplinks for NSX-T networks,
            # so all NSX-T networks
            # are networks and no uplinks
            network[vc_network_ref][:uplink] = false
        else
            raise 'Unknown network type: ' \
                  "#{network[vc_network_ref][:network_type]}"
        end
    end

    # Multicluster nets support
    network[vc_network_ref][:clusters] = {}
    network[vc_network_ref][:clusters][:refs] = []
    network[vc_network_ref][:clusters][:one_ids] = []
    network[vc_network_ref][:clusters][:names] = []

    # Get hosts related to this network and add them if is not
    # excluded
    vc_hosts = vc_network.host
    vc_hosts.each do |vc_host|
        # Get vCenter Cluster
        vc_cluster = vc_host.parent
        vc_cluster_ref = vc_cluster._ref
        vc_cluster_name = vc_cluster.name
        # Get one host from each vCenter cluster
        one_host = VCenterDriver::VIHelper
                   .find_by_ref(OpenNebula::HostPool,
                                'TEMPLATE/VCENTER_CCR_REF',
                                vc_cluster_ref,
                                vcenter_uuid)
        # Check if network is excluded from each host
        next if exclude_network?(
            vc_network,
            one_host,
            args,
            vc_network_hash
        )

        # Insert vCenter cluster ref
        network[vc_network_ref][:clusters][:refs] << vc_cluster_ref
        # Insert OpenNebula cluster id
        cluster_id = one_cluster_id(one_host)
        network[vc_network_ref][:clusters][:one_ids] << cluster_id
        # Insert vCenter cluster name
        network[vc_network_ref][:clusters][:names] << vc_cluster_name
        opts[:dc_name] = vc_cluster_name
    end

    # Remove duplicate entries
    network[vc_network_ref][:clusters][:refs].uniq!
    network[vc_network_ref][:clusters][:one_ids].uniq!
    network[vc_network_ref][:clusters][:names].uniq!

    # Mark network as processed
    network[vc_network_ref][:processed] = true

    if full_process
        # General net_info related to datacenter
        opts[:vcenter_uuid] = vcenter_uuid
        opts[:vcenter_instance_name] = vcenter_instance_name
        opts[:network_name] = network[vc_network_ref]['name']
        opts[:network_ref]  = network.keys.first
        opts[:network_type] = network[vc_network_ref][:network_type]
        opts[:sw_name] = network[vc_network_ref][:sw_name]

        network[vc_network_ref] = \
            network[vc_network_ref]
            .merge(VCenterDriver::Network
            .to_one_template(opts))
    else
        network[vc_network_ref][:ref] = \
            vc_network_ref
        network[vc_network_ref][:name] = \
            network[vc_network_ref]['name']
    end

    network
end

#vcenter_api_versionObject



71
72
73
# File 'lib/datacenter.rb', line 71

def vcenter_api_version
    @vi_client.vim.serviceContent.about.apiVersion
end

#vcenter_instance_uuidObject



67
68
69
# File 'lib/datacenter.rb', line 67

def vcenter_instance_uuid
    @vi_client.vim.serviceContent.about.instanceUuid
end