def main(): """ Main entry point for CLI """ load_maestro_rc() parser = ArgumentParser(prog='maestro', description='DevOps management') sub = parser.add_subparsers() sub_tasks = sub.add_parser('tasks', help='Tasks') sub_tasks.add_argument('-l', '--list', action='store_true', dest='tasks_list', default=False, \ help='Show available tasks') sub_tasks.add_argument('-r', '--run', action='store', dest='tasks_task', \ help='Task to run') sub_tasks.set_defaults(func=parse_tasks) sub_nodes = sub.add_parser('nodes', help='Nodes') sub_nodes.add_argument('-c', '--cloud-provider', action='store', dest='cloud_provider', \ choices=config.AVAILABLE_CLOUD_PROVIDERS, default=None, required=True, \ help='Name of cloud provider to use') sub_nodes.add_argument('-l', '--list', action='store_true', dest='list', default=False, \ help='List all nodes') sub_nodes.add_argument('-t', '--task', action='store', dest='task', \ help='Task to run on nodes') sub_nodes.add_argument('-u', '--user', action='store', dest='user', \ help='Username to use when running task') sub_nodes.add_argument('-p', '--parallel', action='store_true', default=False, \ help='Run task in parallel among nodes') sub_nodes.set_defaults(func=parse_nodes) args = parser.parse_args() args.func(args) # disconnect disconnect_all() sys.exit(0)
def test_load_maestro_rc(self): testrc = tempfile.mktemp() ec2_id = '12345' ec2_key = 'secretkey' with open(testrc, 'w') as f: f.write('EC2_ACCESS_ID={0}\n'.format(ec2_id)) f.write('EC2_SECRET_KEY={0}\n'.format(ec2_key)) load_maestro_rc(testrc) self.assertTrue(os.environ.has_key('EC2_ACCESS_ID')) self.assertTrue(os.environ.has_key('EC2_SECRET_KEY')) self.assertEqual(os.environ.get('EC2_ACCESS_ID'), ec2_id) self.assertEqual(os.environ.get('EC2_SECRET_KEY'), ec2_key)
def decorated(*args, **kwargs): load_maestro_rc() return f(*args, **kwargs)
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from maestro.core import * from maestro import system as sys from maestro.deploy import python as py from maestro.utils import load_maestro_rc from maestro.service import mysql from maestro.service import redis from maestro.service import memcached from maestro.crate import management as crate # load the maestro resource file for provider keys load_maestro_rc() import os import logging # change log levels logging.getLogger('paramiko').setLevel(logging.ERROR) # try to load env password from fabric.api import env env.password = os.environ.get('FABRIC_PASSWORD') if not env.parallel: env.output_prefix = False