@@ -58,30 +58,39 @@ all_definitions(ReqData, Context) ->
58
58
Vsn = rabbit :base_product_version (),
59
59
ProductName = rabbit :product_name (),
60
60
ProductVersion = rabbit :product_version (),
61
- rabbit_mgmt_util :reply (
62
- [{rabbit_version , rabbit_data_coercion :to_binary (Vsn )},
63
- {rabbitmq_version , rabbit_data_coercion :to_binary (Vsn )},
64
- {product_name , rabbit_data_coercion :to_binary (ProductName )},
65
- {product_version , rabbit_data_coercion :to_binary (ProductVersion )}] ++
66
- retain_whitelisted (
67
- [{users , rabbit_mgmt_wm_users :users (all )},
68
- {vhosts , rabbit_mgmt_wm_vhosts :basic ()},
69
- {permissions , rabbit_mgmt_wm_permissions :permissions ()},
70
- {topic_permissions , rabbit_mgmt_wm_topic_permissions :topic_permissions ()},
71
- {parameters , rabbit_mgmt_wm_parameters :basic (ReqData )},
72
- {global_parameters , rabbit_mgmt_wm_global_parameters :basic ()},
73
- {policies , rabbit_mgmt_wm_policies :basic (ReqData )},
74
- {queues , Qs },
75
- {exchanges , Xs },
76
- {bindings , Bs }]),
77
- case rabbit_mgmt_util :qs_val (<<" download" >>, ReqData ) of
78
- undefined -> ReqData ;
79
- Filename -> rabbit_mgmt_util :set_resp_header (
80
- <<" Content-Disposition" >>,
81
- " attachment; filename=" ++
82
- binary_to_list (Filename ), ReqData )
83
- end ,
84
- Context ).
61
+
62
+ Contents = [
63
+ {users , rabbit_mgmt_wm_users :users (all )},
64
+ {vhosts , rabbit_mgmt_wm_vhosts :basic ()},
65
+ {permissions , rabbit_mgmt_wm_permissions :permissions ()},
66
+ {topic_permissions , rabbit_mgmt_wm_topic_permissions :topic_permissions ()},
67
+ {parameters , rabbit_mgmt_wm_parameters :basic (ReqData )},
68
+ {global_parameters , rabbit_mgmt_wm_global_parameters :basic ()},
69
+ {policies , rabbit_mgmt_wm_policies :basic (ReqData )},
70
+ {queues , Qs },
71
+ {exchanges , Xs },
72
+ {bindings , Bs }
73
+ ],
74
+
75
+ TopLevelDefsAndMetadata = [
76
+ {rabbit_version , rabbit_data_coercion :to_binary (Vsn )},
77
+ {rabbitmq_version , rabbit_data_coercion :to_binary (Vsn )},
78
+ {product_name , rabbit_data_coercion :to_binary (ProductName )},
79
+ {product_version , rabbit_data_coercion :to_binary (ProductVersion )},
80
+ {rabbitmq_definition_format , <<" cluster" >>},
81
+ {original_cluster_name , rabbit_nodes :cluster_name ()},
82
+ {explanation , rabbit_data_coercion :to_binary (io_lib :format (" Definitions of cluster '~ts '" , [rabbit_nodes :cluster_name ()]))}
83
+ ],
84
+ Result = TopLevelDefsAndMetadata ++ retain_whitelisted (Contents ),
85
+ ReqData1 = case rabbit_mgmt_util :qs_val (<<" download" >>, ReqData ) of
86
+ undefined -> ReqData ;
87
+ Filename -> rabbit_mgmt_util :set_resp_header (
88
+ <<" Content-Disposition" >>,
89
+ " attachment; filename=" ++
90
+ binary_to_list (Filename ), ReqData )
91
+ end ,
92
+
93
+ rabbit_mgmt_util :reply (Result , ReqData1 , Context ).
85
94
86
95
accept_json (ReqData0 , Context ) ->
87
96
BodySizeLimit = application :get_env (rabbitmq_management , max_http_body_size , ? MANAGEMENT_DEFAULT_HTTP_MAX_BODY_SIZE ),
@@ -94,7 +103,10 @@ accept_json(ReqData0, Context) ->
94
103
accept (Body , ReqData , Context )
95
104
end .
96
105
97
- vhost_definitions (ReqData , VHost , Context ) ->
106
+ vhost_definitions (ReqData , VHostName , Context ) ->
107
+ % % the existence of this virtual host is verified in the called, 'to_json/2'
108
+ VHost = rabbit_vhost :lookup (VHostName ),
109
+
98
110
% % rabbit_mgmt_wm_<>:basic/1 filters by VHost if it is available.
99
111
% % TODO: should we stop stripping virtual host? Such files cannot be imported on boot, for example.
100
112
Xs = [strip_vhost (X ) || X <- rabbit_mgmt_wm_exchanges :basic (ReqData ),
@@ -105,25 +117,41 @@ vhost_definitions(ReqData, VHost, Context) ->
105
117
% % TODO: should we stop stripping virtual host? Such files cannot be imported on boot, for example.
106
118
Bs = [strip_vhost (B ) || B <- rabbit_mgmt_wm_bindings :basic (ReqData ),
107
119
export_binding (B , QNames )],
108
- {ok , Vsn } = application :get_key (rabbit , vsn ),
109
120
Parameters = [strip_vhost (
110
121
rabbit_mgmt_format :parameter (P ))
111
- || P <- rabbit_runtime_parameters :list (VHost )],
112
- rabbit_mgmt_util :reply (
113
- [{rabbit_version , rabbit_data_coercion :to_binary (Vsn )}] ++
114
- retain_whitelisted (
115
- [{parameters , Parameters },
116
- {policies , [strip_vhost (P ) || P <- rabbit_mgmt_wm_policies :basic (ReqData )]},
117
- {queues , Qs },
118
- {exchanges , Xs },
119
- {bindings , Bs }]),
120
- case rabbit_mgmt_util :qs_val (<<" download" >>, ReqData ) of
121
- undefined -> ReqData ;
122
- Filename ->
123
- HeaderVal = " attachment; filename=" ++ binary_to_list (Filename ),
124
- rabbit_mgmt_util :set_resp_header (<<" Content-Disposition" >>, HeaderVal , ReqData )
125
- end ,
126
- Context ).
122
+ || P <- rabbit_runtime_parameters :list (VHostName )],
123
+ Contents = [
124
+ {parameters , Parameters },
125
+ {policies , [strip_vhost (P ) || P <- rabbit_mgmt_wm_policies :basic (ReqData )]},
126
+ {queues , Qs },
127
+ {exchanges , Xs },
128
+ {bindings , Bs }
129
+ ],
130
+
131
+ Vsn = rabbit :base_product_version (),
132
+ ProductName = rabbit :product_name (),
133
+ ProductVersion = rabbit :product_version (),
134
+
135
+ TopLevelDefsAndMetadata = [
136
+ {rabbit_version , rabbit_data_coercion :to_binary (Vsn )},
137
+ {rabbitmq_version , rabbit_data_coercion :to_binary (Vsn )},
138
+ {product_name , rabbit_data_coercion :to_binary (ProductName )},
139
+ {product_version , rabbit_data_coercion :to_binary (ProductVersion )},
140
+ {rabbitmq_definition_format , <<" single_virtual_host" >>},
141
+ {original_vhost_name , VHostName },
142
+ {explanation , rabbit_data_coercion :to_binary (io_lib :format (" Definitions of virtual host '~ts '" , [VHostName ]))},
143
+ {description , vhost :get_description (VHost )},
144
+ {default_queue_type , rabbit_queue_type :short_alias_of (rabbit_vhost :default_queue_type (VHostName ))}
145
+ ],
146
+ Result = TopLevelDefsAndMetadata ++ retain_whitelisted (Contents ),
147
+
148
+ ReqData1 = case rabbit_mgmt_util :qs_val (<<" download" >>, ReqData ) of
149
+ undefined -> ReqData ;
150
+ Filename ->
151
+ HeaderVal = " attachment; filename=" ++ binary_to_list (Filename ),
152
+ rabbit_mgmt_util :set_resp_header (<<" Content-Disposition" >>, HeaderVal , ReqData )
153
+ end ,
154
+ rabbit_mgmt_util :reply (Result , ReqData1 , Context ).
127
155
128
156
accept_multipart (ReqData0 , Context ) ->
129
157
{Parts , ReqData } = get_all_parts (ReqData0 ),
0 commit comments