github.com/gophercloud/gophercloud@v1.11.0/openstack/blockstorage/v3/qos/doc.go (about)

     1  /*
     2  Package qos provides information and interaction with the QoS specifications
     3  for the Openstack Blockstorage service.
     4  
     5  Example to create a QoS specification
     6  
     7  	createOpts := qos.CreateOpts{
     8  		Name:     "test",
     9  		Consumer: qos.ConsumerFront,
    10  		Specs: map[string]string{
    11  			"read_iops_sec": "20000",
    12  		},
    13  	}
    14  
    15  	test, err := qos.Create(client, createOpts).Extract()
    16  	if err != nil {
    17  		log.Fatal(err)
    18  	}
    19  
    20  	fmt.Printf("QoS: %+v\n", test)
    21  
    22  Example to delete a QoS specification
    23  
    24  	qosID := "d6ae28ce-fcb5-4180-aa62-d260a27e09ae"
    25  
    26  	deleteOpts := qos.DeleteOpts{
    27  		Force: false,
    28  	}
    29  
    30  	err = qos.Delete(client, qosID, deleteOpts).ExtractErr()
    31  	if err != nil {
    32  		log.Fatal(err)
    33  	}
    34  
    35  Example to list QoS specifications
    36  
    37  	listOpts := qos.ListOpts{}
    38  
    39  	allPages, err := qos.List(client, listOpts).AllPages()
    40  	if err != nil {
    41  		panic(err)
    42  	}
    43  
    44  	allQoS, err := qos.ExtractQoS(allPages)
    45  	if err != nil {
    46  		panic(err)
    47  	}
    48  
    49  	for _, qos := range allQoS {
    50  		fmt.Printf("List: %+v\n", qos)
    51  	}
    52  
    53  Example to get a single QoS specification
    54  
    55  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
    56  
    57  	singleQos, err := qos.Get(client, test.ID).Extract()
    58  	if err != nil {
    59  		panic(err)
    60  	}
    61  
    62  	fmt.Printf("Get: %+v\n", singleQos)
    63  
    64  Example of updating QoSSpec
    65  
    66  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
    67  
    68  	updateOpts := qos.UpdateOpts{
    69  		Consumer: qos.ConsumerBack,
    70  		Specs: map[string]string{
    71  			"read_iops_sec": "40000",
    72  		},
    73  	}
    74  
    75  	specs, err := qos.Update(client, qosID, updateOpts).Extract()
    76  	if err != nil {
    77  		panic(err)
    78  	}
    79  	fmt.Printf("%+v\n", specs)
    80  
    81  Example of deleting specific keys/specs from a QoS
    82  
    83  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
    84  
    85  	keysToDelete := qos.DeleteKeysOpts{"read_iops_sec"}
    86  	err = qos.DeleteKeys(client, qosID, keysToDelete).ExtractErr()
    87  	if err != nil {
    88  		panic(err)
    89  	}
    90  
    91  Example of associating a QoS with a volume type
    92  
    93  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
    94  	volID := "b596be6a-0ce9-43fa-804a-5c5e181ede76"
    95  
    96  	associateOpts := qos.AssociateOpts{
    97  		VolumeTypeID: volID,
    98  	}
    99  
   100  	err = qos.Associate(client, qosID, associateOpts).ExtractErr()
   101  	if err != nil {
   102  		panic(err)
   103  	}
   104  
   105  Example of disassociating a QoS from a volume type
   106  
   107  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
   108  	volID := "b596be6a-0ce9-43fa-804a-5c5e181ede76"
   109  
   110  	disassociateOpts := qos.DisassociateOpts{
   111  		VolumeTypeID: volID,
   112  	}
   113  
   114  	err = qos.Disassociate(client, qosID, disassociateOpts).ExtractErr()
   115  	if err != nil {
   116  		panic(err)
   117  	}
   118  
   119  Example of disaassociating a Qos from all volume types
   120  
   121  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
   122  
   123  	err = qos.DisassociateAll(client, qosID).ExtractErr()
   124  	if err != nil {
   125  		panic(err)
   126  	}
   127  
   128  Example of listing all associations of a QoS
   129  
   130  	qosID := "de075d5e-8afc-4e23-9388-b84a5183d1c0"
   131  
   132  	allQosAssociations, err := qos.ListAssociations(client, qosID).AllPages()
   133  	if err != nil {
   134  		panic(err)
   135  	}
   136  
   137  	allAssociations, err := qos.ExtractAssociations(allQosAssociations)
   138  	if err != nil {
   139  		panic(err)
   140  	}
   141  
   142  	for _, association := range allAssociations {
   143  		fmt.Printf("Association: %+v\n", association)
   144  	}
   145  */
   146  package qos