]>
Commit | Line | Data |
---|---|---|
d8fdd35b SA |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <workflow xmlns="http://vmware.com/vco/workflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://vmware.com/vco/workflow http://vmware.com/vco/workflow/Workflow-v4.xsd" root-name="item3" object-name="workflow:name=generic" id="25832524-da3e-407e-a64a-d4418bcb3174" version="1.0.3" api-version="3.1.0" allowed-operations="fve" icon-id="93015d83-b1ba-42d0-9b3c-bb3ebb862beb" restartMode="1" resumeFromFailedMode="0"> | |
3 | <display-name>info</display-name> | |
4 | ||
5 | <description>Logger hendelser som skjer til databasen. Også mulig å logge til email dersom variablen enable_mail settes til true</description> | |
6 | ||
7 | <position x="100.0" y="50.0"/> | |
8 | ||
9 | <input> | |
10 | <param name="message" type="string"/> | |
11 | </input> | |
12 | ||
13 | <attrib name="query" type="string" read-only="false"> | |
14 | <value encoded="n"/> | |
15 | <description>sql error query</description> | |
16 | </attrib> | |
17 | <attrib name="rowsAffected" type="number" read-only="false"> | |
18 | <value encoded="n">__NULL__</value> | |
19 | <description>The number of rows affected by the query</description> | |
20 | </attrib> | |
21 | <attrib name="mailto" type="string" read-only="false"> | |
22 | <value encoded="n">__NULL__</value> | |
23 | <description>Default mailto parameter</description> | |
24 | </attrib> | |
25 | <attrib name="smtp_server" type="string" read-only="false"> | |
26 | <value encoded="n">__NULL__</value> | |
27 | <description>Default SMTP server</description> | |
28 | </attrib> | |
29 | <attrib name="smtp_port" type="string" read-only="false"> | |
30 | <value encoded="n">__NULL__</value> | |
31 | <description>Default SMTP port</description> | |
32 | </attrib> | |
33 | <attrib name="database" type="SQL:Database" read-only="false"> | |
34 | <value encoded="n">__NULL__</value> | |
35 | <description>Default database</description> | |
36 | </attrib> | |
37 | <attrib name="state" type="string" read-only="false"> | |
38 | <value encoded="n">INFO</value> | |
39 | <description>Log state</description> | |
40 | </attrib> | |
41 | <attrib name="enable_mail" type="string" read-only="false"> | |
42 | <value encoded="n">false</value> | |
43 | <description>If true, send email for all events</description> | |
44 | </attrib> | |
45 | <attrib name="vmPassword" type="SecureString" read-only="false"> | |
46 | <value encoded="n"/> | |
47 | </attrib> | |
48 | ||
49 | <workflow-item name="item0" type="end" end-mode="0"> | |
50 | <position x="684.5" y="99.95454545454544"/> | |
51 | </workflow-item> | |
52 | ||
53 | <workflow-item name="item1" out-name="item0" type="link" linked-workflow-id="028080808080808080808080808080809F808080013264596926189e8150e1493"> | |
54 | <display-name>Execute a custom query on a database</display-name> | |
55 | ||
56 | <in-binding> | |
57 | <bind name="database" type="SQL:Database" export-name="database"> | |
58 | <description>The database to use for the query</description> | |
59 | </bind> | |
60 | <bind name="query" type="string" export-name="query"> | |
61 | <description>The query to execute</description> | |
62 | </bind> | |
63 | </in-binding> | |
64 | ||
65 | <out-binding> | |
66 | <bind name="rowsAffected" type="number" export-name="rowsAffected"> | |
67 | <description>The number of rows affected by the query</description> | |
68 | </bind> | |
69 | </out-binding> | |
70 | ||
71 | <description>Executes a custom query on a specified database and returns the number of affected rows. You can run the workflow to update, delete, and insert queries.</description> | |
72 | ||
73 | <position x="504.5" y="55.40909090909091"/> | |
74 | </workflow-item> | |
75 | ||
76 | <workflow-item name="item2" out-name="item4" type="task"> | |
77 | <display-name>Generate SQL error string</display-name> | |
78 | ||
79 | <script encoded="false"> | |
80 | //get name of the current workflow | |
81 | var wname = workflow.rootWorkflow.name; | |
82 | ||
83 | // System.debug("Root Workflow "+WorkFlow); | |
84 | ||
85 | ||
86 | //var date = System.getDateFromFormat(Date); | |
87 | ||
88 | var currentdate = new Date(); | |
89 | var date = System.formatDate(currentdate, 'yyyy-MM-dd HH:mm:ss'); | |
90 | ||
91 | // Get current user | |
92 | try { | |
93 | var user = Server.getCredential().username; | |
94 | } | |
95 | catch(err) { | |
96 | // Not able to get user, setting vCAC | |
97 | user = 'vCAC'; | |
98 | } | |
99 | ||
100 | var dbmesg = message.replace(/[`'']/g,'"'); | |
101 | var wname = wname.replace(/[`'']/g,'"'); | |
102 | query="insert into log " | |
103 | +"(log_source, log_date, log_level, log_line, log_category, log_mesg)" | |
104 | +" values " | |
105 | +"('"+user+"@Orchestrator', '"+date+"', '"+state+"', 0, '"+wname+"', '" + dbmesg + "');"; | |
106 | ||
107 | if (enable_mail == "true") { | |
108 | var mail = new EmailMessage() ; | |
109 | mail.fromAddress='virtprov@usit.uio.no'; | |
110 | mail.toAddress=mailto; | |
111 | mail.subject=state+" from "+user+"@Orchestrator/"+wname+""; | |
112 | mail.smtpPort=smtp_port; | |
113 | mail.smtpHost=smtp_server; | |
114 | ||
115 | ||
116 | var body=state+" message from Vmware Orchestrator\n" | |
117 | +"User "+user+" has run a workflow which generated "+state+"\n" | |
118 | +"\n" | |
119 | +state+" message: \n" | |
120 | +message+""; | |
121 | ||
122 | mail.addMimePart(body) | |
123 | mail.sendMessage(); | |
124 | } | |
125 | </script> | |
126 | ||
127 | <in-binding> | |
128 | <bind name="enable_mail" type="string" export-name="enable_mail"> | |
129 | <description>If true, send email for all events</description> | |
130 | </bind> | |
131 | <bind name="mailto" type="string" export-name="mailto"> | |
132 | <description>Default mailto parameter</description> | |
133 | </bind> | |
134 | <bind name="message" type="string" export-name="message"/> | |
135 | <bind name="smtp_port" type="string" export-name="smtp_port"> | |
136 | <description>Default SMTP port</description> | |
137 | </bind> | |
138 | <bind name="smtp_server" type="string" export-name="smtp_server"> | |
139 | <description>Default SMTP server</description> | |
140 | </bind> | |
141 | <bind name="state" type="string" export-name="state"> | |
142 | <description>Log state</description> | |
143 | </bind> | |
144 | </in-binding> | |
145 | ||
146 | <out-binding> | |
147 | <bind name="query" type="string" export-name="query"> | |
148 | <description>The query to execute</description> | |
149 | </bind> | |
150 | </out-binding> | |
151 | ||
152 | <position x="364.5" y="55.40909090909091"/> | |
153 | </workflow-item> | |
154 | ||
155 | <workflow-item name="item3" out-name="item2" type="link" linked-workflow-id="1f0fc470-006c-4c15-a3b9-95e2e7540f22"> | |
156 | <display-name>global_parameters</display-name> | |
157 | ||
158 | <in-binding/> | |
159 | ||
160 | <out-binding> | |
161 | <bind name="mailto" type="string" export-name="mailto"/> | |
162 | <bind name="smtp_server" type="string" export-name="smtp_server"/> | |
163 | <bind name="smtp_port" type="string" export-name="smtp_port"/> | |
164 | <bind name="database" type="SQL:Database" export-name="database"/> | |
165 | <bind name="vmPassword" type="SecureString" export-name="vmPassword"/> | |
166 | </out-binding> | |
167 | ||
168 | <position x="204.5" y="55.40909090909091"/> | |
169 | </workflow-item> | |
170 | ||
171 | <workflow-item name="item4" out-name="item1" type="condition" alt-out-name="item0" comparator="0"> | |
172 | <display-name>Decision</display-name> | |
173 | ||
174 | <script encoded="false"> | |
175 | //Generated by the system, cannot be edited | |
176 | return (database != null ) ; | |
177 | </script> | |
178 | ||
179 | <in-binding> | |
180 | <bind name="database" type="SQL:Database" export-name="database"/> | |
181 | </in-binding> | |
182 | <condition name="database" type="SQL:Database" comparator="0" label="null"/> | |
183 | ||
184 | <position x="445.0" y="99.95454545454544"/> | |
185 | </workflow-item> | |
186 | ||
187 | <presentation> | |
188 | <p-param name="message"> | |
189 | <desc>message</desc> | |
190 | </p-param> | |
191 | </presentation> | |
192 | </workflow> |