github.com/gophercloud/gophercloud@v1.11.0/openstack/clustering/v1/profiles/doc.go (about)

     1  /*
     2  Package profiles provides information and interaction with profiles through
     3  the OpenStack Clustering service.
     4  
     5  Example to Create a Profile
     6  
     7  	networks := []map[string]interface{} {
     8  		{"network": "test-network"},
     9  	}
    10  
    11  	props := map[string]interface{}{
    12  		"name":            "test_gophercloud_profile",
    13  		"flavor":          "t2.micro",
    14  		"image":           "centos7.3-latest",
    15  		"networks":        networks,
    16  		"security_groups": "",
    17  	}
    18  
    19  	createOpts := profiles.CreateOpts {
    20  		Name: "test_profile",
    21  		Spec: profiles.Spec{
    22  			Type:       "os.nova.server",
    23  			Version:    "1.0",
    24  			Properties: props,
    25  		},
    26  	}
    27  
    28  	profile, err := profiles.Create(serviceClient, createOpts).Extract()
    29  	if err != nil {
    30  		panic(err)
    31  	}
    32  
    33  	fmt.Println("Profile", profile)
    34  
    35  Example to Get a Profile
    36  
    37  	profile, err := profiles.Get(serviceClient, "profile-name").Extract()
    38  	if err != nil {
    39  		panic(err)
    40  	}
    41  
    42  	fmt.Print("profile", profile)
    43  
    44  Example to List Profiles
    45  
    46  	listOpts := profiles.ListOpts{
    47  		Limit: 2,
    48  	}
    49  
    50  	profiles.List(serviceClient, listOpts).EachPage(func(page pagination.Page) (bool, error) {
    51  		allProfiles, err := profiles.ExtractProfiles(page)
    52  		if err != nil {
    53  			panic(err)
    54  		}
    55  
    56  		for _, profile := range allProfiles {
    57  			fmt.Printf("%+v\n", profile)
    58  		}
    59  		return true, nil
    60  	})
    61  
    62  Example to Update a Profile
    63  
    64  	updateOpts := profiles.UpdateOpts{
    65  		Name: "new-name",
    66  	}
    67  
    68  	profile, err := profiles.Update(serviceClient, profileName, updateOpts).Extract()
    69  	if err != nil {
    70  		panic(err)
    71  	}
    72  
    73  	fmt.Print("profile", profile)
    74  
    75  Example to Delete a Profile
    76  
    77  	profileID := "6dc6d336e3fc4c0a951b5698cd1236ee"
    78  	err := profiles.Delete(serviceClient, profileID).ExtractErr()
    79  	if err != nil {
    80  		panic(err)
    81  	}
    82  
    83  Example to Validate a profile
    84  
    85  	serviceClient.Microversion = "1.2"
    86  
    87  	validateOpts := profiles.ValidateOpts{
    88  		Spec: profiles.Spec{
    89  			Properties: map[string]interface{}{
    90  				"flavor":   "t2.micro",
    91  				"image":    "cirros-0.3.4-x86_64-uec",
    92  				"key_name": "oskey",
    93  				"name":     "cirros_server",
    94  				"networks": []interface{}{
    95  					map[string]interface{}{"network": "private"},
    96  				},
    97  			},
    98  			Type:    "os.nova.server",
    99  			Version: "1.0",
   100  		},
   101  	}
   102  
   103  	profile, err := profiles.Validate(serviceClient, validateOpts).Extract()
   104  	if err != nil {
   105  		panic(err)
   106  	}
   107  */
   108  package profiles