github.com/gophercloud/gophercloud@v1.11.0/openstack/compute/v2/extensions/hypervisors/doc.go (about)

     1  /*
     2  Package hypervisors returns details about list of hypervisors, shows details for a hypervisor
     3  and shows summary statistics for all hypervisors over all compute nodes in the OpenStack cloud.
     4  
     5  Example of Show Hypervisor Details
     6  
     7  	hypervisorID := "42"
     8  	hypervisor, err := hypervisors.Get(computeClient, hypervisorID).Extract()
     9  	if err != nil {
    10  		panic(err)
    11  	}
    12  
    13  	fmt.Printf("%+v\n", hypervisor)
    14  
    15  Example of Show Hypervisor Details when using Compute API microversion greater than 2.53
    16  
    17  	computeClient.Microversion = "2.53"
    18  
    19  	hypervisorID := "c48f6247-abe4-4a24-824e-ea39e108874f"
    20  	hypervisor, err := hypervisors.Get(computeClient, hypervisorID).Extract()
    21  	if err != nil {
    22  		panic(err)
    23  	}
    24  
    25  	fmt.Printf("%+v\n", hypervisor)
    26  
    27  Example of Retrieving Details of All Hypervisors
    28  
    29  	allPages, err := hypervisors.List(computeClient, nil).AllPages()
    30  	if err != nil {
    31  		panic(err)
    32  	}
    33  
    34  	allHypervisors, err := hypervisors.ExtractHypervisors(allPages)
    35  	if err != nil {
    36  		panic(err)
    37  	}
    38  
    39  	for _, hypervisor := range allHypervisors {
    40  		fmt.Printf("%+v\n", hypervisor)
    41  	}
    42  
    43  Example of Retrieving Details of All Hypervisors when using Compute API microversion 2.33 or greater.
    44  
    45  	computeClient.Microversion = "2.53"
    46  
    47  	iTrue := true
    48  	listOpts := hypervisors.ListOpts{
    49  		WithServers: &true,
    50  	}
    51  
    52  	allPages, err := hypervisors.List(computeClient, listOpts).AllPages()
    53  	if err != nil {
    54  		panic(err)
    55  	}
    56  
    57  	allHypervisors, err := hypervisors.ExtractHypervisors(allPages)
    58  	if err != nil {
    59  		panic(err)
    60  	}
    61  
    62  	for _, hypervisor := range allHypervisors {
    63  		fmt.Printf("%+v\n", hypervisor)
    64  	}
    65  
    66  Example of Show Hypervisors Statistics
    67  
    68  	hypervisorsStatistics, err := hypervisors.GetStatistics(computeClient).Extract()
    69  	if err != nil {
    70  		panic(err)
    71  	}
    72  
    73  	fmt.Printf("%+v\n", hypervisorsStatistics)
    74  
    75  Example of Show Hypervisor Uptime
    76  
    77  	hypervisorID := "42"
    78  	hypervisorUptime, err := hypervisors.GetUptime(computeClient, hypervisorID).Extract()
    79  	if err != nil {
    80  		panic(err)
    81  	}
    82  
    83  	fmt.Printf("%+v\n", hypervisorUptime)
    84  
    85  Example of Show Hypervisor Uptime with Compute API microversion greater than 2.53
    86  
    87  	computeClient.Microversion = "2.53"
    88  
    89  	hypervisorID := "c48f6247-abe4-4a24-824e-ea39e108874f"
    90  	hypervisorUptime, err := hypervisors.GetUptime(computeClient, hypervisorID).Extract()
    91  	if err != nil {
    92  		panic(err)
    93  	}
    94  
    95  	fmt.Printf("%+v\n", hypervisorUptime)
    96  */
    97  package hypervisors