File tree Expand file tree Collapse file tree
openstack/compute/v2/extensions/extendedserverattributes Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package extendedserverattributes
22
3- import (
4- "encoding/base64"
5- "encoding/json"
6- )
7-
83// ServerAttributesExt represents basic OS-EXT-SRV-ATTR server response fields.
94// You should use extract methods from microversions.go to retrieve additional
105// fields.
@@ -45,31 +40,5 @@ type ServerAttributesExt struct {
4540
4641 // Userdata is the userdata of the instance.
4742 // This requires microversion 2.3 or later.
48- Userdata * string `json:"-"`
49- }
50-
51- func (r * ServerAttributesExt ) UnmarshalJSON (b []byte ) error {
52- type tmp ServerAttributesExt
53- var s struct {
54- tmp
55- Userdata * string `json:"OS-EXT-SRV-ATTR:user_data"`
56- }
57- err := json .Unmarshal (b , & s )
58- if err != nil {
59- return err
60- }
61-
62- * r = ServerAttributesExt (s .tmp )
63-
64- if s .Userdata != nil {
65- r .Userdata = new (string )
66- if v , err := base64 .StdEncoding .DecodeString (* s .Userdata ); err != nil {
67- r .Userdata = s .Userdata
68- } else {
69- v := string (v )
70- r .Userdata = & v
71- }
72- }
73-
74- return err
43+ Userdata * string `json:"OS-EXT-SRV-ATTR:user_data"`
7544}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ func TestServerWithUsageExt(t *testing.T) {
3636 th .AssertEquals (t , serverWithAttributesExt .Host , "compute01" )
3737 th .AssertEquals (t , serverWithAttributesExt .InstanceName , "instance-00000001" )
3838 th .AssertEquals (t , serverWithAttributesExt .HypervisorHostname , "compute01" )
39- th .AssertEquals (t , * serverWithAttributesExt .Userdata , "foo " )
39+ th .AssertEquals (t , * serverWithAttributesExt .Userdata , "Zm9v " )
4040 th .AssertEquals (t , * serverWithAttributesExt .ReservationID , "r-ky9gim1l" )
4141 th .AssertEquals (t , * serverWithAttributesExt .LaunchIndex , 0 )
4242 th .AssertEquals (t , * serverWithAttributesExt .Hostname , "test00" )
You can’t perform that action at this time.
0 commit comments