• R/O
  • SSH

vm-ctl: Commit

※ リポジトリはhttps://github.com/linux-ha-japan/vm-ctl-1.0 へ移行しました。
仮想マシンリソース制御機能


Commit MetaInfo

Revisión61f256435311e1598554f2156c84494f8cfa8a07 (tree)
Tiempo2011-09-15 17:11:13
AutorYuusuke Iida <iidayuus@inte...>
CommiterYuusuke Iida

Log Message

Initial commit for vm-ctl - Virtual domain resource controll tool.

Cambiar Resumen

Diferencia incremental

diff -r 000000000000 -r 61f256435311 COPYING
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/COPYING Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,674 @@
1+ GNU GENERAL PUBLIC LICENSE
2+ Version 3, 29 June 2007
3+
4+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5+ Everyone is permitted to copy and distribute verbatim copies
6+ of this license document, but changing it is not allowed.
7+
8+ Preamble
9+
10+ The GNU General Public License is a free, copyleft license for
11+software and other kinds of works.
12+
13+ The licenses for most software and other practical works are designed
14+to take away your freedom to share and change the works. By contrast,
15+the GNU General Public License is intended to guarantee your freedom to
16+share and change all versions of a program--to make sure it remains free
17+software for all its users. We, the Free Software Foundation, use the
18+GNU General Public License for most of our software; it applies also to
19+any other work released this way by its authors. You can apply it to
20+your programs, too.
21+
22+ When we speak of free software, we are referring to freedom, not
23+price. Our General Public Licenses are designed to make sure that you
24+have the freedom to distribute copies of free software (and charge for
25+them if you wish), that you receive source code or can get it if you
26+want it, that you can change the software or use pieces of it in new
27+free programs, and that you know you can do these things.
28+
29+ To protect your rights, we need to prevent others from denying you
30+these rights or asking you to surrender the rights. Therefore, you have
31+certain responsibilities if you distribute copies of the software, or if
32+you modify it: responsibilities to respect the freedom of others.
33+
34+ For example, if you distribute copies of such a program, whether
35+gratis or for a fee, you must pass on to the recipients the same
36+freedoms that you received. You must make sure that they, too, receive
37+or can get the source code. And you must show them these terms so they
38+know their rights.
39+
40+ Developers that use the GNU GPL protect your rights with two steps:
41+(1) assert copyright on the software, and (2) offer you this License
42+giving you legal permission to copy, distribute and/or modify it.
43+
44+ For the developers' and authors' protection, the GPL clearly explains
45+that there is no warranty for this free software. For both users' and
46+authors' sake, the GPL requires that modified versions be marked as
47+changed, so that their problems will not be attributed erroneously to
48+authors of previous versions.
49+
50+ Some devices are designed to deny users access to install or run
51+modified versions of the software inside them, although the manufacturer
52+can do so. This is fundamentally incompatible with the aim of
53+protecting users' freedom to change the software. The systematic
54+pattern of such abuse occurs in the area of products for individuals to
55+use, which is precisely where it is most unacceptable. Therefore, we
56+have designed this version of the GPL to prohibit the practice for those
57+products. If such problems arise substantially in other domains, we
58+stand ready to extend this provision to those domains in future versions
59+of the GPL, as needed to protect the freedom of users.
60+
61+ Finally, every program is threatened constantly by software patents.
62+States should not allow patents to restrict development and use of
63+software on general-purpose computers, but in those that do, we wish to
64+avoid the special danger that patents applied to a free program could
65+make it effectively proprietary. To prevent this, the GPL assures that
66+patents cannot be used to render the program non-free.
67+
68+ The precise terms and conditions for copying, distribution and
69+modification follow.
70+
71+ TERMS AND CONDITIONS
72+
73+ 0. Definitions.
74+
75+ "This License" refers to version 3 of the GNU General Public License.
76+
77+ "Copyright" also means copyright-like laws that apply to other kinds of
78+works, such as semiconductor masks.
79+
80+ "The Program" refers to any copyrightable work licensed under this
81+License. Each licensee is addressed as "you". "Licensees" and
82+"recipients" may be individuals or organizations.
83+
84+ To "modify" a work means to copy from or adapt all or part of the work
85+in a fashion requiring copyright permission, other than the making of an
86+exact copy. The resulting work is called a "modified version" of the
87+earlier work or a work "based on" the earlier work.
88+
89+ A "covered work" means either the unmodified Program or a work based
90+on the Program.
91+
92+ To "propagate" a work means to do anything with it that, without
93+permission, would make you directly or secondarily liable for
94+infringement under applicable copyright law, except executing it on a
95+computer or modifying a private copy. Propagation includes copying,
96+distribution (with or without modification), making available to the
97+public, and in some countries other activities as well.
98+
99+ To "convey" a work means any kind of propagation that enables other
100+parties to make or receive copies. Mere interaction with a user through
101+a computer network, with no transfer of a copy, is not conveying.
102+
103+ An interactive user interface displays "Appropriate Legal Notices"
104+to the extent that it includes a convenient and prominently visible
105+feature that (1) displays an appropriate copyright notice, and (2)
106+tells the user that there is no warranty for the work (except to the
107+extent that warranties are provided), that licensees may convey the
108+work under this License, and how to view a copy of this License. If
109+the interface presents a list of user commands or options, such as a
110+menu, a prominent item in the list meets this criterion.
111+
112+ 1. Source Code.
113+
114+ The "source code" for a work means the preferred form of the work
115+for making modifications to it. "Object code" means any non-source
116+form of a work.
117+
118+ A "Standard Interface" means an interface that either is an official
119+standard defined by a recognized standards body, or, in the case of
120+interfaces specified for a particular programming language, one that
121+is widely used among developers working in that language.
122+
123+ The "System Libraries" of an executable work include anything, other
124+than the work as a whole, that (a) is included in the normal form of
125+packaging a Major Component, but which is not part of that Major
126+Component, and (b) serves only to enable use of the work with that
127+Major Component, or to implement a Standard Interface for which an
128+implementation is available to the public in source code form. A
129+"Major Component", in this context, means a major essential component
130+(kernel, window system, and so on) of the specific operating system
131+(if any) on which the executable work runs, or a compiler used to
132+produce the work, or an object code interpreter used to run it.
133+
134+ The "Corresponding Source" for a work in object code form means all
135+the source code needed to generate, install, and (for an executable
136+work) run the object code and to modify the work, including scripts to
137+control those activities. However, it does not include the work's
138+System Libraries, or general-purpose tools or generally available free
139+programs which are used unmodified in performing those activities but
140+which are not part of the work. For example, Corresponding Source
141+includes interface definition files associated with source files for
142+the work, and the source code for shared libraries and dynamically
143+linked subprograms that the work is specifically designed to require,
144+such as by intimate data communication or control flow between those
145+subprograms and other parts of the work.
146+
147+ The Corresponding Source need not include anything that users
148+can regenerate automatically from other parts of the Corresponding
149+Source.
150+
151+ The Corresponding Source for a work in source code form is that
152+same work.
153+
154+ 2. Basic Permissions.
155+
156+ All rights granted under this License are granted for the term of
157+copyright on the Program, and are irrevocable provided the stated
158+conditions are met. This License explicitly affirms your unlimited
159+permission to run the unmodified Program. The output from running a
160+covered work is covered by this License only if the output, given its
161+content, constitutes a covered work. This License acknowledges your
162+rights of fair use or other equivalent, as provided by copyright law.
163+
164+ You may make, run and propagate covered works that you do not
165+convey, without conditions so long as your license otherwise remains
166+in force. You may convey covered works to others for the sole purpose
167+of having them make modifications exclusively for you, or provide you
168+with facilities for running those works, provided that you comply with
169+the terms of this License in conveying all material for which you do
170+not control copyright. Those thus making or running the covered works
171+for you must do so exclusively on your behalf, under your direction
172+and control, on terms that prohibit them from making any copies of
173+your copyrighted material outside their relationship with you.
174+
175+ Conveying under any other circumstances is permitted solely under
176+the conditions stated below. Sublicensing is not allowed; section 10
177+makes it unnecessary.
178+
179+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180+
181+ No covered work shall be deemed part of an effective technological
182+measure under any applicable law fulfilling obligations under article
183+11 of the WIPO copyright treaty adopted on 20 December 1996, or
184+similar laws prohibiting or restricting circumvention of such
185+measures.
186+
187+ When you convey a covered work, you waive any legal power to forbid
188+circumvention of technological measures to the extent such circumvention
189+is effected by exercising rights under this License with respect to
190+the covered work, and you disclaim any intention to limit operation or
191+modification of the work as a means of enforcing, against the work's
192+users, your or third parties' legal rights to forbid circumvention of
193+technological measures.
194+
195+ 4. Conveying Verbatim Copies.
196+
197+ You may convey verbatim copies of the Program's source code as you
198+receive it, in any medium, provided that you conspicuously and
199+appropriately publish on each copy an appropriate copyright notice;
200+keep intact all notices stating that this License and any
201+non-permissive terms added in accord with section 7 apply to the code;
202+keep intact all notices of the absence of any warranty; and give all
203+recipients a copy of this License along with the Program.
204+
205+ You may charge any price or no price for each copy that you convey,
206+and you may offer support or warranty protection for a fee.
207+
208+ 5. Conveying Modified Source Versions.
209+
210+ You may convey a work based on the Program, or the modifications to
211+produce it from the Program, in the form of source code under the
212+terms of section 4, provided that you also meet all of these conditions:
213+
214+ a) The work must carry prominent notices stating that you modified
215+ it, and giving a relevant date.
216+
217+ b) The work must carry prominent notices stating that it is
218+ released under this License and any conditions added under section
219+ 7. This requirement modifies the requirement in section 4 to
220+ "keep intact all notices".
221+
222+ c) You must license the entire work, as a whole, under this
223+ License to anyone who comes into possession of a copy. This
224+ License will therefore apply, along with any applicable section 7
225+ additional terms, to the whole of the work, and all its parts,
226+ regardless of how they are packaged. This License gives no
227+ permission to license the work in any other way, but it does not
228+ invalidate such permission if you have separately received it.
229+
230+ d) If the work has interactive user interfaces, each must display
231+ Appropriate Legal Notices; however, if the Program has interactive
232+ interfaces that do not display Appropriate Legal Notices, your
233+ work need not make them do so.
234+
235+ A compilation of a covered work with other separate and independent
236+works, which are not by their nature extensions of the covered work,
237+and which are not combined with it such as to form a larger program,
238+in or on a volume of a storage or distribution medium, is called an
239+"aggregate" if the compilation and its resulting copyright are not
240+used to limit the access or legal rights of the compilation's users
241+beyond what the individual works permit. Inclusion of a covered work
242+in an aggregate does not cause this License to apply to the other
243+parts of the aggregate.
244+
245+ 6. Conveying Non-Source Forms.
246+
247+ You may convey a covered work in object code form under the terms
248+of sections 4 and 5, provided that you also convey the
249+machine-readable Corresponding Source under the terms of this License,
250+in one of these ways:
251+
252+ a) Convey the object code in, or embodied in, a physical product
253+ (including a physical distribution medium), accompanied by the
254+ Corresponding Source fixed on a durable physical medium
255+ customarily used for software interchange.
256+
257+ b) Convey the object code in, or embodied in, a physical product
258+ (including a physical distribution medium), accompanied by a
259+ written offer, valid for at least three years and valid for as
260+ long as you offer spare parts or customer support for that product
261+ model, to give anyone who possesses the object code either (1) a
262+ copy of the Corresponding Source for all the software in the
263+ product that is covered by this License, on a durable physical
264+ medium customarily used for software interchange, for a price no
265+ more than your reasonable cost of physically performing this
266+ conveying of source, or (2) access to copy the
267+ Corresponding Source from a network server at no charge.
268+
269+ c) Convey individual copies of the object code with a copy of the
270+ written offer to provide the Corresponding Source. This
271+ alternative is allowed only occasionally and noncommercially, and
272+ only if you received the object code with such an offer, in accord
273+ with subsection 6b.
274+
275+ d) Convey the object code by offering access from a designated
276+ place (gratis or for a charge), and offer equivalent access to the
277+ Corresponding Source in the same way through the same place at no
278+ further charge. You need not require recipients to copy the
279+ Corresponding Source along with the object code. If the place to
280+ copy the object code is a network server, the Corresponding Source
281+ may be on a different server (operated by you or a third party)
282+ that supports equivalent copying facilities, provided you maintain
283+ clear directions next to the object code saying where to find the
284+ Corresponding Source. Regardless of what server hosts the
285+ Corresponding Source, you remain obligated to ensure that it is
286+ available for as long as needed to satisfy these requirements.
287+
288+ e) Convey the object code using peer-to-peer transmission, provided
289+ you inform other peers where the object code and Corresponding
290+ Source of the work are being offered to the general public at no
291+ charge under subsection 6d.
292+
293+ A separable portion of the object code, whose source code is excluded
294+from the Corresponding Source as a System Library, need not be
295+included in conveying the object code work.
296+
297+ A "User Product" is either (1) a "consumer product", which means any
298+tangible personal property which is normally used for personal, family,
299+or household purposes, or (2) anything designed or sold for incorporation
300+into a dwelling. In determining whether a product is a consumer product,
301+doubtful cases shall be resolved in favor of coverage. For a particular
302+product received by a particular user, "normally used" refers to a
303+typical or common use of that class of product, regardless of the status
304+of the particular user or of the way in which the particular user
305+actually uses, or expects or is expected to use, the product. A product
306+is a consumer product regardless of whether the product has substantial
307+commercial, industrial or non-consumer uses, unless such uses represent
308+the only significant mode of use of the product.
309+
310+ "Installation Information" for a User Product means any methods,
311+procedures, authorization keys, or other information required to install
312+and execute modified versions of a covered work in that User Product from
313+a modified version of its Corresponding Source. The information must
314+suffice to ensure that the continued functioning of the modified object
315+code is in no case prevented or interfered with solely because
316+modification has been made.
317+
318+ If you convey an object code work under this section in, or with, or
319+specifically for use in, a User Product, and the conveying occurs as
320+part of a transaction in which the right of possession and use of the
321+User Product is transferred to the recipient in perpetuity or for a
322+fixed term (regardless of how the transaction is characterized), the
323+Corresponding Source conveyed under this section must be accompanied
324+by the Installation Information. But this requirement does not apply
325+if neither you nor any third party retains the ability to install
326+modified object code on the User Product (for example, the work has
327+been installed in ROM).
328+
329+ The requirement to provide Installation Information does not include a
330+requirement to continue to provide support service, warranty, or updates
331+for a work that has been modified or installed by the recipient, or for
332+the User Product in which it has been modified or installed. Access to a
333+network may be denied when the modification itself materially and
334+adversely affects the operation of the network or violates the rules and
335+protocols for communication across the network.
336+
337+ Corresponding Source conveyed, and Installation Information provided,
338+in accord with this section must be in a format that is publicly
339+documented (and with an implementation available to the public in
340+source code form), and must require no special password or key for
341+unpacking, reading or copying.
342+
343+ 7. Additional Terms.
344+
345+ "Additional permissions" are terms that supplement the terms of this
346+License by making exceptions from one or more of its conditions.
347+Additional permissions that are applicable to the entire Program shall
348+be treated as though they were included in this License, to the extent
349+that they are valid under applicable law. If additional permissions
350+apply only to part of the Program, that part may be used separately
351+under those permissions, but the entire Program remains governed by
352+this License without regard to the additional permissions.
353+
354+ When you convey a copy of a covered work, you may at your option
355+remove any additional permissions from that copy, or from any part of
356+it. (Additional permissions may be written to require their own
357+removal in certain cases when you modify the work.) You may place
358+additional permissions on material, added by you to a covered work,
359+for which you have or can give appropriate copyright permission.
360+
361+ Notwithstanding any other provision of this License, for material you
362+add to a covered work, you may (if authorized by the copyright holders of
363+that material) supplement the terms of this License with terms:
364+
365+ a) Disclaiming warranty or limiting liability differently from the
366+ terms of sections 15 and 16 of this License; or
367+
368+ b) Requiring preservation of specified reasonable legal notices or
369+ author attributions in that material or in the Appropriate Legal
370+ Notices displayed by works containing it; or
371+
372+ c) Prohibiting misrepresentation of the origin of that material, or
373+ requiring that modified versions of such material be marked in
374+ reasonable ways as different from the original version; or
375+
376+ d) Limiting the use for publicity purposes of names of licensors or
377+ authors of the material; or
378+
379+ e) Declining to grant rights under trademark law for use of some
380+ trade names, trademarks, or service marks; or
381+
382+ f) Requiring indemnification of licensors and authors of that
383+ material by anyone who conveys the material (or modified versions of
384+ it) with contractual assumptions of liability to the recipient, for
385+ any liability that these contractual assumptions directly impose on
386+ those licensors and authors.
387+
388+ All other non-permissive additional terms are considered "further
389+restrictions" within the meaning of section 10. If the Program as you
390+received it, or any part of it, contains a notice stating that it is
391+governed by this License along with a term that is a further
392+restriction, you may remove that term. If a license document contains
393+a further restriction but permits relicensing or conveying under this
394+License, you may add to a covered work material governed by the terms
395+of that license document, provided that the further restriction does
396+not survive such relicensing or conveying.
397+
398+ If you add terms to a covered work in accord with this section, you
399+must place, in the relevant source files, a statement of the
400+additional terms that apply to those files, or a notice indicating
401+where to find the applicable terms.
402+
403+ Additional terms, permissive or non-permissive, may be stated in the
404+form of a separately written license, or stated as exceptions;
405+the above requirements apply either way.
406+
407+ 8. Termination.
408+
409+ You may not propagate or modify a covered work except as expressly
410+provided under this License. Any attempt otherwise to propagate or
411+modify it is void, and will automatically terminate your rights under
412+this License (including any patent licenses granted under the third
413+paragraph of section 11).
414+
415+ However, if you cease all violation of this License, then your
416+license from a particular copyright holder is reinstated (a)
417+provisionally, unless and until the copyright holder explicitly and
418+finally terminates your license, and (b) permanently, if the copyright
419+holder fails to notify you of the violation by some reasonable means
420+prior to 60 days after the cessation.
421+
422+ Moreover, your license from a particular copyright holder is
423+reinstated permanently if the copyright holder notifies you of the
424+violation by some reasonable means, this is the first time you have
425+received notice of violation of this License (for any work) from that
426+copyright holder, and you cure the violation prior to 30 days after
427+your receipt of the notice.
428+
429+ Termination of your rights under this section does not terminate the
430+licenses of parties who have received copies or rights from you under
431+this License. If your rights have been terminated and not permanently
432+reinstated, you do not qualify to receive new licenses for the same
433+material under section 10.
434+
435+ 9. Acceptance Not Required for Having Copies.
436+
437+ You are not required to accept this License in order to receive or
438+run a copy of the Program. Ancillary propagation of a covered work
439+occurring solely as a consequence of using peer-to-peer transmission
440+to receive a copy likewise does not require acceptance. However,
441+nothing other than this License grants you permission to propagate or
442+modify any covered work. These actions infringe copyright if you do
443+not accept this License. Therefore, by modifying or propagating a
444+covered work, you indicate your acceptance of this License to do so.
445+
446+ 10. Automatic Licensing of Downstream Recipients.
447+
448+ Each time you convey a covered work, the recipient automatically
449+receives a license from the original licensors, to run, modify and
450+propagate that work, subject to this License. You are not responsible
451+for enforcing compliance by third parties with this License.
452+
453+ An "entity transaction" is a transaction transferring control of an
454+organization, or substantially all assets of one, or subdividing an
455+organization, or merging organizations. If propagation of a covered
456+work results from an entity transaction, each party to that
457+transaction who receives a copy of the work also receives whatever
458+licenses to the work the party's predecessor in interest had or could
459+give under the previous paragraph, plus a right to possession of the
460+Corresponding Source of the work from the predecessor in interest, if
461+the predecessor has it or can get it with reasonable efforts.
462+
463+ You may not impose any further restrictions on the exercise of the
464+rights granted or affirmed under this License. For example, you may
465+not impose a license fee, royalty, or other charge for exercise of
466+rights granted under this License, and you may not initiate litigation
467+(including a cross-claim or counterclaim in a lawsuit) alleging that
468+any patent claim is infringed by making, using, selling, offering for
469+sale, or importing the Program or any portion of it.
470+
471+ 11. Patents.
472+
473+ A "contributor" is a copyright holder who authorizes use under this
474+License of the Program or a work on which the Program is based. The
475+work thus licensed is called the contributor's "contributor version".
476+
477+ A contributor's "essential patent claims" are all patent claims
478+owned or controlled by the contributor, whether already acquired or
479+hereafter acquired, that would be infringed by some manner, permitted
480+by this License, of making, using, or selling its contributor version,
481+but do not include claims that would be infringed only as a
482+consequence of further modification of the contributor version. For
483+purposes of this definition, "control" includes the right to grant
484+patent sublicenses in a manner consistent with the requirements of
485+this License.
486+
487+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488+patent license under the contributor's essential patent claims, to
489+make, use, sell, offer for sale, import and otherwise run, modify and
490+propagate the contents of its contributor version.
491+
492+ In the following three paragraphs, a "patent license" is any express
493+agreement or commitment, however denominated, not to enforce a patent
494+(such as an express permission to practice a patent or covenant not to
495+sue for patent infringement). To "grant" such a patent license to a
496+party means to make such an agreement or commitment not to enforce a
497+patent against the party.
498+
499+ If you convey a covered work, knowingly relying on a patent license,
500+and the Corresponding Source of the work is not available for anyone
501+to copy, free of charge and under the terms of this License, through a
502+publicly available network server or other readily accessible means,
503+then you must either (1) cause the Corresponding Source to be so
504+available, or (2) arrange to deprive yourself of the benefit of the
505+patent license for this particular work, or (3) arrange, in a manner
506+consistent with the requirements of this License, to extend the patent
507+license to downstream recipients. "Knowingly relying" means you have
508+actual knowledge that, but for the patent license, your conveying the
509+covered work in a country, or your recipient's use of the covered work
510+in a country, would infringe one or more identifiable patents in that
511+country that you have reason to believe are valid.
512+
513+ If, pursuant to or in connection with a single transaction or
514+arrangement, you convey, or propagate by procuring conveyance of, a
515+covered work, and grant a patent license to some of the parties
516+receiving the covered work authorizing them to use, propagate, modify
517+or convey a specific copy of the covered work, then the patent license
518+you grant is automatically extended to all recipients of the covered
519+work and works based on it.
520+
521+ A patent license is "discriminatory" if it does not include within
522+the scope of its coverage, prohibits the exercise of, or is
523+conditioned on the non-exercise of one or more of the rights that are
524+specifically granted under this License. You may not convey a covered
525+work if you are a party to an arrangement with a third party that is
526+in the business of distributing software, under which you make payment
527+to the third party based on the extent of your activity of conveying
528+the work, and under which the third party grants, to any of the
529+parties who would receive the covered work from you, a discriminatory
530+patent license (a) in connection with copies of the covered work
531+conveyed by you (or copies made from those copies), or (b) primarily
532+for and in connection with specific products or compilations that
533+contain the covered work, unless you entered into that arrangement,
534+or that patent license was granted, prior to 28 March 2007.
535+
536+ Nothing in this License shall be construed as excluding or limiting
537+any implied license or other defenses to infringement that may
538+otherwise be available to you under applicable patent law.
539+
540+ 12. No Surrender of Others' Freedom.
541+
542+ If conditions are imposed on you (whether by court order, agreement or
543+otherwise) that contradict the conditions of this License, they do not
544+excuse you from the conditions of this License. If you cannot convey a
545+covered work so as to satisfy simultaneously your obligations under this
546+License and any other pertinent obligations, then as a consequence you may
547+not convey it at all. For example, if you agree to terms that obligate you
548+to collect a royalty for further conveying from those to whom you convey
549+the Program, the only way you could satisfy both those terms and this
550+License would be to refrain entirely from conveying the Program.
551+
552+ 13. Use with the GNU Affero General Public License.
553+
554+ Notwithstanding any other provision of this License, you have
555+permission to link or combine any covered work with a work licensed
556+under version 3 of the GNU Affero General Public License into a single
557+combined work, and to convey the resulting work. The terms of this
558+License will continue to apply to the part which is the covered work,
559+but the special requirements of the GNU Affero General Public License,
560+section 13, concerning interaction through a network will apply to the
561+combination as such.
562+
563+ 14. Revised Versions of this License.
564+
565+ The Free Software Foundation may publish revised and/or new versions of
566+the GNU General Public License from time to time. Such new versions will
567+be similar in spirit to the present version, but may differ in detail to
568+address new problems or concerns.
569+
570+ Each version is given a distinguishing version number. If the
571+Program specifies that a certain numbered version of the GNU General
572+Public License "or any later version" applies to it, you have the
573+option of following the terms and conditions either of that numbered
574+version or of any later version published by the Free Software
575+Foundation. If the Program does not specify a version number of the
576+GNU General Public License, you may choose any version ever published
577+by the Free Software Foundation.
578+
579+ If the Program specifies that a proxy can decide which future
580+versions of the GNU General Public License can be used, that proxy's
581+public statement of acceptance of a version permanently authorizes you
582+to choose that version for the Program.
583+
584+ Later license versions may give you additional or different
585+permissions. However, no additional obligations are imposed on any
586+author or copyright holder as a result of your choosing to follow a
587+later version.
588+
589+ 15. Disclaimer of Warranty.
590+
591+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599+
600+ 16. Limitation of Liability.
601+
602+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610+SUCH DAMAGES.
611+
612+ 17. Interpretation of Sections 15 and 16.
613+
614+ If the disclaimer of warranty and limitation of liability provided
615+above cannot be given local legal effect according to their terms,
616+reviewing courts shall apply local law that most closely approximates
617+an absolute waiver of all civil liability in connection with the
618+Program, unless a warranty or assumption of liability accompanies a
619+copy of the Program in return for a fee.
620+
621+ END OF TERMS AND CONDITIONS
622+
623+ How to Apply These Terms to Your New Programs
624+
625+ If you develop a new program, and you want it to be of the greatest
626+possible use to the public, the best way to achieve this is to make it
627+free software which everyone can redistribute and change under these terms.
628+
629+ To do so, attach the following notices to the program. It is safest
630+to attach them to the start of each source file to most effectively
631+state the exclusion of warranty; and each file should have at least
632+the "copyright" line and a pointer to where the full notice is found.
633+
634+ <one line to give the program's name and a brief idea of what it does.>
635+ Copyright (C) <year> <name of author>
636+
637+ This program is free software: you can redistribute it and/or modify
638+ it under the terms of the GNU General Public License as published by
639+ the Free Software Foundation, either version 3 of the License, or
640+ (at your option) any later version.
641+
642+ This program is distributed in the hope that it will be useful,
643+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645+ GNU General Public License for more details.
646+
647+ You should have received a copy of the GNU General Public License
648+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649+
650+Also add information on how to contact you by electronic and paper mail.
651+
652+ If the program does terminal interaction, make it output a short
653+notice like this when it starts in an interactive mode:
654+
655+ <program> Copyright (C) <year> <name of author>
656+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657+ This is free software, and you are welcome to redistribute it
658+ under certain conditions; type `show c' for details.
659+
660+The hypothetical commands `show w' and `show c' should show the appropriate
661+parts of the General Public License. Of course, your program's commands
662+might be different; for a GUI interface, you would use an "about box".
663+
664+ You should also get your employer (if you work as a programmer) or school,
665+if any, to sign a "copyright disclaimer" for the program, if necessary.
666+For more information on this, and how to apply and follow the GNU GPL, see
667+<http://www.gnu.org/licenses/>.
668+
669+ The GNU General Public License does not permit incorporating your program
670+into proprietary programs. If your program is a subroutine library, you
671+may consider it more useful to permit linking proprietary applications with
672+the library. If this is what you want to do, use the GNU Lesser General
673+Public License instead of this License. But first, please read
674+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff -r 000000000000 -r 61f256435311 INSTALL
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/INSTALL Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,365 @@
1+Installation Instructions
2+*************************
3+
4+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
5+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6+
7+ Copying and distribution of this file, with or without modification,
8+are permitted in any medium without royalty provided the copyright
9+notice and this notice are preserved. This file is offered as-is,
10+without warranty of any kind.
11+
12+Basic Installation
13+==================
14+
15+ Briefly, the shell commands `./configure; make; make install' should
16+configure, build, and install this package. The following
17+more-detailed instructions are generic; see the `README' file for
18+instructions specific to this package. Some packages provide this
19+`INSTALL' file but do not implement all of the features documented
20+below. The lack of an optional feature in a given package is not
21+necessarily a bug. More recommendations for GNU packages can be found
22+in *note Makefile Conventions: (standards)Makefile Conventions.
23+
24+ The `configure' shell script attempts to guess correct values for
25+various system-dependent variables used during compilation. It uses
26+those values to create a `Makefile' in each directory of the package.
27+It may also create one or more `.h' files containing system-dependent
28+definitions. Finally, it creates a shell script `config.status' that
29+you can run in the future to recreate the current configuration, and a
30+file `config.log' containing compiler output (useful mainly for
31+debugging `configure').
32+
33+ It can also use an optional file (typically called `config.cache'
34+and enabled with `--cache-file=config.cache' or simply `-C') that saves
35+the results of its tests to speed up reconfiguring. Caching is
36+disabled by default to prevent problems with accidental use of stale
37+cache files.
38+
39+ If you need to do unusual things to compile the package, please try
40+to figure out how `configure' could check whether to do them, and mail
41+diffs or instructions to the address given in the `README' so they can
42+be considered for the next release. If you are using the cache, and at
43+some point `config.cache' contains results you don't want to keep, you
44+may remove or edit it.
45+
46+ The file `configure.ac' (or `configure.in') is used to create
47+`configure' by a program called `autoconf'. You need `configure.ac' if
48+you want to change it or regenerate `configure' using a newer version
49+of `autoconf'.
50+
51+ The simplest way to compile this package is:
52+
53+ 1. `cd' to the directory containing the package's source code and type
54+ `./configure' to configure the package for your system.
55+
56+ Running `configure' might take a while. While running, it prints
57+ some messages telling which features it is checking for.
58+
59+ 2. Type `make' to compile the package.
60+
61+ 3. Optionally, type `make check' to run any self-tests that come with
62+ the package, generally using the just-built uninstalled binaries.
63+
64+ 4. Type `make install' to install the programs and any data files and
65+ documentation. When installing into a prefix owned by root, it is
66+ recommended that the package be configured and built as a regular
67+ user, and only the `make install' phase executed with root
68+ privileges.
69+
70+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
71+ this time using the binaries in their final installed location.
72+ This target does not install anything. Running this target as a
73+ regular user, particularly if the prior `make install' required
74+ root privileges, verifies that the installation completed
75+ correctly.
76+
77+ 6. You can remove the program binaries and object files from the
78+ source code directory by typing `make clean'. To also remove the
79+ files that `configure' created (so you can compile the package for
80+ a different kind of computer), type `make distclean'. There is
81+ also a `make maintainer-clean' target, but that is intended mainly
82+ for the package's developers. If you use it, you may have to get
83+ all sorts of other programs in order to regenerate files that came
84+ with the distribution.
85+
86+ 7. Often, you can also type `make uninstall' to remove the installed
87+ files again. In practice, not all packages have tested that
88+ uninstallation works correctly, even though it is required by the
89+ GNU Coding Standards.
90+
91+ 8. Some packages, particularly those that use Automake, provide `make
92+ distcheck', which can by used by developers to test that all other
93+ targets like `make install' and `make uninstall' work correctly.
94+ This target is generally not run by end users.
95+
96+Compilers and Options
97+=====================
98+
99+ Some systems require unusual options for compilation or linking that
100+the `configure' script does not know about. Run `./configure --help'
101+for details on some of the pertinent environment variables.
102+
103+ You can give `configure' initial values for configuration parameters
104+by setting variables in the command line or in the environment. Here
105+is an example:
106+
107+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
108+
109+ *Note Defining Variables::, for more details.
110+
111+Compiling For Multiple Architectures
112+====================================
113+
114+ You can compile the package for more than one kind of computer at the
115+same time, by placing the object files for each architecture in their
116+own directory. To do this, you can use GNU `make'. `cd' to the
117+directory where you want the object files and executables to go and run
118+the `configure' script. `configure' automatically checks for the
119+source code in the directory that `configure' is in and in `..'. This
120+is known as a "VPATH" build.
121+
122+ With a non-GNU `make', it is safer to compile the package for one
123+architecture at a time in the source code directory. After you have
124+installed the package for one architecture, use `make distclean' before
125+reconfiguring for another architecture.
126+
127+ On MacOS X 10.5 and later systems, you can create libraries and
128+executables that work on multiple system types--known as "fat" or
129+"universal" binaries--by specifying multiple `-arch' options to the
130+compiler but only a single `-arch' option to the preprocessor. Like
131+this:
132+
133+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
134+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
135+ CPP="gcc -E" CXXCPP="g++ -E"
136+
137+ This is not guaranteed to produce working output in all cases, you
138+may have to build one architecture at a time and combine the results
139+using the `lipo' tool if you have problems.
140+
141+Installation Names
142+==================
143+
144+ By default, `make install' installs the package's commands under
145+`/usr/local/bin', include files under `/usr/local/include', etc. You
146+can specify an installation prefix other than `/usr/local' by giving
147+`configure' the option `--prefix=PREFIX', where PREFIX must be an
148+absolute file name.
149+
150+ You can specify separate installation prefixes for
151+architecture-specific files and architecture-independent files. If you
152+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
153+PREFIX as the prefix for installing programs and libraries.
154+Documentation and other data files still use the regular prefix.
155+
156+ In addition, if you use an unusual directory layout you can give
157+options like `--bindir=DIR' to specify different values for particular
158+kinds of files. Run `configure --help' for a list of the directories
159+you can set and what kinds of files go in them. In general, the
160+default for these options is expressed in terms of `${prefix}', so that
161+specifying just `--prefix' will affect all of the other directory
162+specifications that were not explicitly provided.
163+
164+ The most portable way to affect installation locations is to pass the
165+correct locations to `configure'; however, many packages provide one or
166+both of the following shortcuts of passing variable assignments to the
167+`make install' command line to change installation locations without
168+having to reconfigure or recompile.
169+
170+ The first method involves providing an override variable for each
171+affected directory. For example, `make install
172+prefix=/alternate/directory' will choose an alternate location for all
173+directory configuration variables that were expressed in terms of
174+`${prefix}'. Any directories that were specified during `configure',
175+but not in terms of `${prefix}', must each be overridden at install
176+time for the entire installation to be relocated. The approach of
177+makefile variable overrides for each directory variable is required by
178+the GNU Coding Standards, and ideally causes no recompilation.
179+However, some platforms have known limitations with the semantics of
180+shared libraries that end up requiring recompilation when using this
181+method, particularly noticeable in packages that use GNU Libtool.
182+
183+ The second method involves providing the `DESTDIR' variable. For
184+example, `make install DESTDIR=/alternate/directory' will prepend
185+`/alternate/directory' before all installation names. The approach of
186+`DESTDIR' overrides is not required by the GNU Coding Standards, and
187+does not work on platforms that have drive letters. On the other hand,
188+it does better at avoiding recompilation issues, and works well even
189+when some directory options were not specified in terms of `${prefix}'
190+at `configure' time.
191+
192+Optional Features
193+=================
194+
195+ If the package supports it, you can cause programs to be installed
196+with an extra prefix or suffix on their names by giving `configure' the
197+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
198+
199+ Some packages pay attention to `--enable-FEATURE' options to
200+`configure', where FEATURE indicates an optional part of the package.
201+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
202+is something like `gnu-as' or `x' (for the X Window System). The
203+`README' should mention any `--enable-' and `--with-' options that the
204+package recognizes.
205+
206+ For packages that use the X Window System, `configure' can usually
207+find the X include and library files automatically, but if it doesn't,
208+you can use the `configure' options `--x-includes=DIR' and
209+`--x-libraries=DIR' to specify their locations.
210+
211+ Some packages offer the ability to configure how verbose the
212+execution of `make' will be. For these packages, running `./configure
213+--enable-silent-rules' sets the default to minimal output, which can be
214+overridden with `make V=1'; while running `./configure
215+--disable-silent-rules' sets the default to verbose, which can be
216+overridden with `make V=0'.
217+
218+Particular systems
219+==================
220+
221+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
222+CC is not installed, it is recommended to use the following options in
223+order to use an ANSI C compiler:
224+
225+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
226+
227+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
228+
229+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
230+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
231+a workaround. If GNU CC is not installed, it is therefore recommended
232+to try
233+
234+ ./configure CC="cc"
235+
236+and if that doesn't work, try
237+
238+ ./configure CC="cc -nodtk"
239+
240+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
241+directory contains several dysfunctional programs; working variants of
242+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
243+in your `PATH', put it _after_ `/usr/bin'.
244+
245+ On Haiku, software installed for all users goes in `/boot/common',
246+not `/usr/local'. It is recommended to use the following options:
247+
248+ ./configure --prefix=/boot/common
249+
250+Specifying the System Type
251+==========================
252+
253+ There may be some features `configure' cannot figure out
254+automatically, but needs to determine by the type of machine the package
255+will run on. Usually, assuming the package is built to be run on the
256+_same_ architectures, `configure' can figure that out, but if it prints
257+a message saying it cannot guess the machine type, give it the
258+`--build=TYPE' option. TYPE can either be a short name for the system
259+type, such as `sun4', or a canonical name which has the form:
260+
261+ CPU-COMPANY-SYSTEM
262+
263+where SYSTEM can have one of these forms:
264+
265+ OS
266+ KERNEL-OS
267+
268+ See the file `config.sub' for the possible values of each field. If
269+`config.sub' isn't included in this package, then this package doesn't
270+need to know the machine type.
271+
272+ If you are _building_ compiler tools for cross-compiling, you should
273+use the option `--target=TYPE' to select the type of system they will
274+produce code for.
275+
276+ If you want to _use_ a cross compiler, that generates code for a
277+platform different from the build platform, you should specify the
278+"host" platform (i.e., that on which the generated programs will
279+eventually be run) with `--host=TYPE'.
280+
281+Sharing Defaults
282+================
283+
284+ If you want to set default values for `configure' scripts to share,
285+you can create a site shell script called `config.site' that gives
286+default values for variables like `CC', `cache_file', and `prefix'.
287+`configure' looks for `PREFIX/share/config.site' if it exists, then
288+`PREFIX/etc/config.site' if it exists. Or, you can set the
289+`CONFIG_SITE' environment variable to the location of the site script.
290+A warning: not all `configure' scripts look for a site script.
291+
292+Defining Variables
293+==================
294+
295+ Variables not defined in a site shell script can be set in the
296+environment passed to `configure'. However, some packages may run
297+configure again during the build, and the customized values of these
298+variables may be lost. In order to avoid this problem, you should set
299+them in the `configure' command line, using `VAR=value'. For example:
300+
301+ ./configure CC=/usr/local2/bin/gcc
302+
303+causes the specified `gcc' to be used as the C compiler (unless it is
304+overridden in the site shell script).
305+
306+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
307+an Autoconf bug. Until the bug is fixed you can use this workaround:
308+
309+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
310+
311+`configure' Invocation
312+======================
313+
314+ `configure' recognizes the following options to control how it
315+operates.
316+
317+`--help'
318+`-h'
319+ Print a summary of all of the options to `configure', and exit.
320+
321+`--help=short'
322+`--help=recursive'
323+ Print a summary of the options unique to this package's
324+ `configure', and exit. The `short' variant lists options used
325+ only in the top level, while the `recursive' variant lists options
326+ also present in any nested packages.
327+
328+`--version'
329+`-V'
330+ Print the version of Autoconf used to generate the `configure'
331+ script, and exit.
332+
333+`--cache-file=FILE'
334+ Enable the cache: use and save the results of the tests in FILE,
335+ traditionally `config.cache'. FILE defaults to `/dev/null' to
336+ disable caching.
337+
338+`--config-cache'
339+`-C'
340+ Alias for `--cache-file=config.cache'.
341+
342+`--quiet'
343+`--silent'
344+`-q'
345+ Do not print messages saying which checks are being made. To
346+ suppress all normal output, redirect it to `/dev/null' (any error
347+ messages will still be shown).
348+
349+`--srcdir=DIR'
350+ Look for the package's source code in directory DIR. Usually
351+ `configure' can determine that directory automatically.
352+
353+`--prefix=DIR'
354+ Use DIR as the installation prefix. *note Installation Names::
355+ for more details, including other options available for fine-tuning
356+ the installation locations.
357+
358+`--no-create'
359+`-n'
360+ Run the configure checks, but stop before creating any output
361+ files.
362+
363+`configure' also accepts some other, not widely useful, options. Run
364+`configure --help' for more details.
365+
diff -r 000000000000 -r 61f256435311 Makefile.am
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.am Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,38 @@
1+MAINTAINERCLEANFILES = Makefile.in
2+vmctldir = @HA_NOARCHDATAHBDIR@/vm-ctl
3+vmctl_SCRIPTS = vm-ctl
4+vmctl_CONFIG = vm-ctl.conf
5+vmctllinkdir = /usr/sbin
6+
7+vmctlcfgdir = @CONFIG_DIR@
8+SHAREDIR = $(vmctldir)
9+SPEC = $(PACKAGE_NAME).spec
10+TARFILE = $(PACKAGE_NAME)-$(VERSION).tar.gz
11+EXTRA_DIST = $(vmctl_SCRIPTS) $(vmctl_CONFIG) $(SPEC)
12+
13+install-data-hook:
14+ @$(NORMAL_INSTALL)
15+ test -z "$(vmctlcfgdir)" || $(mkdir_p) "$(DESTDIR)$(vmctlcfgdir)"
16+ $(INSTALL_DATA) "$(vmctl_CONFIG)" "$(DESTDIR)$(vmctlcfgdir)"
17+ test -z "$(vmctllinkdir)" || $(mkdir_p) "$(DESTDIR)$(vmctllinkdir)"
18+ ln -sf $(vmctldir)/$(vmctl_SCRIPTS) $(vmctllinkdir)
19+
20+uninstall-local:
21+ rm -rf $(vmctllinkdir)/vm-ctl
22+
23+$(TARFILE):
24+ $(MAKE) dist
25+
26+RPM_ROOT = $(shell pwd)
27+RPMBUILDOPTS = --define "_sourcedir $(RPM_ROOT)" \
28+ --define "_specdir $(RPM_ROOT)"
29+
30+srpm: clean
31+ rm -f $(TARFILE)
32+ $(MAKE) $(SPEC) $(TARFILE)
33+ rpmbuild $(RPMBUILDOPTS) $(DEFINE) --nodeps -bs --rmsource $(SPEC)
34+
35+rpm: clean
36+ rm -f $(TARFILE)
37+ $(MAKE) $(SPEC) $(TARFILE)
38+ rpmbuild $(RPMBUILDOPTS) $(DEFINE) -ba --rmsource $(SPEC)
diff -r 000000000000 -r 61f256435311 README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,9 @@
1+ * RHEL5の環境でRPMをビルドする場合は、以下のマクロファイルを作成してください。
2+
3+[root@x3650a ~]# cat /etc/rpm/macros.dist
4+# dist macros.
5+
6+%rhel 5
7+%dist .el5
8+%el5 1
9+[root@x3650a ~]#
diff -r 000000000000 -r 61f256435311 autogen.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/autogen.sh Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,5 @@
1+#!/bin/sh
2+# Run this to generate all the initial makefiles, etc.
3+
4+echo Building configuration system...
5+autoreconf -i && echo Now run ./configure and make
diff -r 000000000000 -r 61f256435311 configure.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configure.in Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,48 @@
1+AC_PREREQ(2.59)
2+AC_INIT(vm-ctl, 1.0)
3+AM_INIT_AUTOMAKE(vm-ctl, 1.0)
4+AC_PREFIX_DEFAULT(/usr)
5+PM_PKG="pacemaker"
6+AM_MAINTAINER_MODE
7+
8+dnl Checks for Pacemaker crm-shell.
9+AC_PATH_PROGS(PCMK_CRM, crm)
10+if test "X${PCMK_CRM}" = "X"; then
11+ AC_MSG_ERROR(Unable to Pacemaker.)
12+fi
13+
14+prefix_orig="$prefix"
15+prefix=`eval echo "$prefix"`
16+case $prefix in
17+ NONE) prefix=/usr;;
18+esac
19+var(){
20+ case $1 in
21+ *'${'*) res=`eval echo "$1"`;;
22+ *) res="$1";;
23+ esac
24+ case "$res" in
25+ ""|NONE) echo "$2";;
26+ *) echo "$res";;
27+ esac
28+}
29+dnl>
30+dnl> Keep copy of original (default) localstatedir
31+dnl>
32+localstatedir_orig="$localstatedir"
33+
34+exec_prefix=`var "$exec_prefix" "$prefix"`
35+datadir=`var "$datadir" "$prefix/share"`
36+config_dir=`var "$config_dir" "/etc/"`
37+
38+CONFIG_DIR="$config_dir"
39+AC_SUBST(CONFIG_DIR)
40+HA_DATADIR="$datadir"
41+AC_SUBST(HA_DATADIR)
42+HA_NOARCHDATAHBDIR="$HA_DATADIR/$PM_PKG"
43+AC_SUBST(HA_NOARCHDATAHBDIR)
44+AC_PROG_LN_S
45+
46+AC_OUTPUT([
47+Makefile
48+])
diff -r 000000000000 -r 61f256435311 vm-ctl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vm-ctl Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,1663 @@
1+#!/bin/sh
2+# -*- coding: utf-8 -*-
3+
4+# vm-ctl : Pacemaker virtualdomain resource generator.
5+#
6+# Copyright (C) 2010 NIPPON TELEGRAPH AND TELEPHONE CORPORATION
7+#
8+# This program is free software; you can redistribute it and/or
9+# modify it under the terms of the GNU General Public
10+# License as published by the Free Software Foundation; either
11+# version 2.1 of the License, or (at your option) any later version.
12+#
13+# This software is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+# General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public
19+# License along with this library; if not, write to the Free Software
20+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
22+:<< '#_comment'
23+変数説明
24+大文字のみ : global(vm-ctl)
25+小文字のみ : global(vm-ctl.conf)
26+先頭にアンダースコア : local (fuction)
27+#_comment
28+
29+# global定数
30+COM_NM="VMCTL"
31+PRM_NM="prm${COM_NM}"
32+LOC_NM="loc${COM_NM}"
33+COL_NM="col${COM_NM}"
34+ODR_NM="odr${COM_NM}"
35+VMCFG_DIR="/etc"
36+BACKUP_CRMFILE="/var/run/.vm-ctl.crm.bk"
37+TMP_CRMFILE="/tmp/.vm-ctl.crm"
38+VMCTL_LOGFILE="/tmp/.vm-ctl.log"
39+PLUS_INFINITY="1000000"
40+MINUS_INFINITY="-1000000"
41+DEF_VALUE=""
42+DC_NODE=""
43+DEL_ID_LIST=""
44+
45+# output messages
46+VMCTL_MSG01="pacemakerが停止しています"
47+VMCTL_MSG02="設定ファイルが存在しません"
48+VMCTL_MSG03="ドメインが存在しません"
49+VMCTL_MSG04="一時ファイルが作成できないため、継続できません"
50+VMCTL_MSG05="予期せぬエラーが発生しました"
51+VMCTL_MSG06="仮想マシン定義ファイルディレクトリが設定されていません"
52+VMCTL_MSG07="ライブマイグレーションの設定に誤りがあります"
53+VMCTL_MSG08="STONITHの設定に誤りがあります"
54+VMCTL_MSG09="pingd制約の設定に誤りがあります"
55+VMCTL_MSG10="diskd制約の設定に誤りがあります"
56+VMCTL_MSG11="リソース追加済みのドメインが指定されています"
57+VMCTL_MSG12="stonith-enabledの設定がありません"
58+VMCTL_MSG13="リソースが起動中の為、削除できません"
59+VMCTL_MSG14="移動先のノードがOnlineではありません"
60+VMCTL_MSG15="リソースが存在しません"
61+VMCTL_MSG16="ノードが存在しません"
62+VMCTL_MSG17="vm-ctlは実行中です"
63+VMCTL_MSG18="リソースが起動していない為、移動を実行できません"
64+VMCTL_MSG19='${DOMAIN_LIST}は、指定のノードに移動できない状態になっています'
65+VMCTL_MSG20='${DOMAIN_LIST}は、移動可能なノードがありません'
66+VMCTL_MSG21="移動元と移動先のノードの指定が同じな為、移動は実行されません"
67+VMCTL_MSG22='vm-ctl.confの設定項目にミスがあるため、デフォルト値[${DEF_VALUE}]を使用します'
68+VMCTL_MSG23="vm-managerd制約の設定に誤りがあります"
69+VMCTL_MSG24="vm-stonithd制約の設定に誤りがあります"
70+VMCTL_MSG25="リソースがunmanaged状態です"
71+VMCTL_MSG26="リソースの移動が実行できませんでした"
72+VMCTL_MSG27="リソースの移動に失敗しました"
73+
74+:<<'#_comment'
75+関数名 : usage
76+引数 : なし
77+戻り値 : なし
78+説明 : usageを出力し、vm-ctlを終了する
79+#_comment
80+usage()
81+{
82+ echo "usage:"
83+ echo "vm-ctl resource add <domain_name>[,<domain_name>] -a <active_node> [-m on|off]"
84+ echo "vm-ctl resource delete <domain_name>[,<domain_name>]"
85+ echo "vm-ctl resource start <domain_name>[,<domain_name>]"
86+ echo "vm-ctl resource stop <domain_name>[,<domain_name>]"
87+ echo "vm-ctl resource move <domain_name> [-n <node_name>]"
88+ echo "vm-ctl resource unmove <domain_name>"
89+ echo "vm-ctl resource list [domain_name|-n node_name]"
90+ echo "vm-ctl location move <domain_name>|-b <node_name>"
91+ exit 1
92+}
93+
94+:<<'#_comment'
95+関数名 : rm_file
96+引数 : ファイル名
97+戻り値 : なし
98+説明 : 指定ファイルを削除する
99+#_comment
100+rm_file()
101+{
102+ rm -rf ${1} >/dev/null 2>&1
103+}
104+
105+:<<'#_comment'
106+関数名 : chk_opt
107+引数 : なし
108+戻り値 : なし
109+説明 : オプションのパラメータが省略されていないか確認し、
110+ 省略されている場合、usageを出力し終了する。
111+#_comment
112+chk_opt()
113+{
114+ if [ "${OPTARG:0:1}" = "-" ] ; then
115+ usage
116+ fi
117+ if [ ! "${OPTARG}" ] ; then
118+ usage
119+ fi
120+}
121+
122+:<<'#_comment'
123+関数名 : chk_vm
124+引数 : なし
125+戻り値 : なし
126+説明 : 指定されたドメイン名が、ハイパーバイザー上に存在するか確認し、
127+ 存在しない場合、メッセージを出力し、vm-ctlを終了する
128+#_comment
129+chk_vm()
130+{
131+ local _domain_name
132+ local _cnt
133+ for _domain_name in ${DOMAIN_LIST}
134+ do
135+ _cnt=$(virsh list --all 2>/dev/null | grep -w ${_domain_name} 2>/dev/null | wc -l 2>/dev/null)
136+ if [ ${_cnt} -eq 0 ] ; then
137+ echo ${VMCTL_MSG03}
138+ exit 1
139+ fi
140+ done
141+}
142+
143+:<<'#_comment'
144+関数名 : chk_rsc
145+引数 : $1 判定方法(0:無 1:有)
146+ $2 出力メッセージ
147+戻り値 : なし
148+説明 : 指定されたドメイン名が、リソース登録されているか確認し、
149+ $1の判定方法に一致しなかった場合、メッセージを出力し、vm-ctlを終了する
150+#_comment
151+chk_rsc()
152+{
153+ local _domain_name
154+ local _cnt
155+ for _domain_name in ${DOMAIN_LIST}
156+ do
157+ _cnt=$(grep "primitive ${PRM_NM}_${_domain_name}" ${BACKUP_CRMFILE} 2>/dev/null | wc -l 2>/dev/null)
158+ if [ ${_cnt} -ne ${1} ] ; then
159+ echo ${2}
160+ exit 1
161+ fi
162+ done
163+}
164+
165+:<<'#_comment'
166+関数名 : chk_domain_list
167+引数 : なし
168+戻り値 : なし
169+説明 : ドメインリストの指定が無い場合、usageを出力し、vm-ctlを終了する
170+#_comment
171+chk_domain_list()
172+{
173+ if [ ! ${DOMAIN_LIST//,/} ] ; then
174+ usage
175+ fi
176+}
177+
178+:<<'#_comment'
179+関数名 : chk_domain
180+引数 : なし
181+戻り値 : なし
182+説明 : ドメインの指定が不正な場合、usageを出力し、vm-ctlを終了する
183+#_comment
184+chk_domain()
185+{
186+ local _tmp=${DOMAIN_LIST//,/}
187+ if [ ${#_tmp} -ne ${#DOMAIN_LIST} -o ! "${DOMAIN_LIST}" ] ; then
188+ usage
189+ fi
190+}
191+
192+:<<'#_comment'
193+関数名 : chk_onoff
194+引数 : $1 判定文字列
195+ $2 配列番号
196+ $3 出力メッセージ
197+戻り値 : なし
198+説明 : on/off判定を行い、RET_VALUE(global)に値を設定する
199+#_comment
200+chk_onoff()
201+{
202+ local _onvalue=(true fence)
203+ local _offvalue=(false block)
204+ RET_VALUE=""
205+ if [ "${1}" = "on" ] ; then
206+ RET_VALUE=${_onvalue[${2}]}
207+ elif [ "${1}" = "off" ] ; then
208+ RET_VALUE=${_offvalue[${2}]}
209+ else
210+ echo ${3}
211+ exit 1
212+ fi
213+}
214+
215+:<<'#_comment'
216+関数名 : chk_stonith
217+引数 : なし
218+戻り値 : なし
219+説明 : リソース情報にstonith-enabledの設定があるかどうか確認し、
220+ 設定が無い場合、ログを出力し、終了する
221+#_comment
222+chk_stonith()
223+{
224+ local _cnt
225+ _cnt=$(grep "stonith-enabled=" ${BACKUP_CRMFILE} 2>/dev/null | wc -l 2>/dev/null)
226+ if [ ${_cnt} -eq 0 ] ; then
227+ echo ${VMCTL_MSG12}
228+ exit 1
229+ fi
230+}
231+
232+:<<'#_comment'
233+関数名 : chk_crm_error
234+引数 : $1 コマンドの戻り値
235+戻り値 : なし
236+説明 : crmコマンドがエラーかどうか判定し、エラーの場合、vm-ctlを終了する。
237+#_comment
238+chk_crm_error()
239+{
240+ local _cnt
241+ _cnt=$(egrep 'ERROR|error' ${VMCTL_LOGFILE} 2>/dev/null | wc -l 2>/dev/null)
242+ if [ ${_cnt} -ne 0 -o ${1} -ne 0 ] ; then
243+ echo ${VMCTL_MSG05}
244+ cat ${VMCTL_LOGFILE}
245+ exit 1
246+ fi
247+}
248+
249+:<<'#_comment'
250+関数名 : chk_cluster
251+引数 : なし
252+戻り値 : なし
253+説明 : pacemaker起動チェック
254+ crmコマンド実行前に必ず呼び出し、起動中以外であれば
255+ メッセージを出力し、vm-ctlを終了する
256+#_comment
257+chk_cluster()
258+{
259+ local _ret
260+ local _tmp
261+ DC_NODE=""
262+ _tmp=$(crmadmin -D -t ${crmadmin_timeout} 2>&1)
263+ _ret=${?}
264+ if [ ${_ret} -eq 254 ] ; then
265+ echo ${VMCTL_MSG01}
266+ exit 1
267+ fi
268+ if [ ${_ret} -ne 0 ] ; then
269+ echo ${VMCTL_MSG05}
270+ exit 1
271+ fi
272+ DC_NODE=$(echo ${_tmp} 2>&1 | awk '{print $4}' 2>&1)
273+ while true
274+ do
275+ _tmp=$(crmadmin -S ${DC_NODE} -t ${crmadmin_timeout} 2>&1)
276+ _ret=${?}
277+ if [ ${_ret} -ne 0 ] ; then
278+ echo ${VMCTL_MSG05}
279+ exit 1
280+ fi
281+ echo ${_tmp} | grep "S_IDLE" -qs
282+ _ret=${?}
283+ if [ ${_ret} -eq 0 ] ; then
284+ break
285+ fi
286+ sleep 1
287+ done
288+}
289+
290+:<<'#_comment'
291+関数名 : chk_base_config
292+引数 : なし
293+戻り値 : なし
294+説明 : vm-ctl.conf基本設定内容チェック
295+ vm-ctl.confの基本設定内容(ユーザ任意)をチェックし
296+ 不正であれば、メッセージを出力し、vm-ctlを終了する
297+#_comment
298+chk_base_config()
299+{
300+ local _idx
301+ local _val1
302+ local _val
303+ # dumpxml設定チェック
304+ if [ ! ${vm_cfg_dir} ] ; then
305+ echo ${VMCTL_MSG06}
306+ exit 1
307+ fi
308+
309+ # migrate設定チェック(コマンドオプション指定なしの場合)
310+ if [ ! "${MIGRATE}" ] ; then
311+ MIGRATE=${vm_allow_migrate}
312+ fi
313+ chk_onoff "${MIGRATE}" 0 ${VMCTL_MSG07}
314+ MIGRATE=${RET_VALUE}
315+
316+ # stonith設定チェック
317+ chk_onoff "${vm_stonith}" 1 ${VMCTL_MSG08}
318+ STONITH=${RET_VALUE}
319+
320+ # 無限ループにならないように、上限10個
321+ _idx=1
322+ while [ ${_idx} -le 10 ]
323+ do
324+ _val1="_val1=\${vm_pingd${_idx}[@]}"
325+ eval $_val1
326+ _val=($_val1)
327+ _val1="${_val[@]}"
328+ if [ ! "${_val1}" ] ; then
329+ break
330+ fi
331+ # パラメータ数チェック
332+ if [ ${#_val[@]} -ne 1 -a ${#_val[@]} -ne 2 ] ; then
333+ echo ${VMCTL_MSG09}
334+ exit 1
335+ fi
336+ _idx=$(expr ${_idx} + 1)
337+ done
338+
339+ # 無限ループにならないように、上限10個
340+ _idx=1
341+ while [ ${_idx} -le 10 ]
342+ do
343+ _val1="_val1=\${vm_diskd${_idx}[@]}"
344+ eval $_val1
345+ _val=($_val1)
346+ _val1="${_val[@]}"
347+ if [ ! "${_val1}" ] ; then
348+ break
349+ fi
350+ # パラメータ数チェック
351+ if [ ${#_val[@]} -ne 1 -a ${#_val[@]} -ne 2 ] ; then
352+ echo ${VMCTL_MSG10}
353+ exit 1
354+ fi
355+ _idx=$(expr ${_idx} + 1)
356+ done
357+
358+ # 無限ループにならないように、上限10個
359+ _idx=1
360+ while [ ${_idx} -le 10 ]
361+ do
362+ _val1="_val1=\${vm_managerd${_idx}[@]}"
363+ eval $_val1
364+ _val=($_val1)
365+ _val1="${_val[@]}"
366+ if [ ! "${_val1}" ] ; then
367+ break
368+ fi
369+ # パラメータ数チェック
370+ if [ ${#_val[@]} -ne 1 -a ${#_val[@]} -ne 2 ] ; then
371+ echo ${VMCTL_MSG23}
372+ exit 1
373+ fi
374+ _idx=$(expr ${_idx} + 1)
375+ done
376+
377+ # 無限ループにならないように、上限10個
378+ _idx=1
379+ while [ ${_idx} -le 10 ]
380+ do
381+ _val1="_val1=\${vm_stonithd${_idx}[@]}"
382+ eval $_val1
383+ _val=($_val1)
384+ _val1="${_val[@]}"
385+ if [ ! "${_val1}" ] ; then
386+ break
387+ fi
388+ # パラメータ数チェック
389+ if [ ${#_val[@]} -ne 1 ] ; then
390+ echo ${VMCTL_MSG24}
391+ exit 1
392+ fi
393+ _idx=$(expr ${_idx} + 1)
394+ done
395+}
396+
397+:<<'#_comment'
398+関数名 : chk_rsc_config
399+引数 : なし
400+戻り値 : なし
401+説明 : vm-ctl.confのリソースオペレーションを確認する
402+ 指定がないなどあれば、強制的に初期内容に設定する
403+#_comment
404+chk_rsc_config()
405+{
406+ if [ ! "${vm_hypervisor}" ] ; then
407+ DEF_VALUE="vm_hypervisor=qemu:///system"
408+ eval echo "${VMCTL_MSG22}"
409+ eval ${DEF_VALUE}
410+ fi
411+ if [ ! "${vm_migration_transport}" ] ; then
412+ DEF_VALUE="vm_migration_transport=ssh"
413+ eval echo "${VMCTL_MSG22}"
414+ eval ${DEF_VALUE}
415+ fi
416+
417+ if [ ! "${vm_start_op}" -o ${#vm_start_op[@]} -ne 3 ] ; then
418+ DEF_VALUE="vm_start_op=(0 120s restart)"
419+ eval echo "${VMCTL_MSG22}"
420+ eval ${DEF_VALUE}
421+ fi
422+ if [ ! "${vm_stop_op}" -o ${#vm_stop_op[@]} -ne 2 ] ; then
423+ DEF_VALUE="vm_stop_op=(0 90s)"
424+ eval echo "${VMCTL_MSG22}"
425+ eval ${DEF_VALUE}
426+ fi
427+ if [ ! "${vm_monitor_op}" -o ${#vm_monitor_op[@]} -ne 3 ] ; then
428+ DEF_VALUE="vm_monitor_op=(10s 30s restart)"
429+ eval echo "${VMCTL_MSG22}"
430+ eval ${DEF_VALUE}
431+ fi
432+ if [ ! "${vm_migrate_to_op}" -o ${#vm_migrate_to_op[@]} -ne 2 ] ; then
433+ DEF_VALUE="vm_migrate_to_op=(0 300s)"
434+ eval echo "${VMCTL_MSG22}"
435+ eval ${DEF_VALUE}
436+ fi
437+ if [ ! "${vm_migrate_from_op}" -o ${#vm_migrate_from_op[@]} -ne 3 ] ; then
438+ DEF_VALUE="vm_migrate_from_op=(0 240s restart)"
439+ eval echo "${VMCTL_MSG22}"
440+ eval ${DEF_VALUE}
441+ fi
442+
443+ if [ ! "${vm_node_loc_act}" ] ; then
444+ DEF_VALUE="vm_node_loc_act=200"
445+ eval echo "${VMCTL_MSG22}"
446+ eval ${DEF_VALUE}
447+ fi
448+ if [ ! "${vm_pingd_loc}" -o ${#vm_pingd_loc[@]} -ne 2 ] ; then
449+ DEF_VALUE="vm_pingd_loc=(lt 100)"
450+ eval echo "${VMCTL_MSG22}"
451+ eval ${DEF_VALUE}
452+ fi
453+ if [ ! "${vm_pingd_col}" ] ; then
454+ DEF_VALUE="vm_pingd_col=INFINITY"
455+ eval echo "${VMCTL_MSG22}"
456+ eval ${DEF_VALUE}
457+ fi
458+ if [ ! "${vm_pingd_odr}" -o ${#vm_pingd_odr[@]} -ne 2 ] ; then
459+ DEF_VALUE="vm_pingd_odr=(0 false)"
460+ eval echo "${VMCTL_MSG22}"
461+ eval ${DEF_VALUE}
462+ fi
463+ if [ ! "${vm_diskd_loc}" -o ${#vm_diskd_loc[@]} -ne 2 ] ; then
464+ DEF_VALUE="vm_diskd_loc=(eq ERROR)"
465+ eval echo "${VMCTL_MSG22}"
466+ eval ${DEF_VALUE}
467+ fi
468+ if [ ! "${vm_diskd_col}" ] ; then
469+ DEF_VALUE="vm_diskd_col=INFINITY"
470+ eval echo "${VMCTL_MSG22}"
471+ eval ${DEF_VALUE}
472+ fi
473+ if [ ! "${vm_diskd_odr}" -o ${#vm_diskd_odr[@]} -ne 2 ] ; then
474+ DEF_VALUE="vm_diskd_odr=(0 false)"
475+ eval echo "${VMCTL_MSG22}"
476+ eval ${DEF_VALUE}
477+ fi
478+ if [ ! "${vm_managerd_loc}" -o ${#vm_managerd_loc[@]} -ne 2 ] ; then
479+ DEF_VALUE="vm_managerd_loc=(eq ERROR)"
480+ eval echo "${VMCTL_MSG22}"
481+ eval ${DEF_VALUE}
482+ fi
483+ if [ ! "${vm_managerd_col}" ] ; then
484+ DEF_VALUE="vm_managerd_col=INFINITY"
485+ eval echo "${VMCTL_MSG22}"
486+ eval ${DEF_VALUE}
487+ fi
488+ if [ ! "${vm_managerd_odr}" -o ${#vm_managerd_odr[@]} -ne 2 ] ; then
489+ DEF_VALUE="vm_managerd_odr=(0 false)"
490+ eval echo "${VMCTL_MSG22}"
491+ eval ${DEF_VALUE}
492+ fi
493+ if [ ! "${vm_stonithd_col}" ] ; then
494+ DEF_VALUE="vm_stonithd_col=INFINITY"
495+ eval echo "${VMCTL_MSG22}"
496+ eval ${DEF_VALUE}
497+ fi
498+ if [ ! "${vm_stonithd_odr}" -o ${#vm_stonithd_odr[@]} -ne 2 ] ; then
499+ DEF_VALUE="vm_stonithd_odr=(0 false)"
500+ eval echo "${VMCTL_MSG22}"
501+ eval ${DEF_VALUE}
502+ fi
503+}
504+
505+:<<'#_comment'
506+関数名 : get_domain
507+引数 : なし
508+戻り値 : なし
509+説明 : primitive情報からドメインのリストを取得する
510+#_comment
511+get_domain()
512+{
513+ RET_VALUE=""
514+ RET_VALUE=$(grep "primitive ${PRM_NM}.*VirtualDomain" ${BACKUP_CRMFILE} 2>/dev/null \
515+ | awk '{print substr($2,length("'${PRM_NM}'_")+1)}' 2>/dev/null)
516+}
517+
518+:<<'#_comment'
519+関数名 : get_migrate
520+引数 : $1 リソース名
521+戻り値 : なし
522+説明 : primitive情報からマイグレーション設定を取得する
523+#_comment
524+get_migrate()
525+{
526+ local _line
527+ local _migrate
528+ RET_VALUE=""
529+ while read _line
530+ do
531+ _migrate=$(echo ${_line} 2>/dev/null \
532+ | grep "primitive ${1}" 2>/dev/null \
533+ | sed -e 's/.*allow-migrate=\"\(true\|false\)\" .*/\1/' 2>/dev/null)
534+ if [ "${_migrate}" ] ; then
535+ if [ "${_migrate}" = "true" ] ; then
536+ RET_VALUE="on"
537+ elif [ "${_migrate}" = "false" ] ; then
538+ RET_VALUE="off"
539+ fi
540+ break
541+ fi
542+ done < ${BACKUP_CRMFILE}
543+}
544+
545+:<<'#_comment'
546+関数名 : get_act_location
547+引数 : $1 ドメイン名
548+戻り値 : なし
549+説明 : location情報からリソースの優先ノードの情報を取得する
550+#_comment
551+get_act_location()
552+{
553+ local _line
554+ local _act
555+ RET_VALUE=""
556+ while read _line
557+ do
558+ _act=$(echo ${_line} 2>/dev/null \
559+ | grep "location ${LOC_NM}_${1}.*ACT" 2>/dev/null \
560+ | awk '{print $5}')
561+ if [ "${_act}" ] ; then
562+ RET_VALUE=${_act}
563+ break
564+ fi
565+ done < ${BACKUP_CRMFILE}
566+}
567+
568+:<<'#_comment'
569+関数名 : get_move_location
570+引数 : $1 リソース名
571+戻り値 : なし
572+説明 : location情報から移動制約の情報を取得する
573+#_comment
574+get_move_location()
575+{
576+ local _line
577+ RET_VALUE="no"
578+ while read _line
579+ do
580+ _migrate=$(echo ${_line} 2>/dev/null \
581+ | egrep "location cli-standby-${1}|location cli-prefer-${1}" 2>/dev/null)
582+ if [ ${?} -eq 0 ] ; then
583+ RET_VALUE="yes"
584+ fi
585+ done < ${BACKUP_CRMFILE}
586+}
587+
588+:<<'#_comment'
589+関数名 : cre_node_location
590+引数 : $1 ドメイン名
591+ $2 スコア値
592+ $3 ノード名
593+戻り値 : なし
594+説明 : crm形式で、node locationを作成する
595+
596+location locVMCTL_dom-a1_x3650c_ACT prmVMCTL_dom-a1 200: x3650c
597+#_comment
598+cre_node_location()
599+{
600+ echo "location ${LOC_NM}_${1}_${3}_ACT ${PRM_NM}_${1} ${2}: ${3}
601+" >> ${TMP_CRMFILE}
602+}
603+
604+:<<'#_comment'
605+関数名 : cre_pingd_location
606+引数 : $1 ドメイン名
607+ $2 属性名
608+戻り値 : なし
609+説明 : crm形式で、pingd用のlocationを作成する
610+
611+location locVMCTL_dom-a1_default_ping_set prmVMCTL_dom-a1 \
612+ rule $id="locVMCTL_dom-a1_default_ping_set-rule" -inf: not_defined default_ping_set or default_ping_set lt 100
613+#_comment
614+cre_pingd_location()
615+{
616+ echo "location ${LOC_NM}_${1}_${2} ${PRM_NM}_${1} rule -inf: not_defined ${2} or ${2} ${vm_pingd_loc[@]}
617+" >> ${TMP_CRMFILE}
618+}
619+
620+:<<'#_comment'
621+関数名 : cre_pingd_order
622+引数 : $1 ドメイン名
623+ $2 リソース名
624+戻り値 : なし
625+説明 : crm形式で、pingd用のorderを作成する
626+
627+order odrVMCTL_dom-a1_clnPingd 0: clnPingd prmVMCTL_dom-a1 symmetrical=false
628+#_comment
629+cre_pingd_order()
630+{
631+ echo "order ${ODR_NM}_${1}_${2} ${vm_pingd_odr[0]}: ${2} ${PRM_NM}_${1} symmetrical=${vm_pingd_odr[1]}
632+" >> ${TMP_CRMFILE}
633+}
634+
635+:<<'#_comment'
636+関数名 : cre_pingd_colocation
637+引数 : $1 ドメイン名
638+ $2 リソース名
639+戻り値 : なし
640+説明 : crm形式で、pingd用のcolocationを作成する
641+
642+colocation colVMCTL_dom-a1_clnPingd inf: prmVMCTL_dom-a1 clnPingd
643+#_comment
644+cre_pingd_colocation()
645+{
646+ echo "colocation ${COL_NM}_${1}_${2} ${vm_pingd_col}: ${PRM_NM}_${1} ${2}" >> ${TMP_CRMFILE}
647+}
648+
649+:<<'#_comment'
650+関数名 : cre_pingd
651+引数 : $1 ドメイン名
652+戻り値 : なし
653+説明 : crm形式で、pingd用のlocation/colocation/orderを作成する
654+#_comment
655+cre_pingd()
656+{
657+ local _val
658+ local _val1
659+ local _idx=1
660+ while [ ${_idx} -le 10 ]
661+ do
662+ _val1="_val1=\${vm_pingd${_idx}[@]}"
663+ eval ${_val1}
664+ _val=(${_val1})
665+ _val1="${_val[@]}"
666+ if [ ! "${_val1}" ] ; then
667+ break
668+ fi
669+ if [ -n "${_val[1]}" ] ; then
670+ cre_pingd_location ${1} ${_val[1]}
671+ fi
672+ cre_pingd_colocation ${1} ${_val[0]}
673+ cre_pingd_order ${1} ${_val[0]}
674+ _idx=$(expr ${_idx} + 1)
675+ done
676+}
677+
678+:<<'#_comment'
679+関数名 : cre_diskd_location
680+引数 : $1 ドメイン名
681+ $2 属性名
682+戻り値 : なし
683+説明 : crm形式で、diskd用のlocationを作成する
684+
685+location locVMCTL_dom-a1_diskcheck_status prmVMCTL_dom-a1 \
686+ rule $id="locVMCTL_dom-a1_diskcheck_status-rule" -inf: not_defined diskcheck_status or diskcheck_status eq ERROR
687+#_comment
688+cre_diskd_location()
689+{
690+ echo "location ${LOC_NM}_${1}_${2} ${PRM_NM}_${1} rule -inf: not_defined ${2} or ${2} ${vm_diskd_loc[@]}
691+" >> ${TMP_CRMFILE}
692+}
693+
694+:<<'#_comment'
695+関数名 : cre_diskd_order
696+引数 : $1 ドメイン名
697+ $2 リソース名
698+戻り値 : なし
699+説明 : crm形式で、pingd用のorderを作成する
700+
701+order odrVMCTL_dom-a1_clnDiskd1 0: clnDiskd1 prmVMCTL_dom-a1 symmetrical=false
702+#_comment
703+cre_diskd_order()
704+{
705+ echo "order ${ODR_NM}_${1}_${2} ${vm_diskd_odr[0]}: ${2} ${PRM_NM}_${1} symmetrical=${vm_diskd_odr[1]}
706+" >> ${TMP_CRMFILE}
707+}
708+
709+:<<'#_comment'
710+関数名 : cre_diskd_colocation
711+引数 : $1 ドメイン名
712+ $2 リソース名
713+戻り値 : なし
714+説明 : crm形式で、diskd用のcolocationを作成する
715+
716+colocation colVMCTL_dom-a1_clnDiskd1 inf: prmVMCTL_dom-a1 clnDiskd1
717+#_comment
718+cre_diskd_colocation()
719+{
720+ echo "colocation ${COL_NM}_${1}_${2} ${vm_diskd_col}: ${PRM_NM}_${1} ${2}" >> ${TMP_CRMFILE}
721+}
722+
723+:<<'#_comment'
724+関数名 : cre_diskd
725+引数 : $1 ドメイン名
726+戻り値 : なし
727+説明 : crm形式で、diskd用のlocation/colocation/orderを作成する
728+#_comment
729+cre_diskd()
730+{
731+ local _val
732+ local _val1
733+ local _idx=1
734+ while [ ${_idx} -le 10 ]
735+ do
736+ _val1="_val1=\${vm_diskd${_idx}[@]}"
737+ eval ${_val1}
738+ _val=(${_val1})
739+ _val1="${_val[@]}"
740+ if [ ! "${_val1}" ] ; then
741+ break
742+ fi
743+ if [ -n "${_val[1]}" ] ; then
744+ cre_diskd_location ${1} ${_val[1]}
745+ fi
746+ cre_diskd_colocation ${1} ${_val[0]}
747+ cre_diskd_order ${1} ${_val[0]}
748+ _idx=$(expr ${_idx} + 1)
749+ done
750+}
751+
752+:<<'#_comment'
753+関数名 : cre_managerd_location
754+引数 : $1 ドメイン名
755+ $2 属性名
756+戻り値 : なし
757+説明 : crm形式で、vm-managerd用のlocationを作成する
758+
759+location locVMCTL_dom-a1_operator_check_status prmVMCTL_dom-a1 \
760+ rule $id="locVMCTL_dom-a1_operator_check_status-rule" -inf: not_defined operator_check_status or operator_check_status eq ERROR
761+#_comment
762+cre_managerd_location()
763+{
764+ echo "location ${LOC_NM}_${1}_${2} ${PRM_NM}_${1} rule -inf: not_defined ${2} or ${2} ${vm_managerd_loc[@]}
765+" >> ${TMP_CRMFILE}
766+}
767+
768+:<<'#_comment'
769+関数名 : cre_managerd_order
770+引数 : $1 ドメイン名
771+ $2 リソース名
772+戻り値 : なし
773+説明 : crm形式で、vm-managerd用のorderを作成する
774+
775+order odrVMCTL_dom-a1_clnVmManagerd 0: clnVmManagerd prmVMCTL_dom-a1 symmetrical=false
776+#_comment
777+cre_managerd_order()
778+{
779+ echo "order ${ODR_NM}_${1}_${2} ${vm_managerd_odr[0]}: ${2} ${PRM_NM}_${1} symmetrical=${vm_managerd_odr[1]}
780+" >> ${TMP_CRMFILE}
781+}
782+
783+:<<'#_comment'
784+関数名 : cre_managerd_colocation
785+引数 : $1 ドメイン名
786+ $2 リソース名
787+戻り値 : なし
788+説明 : crm形式で、vm-managerd用のcolocationを作成する
789+
790+colocation colVMCTL_dom-b1_clnVmManagerd inf: prmVMCTL_dom-b1 clnVmManagerd
791+#_comment
792+cre_managerd_colocation()
793+{
794+ echo "colocation ${COL_NM}_${1}_${2} ${vm_managerd_col}: ${PRM_NM}_${1} ${2}" >> ${TMP_CRMFILE}
795+}
796+
797+:<<'#_comment'
798+関数名 : cre_managerd
799+引数 : $1 ドメイン名
800+戻り値 : なし
801+説明 : crm形式で、vm-managerd用のlocation/colocation/orderを作成する
802+#_comment
803+cre_managerd()
804+{
805+ local _val
806+ local _val1
807+ local _idx=1
808+ while [ ${_idx} -le 10 ]
809+ do
810+ _val1="_val1=\${vm_managerd${_idx}[@]}"
811+ eval ${_val1}
812+ _val=(${_val1})
813+ _val1="${_val[@]}"
814+ if [ ! "${_val1}" ] ; then
815+ break
816+ fi
817+ if [ -n "${_val[1]}" ] ; then
818+ cre_managerd_location ${1} ${_val[1]}
819+ fi
820+ cre_managerd_colocation ${1} ${_val[0]}
821+ cre_managerd_order ${1} ${_val[0]}
822+ _idx=$(expr ${_idx} + 1)
823+ done
824+}
825+
826+:<<'#_comment'
827+関数名 : cre_stonithd_order
828+引数 : $1 ドメイン名
829+ $2 リソース名
830+戻り値 : なし
831+説明 : crm形式で、vm-stonithd用のorderを作成する
832+
833+order odrVMCTL_dom-b1_clnVmStonithd 0: clnVmStonithd prmVMCTL_dom-b1 symmetrical=false
834+#_comment
835+cre_stonithd_order()
836+{
837+ echo "order ${ODR_NM}_${1}_${2} ${vm_stonithd_odr[0]}: ${2} ${PRM_NM}_${1} symmetrical=${vm_stonithd_odr[1]}
838+" >> ${TMP_CRMFILE}
839+}
840+
841+:<<'#_comment'
842+関数名 : cre_stonithd_colocation
843+引数 : $1 ドメイン名
844+ $2 リソース名
845+戻り値 : なし
846+説明 : crm形式で、vm-stonithd用のcolocationを作成する
847+
848+colocation colVMCTL_dom-b1_clnVmStonithd inf: prmVMCTL_dom-b1 clnVmStonithd
849+#_comment
850+cre_stonithd_colocation()
851+{
852+ echo "colocation ${COL_NM}_${1}_${2} ${vm_stonithd_col}: ${PRM_NM}_${1} ${2}" >> ${TMP_CRMFILE}
853+}
854+
855+:<<'#_comment'
856+関数名 : cre_stonithd
857+引数 : $1 ドメイン名
858+戻り値 : なし
859+説明 : crm形式で、vm-stonithd用のcolocation/orderを作成する
860+#_comment
861+cre_stonithd()
862+{
863+ local _val
864+ local _val1
865+ local _idx=1
866+ while [ ${_idx} -le 10 ]
867+ do
868+ _val1="_val1=\${vm_stonithd${_idx}[@]}"
869+ eval ${_val1}
870+ _val=(${_val1})
871+ _val1="${_val[@]}"
872+ if [ ! "${_val1}" ] ; then
873+ break
874+ fi
875+ cre_stonithd_colocation ${1} ${_val[0]}
876+ cre_stonithd_order ${1} ${_val[0]}
877+ _idx=$(expr ${_idx} + 1)
878+ done
879+}
880+
881+:<<'#_comment'
882+関数名 : cre_crm_resource
883+引数 : $1 リソース名
884+ $2 ノード名
885+戻り値 : なし
886+説明 : crm形式でリソース情報を作成する。
887+
888+primitive prmVMCTL_dom-a1 ocf:extra:VirtualDomain \
889+ params config="/etc/libvirt/qmue/dom-a1.xml" hypervisor="qemu:///system" migration_transport="ssh" \
890+ meta target-role="Stopped" meta allow-migrate="true" \
891+ op start interval="0" timeout="120s" on-fail="restart" \
892+ op monitor interval="10s" timeout="30s" on-fail="restart" \
893+ op stop interval="0" timeout="90s" on-fail="block" \
894+ op migrate_to interval="0" timeout="120s" on-fail="restart" \
895+ op migrate_from interval="0" timeout="60s" on-fail="block"
896+#_comment
897+cre_crm_resource()
898+{
899+ echo "primitive ${PRM_NM}_${1} ${vm_ocf} \\
900+ params config=\"${vm_cfg_dir}/${1}${vm_cfg_ext}\" hypervisor=\"${vm_hypervisor}\" migration_transport=\"${vm_migration_transport}\" \\
901+ meta allow-migrate=\"${MIGRATE}\" target-role=\"Stopped\" \\
902+ op start interval=\"${vm_start_op[0]}\" timeout=\"${vm_start_op[1]}\" on-fail=\"${vm_start_op[2]}\" \\
903+ op monitor interval=\"${vm_monitor_op[0]}\" timeout=\"${vm_monitor_op[1]}\" on-fail=\"${vm_monitor_op[2]}\" \\
904+ op stop interval=\"${vm_stop_op[0]}\" timeout=\"${vm_stop_op[1]}\" on-fail=\"${STONITH}\" \\
905+ op migrate_to interval=\"${vm_migrate_to_op[0]}\" timeout=\"${vm_migrate_to_op[1]}\" on-fail=\"${STONITH}\" \\
906+ op migrate_from interval=\"${vm_migrate_from_op[0]}\" timeout=\"${vm_migrate_from_op[1]}\" on-fail=\"${vm_migrate_from_op[2]}\"
907+" >> ${TMP_CRMFILE}
908+
909+ # location/order作成
910+ cre_node_location ${1} ${vm_node_loc_act} ${2}
911+ cre_pingd ${1}
912+ cre_diskd ${1}
913+ cre_managerd ${1}
914+ cre_stonithd ${1}
915+}
916+
917+:<<'#_comment'
918+関数名 : crm_get_actrsc_node
919+引数 : $1 リソース名
920+戻り値 : なし
921+説明 : リソースが起動しているノードを取得する
922+ ※リソースが起動していない場合は、NULLが設定される
923+
924+ crm status inactive
925+ prmdom-a1 (ocf::heartbeat:Dummy): Started x3650c
926+ prmdom-b1 (ocf::heartbeat:Dummy): Stopped
927+#_comment
928+crm_get_actrsc_node()
929+{
930+ RET_VALUE=""
931+ chk_cluster
932+ RET_VALUE=$(crm status inactive 2>/dev/null \
933+ | grep ${1}.*VirtualDomain 2>/dev/null \
934+ | awk '{print $4}' 2>/dev/null)
935+}
936+
937+:<<'#_comment'
938+関数名 : crm_get_node_rsclist
939+引数 : $1 ノード名
940+戻り値 : なし
941+説明 : 指定ノード上で起動しているリソースのリストを取得する
942+ * リソースが1つも起動していない場合は、NULLが設定される
943+
944+ crm status inactive
945+ prmdom-a1 (ocf::heartbeat:Dummy): Started x3650c
946+ prmdom-b1 (ocf::heartbeat:Dummy): Stopped
947+#_comment
948+crm_get_node_rsclist()
949+{
950+ RET_VALUE=""
951+ chk_cluster
952+ RET_VALUE=$(crm status inactive 2>/dev/null \
953+ | grep VirtualDomain.*${1} 2>/dev/null \
954+ | awk '{print $1}' 2>/dev/null \
955+ | awk '{print substr($1,length("'${PRM_NM}'_")+1)}' 2>/dev/null)
956+}
957+
958+:<<'#_comment'
959+関数名 : crm_chk_str_resource
960+引数 : $1 リソース名
961+戻り値 : なし
962+説明 : リソースの起動状態をチェックし、
963+ 起動中であれば、メッセージを出力し、vm-ctlを終了する
964+#_comment
965+crm_chk_str_resource()
966+{
967+ crm_get_actrsc_node ${1}
968+ if [ "${RET_VALUE}" ] ; then
969+ echo ${VMCTL_MSG13}
970+ exit 1
971+ fi
972+}
973+
974+:<<'#_comment'
975+関数名 : crm_chk_node
976+引数 : $1 ノード名
977+戻り値 : なし
978+説明 : クラスタ構成に対象ノードが存在するか確認し、
979+ 存在しない場合、メッセージを出力し、vm-ctlを終了する
980+#_comment
981+crm_chk_node()
982+{
983+ local _cnt
984+ chk_cluster
985+ _cnt=$(crm node show ${1} 2>/dev/null \
986+ | wc -l 2>/dev/null)
987+ if [ ${_cnt} -eq 0 ] ; then
988+ echo ${VMCTL_MSG16}
989+ exit 1
990+ fi
991+}
992+
993+:<<'#_comment'
994+関数名 : crm_chk_can_move
995+引数 : $1 ドメイン名
996+ : $2 稼働元ノード名
997+ : $3 移動先ノード名(非必須)
998+戻り値 : 0:移動可
999+ : 1:移動不可
1000+説明 : リソースが指定ノード、または他ノードに移動可能か確認し、
1001+ 移動が不可能だった場合、メッセージを出力し、リターンコードを返す
1002+#_comment
1003+crm_chk_can_move()
1004+{
1005+ local _cnt
1006+ local _scores
1007+ local _flg=0
1008+
1009+ if [ ${3} ] ; then
1010+ chk_cluster
1011+ _cnt=$(crm status 2>/dev/null \
1012+ | grep -v VirtualDomain 2>/dev/null \
1013+ | grep "Online" 2>/dev/null \
1014+ | grep ${3} 2>/dev/null \
1015+ | wc -l 2>/dev/null)
1016+ if [ ${_cnt} -eq 0 ] ; then
1017+ echo ${VMCTL_MSG14}
1018+ return 1
1019+ fi
1020+ fi
1021+ chk_cluster
1022+ crm status inactive 2>/dev/null \
1023+ | grep ${PRM_NM}_${1}.*VirtualDomain 2>/dev/null \
1024+ | egrep 'unmanaged' >/dev/null 2>&1
1025+ if [ ${?} -eq 0 ] ; then
1026+ echo ${VMCTL_MSG25}
1027+ return 1
1028+ fi
1029+ chk_cluster
1030+ _scores=$(crm configure ptest scores 2>/dev/null \
1031+ | grep "native_color: ${PRM_NM}_${1} allocation score on ${3}" 2>/dev/null \
1032+ | grep -v ${2} 2>/dev/null \
1033+ | awk '{print $7}' 2>/dev/null)
1034+
1035+ if [ ${3} ] ; then
1036+ if [ "${_scores}" = "${MINUS_INFINITY}" ] ; then
1037+ eval echo "${VMCTL_MSG19}"
1038+ return 1
1039+ fi
1040+ else
1041+ for _score in ${_scores}
1042+ do
1043+ if [ "${_score}" != "${MINUS_INFINITY}" ] ; then
1044+ _flg=1
1045+ fi
1046+ done
1047+ if [ ${_flg} -eq 0 ] ; then
1048+ eval echo "${VMCTL_MSG20}"
1049+ return 1
1050+ fi
1051+ fi
1052+ return 0
1053+}
1054+
1055+:<<'#_comment'
1056+関数名 : crm_upd_resource
1057+引数 : なし
1058+戻り値 : なし
1059+説明 : crmファイルを更新する
1060+#_comment
1061+crm_upd_resource()
1062+{
1063+ local _cnt
1064+ if [ ! -e ${TMP_CRMFILE} ] ; then
1065+ return
1066+ fi
1067+ chk_cluster
1068+ crm configure load update ${TMP_CRMFILE}<<EOF>${VMCTL_LOGFILE} 2>&1
1069+no
1070+EOF
1071+ # エラーチェック
1072+ chk_crm_error ${?}
1073+}
1074+
1075+:<<'#_comment'
1076+関数名 : crm_del_resource
1077+引数 : $1 リソース名
1078+戻り値 : なし
1079+説明 : crmファイルから、対象となるリソース関連情報を削除する
1080+#_comment
1081+crm_del_resource()
1082+{
1083+ chk_cluster
1084+ crm configure delete ${1}<<EOF>>${VMCTL_LOGFILE} 2>&1
1085+no
1086+EOF
1087+ # エラーチェック
1088+ chk_crm_error ${?}
1089+}
1090+
1091+:<<'#_comment'
1092+関数名 : crm_str_resource
1093+引数 : $1 リソース名
1094+戻り値 : なし
1095+説明 : 対象となるリソースを起動する。
1096+#_comment
1097+crm_str_resource()
1098+{
1099+ chk_cluster
1100+ crm resource start ${1} >>${VMCTL_LOGFILE} 2>&1
1101+ # エラーチェック
1102+ chk_crm_error ${?}
1103+}
1104+
1105+:<<'#_comment'
1106+関数名 : crm_stp_resource
1107+引数 : $1 リソース名
1108+戻り値 : なし
1109+説明 : 対象となるリソースを停止する。
1110+#_comment
1111+crm_stp_resource()
1112+{
1113+ chk_cluster
1114+ crm resource stop ${1} >>${VMCTL_LOGFILE} 2>&1
1115+ # エラーチェック
1116+ chk_crm_error ${?}
1117+}
1118+
1119+:<<'#_comment'
1120+関数名 : crm_move_resource
1121+引数 : $1 ドメイン名
1122+ : $2 移動元ノード名
1123+ : $3 移動先ノード名
1124+戻り値 : なし
1125+説明 : 対象となるリソースを移動する。
1126+#_comment
1127+crm_move_resource()
1128+{
1129+ chk_cluster
1130+ # 移動用location作成&実行
1131+ if [ ! "${3}" ] ; then
1132+ crm resource move ${PRM_NM}_${1} >>${VMCTL_LOGFILE} 2>&1
1133+ else
1134+ crm resource move ${PRM_NM}_${1} ${3} force >>${VMCTL_LOGFILE} 2>&1
1135+ fi
1136+ chk_crm_error ${?}
1137+ # リソース移動完了チェック
1138+ while true
1139+ do
1140+ crm_chk_can_move ${1} ${2} ${3}
1141+ if [ ${?} -eq 1 ] ; then
1142+ echo ${VMCTL_MSG27}
1143+ exit 1
1144+ fi
1145+ crm_get_actrsc_node ${PRM_NM}_${1}
1146+ if [ ! ${3} ] ; then
1147+ if [ ${RET_VALUE} -a "${RET_VALUE}" != "${2}" ] ; then
1148+ break
1149+ fi
1150+ else
1151+ if [ "${RET_VALUE}" = "${3}" ] ; then
1152+ break
1153+ fi
1154+ fi
1155+ sleep 1
1156+ done
1157+ # 移動用location削除
1158+ chk_cluster
1159+ crm resource unmove ${PRM_NM}_${1} >>${VMCTL_LOGFILE} 2>&1
1160+ chk_crm_error ${?}
1161+}
1162+
1163+:<<'#_comment'
1164+関数名 : crm_unmove_resource
1165+引数 : $1 リソース名
1166+戻り値 : なし
1167+説明 : 対象となるリソースの移動制約を解除する。
1168+#_comment
1169+crm_unmove_resource()
1170+{
1171+ chk_cluster
1172+ crm resource unmove ${1} >>${VMCTL_LOGFILE} 2>&1
1173+ # エラーチェック
1174+ chk_crm_error ${?}
1175+}
1176+
1177+:<<'#_comment'
1178+関数名 : crm_move_location
1179+引数 : $1 ドメイン名
1180+ $2 移動先ノード名
1181+戻り値 : なし
1182+説明 : 対象となるリソースのlocationを変更する。
1183+#_comment
1184+crm_move_location()
1185+{
1186+ # 現状のlocation取得
1187+ get_act_location ${1}
1188+ # 現状のlocationと設定ノードが同じなら何もしない
1189+ if [ "${2}" != "${RET_VALUE}" ] ; then
1190+ DEL_ID_LIST="${DEL_ID_LIST} ${LOC_NM}_${1}_${RET_VALUE}_ACT"
1191+ cre_node_location ${1} ${vm_node_loc_act} ${2}
1192+ fi
1193+}
1194+:<<'#_comment'
1195+関数名 : resource_add
1196+引数 : なし
1197+戻り値 : なし
1198+説明 : リソース追加する
1199+#_comment
1200+resource_add()
1201+{
1202+ local _domain_name
1203+
1204+ chk_vm
1205+ chk_rsc 0 ${VMCTL_MSG11}
1206+ chk_base_config
1207+ chk_stonith
1208+ # ノードチェック
1209+ crm_chk_node ${NODE_NAME}
1210+ # 対象のリソース情報を作成
1211+ for _domain_name in ${DOMAIN_LIST}
1212+ do
1213+ cre_crm_resource ${_domain_name} ${NODE_NAME}
1214+ done
1215+ # リソース情報更新
1216+ crm_upd_resource
1217+ # crmの結果をoutput
1218+ cat ${VMCTL_LOGFILE}
1219+}
1220+
1221+:<<'#_comment'
1222+関数名 : resource_delete
1223+引数 : なし
1224+戻り値 : なし
1225+説明 : リソースを削除する
1226+#_comment
1227+resource_delete()
1228+{
1229+ local _domain_name
1230+
1231+ chk_vm
1232+ chk_rsc 1 ${VMCTL_MSG15}
1233+ # 削除対象のリソースが停止しているか確認
1234+ for _domain_name in ${DOMAIN_LIST}
1235+ do
1236+ crm_chk_str_resource ${PRM_NM}_${_domain_name}
1237+ done
1238+ # 対象のリソースを削除
1239+ for _domain_name in ${DOMAIN_LIST}
1240+ do
1241+ DEL_ID_LIST="${DEL_ID_LIST} ${PRM_NM}_${_domain_name}"
1242+ done
1243+ crm_del_resource "${DEL_ID_LIST}"
1244+ # crmの結果をoutput
1245+# cat ${VMCTL_LOGFILE} 2>/dev/null | grep -v 'INFO:.*_dom-a1_.* deleted' 2>/dev/null
1246+ cat ${VMCTL_LOGFILE} 2>/dev/null
1247+}
1248+
1249+:<<'#_comment'
1250+関数名 : resource_start
1251+引数 : なし
1252+戻り値 : なし
1253+説明 : リソースを起動する
1254+#_comment
1255+resource_start()
1256+{
1257+ local _domain_name
1258+
1259+ chk_vm
1260+ chk_rsc 1 ${VMCTL_MSG15}
1261+ # 対象のリソースを起動
1262+ for _domain_name in ${DOMAIN_LIST}
1263+ do
1264+ crm_str_resource ${PRM_NM}_${_domain_name}
1265+ done
1266+}
1267+
1268+:<<'#_comment'
1269+関数名 : resource_stop
1270+引数 : なし
1271+戻り値 : なし
1272+説明 : リソースを停止する
1273+#_comment
1274+resource_stop()
1275+{
1276+ local _domain_name
1277+
1278+ chk_vm
1279+ chk_rsc 1 ${VMCTL_MSG15}
1280+ # 対象のリソースを停止
1281+ for _domain_name in ${DOMAIN_LIST}
1282+ do
1283+ crm_stp_resource ${PRM_NM}_${_domain_name}
1284+ done
1285+}
1286+
1287+:<<'#_comment'
1288+関数名 : resource_move
1289+引数 : なし
1290+戻り値 : なし
1291+説明 : 指定ノードにリソースを移動する
1292+#_comment
1293+resource_move()
1294+{
1295+ local _to=${NODE_NAME}
1296+ local _from
1297+
1298+ chk_vm
1299+ chk_rsc 1 ${VMCTL_MSG15}
1300+ # 稼動中のノード名を取得
1301+ crm_get_actrsc_node ${PRM_NM}_${DOMAIN_LIST}
1302+ _from=${RET_VALUE}
1303+ # 稼動中のノードが存在しない場合エラー
1304+ if [ ! "${_from}" ] ; then
1305+ echo ${VMCTL_MSG18}
1306+ exit 1
1307+ fi
1308+ # 移動先ノードチェック
1309+ if [ "${_to}" ] ; then
1310+ crm_chk_node ${_to}
1311+ fi
1312+ # リソース移動可否チェック
1313+ crm_chk_can_move ${DOMAIN_LIST} ${_from} ${_to}
1314+ if [ ${?} -eq 1 ] ; then
1315+ echo ${VMCTL_MSG26}
1316+ exit 1
1317+ fi
1318+ # 移動先と稼動が同じなら何もしない
1319+ if [ "${_to}" = "${_from}" ] ; then
1320+ echo ${VMCTL_MSG21}
1321+ exit 0
1322+ fi
1323+ # リソース移動
1324+ crm_move_resource ${DOMAIN_LIST} ${_from} ${_to}
1325+}
1326+
1327+:<<'#_comment'
1328+関数名 : resource_unmove
1329+引数 : なし
1330+戻り値 : なし
1331+説明 : 指定ノードにリソースを移動する
1332+#_comment
1333+resource_unmove()
1334+{
1335+ chk_vm
1336+ chk_rsc 1 ${VMCTL_MSG15}
1337+ # リソース移動制約解除
1338+ crm_unmove_resource ${PRM_NM}_${DOMAIN_LIST}
1339+}
1340+
1341+:<<'#_comment'
1342+関数名 : resource_list
1343+引数 : なし
1344+戻り値 : なし
1345+説明 : リソース一覧を表示する
1346+#_comment
1347+resource_list()
1348+{
1349+ local _domain_name
1350+ local _output
1351+ local _tmp
1352+ local _idx=0
1353+ # ノード指定
1354+ if [ ${N_FLG} -eq 1 ] ; then
1355+ crm_chk_node ${NODE_NAME}
1356+ # ドメイン名取得
1357+ crm_get_node_rsclist ${NODE_NAME}
1358+ DOMAIN_LIST=${RET_VALUE}
1359+ # オプション未指定
1360+ elif [ ! "${DOMAIN_LIST}" ] ; then
1361+ get_domain
1362+ if [ "${RET_VALUE}" ] ; then
1363+ DOMAIN_LIST=${RET_VALUE}
1364+ fi
1365+ # ドメイン指定
1366+ else
1367+ chk_vm
1368+ chk_rsc 1 ${VMCTL_MSG15}
1369+ fi
1370+
1371+ # リソース情報取得
1372+ for _domain_name in ${DOMAIN_LIST}
1373+ do
1374+ # ドメイン名、リソース名設定
1375+ _tmp="${_domain_name} ${PRM_NM}_${_domain_name}"
1376+
1377+ # マイグレーション設定取得
1378+ get_migrate ${PRM_NM}_${_domain_name}
1379+ # マイグレーション設定
1380+ if [ "${RET_VALUE}" ] ; then
1381+ _tmp="${_tmp} ${RET_VALUE}"
1382+ else
1383+ _tmp="${_tmp} NONE"
1384+ fi
1385+ # 優先ノード設定取得
1386+ get_act_location ${_domain_name}
1387+ if [ "${RET_VALUE}" ] ; then
1388+ # 優先ノード設定
1389+ _tmp="${_tmp} ${RET_VALUE}"
1390+ else
1391+ _tmp="${_tmp} NONE"
1392+ fi
1393+
1394+ # 稼動ノード取得
1395+ crm_get_actrsc_node ${PRM_NM}_${_domain_name}
1396+ # 起動状態判定
1397+ if [ "${RET_VALUE}" ] ; then
1398+ # 起動ノード設定
1399+ _tmp="${_tmp} ${RET_VALUE}"
1400+ else
1401+ # 停止を設定
1402+ _tmp="${_tmp} Stopped"
1403+ fi
1404+
1405+ # 移動用制約の取得
1406+ get_move_location ${PRM_NM}_${_domain_name}
1407+ _tmp="${_tmp} ${RET_VALUE}"
1408+
1409+ _output="${_output} ${_tmp}"
1410+ _idx=$(expr ${_idx} + 1)
1411+ done
1412+ printf "%-25s %-25s %-28s %-25s %-27s %s\n" "ドメイン名" "リソース名" "マイグレーション" "優先ノード" "稼動ノード(状態)" "移動制約"
1413+ printf "%-20s %-20s %-20s %-20s %-20s %s\n" "--------------------" "--------------------" "--------------------" "--------------------" "--------------------" "--------------------"
1414+ printf "%-20s %-20s %-20s %-20s %-20s %s\n" ${_output}
1415+}
1416+
1417+:<<'#_comment'
1418+関数名 : location_move
1419+引数 : なし
1420+戻り値 : なし
1421+説明 : 稼動ノードにlocationを設定する
1422+#_comment
1423+location_move()
1424+{
1425+ local _domain_name
1426+ local _tmp_list
1427+ if [ ${B_FLG} -eq 1 ] ; then
1428+ crm_chk_node ${NODE_NAME}
1429+ # ドメイン名取得
1430+ get_domain
1431+ _tmp_list=${RET_VALUE}
1432+ # 指定ノードと同じlocationを持つリソースを特定
1433+ for _domain_name in ${_tmp_list}
1434+ do
1435+ get_act_location ${_domain_name}
1436+ if [ "${NODE_NAME}" = "${RET_VALUE}" ] ; then
1437+ DOMAIN_LIST="${DOMAIN_LIST} ${_domain_name}"
1438+ fi
1439+ done
1440+ else
1441+ chk_vm
1442+ chk_rsc 1 ${VMCTL_MSG15}
1443+ fi
1444+ if [ "${DOMAIN_LIST}" ] ; then
1445+ # location再設定
1446+ for _domain_name in ${DOMAIN_LIST}
1447+ do
1448+ # 稼動ノード取得
1449+ crm_get_actrsc_node ${PRM_NM}_${_domain_name}
1450+ if [ "${RET_VALUE}" ] ; then
1451+ crm_move_location ${_domain_name} ${RET_VALUE}
1452+ fi
1453+ done
1454+ # location更新
1455+ if [ "${DEL_ID_LIST}" ] ; then
1456+ crm_del_resource "${DEL_ID_LIST}"
1457+ fi
1458+ crm_upd_resource
1459+ rm_file ${TMP_CRMFILE}
1460+ fi
1461+}
1462+#############################################################################
1463+# main #
1464+#############################################################################
1465+sleep 0.3
1466+# 多重起動チェック
1467+pid=$(pgrep vm-ctl)
1468+cnt=$(echo -n "${pid}" 2>/dev/null | grep -vw $$ 2>/dev/null | wc -l 2>/dev/null)
1469+if [ ${cnt} -ne 0 ] ; then
1470+ echo ${VMCTL_MSG17}
1471+ exit 1
1472+fi
1473+# 一時ファイル削除
1474+rm_file ${BACKUP_CRMFILE}
1475+rm_file ${TMP_CRMFILE}
1476+rm_file ${VMCTL_LOGFILE}
1477+
1478+CMD_ALL="${@}"
1479+NOW=$(date +"%Y/%m/%d %H:%M:%S")
1480+CMD_NAME="${1} ${2}"
1481+EXEC_FUNC=""
1482+MIGRATE=""
1483+STONITH=
1484+NODE_NAME=""
1485+RET_VALUE=""
1486+
1487+# vm-ctl.confチェック
1488+if [ ! -e ${VMCFG_DIR}/vm-ctl.conf ] ; then
1489+ echo ${VMCTL_MSG02}
1490+ exit 1
1491+fi
1492+# vm-ctl.conf読み込み
1493+. ${VMCFG_DIR}/vm-ctl.conf
1494+
1495+# コマンドオプションチェック
1496+shift 2
1497+# ドメイン名取得
1498+if [ "${1:0:1}" != "-" ] ; then
1499+ DOMAIN_LIST="${1}"
1500+ shift 1
1501+fi
1502+
1503+:<<'#_comment'
1504+a <activate_node>
1505+b <node_name> #bundle
1506+m <migrate_flag(on|off)>
1507+n <node_name>
1508+#_comment
1509+A_FLG=0
1510+B_FLG=0
1511+M_FLG=0
1512+N_FLG=0
1513+while getopts a:b:m:n: OPT
1514+do
1515+ case ${OPT} in
1516+ "a")
1517+ chk_opt
1518+ NODE_NAME="${OPTARG}"
1519+ A_FLG=$(expr ${A_FLG} + 1)
1520+ if [ ${A_FLG} -gt 1 ] ; then
1521+ usage
1522+ fi
1523+ ;;
1524+ "b")
1525+ chk_opt
1526+ NODE_NAME="${OPTARG}"
1527+ B_FLG=$(expr ${B_FLG} + 1)
1528+ if [ ${B_FLG} -gt 1 ] ; then
1529+ usage
1530+ fi
1531+ ;;
1532+ "m")
1533+ chk_opt
1534+ MIGRATE=${OPTARG}
1535+ M_FLG=$(expr ${M_FLG} + 1)
1536+ if [ ${M_FLG} -gt 1 ] ; then
1537+ usage
1538+ fi
1539+ if [ "${MIGRATE}" != "on" -a "${MIGRATE}" != "off" ] ; then
1540+ usage
1541+ fi
1542+ ;;
1543+ "n")
1544+ chk_opt
1545+ NODE_NAME="${OPTARG}"
1546+ N_FLG=$(expr ${N_FLG} + 1)
1547+ if [ ${N_FLG} -gt 1 ] ; then
1548+ usage
1549+ fi
1550+ ;;
1551+ *)
1552+ usage
1553+ ;;
1554+ esac
1555+done
1556+
1557+if [ ! "${DOMAIN_LIST}" ] ; then
1558+ shift $(expr ${OPTIND} - 1)
1559+ DOMAIN_LIST=${1}
1560+fi
1561+
1562+# コマンド解析&チェック
1563+case ${CMD_NAME} in
1564+ "resource add")
1565+ if [ $((${B_FLG}|${N_FLG})) -ne 0 -o ${A_FLG} -ne 1 ] ; then
1566+ usage
1567+ fi
1568+ chk_domain_list
1569+ EXEC_FUNC="resource_add"
1570+ ;;
1571+ "resource delete")
1572+ if [ $((${A_FLG}|${B_FLG}|${M_FLG}|${N_FLG})) -ne 0 ] ; then
1573+ usage
1574+ fi
1575+ chk_domain_list
1576+ EXEC_FUNC="resource_delete"
1577+ ;;
1578+ "resource move")
1579+ if [ $((${A_FLG}|${B_FLG}|${M_FLG})) -ne 0 ] ; then
1580+ usage
1581+ fi
1582+ chk_domain
1583+ EXEC_FUNC="resource_move"
1584+ ;;
1585+ "resource unmove")
1586+ if [ $((${A_FLG}|${B_FLG}|${M_FLG}|${N_FLG})) -ne 0 ] ; then
1587+ usage
1588+ fi
1589+ chk_domain
1590+ EXEC_FUNC="resource_unmove"
1591+ ;;
1592+ "resource start")
1593+ if [ $((${A_FLG}|${B_FLG}|${M_FLG}|${N_FLG})) -ne 0 ] ; then
1594+ usage
1595+ fi
1596+ chk_domain_list
1597+ EXEC_FUNC="resource_start"
1598+ ;;
1599+ "resource stop")
1600+ if [ $((${A_FLG}|${B_FLG}|${M_FLG}|${N_FLG})) -ne 0 ] ; then
1601+ usage
1602+ fi
1603+ chk_domain_list
1604+ EXEC_FUNC="resource_stop"
1605+ ;;
1606+ "resource list")
1607+ if [ $((${A_FLG}|${B_FLG}|${M_FLG})) -ne 0 ] ; then
1608+ usage
1609+ fi
1610+ if [ ${N_FLG} -eq 1 -a "${DOMAIN_LIST}" ] ; then
1611+ usage
1612+ fi
1613+ if [ "${DOMAIN_LIST}" ] ; then
1614+ chk_domain
1615+ fi
1616+ EXEC_FUNC="resource_list"
1617+ ;;
1618+ "location move")
1619+ if [ $((${A_FLG}|${M_FLG}|${N_FLG})) -ne 0 ] ; then
1620+ usage
1621+ fi
1622+ if [ ${B_FLG} -eq 1 -a "${DOMAIN_LIST}" ] ; then
1623+ usage
1624+ fi
1625+ if [ ${B_FLG} -eq 0 ] ; then
1626+ chk_domain
1627+ fi
1628+ EXEC_FUNC="location_move"
1629+ ;;
1630+ *)
1631+ usage
1632+ ;;
1633+esac
1634+
1635+# 空白削除&重複内容削除
1636+DOMAIN_LIST=$(echo ${DOMAIN_LIST} | sed -e 's/ *//g')
1637+DOMAIN_LIST=${DOMAIN_LIST//,/\\n}
1638+DOMAIN_LIST=$(echo -e ${DOMAIN_LIST} | sort | uniq)
1639+#DOMAIN_LIST=${DOMAIN_LIST//\\n/ }
1640+
1641+# 現在のcrmファイルバックアップ
1642+chk_cluster
1643+crm configure save ${BACKUP_CRMFILE}<<EOF>${VMCTL_LOGFILE} 2>&1
1644+yes
1645+EOF
1646+if [ ${?} -ne 0 ] ; then
1647+ echo ${VMCTL_MSG04}
1648+ cat ${VMCTL_LOGFILE}
1649+ exit 1
1650+fi
1651+BACKUP_VAL=$(cat ${BACKUP_CRMFILE} 2>/dev/null)
1652+#メタデータ登録
1653+echo "# ${NOW} vm-ctl ${CMD_ALL}" > ${BACKUP_CRMFILE}
1654+echo -e "${BACKUP_VAL}" >> ${BACKUP_CRMFILE}
1655+
1656+# リソースオペレーション定数チェック
1657+[ "${EXEC_FUNC}" = "resource_add" -o "${EXEC_FUNC}" = "location_move" ] && chk_rsc_config
1658+
1659+# vmctl実行
1660+${EXEC_FUNC}
1661+
1662+exit 0
1663+
diff -r 000000000000 -r 61f256435311 vm-ctl.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vm-ctl.conf Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,60 @@
1+#########################################################################
2+# 基本設定内容 #
3+#########################################################################
4+# 仮想マシン定義ファイルディレクトリ
5+#vm_cfg_dir="/etc/xen/xml"
6+vm_cfg_dir="/etc/libvirt/qemu"
7+# VM設定ファイル拡張子
8+vm_cfg_ext=".xml"
9+# ライブマイグレーション
10+vm_allow_migrate="off"
11+# STONITH設定
12+vm_stonith="on"
13+# VM制御OCF
14+vm_ocf=ocf:extra:VirtualDomain
15+# crmadmin タイムアウト値
16+crmadmin_timeout=10000
17+# pingd制約(リソース名 属性名)
18+#vm_pingd1=(clnPingd default_ping_set)
19+# diskd制約(リソース名 属性名)
20+#vm_diskd1=(clnDiskd1 diskcheck_status)
21+#vm_diskd2=(clnDiskd2 diskcheck_status_internal)
22+# vm-managerd制約(リソース名 属性名)
23+#vm_managerd1=(clnVmManagerd operator_check_status)
24+# vm-stonithd制約(リソース名)
25+#vm_stonithd1=(clnVmStonithd)
26+
27+
28+#########################################################################
29+# リソースオペレーション(変更非推奨) #
30+#########################################################################
31+# ハイパーバイザー接続
32+#vm_hypervisor="xen:///system"
33+vm_hypervisor="qemu:///system"
34+# ライブマイグレーショントランスポート
35+vm_migration_transport="ssh"
36+
37+# VMリソースオペレーション(interval timeout on-fail)
38+vm_start_op=(0 120s restart)
39+vm_stop_op=(0 90s)
40+vm_monitor_op=(10s 30s restart)
41+vm_migrate_to_op=(0 300s)
42+vm_migrate_from_op=(0 240s restart)
43+
44+# VMノード配置制約
45+vm_node_loc_act=200
46+# pingd制約
47+vm_pingd_loc=(lt 100)
48+vm_pingd_col=INFINITY
49+vm_pingd_odr=(0 false)
50+# diskd制約
51+vm_diskd_loc=(eq ERROR)
52+vm_diskd_col=INFINITY
53+vm_diskd_odr=(0 false)
54+# vm-managerd制約
55+vm_managerd_loc=(eq ERROR)
56+vm_managerd_col=INFINITY
57+vm_managerd_odr=(0 false)
58+# vm-stonithd制約
59+vm_stonithd_col=INFINITY
60+vm_stonithd_odr=(0 false)
diff -r 000000000000 -r 61f256435311 vm-ctl.spec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vm-ctl.spec Thu Sep 15 17:11:13 2011 +0900
@@ -0,0 +1,90 @@
1+########################################
2+# Derived definitions
3+########################################
4+%define name vm-ctl
5+%define version 1.0
6+%define release 1
7+%define prefix /usr
8+%define vmctldir vm-ctl
9+Summary: Pacemaker VirtualDomain resource generator.
10+Name: %{name}
11+Version: %{version}
12+Release: %{release}%{?dist}
13+Group: Applications
14+Source: %{name}-%{version}.tar.gz
15+License: GPL
16+Vendor: NIPPON TELEGRAPH AND TELEPHONE CORPORATION
17+BuildRoot: %{_tmppath}/%{name}-%{version}
18+BuildRequires: make
19+BuildArch: noarch
20+Requires: pacemaker >= 1.0.10
21+
22+########################################
23+%description
24+Generate crm-file from cmmandline and config-file.
25+
26+########################################
27+%prep
28+########################################
29+rm -rf $RPM_BUILD_ROOT
30+
31+########################################
32+%setup -q
33+########################################
34+
35+########################################
36+%build
37+########################################
38+
39+########################################
40+%configure
41+########################################
42+
43+########################################
44+%pre
45+########################################
46+
47+########################################
48+%install
49+########################################
50+make DESTDIR=$RPM_BUILD_ROOT install
51+mkdir -p $RPM_BUILD_ROOT%{prefix}/sbin
52+ln -sf %{prefix}/share/pacemaker/%{vmctldir}/%{name} $RPM_BUILD_ROOT%{prefix}/sbin/%{name}
53+
54+########################################
55+%clean
56+########################################
57+if
58+ [ -n "${RPM_BUILD_ROOT}" -a "${RPM_BUILD_ROOT}" != "/" ]
59+then
60+ rm -rf $RPM_BUILD_ROOT
61+fi
62+rm -rf $RPM_BUILD_DIR/%{name}-%{version}
63+
64+########################################
65+%post
66+########################################
67+true
68+########################################
69+%preun
70+########################################
71+true
72+########################################
73+%postun
74+########################################
75+true
76+
77+########################################
78+%files
79+########################################
80+%defattr(-,root,root)
81+%dir %{prefix}/share/pacemaker/%{vmctldir}
82+%config /etc/vm-ctl.conf
83+%{prefix}/share/pacemaker/%{vmctldir}/%{name}
84+%{prefix}/sbin/%{name}
85+
86+########################################
87+%changelog
88+########################################
89+* Tue May 31 2011 Yuusuke IIDA <iidayuus@intellilink.co.jp>
90+- initial release
Show on old repository browser