debian/0000775000000000000000000000000012355033624007173 5ustar debian/copyright0000664000000000000000000010461212272754675011150 0ustar Format: http://dep.debian.net/deps/dep5 Upstream-Name: juju-quickstart Source: http://launchpad.net/juju-quickstart Files: * Copyright: 2013-2014 Canonical, Ltd. License: AGPL-3.0+ Files: debian/* Copyright: 2013-2014 Canonical, Ltd. License: AGPL-3.0+ License: AGPL-3.0+ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 . Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. . Preamble . The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. . The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. . When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. . Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. . A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. . The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. . An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. . The precise terms and conditions for copying, distribution and modification follow. . TERMS AND CONDITIONS . 0. Definitions. . "This License" refers to version 3 of the GNU Affero General Public License. . "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. . "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. . To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. . A "covered work" means either the unmodified Program or a work based on the Program. . To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. . To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. . An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. . 1. Source Code. . The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. . A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. . The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. . The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. . The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. . The Corresponding Source for a work in source code form is that same work. . 2. Basic Permissions. . All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. . You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. . Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. . 3. Protecting Users' Legal Rights From Anti-Circumvention Law. . No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. . When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. . 4. Conveying Verbatim Copies. . You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. . You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. . 5. Conveying Modified Source Versions. . You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: . a) The work must carry prominent notices stating that you modified it, and giving a relevant date. . b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". . c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. . d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. . A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. . 6. Conveying Non-Source Forms. . You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: . a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. . b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. . c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. . d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. . e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. . A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. . A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. . "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. . If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). . The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. . Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. . 7. Additional Terms. . "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. . When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. . Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: . a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or . b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or . c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or . d) Limiting the use for publicity purposes of names of licensors or authors of the material; or . e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or . f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. . All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. . If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. . Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. . 8. Termination. . You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). . However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. . Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. . Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. . 9. Acceptance Not Required for Having Copies. . You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. . 10. Automatic Licensing of Downstream Recipients. . Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. . An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. . You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. . 11. Patents. . A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". . A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. . Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. . In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. . If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. . If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. . A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. . Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. . 12. No Surrender of Others' Freedom. . If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. . 13. Remote Network Interaction; Use with the GNU General Public License. . Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. . Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. . 14. Revised Versions of this License. . The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. . Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. . If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. . Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. . 15. Disclaimer of Warranty. . THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. . 16. Limitation of Liability. . IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. . 17. Interpretation of Sections 15 and 16. . If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. . END OF TERMS AND CONDITIONS . How to Apply These Terms to Your New Programs . If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. . To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. . Copyright (C) . This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. . You should have received a copy of the GNU Affero General Public License along with this program. If not, see . . Also add information on how to contact you by electronic and paper mail. . If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. . You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . debian/rules0000775000000000000000000000126112310324110010233 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ --with python2 --buildsystem=python_distutils override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) set -e; for ver in $(shell pyversions -rv); do \ nosetests-$$ver quickstart; \ done; else @echo "** tests disabled" endif debian/manpages0000664000000000000000000000003112272754265010714 0ustar debian/juju-quickstart.1 debian/source/0000775000000000000000000000000012272756062010501 5ustar debian/source/format0000664000000000000000000000001412272752024011701 0ustar 3.0 (quilt) debian/docs0000664000000000000000000000001312272752435010046 0ustar README.rst debian/watch0000664000000000000000000000014212272752065010226 0ustar version=3 https://pypi.python.org/packages/source/j/juju-quickstart/juju-quickstart-(.*)\.tar\.gz debian/juju-quickstart.10000664000000000000000000000511612272754405012432 0ustar .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.43.3. .TH JUJU-QUICKSTART "1" "January 2014" "juju-quickstart 1.0.0" "User Commands" .SH NAME juju-quickstart \- Quickly configure, deploy and manage Juju bundles with the Juju GUI .SH DESCRIPTION usage: juju\-quickstart [\-h] [\-e ENV_NAME] [\-n BUNDLE_NAME] [\-i] [\-\-environments\-file ENV_FILE] [\-\-gui\-charm\-url CHARM_URL] [\-\-no\-browser] [\-\-version] [\-\-debug] [\-\-description] [bundle] .PP Juju Quickstart is a Juju plugin which allows for easily setting up a Juju environment in very few steps. The environment is bootstrapped and set up so that it can be managed using a Web interface (the Juju GUI). .SS "positional arguments:" .TP bundle The optional bundle to be deployed. The bundle can be 1) a fully qualified bundle URL (starting with "bundle:"), 2) a URL ("http:" or "https:") to a YAML/JSON, 3) a path to a YAML/JSON file, or 4) a path to a directory containing a "bundles.yaml" file .SS "optional arguments:" .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-e\fR ENV_NAME, \fB\-\-environment\fR ENV_NAME The name of the Juju environment to use .TP \fB\-n\fR BUNDLE_NAME, \fB\-\-bundle\-name\fR BUNDLE_NAME The name of the bundle to use. This must be included in the provided bundle YAML/JSON. Specifying the bundle name is not required if the bundle YAML/JSON only contains one bundle. This option is ignored if the bundle file is not specified .TP \fB\-i\fR, \fB\-\-interactive\fR Start the environments management interactive session .TP \fB\-\-environments\-file\fR ENV_FILE The path to the Juju environments YAML file (~/.juju/environments.yaml) .TP \fB\-\-gui\-charm\-url\fR CHARM_URL The Juju GUI charm URL to deploy in the environment. If not provided, the last release of the GUI will be deployed. The charm URL must include the charm version, e.g. cs:~juju\-gui/precise/juju\-gui\-116. This option is ignored if Juju GUI is already present in the environment .TP \fB\-\-no\-browser\fR Avoid opening the browser to the GUI at the end of the process .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-\-debug\fR Turn debug mode on. When enabled, all the subcommands and API calls are logged to stdout, and the Juju environment is bootstrapped passing \fB\-\-debug\fR .TP \fB\-\-description\fR Show program's description and exit .SH "SEE ALSO" The full documentation for .B juju-quickstart is maintained as a Texinfo manual. If the .B info and .B juju-quickstart programs are properly installed at your site, the command .IP .B info juju-quickstart .PP should give you access to the complete manual. debian/changelog0000664000000000000000000000315512355033624011051 0ustar juju-quickstart (1.3.1-0ubuntu1.1) trusty; urgency=medium * Cherry-pick bugfixes from 1.3.2: - Make control bucket optional (LP: #1309678). - Support Trusty environments (LP: #1306537). - Check unicode support (LP: #1311321). -- Robie Basak Wed, 02 Jul 2014 16:47:16 +0000 juju-quickstart (1.3.1-0ubuntu1) trusty; urgency=medium * New upstream release. Upstream changes: - Support MachineInfo addresses (LP: #1301464). - Support the --ppa flag for distro packaging (for LP: #1301481). * d/p/distro-only-default: default to --distro-only when running juju-quickstart installed from the Ubuntu archive (LP: #1301481). -- Robie Basak Wed, 09 Apr 2014 09:03:59 +0000 juju-quickstart (1.3.0-0ubuntu1) trusty; urgency=medium * New upstream release (LP: #1282630). * Drop patch now included in release: d/p/trusty-jujuclient. -- Robie Basak Wed, 02 Apr 2014 14:02:36 +0000 juju-quickstart (1.1.0-0ubuntu2) trusty; urgency=medium * Add test dependencies to Build-Depends. * d/p/trusty-jujuclient: make quickstart use the newer python-jujuclient included in Trusty. This was required for tests to pass. * Run tests on package build. -- Robie Basak Mon, 17 Mar 2014 16:27:26 +0000 juju-quickstart (1.1.0-0ubuntu1) trusty; urgency=medium * New upstream release. -- Robie Basak Thu, 20 Feb 2014 15:35:59 +0000 juju-quickstart (1.0.0-0ubuntu1) trusty; urgency=medium * Initial release. -- James Page Fri, 31 Jan 2014 17:13:54 +0000 debian/control0000664000000000000000000000150212311607725010575 0ustar Source: juju-quickstart Section: python Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Francesco Banconi Standards-Version: 3.9.5 Build-Depends: debhelper (>= 8~), python-all, python-setuptools, python-nose, python-jujuclient, python-mock, python-urwid, python-yaml XS-Python-Version: all Homepage: https://launchpad.net/juju-quickstart Package: juju-quickstart Architecture: all XB-Python-Version: ${python:Versions} Depends: ${python:Depends}, ${misc:Depends} Provides: ${python:Provides} Description: Easy configuration of Juju environments Juju Quickstart is a Juju plugin which supports easy configuration of a Juju environment. The environment is bootstrapped and set up that it can be managed using the Juju GUI. debian/patches/0000775000000000000000000000000012355034072010620 5ustar debian/patches/support-trusty-environments0000664000000000000000000020561012353262240016356 0ustar Author: Francesco Banconi Description: Support trusty environments Origin: backport, http://bazaar.launchpad.net/~juju-gui/juju-quickstart/trunk/revision/66 Bug: https://launchpad.net/bugs/1306537 Bug-Ubuntu: https://launchpad.net/bugs/1306537 Last-Update: 2014-06-27 Modified from upstream commit by Robie Basak , to make SRU more minimal: * Dropped version bump to 1.3.2 in quickstart/__init__.py. * Dropped whitespace noise hunk in quickstart/app.py. ------------------------------------------------------------ revno: 66 [merge] committer: Francesco Banconi branch nick: juju-quickstart timestamp: Wed 2014-04-30 11:19:39 -0700 message: Support trusty environments. Add the ability to deploy the trusty charm. Introduced the concept of multiple supported series for the Juju GUI charm. Split the app.deploy_gui function in two separate function: - check_environment inspects the environment and returns the data required to deploy the GUI; - deploy_gui's only responsibility is to return when the GUI service is deployed/exposed and the unit created. Include the default-series field in the auto-generated local environment. This is the environment that quickstart offers to automatically create when no other environments are found. Also propose "trusty" as the default series when manually creating new environments. Bump version up: while this branch incidentally fixes bug 1306537 [1], the ability to deploy the GUI on trusty can be considered a new feature. My apologies for the long diff. Tests: `make check`. QA: Use quickstart like the following: `.venv/bin/python juju-quickstart [-i]`. You should be able to deploy the trusty GUI charm. If you are on trusty, the trusty charm should be deployed when the default-series field is missing. This must be tested also using the local provider, in which case Juju is currently not able to deploy precise charms when the bootstrap node is trusty (bug 1306537). In general quickstart should deploy the charm series corresponding to the bootstrap node series: so on trusty environments the trusty charm should be installed, on precise environments the precise one. This way, at least when the bootstrap node series is precise or trusty, quickstart is able to add the GUI unit to machine 0. You can test it using, e.g. an ec2 environment. This is true also when providing a custom charm URL, e.g.: `.venv/bin/python juju-quickstart --gui-charm-url cs:~juju-gui/trusty/juju-gui-1` In all the other cases, quickstart uses the trusty charm. You can test this by using quickstart with an ec2 environment having "default-series: saucy": a trusty GUI should be deployed on machine 1. Two final checks: - try to create a new environment with quickstart: the default-series field should be pre-filled with "trusty"; - move temporarily your environments.yaml somewhere else, and let quickstart auto-generate a local environment for you: the deployment process should succeed and the environment should include the "trusty" default series. Thanks a lot for all of this, and sorry for the long QA: this is going to be released in trusty, so your efforts are really appreciated! [1] https://bugs.launchpad.net/juju-core/+bug/1306537 R= CC= https://codereview.appspot.com/90570044 === modified file 'quickstart/app.py' --- old/quickstart/app.py 2014-04-21 21:05:13 +0000 +++ new/quickstart/app.py 2014-04-24 15:33:13 +0000 @@ -325,27 +324,41 @@ return result['Token'] -def deploy_gui( - env, service_name, machine, charm_url=None, check_preexisting=False): - """Deploy and expose the given service, reusing the bootstrap node. - - Only deploy the service if not already present in the environment. - Do not add a unit to the service if the unit is already there. - - Receive an authenticated Juju Environment instance, the name of the - service, the machine where to deploy to (or None for a new machine), - the optional Juju GUI charm URL (e.g. cs:~juju-gui/precise/juju-gui-42), - and a flag (check_preexisting) that can be set to True in order to make - the function check for a pre-existing service and/or unit. +def check_environment( + env, service_name, charm_url, env_type, bootstrap_node_series, + check_preexisting): + """Inspect the current Juju environment. + + This function is responsible for retrieving all the information required + to deploy the Juju GUI charm to the current environment. + + Receive the following arguments: + - env: an authenticated Juju Environment instance; + - service_name: the name of the service to look for; + - charm_url: a fully qualified charm URL if the user requested the + deployment of a custom charm, or None otherwise; + - env_type: the environment's provider type; + - bootstrap_node_series: the bootstrap node series; + - check_preexisting: whether to check for a pre-existing service and/or + unit. If the charm URL is not provided, and the service is not already deployed, - the function tries to retrieve it from charmworld. In this case a default - charm URL is used if charmworld is not available. - - Return the name of the first running unit belonging to the given service. + the function tries to retrieve it from the charmworld API. In this case a + default charm URL is used if charmworld is not available. + + Return a tuple including the following values: + - charm_url: the charm URL that will be used to deploy the service; + - machine: the machine where to deploy to (e.g. "0") or None if a new + machine must be created; + - service_data: the service info as returned by the mega-watcher for + services, or None if the service is not present in the environment; + - unit_data: the unit info as returned by the mega-watcher for units, + or None if the unit is not present in the environment. + Raise a ProgramExit if the API server returns an error response. """ - service_data, unit_data = None, None + print('bootstrap node series: {}'.format(bootstrap_node_series)) + service_data, unit_data, machine = None, None, None if check_preexisting: # The service and/or the unit can be already in the environment. try: @@ -355,16 +368,56 @@ service_data, unit_data = utils.get_service_info(status, service_name) if service_data is None: # The service does not exist in the environment. - print('requesting {} deployment'.format(service_name)) if charm_url is None: + # The user did not provide a customized charm. + if bootstrap_node_series in settings.JUJU_GUI_SUPPORTED_SERIES: + series = bootstrap_node_series + else: + series = settings.JUJU_GUI_SUPPORTED_SERIES[-1] try: - charm_url = utils.get_charm_url() + # Try to get the charm URL from charmworld. + charm_url = utils.get_charm_url(series) except (IOError, ValueError) as err: + # Fall back to the default URL for the current series. msg = 'unable to retrieve the {} charm URL from the API: {}' logging.warn(msg.format(service_name, err)) - charm_url = settings.DEFAULT_CHARM_URL - utils.check_gui_charm_url(charm_url) - # Deploy the service without units. + charm_url = settings.DEFAULT_CHARM_URLS[series] + else: + # A deployed service already exists in the environment: ignore the + # provided charm URL and just use the already deployed charm. + charm_url = service_data['CharmURL'] + charm = utils.parse_gui_charm_url(charm_url) + # Deploy on the bootstrap node if we are not using the local provider, and + # if the requested charm and the bootstrap node have the same series. + if (env_type != 'local') and (charm.series == bootstrap_node_series): + machine = '0' + return charm_url, machine, service_data, unit_data + + +def deploy_gui(env, service_name, charm_url, machine, service_data, unit_data): + """Deploy and expose the given service to the given machine. + + Only deploy the service if not already present in the environment. + Do not add a unit to the service if the unit is already there. + + Receive the following arguments: + - env: an authenticated Juju Environment instance; + - service_name: the name of the service to be deployed; + - charm_url: the fully qualified charm URL to be used to deploy the + service; + - machine: the machine where to deploy to (e.g. "0") or None if a new + machine must be created; + - service_data: the service info as returned by the mega-watcher for + services, or None if the service is not present in the environment; + - unit_data: the unit info as returned by the mega-watcher for units, + or None if the unit is not present in the environment. + + Return the name of the first running unit belonging to the given service. + Raise a ProgramExit if the API server returns an error response. + """ + if service_data is None: + # The service is not in the environment: deploy it without units. + print('requesting {} deployment'.format(service_name)) try: env.deploy(service_name, charm_url, num_units=0) except jujuclient.EnvError as err: @@ -374,7 +427,6 @@ else: # We already have the service in the environment. print('service {} already deployed'.format(service_name)) - utils.check_gui_charm_url(service_data['CharmURL']) service_exposed = service_data.get('Exposed', False) # At this point the service is surely deployed in the environment: expose # it if necessary and add a unit if it is missing. === modified file 'quickstart/cli/views.py' --- old/quickstart/cli/views.py 2014-01-16 12:46:45 +0000 +++ new/quickstart/cli/views.py 2014-04-23 15:53:32 +0000 @@ -233,8 +233,9 @@ urwid.Divider(), ]) # The Juju GUI can be safely installed in the bootstrap node only if its - # series is "precise". Suggest this setting by pre-filling the value. - preferred_series = settings.JUJU_GUI_PREFERRED_SERIES + # series matches one of the series supported by the GUI. + # Suggest the most recent supported series by pre-filling the value. + preferred_series = settings.JUJU_GUI_SUPPORTED_SERIES[-1] widgets.extend([ ui.MenuButton( ['\N{BULLET} new ', ('highlight', label), ' environment'], === modified file 'quickstart/manage.py' --- old/quickstart/manage.py 2014-04-22 12:20:10 +0000 +++ new/quickstart/manage.py 2014-04-23 11:22:44 +0000 @@ -153,10 +153,9 @@ # The user requested a bundle deployment. options.bundle and # This is the official Juju GUI charm. - charm.name == settings.JUJU_GUI_CHARM_NAME and - not charm.user and + charm.name == settings.JUJU_GUI_CHARM_NAME and not charm.user and # The charm at this revision does not support bundle deployments. - charm.revision < settings.MINIMUM_CHARM_REVISION_FOR_BUNDLES + charm.revision < settings.MINIMUM_REVISIONS_FOR_BUNDLES[charm.series] ): return parser.error( 'bundle deployments not supported by the requested charm ' @@ -449,16 +448,15 @@ print('bootstrapping the {} environment (type: {})'.format( options.env_name, options.env_type)) - is_local = options.env_type == 'local' requires_sudo = False - if is_local: + if options.env_type == 'local': # If this is a local environment, notify the user that "sudo" will be # required to bootstrap the application, even in newer Juju versions # where "sudo" is invoked by juju-core itself. print('sudo privileges will be required to bootstrap the environment') # If the Juju version is less than 1.17.2 then use sudo for local envs. requires_sudo = juju_version < (1, 17, 2) - already_bootstrapped, bsn_series = app.bootstrap( + already_bootstrapped, bootstrap_node_series = app.bootstrap( options.env_name, requires_sudo=requires_sudo, debug=options.debug) # Retrieve the admin-secret for the current environment. @@ -478,15 +476,15 @@ print('connecting to {}'.format(api_url)) env = app.connect(api_url, admin_secret) - # It is not possible to deploy on the bootstrap node if we are using the - # local provider, or if the bootstrap node series is not compatible with - # the Juju GUI charm. - machine = '0' - if is_local or (bsn_series != settings.JUJU_GUI_PREFERRED_SERIES): - machine = None + # Inspect the environment and deploy the charm if required. + charm_url, machine, service_data, unit_data = app.check_environment( + env, settings.JUJU_GUI_SERVICE_NAME, options.charm_url, + options.env_type, bootstrap_node_series, already_bootstrapped) unit_name = app.deploy_gui( - env, settings.JUJU_GUI_SERVICE_NAME, machine, - charm_url=options.charm_url, check_preexisting=already_bootstrapped) + env, settings.JUJU_GUI_SERVICE_NAME, charm_url, machine, + service_data, unit_data) + + # Observe the deployment progress. address = app.watch(env, unit_name) env.close() url = 'https://{}'.format(address) === modified file 'quickstart/models/envs.py' --- old/quickstart/models/envs.py 2014-04-21 21:02:09 +0000 +++ new/quickstart/models/envs.py 2014-04-23 11:22:44 +0000 @@ -344,7 +344,14 @@ either optional or suitable for automatic generation of their values. For this reason local environments can be safely created given just their name. """ - env_data = {'type': 'local', 'name': name, 'is-default': is_default} + env_data = { + 'type': 'local', + 'name': name, + 'is-default': is_default, + # Workaround for bug 1306537: force tools for the most recent Juju GUI + # supported series to be uploaded. + 'default-series': settings.JUJU_GUI_SUPPORTED_SERIES[-1], + } env_metadata = get_env_metadata(env_type_db, env_data) # Retrieve a list of missing required fields. missing_fields = [ @@ -402,7 +409,6 @@ default_series_field = fields.ChoiceField( 'default-series', choices=settings.JUJU_DEFAULT_SERIES, label='default series', required=False, - default=settings.JUJU_GUI_PREFERRED_SERIES, help='the default Ubuntu series to use for the bootstrap node') is_default_field = fields.BoolField( 'is-default', label='default', allow_mixed=False, required=True, === modified file 'quickstart/settings.py' --- old/quickstart/settings.py 2014-04-03 13:11:27 +0000 +++ new/quickstart/settings.py 2014-04-23 15:53:32 +0000 @@ -18,15 +18,22 @@ from __future__ import unicode_literals +import collections import os -# The URL containing information about the last Juju GUI charm version. -CHARMWORLD_API = 'http://manage.jujucharms.com/api/3/charm/precise/juju-gui' +# The base charmworld API URL containing information about charms. +# This URL must be formatted with a series and a charm name. +CHARMWORLD_API = 'http://manage.jujucharms.com/api/3/charm/{series}/{charm}' -# The default Juju GUI charm URL to use when it is not possible to retrieve it -# from the charmworld API, e.g. due to temporary connection/charmworld errors. -DEFAULT_CHARM_URL = 'cs:precise/juju-gui-86' +# The default Juju GUI charm URLs for each supported series. Used when it is +# not possible to retrieve the charm URL from the charmworld API, e.g. due to +# temporary connection/charmworld errors. +# Keep this list sorted by release date (older first). +DEFAULT_CHARM_URLS = collections.OrderedDict(( + ('precise', 'cs:precise/juju-gui-90'), + ('trusty', 'cs:trusty/juju-gui-2'), +)) # The quickstart app short description. DESCRIPTION = 'set up a Juju environment (including the GUI) in very few steps' @@ -50,11 +57,9 @@ JUJU_GUI_SERVICE_NAME = JUJU_GUI_CHARM_NAME # The set of series supported by the Juju GUI charm. -JUJU_GUI_SUPPORTED_SERIES = ('precise',) - -# The preferred series for the Juju GUI charm. It will be the newest, -# assuming our naming convention holds. -JUJU_GUI_PREFERRED_SERIES = sorted(JUJU_GUI_SUPPORTED_SERIES).pop() - -# The minimum Juju GUI charm revision supporting bundle deployments. -MINIMUM_CHARM_REVISION_FOR_BUNDLES = 80 +JUJU_GUI_SUPPORTED_SERIES = tuple(DEFAULT_CHARM_URLS.keys()) + +# The minimum Juju GUI charm revision supporting bundle deployments, for each +# supported series. Assume not listed series to always support bundles. +MINIMUM_REVISIONS_FOR_BUNDLES = collections.defaultdict( + lambda: 0, {'precise': 80}) === modified file 'quickstart/tests/cli/test_views.py' --- old/quickstart/tests/cli/test_views.py 2014-01-28 20:35:42 +0000 +++ new/quickstart/tests/cli/test_views.py 2014-04-23 12:20:35 +0000 @@ -212,7 +212,7 @@ mock_env_edit.assert_called_once_with( self.app, self.env_type_db, env_db, self.save_callable, {'type': env_type, - 'default-series': settings.JUJU_GUI_PREFERRED_SERIES}) + 'default-series': settings.JUJU_GUI_SUPPORTED_SERIES[-1]}) # Reset the mock so that it does not include any calls on the next # loop cycle. mock_env_edit.reset_mock() === modified file 'quickstart/tests/helpers.py' --- old/quickstart/tests/helpers.py 2014-03-14 12:43:23 +0000 +++ new/quickstart/tests/helpers.py 2014-04-23 13:08:12 +0000 @@ -226,13 +226,8 @@ class WatcherDataTestsMixin(object): """Shared methods for testing Juju mega-watcher data.""" - def _make_change(self, entity, action, default_data, data): - if data is not None: - default_data.update(data) - return entity, action, default_data - - def make_service_change(self, action='change', data=None): - """Create and return a change on a service. + def make_service_data(self, data=None): + """Create and return a data dictionary for a service. The passed data can be used to override default values. """ @@ -242,12 +237,30 @@ 'Life': 'alive', 'Name': 'my-gui', } - return self._make_change('service', action, default_data, data) + if data is not None: + default_data.update(data) + return default_data + + def make_service_change(self, action='change', data=None): + """Create and return a change on a service. + + The passed data can be used to override default values. + """ + return 'service', action, self.make_service_data(data) + + def make_unit_data(self, data=None): + """Create and return a data dictionary for a unit. + + The passed data can be used to override default values. + """ + default_data = {'Name': 'my-gui/47', 'Service': 'my-gui'} + if data is not None: + default_data.update(data) + return default_data def make_unit_change(self, action='change', data=None): """Create and return a change on a unit. The passed data can be used to override default values. """ - default_data = {'Name': 'my-gui/47', 'Service': 'my-gui'} - return self._make_change('unit', action, default_data, data) + return 'unit', action, self.make_unit_data(data) === modified file 'quickstart/tests/models/test_envs.py' --- old/quickstart/tests/models/test_envs.py 2014-04-21 21:02:09 +0000 +++ new/quickstart/tests/models/test_envs.py 2014-04-23 12:20:35 +0000 @@ -29,6 +29,7 @@ import mock import yaml +from quickstart import settings from quickstart.models import ( envs, fields, @@ -619,8 +620,13 @@ # value should be the admin-secret. admin_secret = env_data.pop('admin-secret', '') self.assertNotEqual(0, len(admin_secret)) - expected = {'type': 'local', 'name': 'my-lxc', 'is-default': False} - self.assertEqual(expected, env_data) + expected_env_data = { + 'type': 'local', + 'name': 'my-lxc', + 'is-default': False, + 'default-series': settings.JUJU_GUI_SUPPORTED_SERIES[-1], + } + self.assertEqual(expected_env_data, env_data) def test_default(self): # The resulting env_data is correctly structured for default envs. @@ -629,8 +635,13 @@ # See the comment about auto-generated fields in the test method above. admin_secret = env_data.pop('admin-secret', '') self.assertNotEqual(0, len(admin_secret)) - expected = {'type': 'local', 'name': 'my-default', 'is-default': True} - self.assertEqual(expected, env_data) + expected_env_data = { + 'type': 'local', + 'name': 'my-default', + 'is-default': True, + 'default-series': settings.JUJU_GUI_SUPPORTED_SERIES[-1], + } + self.assertEqual(expected_env_data, env_data) class TestRemoveEnv( === modified file 'quickstart/tests/test_app.py' --- old/quickstart/tests/test_app.py 2014-04-21 21:02:09 +0000 +++ new/quickstart/tests/test_app.py 2014-04-23 15:53:32 +0000 @@ -725,173 +725,357 @@ @helpers.mock_print -class TestDeployGui( +class TestCheckEnvironment( ProgramExitTestsMixin, helpers.WatcherDataTestsMixin, unittest.TestCase): - charm_url = 'cs:precise/juju-gui-100' - - def make_env(self, unit_name=None, service_data=None, unit_data=None): + def make_env(self, include_data=False, side_effect=None): """Create and return a mock environment object. - Set up the object so that a call to add_unit returns the given - unit_name, and a call to status returns a status object containing the - service and unit described by the given service_data and unit_data. + If include_data is True, set up the object so that a call to status + returns a status object containing service and unit data. + + The side_effect argument can be used to simulate status errors. """ env = mock.Mock() - # Set up the add_unit return value. - if unit_name is not None: - env.add_unit.return_value = {'Units': [unit_name]} # Set up the get_status return value. status = [] - if service_data is not None: - status.append(self.make_service_change(data=service_data)) - if unit_data is not None: - status.append(self.make_unit_change(data=unit_data)) + if include_data: + status = [self.make_service_change(), self.make_unit_change()] env.get_status.return_value = status + env.get_status.side_effect = side_effect return env - def patch_get_charm_url(self, side_effect=None): + def patch_get_charm_url(self, return_value=None, side_effect=None): """Patch the get_charm_url helper function.""" - if side_effect is None: - side_effect = [self.charm_url] - mock_get_charm_url = mock.Mock(side_effect=side_effect) + mock_get_charm_url = mock.Mock( + return_value=return_value, side_effect=side_effect) return mock.patch('quickstart.utils.get_charm_url', mock_get_charm_url) - def check_provided_charm_url( - self, charm_url, mock_print, expected_logs=None): - """Ensure the service is deployed and exposed with the given charm URL. - - Also check the expected warnings, if they are provided, are logged. - """ - env = self.make_env(unit_name='my-gui/42') - with helpers.assert_logs(expected_logs or [], level='warn'): - app.deploy_gui(env, 'my-gui', '0', charm_url=charm_url) - env.assert_has_calls([ - mock.call.deploy('my-gui', charm_url, num_units=0), - mock.call.expose('my-gui'), - mock.call.add_unit('my-gui', machine_spec='0'), - ]) - mock_print.assert_has_calls([ - mock.call('requesting my-gui deployment'), - mock.call('charm URL: {}'.format(charm_url)), - ]) - - def check_existing_charm_url( - self, charm_url, mock_print, expected_logs=None): - """Ensure the service is correctly found with the given charm URL. - - Also check the expected warnings, if they are provided, are logged. - """ - service_data = {'CharmURL': charm_url} - env = self.make_env(unit_name='my-gui/42', service_data=service_data) - with helpers.assert_logs(expected_logs or [], level='warn'): - app.deploy_gui(env, 'my-gui', '0', check_preexisting=True) - env.assert_has_calls([ - mock.call.get_status(), - mock.call.add_unit('my-gui', machine_spec='0'), - ]) - mock_print.assert_has_calls([ - mock.call('service my-gui already deployed'), - mock.call('charm URL: {}'.format(charm_url)), - ]) - - def test_deployment(self, mock_print): - # The function correctly deploys and exposes the service, retrieving - # the charm URL from the charmworld API. - env = self.make_env(unit_name='my-gui/42') - with self.patch_get_charm_url(): - unit_name = app.deploy_gui(env, 'my-gui', '0') - self.assertEqual('my-gui/42', unit_name) - env.assert_has_calls([ - mock.call.deploy('my-gui', self.charm_url, num_units=0), - mock.call.expose('my-gui'), - mock.call.add_unit('my-gui', machine_spec='0'), - ]) + def test_environment_just_bootstrapped(self, mock_print): + # The function correctly retrieves the charm URL and machine, and + # handles the case when the charm URL is not provided by the user. + # In this scenario, the environment has been bootstrapped by + # quickstart, so there is no need to check its status. For this reason, + # service_data and unit_data should be set to None. + env = self.make_env() + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'trusty' + check_preexisting = False + with self.patch_get_charm_url( + return_value='cs:trusty/juju-gui-42') as mock_get_charm_url: + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) # There is no need to call status if the environment was just created. self.assertFalse(env.get_status.called) + # The charm URL has been retrieved from charmworld based on the current + # bootstrap node series. + self.assertEqual('cs:trusty/juju-gui-42', url) + mock_get_charm_url.assert_called_once_with(bootstrap_node_series) + # Since the bootstrap node series is supported by the GUI charm, the + # GUI unit can be deployed to machine 0. + self.assertEqual('0', machine) + # When not checking for pre-existing service and/or unit, the + # corresponding service and unit data are set to None. + self.assertIsNone(service_data) + self.assertIsNone(unit_data) + # Ensure the function output makes sense. + self.assertEqual(2, mock_print.call_count) mock_print.assert_has_calls([ - mock.call('requesting my-gui deployment'), - mock.call('charm URL: {}'.format(self.charm_url)), - mock.call('my-gui deployment request accepted'), - mock.call('exposing service my-gui'), - mock.call('requesting new unit deployment'), - mock.call('my-gui/42 deployment request accepted'), + mock.call('bootstrap node series: trusty'), + mock.call('charm URL: cs:trusty/juju-gui-42'), ]) def test_existing_environment_without_entities(self, mock_print): - # The deployment is processed in an already bootstrapped environment - # with no relevant entities in it. - env = self.make_env(unit_name='my-gui/42') - with self.patch_get_charm_url(): - unit_name = app.deploy_gui( - env, 'my-gui', '0', check_preexisting=True) - self.assertEqual('my-gui/42', unit_name) - env.assert_has_calls([ - mock.call.get_status(), - mock.call.deploy('my-gui', self.charm_url, num_units=0), - mock.call.expose('my-gui'), - mock.call.add_unit('my-gui', machine_spec='0'), - ]) + # The function correctly retrieves the charm URL and machine. + # In this scenario, the environment was already bootstrapped, but it + # does not include the GUI. For this reason, service_data and unit_data + # are set to None. + env = self.make_env() + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'precise' + check_preexisting = True + with self.patch_get_charm_url( + return_value='cs:precise/juju-gui-42') as mock_get_charm_url: + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # The environment status has been retrieved. + env.get_status.assert_called_once_with() + # The charm URL has been retrieved from charmworld based on the current + # bootstrap node series. + self.assertEqual('cs:precise/juju-gui-42', url) + mock_get_charm_url.assert_called_once_with(bootstrap_node_series) + # Since the bootstrap node series is supported by the GUI charm, the + # GUI unit can be deployed to machine 0. + self.assertEqual('0', machine) + # The service and unit data are set to None. + self.assertIsNone(service_data) + self.assertIsNone(unit_data) + # Ensure the function output makes sense. + self.assertEqual(2, mock_print.call_count) + mock_print.assert_has_calls([ + mock.call('bootstrap node series: precise'), + mock.call('charm URL: cs:precise/juju-gui-42'), + ]) + + def test_existing_environment_with_entities(self, mock_print): + # The function correctly retrieves the charm URL and machine when the + # environment is already bootstrapped and includes a Juju GUI unit. + # In this case service_data and unit_data are actually populated. + env = self.make_env(include_data=True) + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'precise' + check_preexisting = True + with self.patch_get_charm_url() as mock_get_charm_url: + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # The environment status has been retrieved. + env.get_status.assert_called_once_with() + # The charm URL has been retrieved from the environment. + self.assertEqual('cs:precise/juju-gui-47', url) + self.assertFalse(mock_get_charm_url.called) + # Since the bootstrap node series is supported by the GUI charm, the + # GUI unit can be safely deployed to machine 0. + self.assertEqual('0', machine) + # The service and unit data are correctly returned. + self.assertEqual(self.make_service_data(), service_data) + self.assertEqual(self.make_unit_data(), unit_data) + + def test_bootstrap_node_series_not_supported(self, mock_print): + # If the bootstrap node is not suitable for hosting the Juju GUI unit, + # the returned machine is set to None. + env = self.make_env() + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'saucy' + check_preexisting = False + with self.patch_get_charm_url( + return_value='cs:trusty/juju-gui-42') as mock_get_charm_url: + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # The charm URL has been retrieved from charmworld using the most + # recent supported series. + self.assertEqual('cs:trusty/juju-gui-42', url) + mock_get_charm_url.assert_called_once_with('trusty') + # The Juju GUI unit cannot be deployed to saucy machine 0. + self.assertIsNone(machine) + # Ensure the function output makes sense. + self.assertEqual(2, mock_print.call_count) + mock_print.assert_has_calls([ + mock.call('bootstrap node series: saucy'), + mock.call('charm URL: cs:trusty/juju-gui-42'), + ]) + + def test_local_provider(self, mock_print): + # If the local provider is used the Juju GUI unit cannot be deployed to + # machine 0. + env = self.make_env() + charm_url = None + env_type = 'local' + bootstrap_node_series = 'trusty' + check_preexisting = False + with self.patch_get_charm_url(return_value='cs:trusty/juju-gui-42'): + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # The charm URL has been correctly retrieved from charmworld. + self.assertEqual('cs:trusty/juju-gui-42', url) + # The Juju GUI unit cannot be deployed to localhost. + self.assertIsNone(machine) def test_default_charm_url(self, mock_print): - # The function correctly deploys and exposes the service, even if it is - # not able to retrieve the charm URL from the charmworld API. + # A default charm URL suitable to be deployed in the bootstrap node is + # returned if the charmworld API is not reachable. + env = self.make_env() + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'precise' + check_preexisting = False + with self.patch_get_charm_url(side_effect=IOError('boo!')): + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # The default charm URL for the given series is returned. + self.assertEqual(settings.DEFAULT_CHARM_URLS['precise'], url) + self.assertEqual('0', machine) + + def test_most_recent_default_charm_url(self, mock_print): + # The default charm URL corresponding to the most recent series + # supported by the GUI is returned if the charmworld API is not + # reachable and the bootstrap node cannot host the Juju GUI unit. + env = self.make_env() + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'saucy' + check_preexisting = False + with self.patch_get_charm_url(side_effect=IOError('boo!')): + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # The default charm URL for the given series is returned. + series = settings.JUJU_GUI_SUPPORTED_SERIES[-1] + self.assertEqual(settings.DEFAULT_CHARM_URLS[series], url) + self.assertIsNone(machine) + + def test_charm_url_provided(self, mock_print): + # The function knows when a custom charm URL can be deployed in the + # bootstrap node. + env = self.make_env() + charm_url = 'cs:~juju-gui/trusty/juju-gui-100' + env_type = 'ec2' + bootstrap_node_series = 'trusty' + check_preexisting = False + with self.patch_get_charm_url() as mock_get_charm_url: + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # There is no need to call the charmword API if the charm URL is + # provided by the user. + self.assertFalse(mock_get_charm_url.called) + # The provided charm URL has been correctly returned. + self.assertEqual(charm_url, url) + # Since the provided charm series is trusty, the charm itself can be + # safely deployed to machine 0. + self.assertEqual('0', machine) + # Ensure the function output makes sense. + self.assertEqual(2, mock_print.call_count) + mock_print.assert_has_calls([ + mock.call('bootstrap node series: trusty'), + mock.call('charm URL: cs:~juju-gui/trusty/juju-gui-100'), + ]) + + def test_charm_url_provided_series_not_supported(self, mock_print): + # The function knows when a custom charm URL cannot be deployed in the + # bootstrap node. + env = self.make_env() + charm_url = 'cs:~juju-gui/trusty/juju-gui-100' + env_type = 'ec2' + bootstrap_node_series = 'precise' + check_preexisting = False + with self.patch_get_charm_url() as mock_get_charm_url: + url, machine, service_data, unit_data = app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + # There is no need to call the charmword API if the charm URL is + # provided by the user. + self.assertFalse(mock_get_charm_url.called) + # The provided charm URL has been correctly returned. + self.assertEqual(charm_url, url) + # Since the provided charm series is not precise, the charm must be + # deployed to a new machine. + self.assertIsNone(machine) + # Ensure the function output makes sense. + self.assertEqual(2, mock_print.call_count) + mock_print.assert_has_calls([ + mock.call('bootstrap node series: precise'), + mock.call('charm URL: cs:~juju-gui/trusty/juju-gui-100'), + ]) + + def test_status_error(self, mock_print): + # A ProgramExit is raised if an error occurs in the status API call. + env = self.make_env(side_effect=self.make_env_error('bad wolf')) + charm_url = None + env_type = 'ec2' + bootstrap_node_series = 'trusty' + check_preexisting = True + with self.assert_program_exit('bad API response: bad wolf'): + app.check_environment( + env, 'my-gui', charm_url, env_type, bootstrap_node_series, + check_preexisting) + env.get_status.assert_called_once_with() + + +@helpers.mock_print +class TestDeployGui( + ProgramExitTestsMixin, helpers.WatcherDataTestsMixin, + unittest.TestCase): + + charm_url = 'cs:trusty/juju-gui-42' + + def make_env(self, unit_name=None): + """Create and return a mock environment object. + + Set up the mock object so that a call to env.add_unit returns the given + unit_name. + """ + env = mock.Mock() + # Set up the add_unit return value. + if unit_name is not None: + env.add_unit.return_value = {'Units': [unit_name]} + return env + + def test_deployment(self, mock_print): + # The function correctly deploys and exposes the service in the case + # the service and its unit are not present in the environment. env = self.make_env(unit_name='my-gui/42') - log = 'unable to retrieve the my-gui charm URL from the API: boo!' - with self.patch_get_charm_url(side_effect=IOError('boo!')): - # A warning is logged which notifies we are using the default URL. - with helpers.assert_logs([log], level='warn'): - app.deploy_gui(env, 'my-gui', '0') + service_data = unit_data = None + unit_name = app.deploy_gui( + env, 'my-gui', self.charm_url, '0', service_data, unit_data) + self.assertEqual('my-gui/42', unit_name) env.assert_has_calls([ - mock.call.deploy( - 'my-gui', settings.DEFAULT_CHARM_URL, num_units=0), + # The service has been deployed. + mock.call.deploy('my-gui', self.charm_url, num_units=0), + # The service has been exposed. mock.call.expose('my-gui'), + # One service unit has been added. mock.call.add_unit('my-gui', machine_spec='0'), ]) + self.assertEqual(5, mock_print.call_count) mock_print.assert_has_calls([ mock.call('requesting my-gui deployment'), - mock.call('charm URL: {}'.format(settings.DEFAULT_CHARM_URL)), + mock.call('my-gui deployment request accepted'), + mock.call('exposing service my-gui'), + mock.call('requesting new unit deployment'), + mock.call('my-gui/42 deployment request accepted'), ]) def test_existing_service(self, mock_print): # The deployment is executed reusing an already deployed service. - env = self.make_env(unit_name='my-gui/42', service_data={}) + env = self.make_env(unit_name='my-gui/42') + service_data = self.make_service_data() + unit_data = None unit_name = app.deploy_gui( - env, 'my-gui', '0', check_preexisting=True) + env, 'my-gui', self.charm_url, '0', service_data, unit_data) self.assertEqual('my-gui/42', unit_name) - env.assert_has_calls([ - mock.call.get_status(), - mock.call.add_unit('my-gui', machine_spec='0'), - ]) + # One service unit has been added. + env.add_unit.assert_called_once_with('my-gui', machine_spec='0') # The service is not re-deployed. self.assertFalse(env.deploy.called) # The service is not re-exposed. self.assertFalse(env.expose.called) + self.assertEqual(3, mock_print.call_count) mock_print.assert_has_calls([ mock.call('service my-gui already deployed'), - mock.call('charm URL: cs:precise/juju-gui-47'), mock.call('requesting new unit deployment'), mock.call('my-gui/42 deployment request accepted'), ]) def test_existing_service_unexposed(self, mock_print): # The existing service is exposed if required. - service_data = {'Exposed': False} - env = self.make_env(unit_name='my-gui/42', service_data=service_data) + env = self.make_env(unit_name='my-gui/42') + service_data = self.make_service_data({'Exposed': False}) + unit_data = None unit_name = app.deploy_gui( - env, 'my-gui', '1', check_preexisting=True) + env, 'my-gui', self.charm_url, '1', service_data, unit_data) self.assertEqual('my-gui/42', unit_name) env.assert_has_calls([ - mock.call.get_status(), + # The service has been exposed. mock.call.expose('my-gui'), + # One service unit has been added. mock.call.add_unit('my-gui', machine_spec='1'), ]) # The service is not re-deployed. self.assertFalse(env.deploy.called) + self.assertEqual(4, mock_print.call_count) mock_print.assert_has_calls([ mock.call('service my-gui already deployed'), - mock.call('charm URL: cs:precise/juju-gui-47'), mock.call('exposing service my-gui'), mock.call('requesting new unit deployment'), mock.call('my-gui/42 deployment request accepted'), @@ -899,105 +1083,49 @@ def test_existing_service_and_unit(self, mock_print): # A unit is reused if a suitable one is already present. - env = self.make_env(service_data={}, unit_data={}) + env = self.make_env() + service_data = self.make_service_data() + unit_data = self.make_unit_data() unit_name = app.deploy_gui( - env, 'my-gui', '0', check_preexisting=True) + env, 'my-gui', self.charm_url, '0', service_data, unit_data) self.assertEqual('my-gui/47', unit_name) - env.get_status.assert_called_once_with() # The service is not re-deployed. self.assertFalse(env.deploy.called) # The service is not re-exposed. self.assertFalse(env.expose.called) # The unit is not re-added. self.assertFalse(env.add_unit.called) + self.assertEqual(2, mock_print.call_count) mock_print.assert_has_calls([ mock.call('service my-gui already deployed'), - mock.call('charm URL: cs:precise/juju-gui-47'), mock.call('reusing unit my-gui/47'), ]) def test_new_machine(self, mock_print): # The unit is correctly deployed in a new machine. env = self.make_env(unit_name='my-gui/42') - with self.patch_get_charm_url(): - unit_name = app.deploy_gui(env, 'my-gui', None) + service_data = unit_data = None + unit_name = app.deploy_gui( + env, 'my-gui', self.charm_url, None, service_data, unit_data) self.assertEqual('my-gui/42', unit_name) env.assert_has_calls([ + # The service has been deployed. mock.call.deploy('my-gui', self.charm_url, num_units=0), + # The service has been exposed. mock.call.expose('my-gui'), + # One service unit has been added to a new machine. mock.call.add_unit('my-gui', machine_spec=None), ]) - def test_offical_charm_url_provided(self, mock_print): - # The function correctly deploys and exposes the service using a user - # provided revision of the Juju GUI charm URL. - self.check_provided_charm_url('cs:precise/juju-gui-4242', mock_print) - - def test_customized_charm_url_provided(self, mock_print): - # A customized charm URL is correctly recognized and logged if provided - # by the user. - self.check_provided_charm_url( - 'cs:~juju-gui/precise/juju-gui-42', mock_print, - expected_logs=['using a customized juju-gui charm']) - - def test_outdated_charm_url_provided(self, mock_print): - # An outdated charm URL is correctly recognized and logged if provided - # by the user. - self.check_provided_charm_url( - 'cs:precise/juju-gui-1', mock_print, - expected_logs=[ - 'charm is outdated and may not support bundle deployments']) - - def test_unexpected_charm_url_provided(self, mock_print): - # An unexpected charm URL is correctly recognized and logged if - # provided by the user. - self.check_provided_charm_url( - 'cs:precise/exterminate-the-gui-666', mock_print, - expected_logs=[ - 'unexpected URL for the juju-gui charm: ' - 'the service may not work as expected']) - - def test_offical_charm_url_existing(self, mock_print): - # An existing official charm URL is correctly found. - self.check_existing_charm_url('cs:precise/juju-gui-4242', mock_print) - - def test_customized_charm_url_existing(self, mock_print): - # An existing customized charm URL is correctly found and logged. - self.check_existing_charm_url( - 'cs:~juju-gui/precise/juju-gui-42', mock_print, - expected_logs=['using a customized juju-gui charm']) - - def test_outdated_charm_url_existing(self, mock_print): - # An existing but outdated charm URL is correctly found and logged. - self.check_existing_charm_url( - 'cs:precise/juju-gui-1', mock_print, - expected_logs=[ - 'charm is outdated and may not support bundle deployments']) - - def test_unexpected_charm_url_existing(self, mock_print): - # An existing but unexpected charm URL is correctly found and logged. - self.check_existing_charm_url( - 'cs:precise/exterminate-the-gui-666', mock_print, - expected_logs=[ - 'unexpected URL for the juju-gui charm: ' - 'the service may not work as expected']) - - def test_status_error(self, mock_print): - # A ProgramExit is raised if an error occurs in the status API call. - env = self.make_env() - env.get_status.side_effect = self.make_env_error('bad wolf') - with self.assert_program_exit('bad API response: bad wolf'): - app.deploy_gui( - env, 'another-gui', '0', check_preexisting=True) - env.get_status.assert_called_once_with() - def test_deploy_error(self, mock_print): # A ProgramExit is raised if an error occurs in the deploy API call. env = self.make_env() env.deploy.side_effect = self.make_env_error('bad wolf') - with self.patch_get_charm_url(): - with self.assert_program_exit('bad API response: bad wolf'): - app.deploy_gui(env, 'another-gui', '0') + service_data = unit_data = None + with self.assert_program_exit('bad API response: bad wolf'): + app.deploy_gui( + env, 'another-gui', self.charm_url, '0', + service_data, unit_data) env.deploy.assert_called_once_with( 'another-gui', self.charm_url, num_units=0) @@ -1005,18 +1133,22 @@ # A ProgramExit is raised if an error occurs in the expose API call. env = self.make_env() env.expose.side_effect = self.make_env_error('bad wolf') - with self.patch_get_charm_url(): - with self.assert_program_exit('bad API response: bad wolf'): - app.deploy_gui(env, 'another-gui', '0') + service_data = unit_data = None + with self.assert_program_exit('bad API response: bad wolf'): + app.deploy_gui( + env, 'another-gui', self.charm_url, '0', + service_data, unit_data) env.expose.assert_called_once_with('another-gui') def test_add_unit_error(self, mock_print): # A ProgramExit is raised if an error occurs in the add_unit API call. env = self.make_env() env.add_unit.side_effect = self.make_env_error('bad wolf') - with self.patch_get_charm_url(): - with self.assert_program_exit('bad API response: bad wolf'): - app.deploy_gui(env, 'another-gui', '0') + service_data = unit_data = None + with self.assert_program_exit('bad API response: bad wolf'): + app.deploy_gui( + env, 'another-gui', self.charm_url, '0', + service_data, unit_data) env.add_unit.assert_called_once_with('another-gui', machine_spec='0') def test_other_errors(self, mock_print): @@ -1024,9 +1156,11 @@ error = ValueError('explode!') env = self.make_env(unit_name='my-gui/42') env.expose.side_effect = error - with self.patch_get_charm_url(): - with self.assertRaises(ValueError) as context_manager: - app.deploy_gui(env, 'juju-gui', '0') + service_data = unit_data = None + with self.assertRaises(ValueError) as context_manager: + app.deploy_gui( + env, 'juju-gui', self.charm_url, '0', + service_data, unit_data) env.deploy.assert_called_once_with( 'juju-gui', self.charm_url, num_units=0) env.expose.assert_called_once_with('juju-gui') === modified file 'quickstart/tests/test_manage.py' --- old/quickstart/tests/test_manage.py 2014-04-22 12:20:10 +0000 +++ new/quickstart/tests/test_manage.py 2014-04-23 13:08:12 +0000 @@ -719,9 +719,19 @@ def test_no_bundle(self, mock_app, mock_open): # The application runs correctly if no bundle is provided. mock_app.ensure_dependencies.return_value = (1, 18, 0) - mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. + mock_app.bootstrap.return_value = (True, 'trusty') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + service_data = {'Name': 'juju-gui'} + unit_data = {'Name': 'juju-gui/0'} + mock_app.check_environment.return_value = ( + 'cs:trusty/juju-gui-42', '0', service_data, unit_data) mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error + # Make mock_app.watch return the Juju GUI unit address. mock_app.watch.return_value = '1.2.3.4' + # Make mock_app.create_auth_token return a fake authentication token. mock_app.create_auth_token.return_value = 'AUTHTOKEN' options = self.make_options() manage.run(options) @@ -736,10 +746,13 @@ mock.call('wss://1.2.3.4:443/ws', options.admin_secret), mock.call().close(), ]) + mock_app.check_environment.assert_called_once_with( + mock_app.connect(), settings.JUJU_GUI_SERVICE_NAME, + options.charm_url, options.env_type, mock_app.bootstrap()[1], + mock_app.bootstrap()[0]) mock_app.deploy_gui.assert_called_once_with( - mock_app.connect(), settings.JUJU_GUI_SERVICE_NAME, '0', - charm_url=options.charm_url, - check_preexisting=mock_app.bootstrap()[0]) + mock_app.connect(), settings.JUJU_GUI_SERVICE_NAME, + 'cs:trusty/juju-gui-42', '0', service_data, unit_data) mock_app.watch.assert_called_once_with( mock_app.connect(), mock_app.deploy_gui()) mock_app.create_auth_token.assert_called_once_with(mock_app.connect()) @@ -748,8 +761,16 @@ self.assertFalse(mock_app.deploy_bundle.called) def test_no_token(self, mock_app, mock_open): + # The process continues even if the authentication token cannot be + # retrieved. mock_app.create_auth_token.return_value = None + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:precise/juju-gui-42', '0', None, None) options = self.make_options() manage.run(options) mock_app.create_auth_token.assert_called_once_with(mock_app.connect()) @@ -761,7 +782,14 @@ options = self.make_options( bundle='/my/bundle/file.yaml', bundle_yaml='mybundle: contents', bundle_name='mybundle', bundle_services=['service1', 'service2']) - mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. + mock_app.bootstrap.return_value = (True, 'trusty') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:trusty/juju-gui-42', '0', None, None) + # Make mock_app.watch return the Juju GUI unit address. mock_app.watch.return_value = 'gui.example.com' manage.run(options) mock_app.deploy_bundle.assert_called_once_with( @@ -774,7 +802,13 @@ options = self.make_options(env_type='local') versions = [ (1, 17, 2), (1, 17, 10), (1, 18, 0), (1, 18, 2), (2, 16, 1)] + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:precise/juju-gui-42', '0', None, None) for version in versions: mock_app.ensure_dependencies.return_value = version manage.run(options) @@ -788,7 +822,13 @@ # Sudo privileges are required if the Juju version is < 1.17.2. options = self.make_options(env_type='local') versions = [(0, 7, 9), (1, 0, 0), (1, 16, 42), (1, 17, 0), (1, 17, 1)] - mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. + mock_app.bootstrap.return_value = (True, 'trusty') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:trusty/juju-gui-42', '0', None, None) for version in versions: mock_app.ensure_dependencies.return_value = version manage.run(options) @@ -800,14 +840,26 @@ # Sudo privileges are never required for non-local environments. options = self.make_options(env_type='ec2') mock_app.ensure_dependencies.return_value = (1, 14, 0) + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:precise/juju-gui-42', '0', None, None) manage.run(options) mock_app.bootstrap.assert_called_once_with( options.env_name, requires_sudo=False, debug=options.debug) def test_no_browser(self, mock_app, mock_open): # It is possible to avoid opening the GUI in the browser. - mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. + mock_app.bootstrap.return_value = (True, 'trusty') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:trusty/juju-gui-42', '0', None, None) options = self.make_options(open_browser=False) manage.run(options) self.assertFalse(mock_open.called) @@ -816,7 +868,13 @@ # If an admin secret is fetched from jenv it is used, even if one is # found in environments.yaml, as set in options.admin_secret. mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_success + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:precise/juju-gui-42', '0', None, None) options = self.make_options(admin_secret='secret in environments.yaml') manage.run(options) mock_app.connect.assert_has_calls([ @@ -827,7 +885,13 @@ # If an admin secret is not fetched from jenv, then the one from # environments.yaml is used, as found in options.admin_secret. mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:precise/juju-gui-42', '0', None, None) options = self.make_options(admin_secret='secret in environments.yaml') manage.run(options) mock_app.connect.assert_has_calls([ @@ -838,7 +902,13 @@ # If admin-secret cannot be found anywhere a ProgramExit is called. mock_app.ProgramExit = app.ProgramExit mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error + # Make mock_app.bootstrap return the already_bootstrapped flag and the + # bootstrap node series. mock_app.bootstrap.return_value = (True, 'precise') + # Make mock_app.check_environment return the charm URL, the machine + # where to deploy the charm, the service and unit data. + mock_app.check_environment.return_value = ( + 'cs:precise/juju-gui-42', '0', None, None) options = self.make_options( admin_secret=None, env_name='local', === modified file 'quickstart/tests/test_utils.py' --- old/quickstart/tests/test_utils.py 2014-03-14 12:03:55 +0000 +++ new/quickstart/tests/test_utils.py 2014-04-23 12:20:35 +0000 @@ -36,6 +36,7 @@ settings, utils, ) +from quickstart.models import charms from quickstart.tests import helpers @@ -158,19 +159,25 @@ @mock.patch('__builtin__.print', mock.Mock()) -class TestCheckGuiCharmUrl(unittest.TestCase): +class TestParseGuiCharmUrl(unittest.TestCase): + + def test_charm_instance_returned(self): + # A charm instance is correctly returned. + charm = utils.parse_gui_charm_url('cs:trusty/juju-gui-42') + self.assertIsInstance(charm, charms.Charm) + self.assertEqual('cs:trusty/juju-gui-42', charm.url()) def test_customized(self): # A customized charm URL is properly logged. expected = 'using a customized juju-gui charm' with helpers.assert_logs([expected], level='warn'): - utils.check_gui_charm_url('cs:~juju-gui/precise/juju-gui-28') + utils.parse_gui_charm_url('cs:~juju-gui/precise/juju-gui-28') def test_outdated(self): # An outdated charm URL is properly logged. expected = 'charm is outdated and may not support bundle deployments' with helpers.assert_logs([expected], level='warn'): - utils.check_gui_charm_url('cs:precise/juju-gui-1') + utils.parse_gui_charm_url('cs:precise/juju-gui-1') def test_unexpected(self): # An unexpected charm URL is properly logged. @@ -178,12 +185,12 @@ 'unexpected URL for the juju-gui charm: the service may not work ' 'as expected') with helpers.assert_logs([expected], level='warn'): - utils.check_gui_charm_url('cs:precise/another-gui-42') + utils.parse_gui_charm_url('cs:precise/another-gui-42') def test_official(self): # No warnings are logged if an up to date charm is passed. with mock.patch('logging.warn') as mock_warn: - utils.check_gui_charm_url('cs:precise/juju-gui-100') + utils.parse_gui_charm_url('cs:precise/juju-gui-100') self.assertFalse(mock_warn.called) @@ -304,18 +311,20 @@ def test_charm_url(self): # The Juju GUI charm URL is correctly returned. - contents = json.dumps({'charm': {'url': 'cs:precise/juju-gui-42'}}) + contents = json.dumps({'charm': {'url': 'cs:trusty/juju-gui-42'}}) with self.patch_urlread(contents=contents) as mock_urlread: - charm_url = utils.get_charm_url() - self.assertEqual('cs:precise/juju-gui-42', charm_url) - mock_urlread.assert_called_once_with(settings.CHARMWORLD_API) + charm_url = utils.get_charm_url('trusty') + self.assertEqual('cs:trusty/juju-gui-42', charm_url) + mock_urlread.assert_called_once_with( + 'http://manage.jujucharms.com/api/3/charm/trusty/juju-gui') def test_io_error(self): # IOErrors are properly propagated. with self.patch_urlread(error=True) as mock_urlread: with self.assertRaises(IOError) as context_manager: - utils.get_charm_url() - mock_urlread.assert_called_once_with(settings.CHARMWORLD_API) + utils.get_charm_url('precise') + mock_urlread.assert_called_once_with( + 'http://manage.jujucharms.com/api/3/charm/precise/juju-gui') self.assertEqual('bad wolf', bytes(context_manager.exception)) def test_value_error(self): @@ -323,8 +332,9 @@ contents = json.dumps({'charm': {}}) with self.patch_urlread(contents=contents) as mock_urlread: with self.assertRaises(ValueError) as context_manager: - utils.get_charm_url() - mock_urlread.assert_called_once_with(settings.CHARMWORLD_API) + utils.get_charm_url('trusty') + mock_urlread.assert_called_once_with( + 'http://manage.jujucharms.com/api/3/charm/trusty/juju-gui') self.assertEqual( 'unable to find the charm URL', bytes(context_manager.exception)) === modified file 'quickstart/utils.py' --- old/quickstart/utils.py 2014-03-14 12:03:55 +0000 +++ new/quickstart/utils.py 2014-04-23 11:22:44 +0000 @@ -105,24 +105,32 @@ return retcode, output.decode('utf-8'), error.decode('utf-8') -def check_gui_charm_url(charm_url): - """Print (to stdout or to logs) info and warnings about the charm URL.""" +def parse_gui_charm_url(charm_url): + """Parse the given charm URL. + + Check if the charm looks like a Juju GUI charm. + Print (to stdout or to logs) info and warnings about the charm URL. + + Return the parsed charm object as an instance of + quickstart.models.charms.Charm. + """ print('charm URL: {}'.format(charm_url)) charm = charms.Charm.from_url(charm_url) charm_name = settings.JUJU_GUI_CHARM_NAME - if charm.name == charm_name: - if charm.user or charm.is_local(): - # This is not the official Juju GUI charm. - logging.warn('using a customized {} charm'.format(charm_name)) - elif charm.revision < settings.MINIMUM_CHARM_REVISION_FOR_BUNDLES: - # This is the official Juju GUI charm, but it is outdated. - logging.warn( - 'charm is outdated and may not support bundle deployments') - else: + if charm.name != charm_name: # This does not seem to be a Juju GUI charm. logging.warn( 'unexpected URL for the {} charm: ' 'the service may not work as expected'.format(charm_name)) + return charm + if charm.user or charm.is_local(): + # This is not the official Juju GUI charm. + logging.warn('using a customized {} charm'.format(charm_name)) + elif charm.revision < settings.MINIMUM_REVISIONS_FOR_BUNDLES[charm.series]: + # This is the official Juju GUI charm, but it is outdated. + logging.warn( + 'charm is outdated and may not support bundle deployments') + return charm def convert_bundle_url(bundle_url): @@ -142,13 +150,15 @@ bundle_id) -def get_charm_url(): +def get_charm_url(series): """Return the charm URL of the latest Juju GUI charm revision. Raise an IOError if any problems occur connecting to the API endpoint. Raise a ValueError if the API returns invalid data. """ - charm_info = json.loads(urlread(settings.CHARMWORLD_API)) + url = settings.CHARMWORLD_API.format( + series=series, charm=settings.JUJU_GUI_CHARM_NAME) + charm_info = json.loads(urlread(url)) charm_url = charm_info.get('charm', {}).get('url') if charm_url is None: raise ValueError(b'unable to find the charm URL') debian/patches/check-unicode-support0000664000000000000000000001107312353254557014772 0ustar Author: Francesco Banconi Description: Check unicode support Origin: upstream, http://bazaar.launchpad.net/~juju-gui/juju-quickstart/trunk/revision/67 Bug: https://launchpad.net/bugs/1311321 Bug-Ubuntu: https://launchpad.net/bugs/1311321 Last-Update: 2014-06-27 ------------------------------------------------------------ revno: 67 [merge] committer: Francesco Banconi branch nick: juju-quickstart timestamp: Wed 2014-04-30 11:24:49 -0700 message: Check unicode support. Ensure utf-8 is supported before starting the Urwid interactive session. This way we hope to avoid bad crashes when the user has locale configuration problems. Tests: `make check`. QA: If you have juju-quickstart installed, you should be able to make it crash by overriding all the language env vars, like the following: `LC_ALL=C juju-quickstart -i` You should see a UnicodeEncodeError: 'ascii' codec can't encode character u'\u2582' in position 0: ordinal not in range(128) With this branch, the following should instead work as usual: `LC_ALL=C .venv/bin/python juju-quickstart -i`. I am not sure how to make Urwid fail so that we can QA the system exit in the code, but at least that code path is tested. R=rharding CC= https://codereview.appspot.com/90740043 === modified file 'quickstart/cli/base.py' --- old/quickstart/cli/base.py 2014-01-03 10:22:24 +0000 +++ new/quickstart/cli/base.py 2014-04-24 14:47:18 +0000 @@ -26,6 +26,7 @@ from __future__ import unicode_literals from collections import namedtuple +import sys import urwid @@ -44,6 +45,24 @@ ) +def _check_encoding(): + """Set the Urwid global byte encoding to utf-8. + + Exit the application if, for some reasons, the change does not have effect. + """ + urwid.set_encoding('utf-8') + if not urwid.supports_unicode(): + # Note: the following message must only include ASCII characters. + msg = ( + 'Error: your terminal does not seem to support UTF-8 encoding.\n' + 'Please check your locale settings.\n' + 'On Ubuntu, running the following might fix the problem:\n' + ' sudo locale-gen en_US.UTF-8\n' + ' sudo dpkg-reconfigure locales' + ) + sys.exit(msg.encode('ascii')) + + class _MainLoop(urwid.MainLoop): """A customized Urwid loop. @@ -109,6 +128,7 @@ with the exit shortcut. See the quickstart.cli.views module docstring for more information about this functionality. """ + _check_encoding() # Set up the application header. title = urwid.Text('\npreparing...') header_line = urwid.Divider('\N{LOWER ONE QUARTER BLOCK}') === modified file 'quickstart/tests/cli/test_base.py' --- old/quickstart/tests/cli/test_base.py 2014-01-03 10:22:24 +0000 +++ new/quickstart/tests/cli/test_base.py 2014-04-24 14:49:16 +0000 @@ -18,14 +18,49 @@ from __future__ import unicode_literals +from contextlib import contextmanager import unittest +import mock import urwid from quickstart.cli import base from quickstart.tests.cli import helpers as cli_helpers +class TestCheckEncoding(unittest.TestCase): + + @contextmanager + def patch_urwid(self, supports_unicode=True): + """Patch the urwid.set_encoding and urwid.supports_unicode calls. + + Ensure the mock functions are called once with the expected arguments. + + Make urwid.supports_unicode return the given supports_unicode value. + """ + mock_supports_unicode = mock.Mock(return_value=supports_unicode) + with mock.patch('urwid.set_encoding') as mock_set_encoding: + with mock.patch('urwid.supports_unicode', mock_supports_unicode): + yield + mock_set_encoding.assert_called_once_with('utf-8') + mock_supports_unicode.assert_called_once_with() + + def test_unicode_supported(self): + # The utf-8 encoding is properly set and the function exits without + # errors. + with self.patch_urwid(supports_unicode=True): + base._check_encoding() + + def test_unicode_not_supported(self): + # If unicode is not supported, the program exits with an error. + with self.patch_urwid(supports_unicode=False): + with self.assertRaises(SystemExit) as context_manager: + base._check_encoding() + self.assertIn( + b'Error: your terminal does not seem to support UTF-8 encoding.', + bytes(context_manager.exception)) + + class TestMainLoop(unittest.TestCase): def setUp(self): debian/patches/distro-only-default0000664000000000000000000000112412321006167014443 0ustar Description: default to --distro-only juju-quickstart installed from the archive should only install juju-core from the archive by default. See the bug for rationale. Author: Robie Basak Bug-Ubuntu: https://launchpad.net/bugs/1301481 Forwarded: not-needed Last-Update: 2014-04-08 --- a/quickstart/packaging.py +++ b/quickstart/packaging.py @@ -28,4 +28,4 @@ # base and PyPI releases; # - distro: the distribution repository. This value is usually set in the deb # releases included in the Ubuntu repositories. -JUJU_SOURCE = 'ppa' +JUJU_SOURCE = 'distro' debian/patches/series0000664000000000000000000000014312353260364012036 0ustar distro-only-default make-control-bucket-optional support-trusty-environments check-unicode-support debian/patches/make-control-bucket-optional0000664000000000000000000002332512353254541016244 0ustar Author: Brad Crittenden Description: Make control-bucket optional Origin: upstream, http://bazaar.launchpad.net/~juju-gui/juju-quickstart/trunk/revision/65 Bug: https://launchpad.net/bugs/1309678 Bug-Ubuntu: https://launchpad.net/bugs/1309678 Last-Update: 2014-06-27 ------------------------------------------------------------ revno: 65 [merge] committer: Brad Crittenden branch nick: juju-quickstart timestamp: Tue 2014-04-22 09:16:21 -0400 message: Make control-bucket optional. The existing function get_admin_secret is made generic and the name is changed to get_value_from_jenv. It now takes a keyname to be fetched from the generated file. For both ec2 and openstack the control-bucket field has been made optional with respect to the environments.yaml file. QA: 1) Create an ec2 environment with no control-bucket. 2) Bootstrap that environment. Ensure a control-bucket is in the .jenv file. 3) Run quickstart and see that it uses the existing environment and does not raise an error. R=frankban CC= https://codereview.appspot.com/90060043 === modified file 'quickstart/app.py' --- old/quickstart/app.py 2014-04-04 17:46:47 +0000 +++ new/quickstart/app.py 2014-04-21 21:05:13 +0000 @@ -238,25 +238,27 @@ raise ProgramExit('the state server is not ready:\n{}'.format(details)) -def get_admin_secret(env_name, juju_home): - """Read the admin-secret from the generated environment file. - - At bootstrap, juju (v1.16 and later) writes the admin-secret to a - generated file located in JUJU_HOME. Return the value. +def get_value_from_jenv(env_name, juju_home, key): + + """Read the key from the generated environment file. + + At bootstrap, juju (v1.16 and later) writes a generated file + located in JUJU_HOME. Return the value for the key. + Raise a ValueError if: - the environment file is not found; - the environment file contents are not parsable by YAML; - the YAML contents are not properly structured; - - the admin-secret is not found. + - the key is not found. """ filename = '{}.jenv'.format(env_name) juju_env_file = os.path.expanduser( os.path.join(juju_home, 'environments', filename)) jenv_db = envs.load_generated(juju_env_file) try: - return jenv_db['admin-secret'] + return jenv_db[key] except KeyError: - msg = 'admin-secret not found in {}'.format(juju_env_file) + msg = '{} not found in {}'.format(key, juju_env_file) raise ValueError(msg.encode('utf-8')) === modified file 'quickstart/manage.py' --- old/quickstart/manage.py 2014-04-07 15:52:55 +0000 +++ new/quickstart/manage.py 2014-04-22 12:20:10 +0000 @@ -463,8 +463,8 @@ # Retrieve the admin-secret for the current environment. try: - admin_secret = app.get_admin_secret( - options.env_name, settings.JUJU_HOME) + admin_secret = app.get_value_from_jenv( + options.env_name, settings.JUJU_HOME, 'admin-secret') except ValueError as err: admin_secret = options.admin_secret if admin_secret is None: === modified file 'quickstart/models/envs.py' --- old/quickstart/models/envs.py 2014-04-10 09:22:37 +0000 +++ new/quickstart/models/envs.py 2014-04-21 21:02:09 +0000 @@ -477,7 +477,7 @@ help='The secret key to use to authenticate to AWS. ' 'See the access key help above.'), fields.AutoGeneratedStringField( - 'control-bucket', label='control bucket', required=True, + 'control-bucket', label='control bucket', required=False, help='the globally unique S3 bucket name'), fields.ChoiceField( 'region', choices=ec2_regions, default='us-east-1', @@ -508,7 +508,7 @@ 'Some installations assign public IP addresses by ' 'default without requiring a floating IP address.'), fields.AutoGeneratedStringField( - 'control-bucket', label='control bucket', required=True, + 'control-bucket', label='control bucket', required=False, help='the globally unique swift bucket name'), fields.SuggestionsStringField( 'auth-url', label='authentication URL', required=True, === modified file 'quickstart/tests/models/test_envs.py' --- old/quickstart/tests/models/test_envs.py 2014-04-03 08:24:13 +0000 +++ new/quickstart/tests/models/test_envs.py 2014-04-21 21:02:09 +0000 @@ -745,7 +745,7 @@ 'secret-key', 'control-bucket', 'region', 'is-default'] expected_required = [ 'type', 'name', 'access-key', 'secret-key', - 'control-bucket', 'is-default'] + 'is-default'] self.assert_fields(expected, env_metadata) self.assert_required_fields(expected_required, env_metadata) @@ -760,8 +760,7 @@ 'secret-key', 'is-default'] expected_required = [ 'type', 'name', 'use-floating-ip', - 'control-bucket', 'auth-url', 'tenant-name', 'region', - 'is-default'] + 'auth-url', 'tenant-name', 'region', 'is-default'] self.assert_fields(expected, env_metadata) self.assert_required_fields(expected_required, env_metadata) === modified file 'quickstart/tests/test_app.py' --- old/quickstart/tests/test_app.py 2014-04-04 15:49:16 +0000 +++ new/quickstart/tests/test_app.py 2014-04-21 21:02:09 +0000 @@ -572,23 +572,25 @@ ] + self.make_status_calls(2)) -class TestGetAdminSecret(unittest.TestCase): +class TestGetValueFromJenv(unittest.TestCase): - def test_no_admin_secret(self): + def test_no_key(self): with mock.patch('quickstart.manage.envs.load_generated', lambda x: {}): with self.assertRaises(ValueError) as exc: - app.get_admin_secret('local', '/home/bac/.juju') + app.get_value_from_jenv( + 'local', '/home/bac/.juju', 'my-key') expected = ( - u'admin-secret not found in ' + u'my-key not found in ' '/home/bac/.juju/environments/local.jenv') self.assertIn(expected, bytes(exc.exception)) def test_success(self): expected = 'superchunk' with mock.patch('quickstart.manage.envs.load_generated', - lambda x: {'admin-secret': expected}): - secret = app.get_admin_secret('local', '~bac/.juju') + lambda x: {'my-key': expected}): + secret = app.get_value_from_jenv( + 'local', '~bac/.juju', 'my-key') self.assertEqual(expected, secret) === modified file 'quickstart/tests/test_manage.py' --- old/quickstart/tests/test_manage.py 2014-04-07 10:29:29 +0000 +++ new/quickstart/tests/test_manage.py 2014-04-22 12:20:10 +0000 @@ -706,21 +706,21 @@ return mock.Mock(**options) @staticmethod - def mock_get_admin_secret_success(name, home): - return 'jenv secret' + def mock_get_value_from_jenv_success(name, home, key): + return 'from jenv' @staticmethod - def mock_get_admin_secret_error(name, home): + def mock_get_value_from_jenv_error(name, home, key): fn = '{}.jenv'.format(name) path = os.path.join(home, 'environments', fn) - msg = 'admin-secret not found in {}'.format(path) + msg = '{} not found in {}'.format(key, path) raise ValueError(msg.encode('utf-8')) def test_no_bundle(self, mock_app, mock_open): # The application runs correctly if no bundle is provided. mock_app.ensure_dependencies.return_value = (1, 18, 0) mock_app.bootstrap.return_value = (True, 'precise') - mock_app.get_admin_secret = self.mock_get_admin_secret_error + mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error mock_app.watch.return_value = '1.2.3.4' mock_app.create_auth_token.return_value = 'AUTHTOKEN' options = self.make_options() @@ -815,18 +815,18 @@ def test_admin_secret_fetched(self, mock_app, mock_open): # If an admin secret is fetched from jenv it is used, even if one is # found in environments.yaml, as set in options.admin_secret. - mock_app.get_admin_secret = self.mock_get_admin_secret_success + mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_success mock_app.bootstrap.return_value = (True, 'precise') options = self.make_options(admin_secret='secret in environments.yaml') manage.run(options) mock_app.connect.assert_has_calls([ - mock.call(mock_app.get_api_url(), 'jenv secret'), + mock.call(mock_app.get_api_url(), 'from jenv'), ]) def test_admin_secret_from_environments_yaml(self, mock_app, mock_open): # If an admin secret is not fetched from jenv, then the one from # environments.yaml is used, as found in options.admin_secret. - mock_app.get_admin_secret = self.mock_get_admin_secret_error + mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error mock_app.bootstrap.return_value = (True, 'precise') options = self.make_options(admin_secret='secret in environments.yaml') manage.run(options) @@ -837,7 +837,7 @@ def test_no_admin_secret_found(self, mock_app, mock_open): # If admin-secret cannot be found anywhere a ProgramExit is called. mock_app.ProgramExit = app.ProgramExit - mock_app.get_admin_secret = self.mock_get_admin_secret_error + mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error mock_app.bootstrap.return_value = (True, 'precise') options = self.make_options( admin_secret=None, debian/compat0000664000000000000000000000000212272752443010376 0ustar 8