from himlarcli import tests as tests tests.is_virtual_env() from himlarcli.keystone import Keystone from himlarcli.nova import Nova #from himlarcli.cinder import Cinder from himlarcli.gnocchi import Gnocchi from himlarcli.cinder import Cinder from himlarcli.parser import Parser from himlarcli.printer import Printer from himlarcli import utils as himutils from datetime import date, timedelta from collections import OrderedDict parser = Parser() options = parser.parse_args() printer = Printer(options.format) kc= Keystone(options.config, debug=options.debug) kc.set_domain(options.domain) kc.set_dry_run(options.dry_run) logger = kc.get_logger() # Billing will always use all regions regions = kc.find_regions() def action_whales(): start = himutils.get_date(options.start, date.today() - timedelta(days=1)) stop = himutils.get_date(options.end, date.today() + timedelta(days=1)) if start > stop:
#!/usr/bin/env python from himlarcli.keystone import Keystone from himlarcli.cinder import Cinder from himlarcli.nova import Nova from himlarcli.neutron import Neutron from himlarcli.parser import Parser from himlarcli.printer import Printer from himlarcli import utils as himutils himutils.is_virtual_env() parser = Parser() options = parser.parse_args() printer = Printer(options.format) ksclient = Keystone(options.config, debug=options.debug) logger = ksclient.get_logger() regions = ksclient.find_regions(region_name=options.region) if not regions: himutils.sys_error('no regions found!') def action_show(): for region in regions: novaclient = Nova(options.config, debug=options.debug, log=logger, region=region) cinderclient = Cinder(options.config,
from himlarcli.parser import Parser from himlarcli.parser import Printer import novaclient.exceptions as novaexc import time import sys # OPS! It might need some updates. We use class Mail instead of Notify now. himutils.is_virtual_env() # Default value for date: today + 5 days at 14:00 today = datetime.today() date = datetime(today.year, today.month, today.day, 15, 0) + timedelta(days=5) # Load parser config from config/parser/* parser = Parser() parser.update_default('-m', date.strftime('%Y-%m-%d around %H:00')) options = parser.parse_args() printer = Printer(options.format) ksclient = Keystone(options.config, debug=options.debug) logger = ksclient.get_logger() novaclient = Nova(options.config, debug=options.debug, log=logger) domain = 'Dataporten' zone = '%s-default-1' % ksclient.region msg_file = 'notify/notify_reboot.txt' # aggregate in <loc>-legacy-1 AZ legacy_aggregate = ['group1', 'group2', 'group3'] if 'host' in options and options.host:
from himlarcli import tests as tests tests.is_virtual_env() from sqlalchemy import Column, Integer, String, DateTime from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from datetime import datetime from himlarcli.keystone import Keystone from himlarcli.nova import Nova from himlarcli.neutron import Neutron from himlarcli.parser import Parser from himlarcli import utils as himutils parser = Parser() parser.toggle_show('dry-run') parser.toggle_show('format') options = parser.parse_args() kc= Keystone(options.config, debug=options.debug) kc.set_domain(options.domain) logger = kc.get_logger() # Region if hasattr(options, 'region'): regions = kc.find_regions(region_name=options.region) else: regions = kc.find_regions() logger.debug('=> regions used: %s', ','.join(regions))
from himlarcli import utils as himutils from himlarcli.notify import Notify from himlarcli.state import State from himlarcli.parser import Parser import novaclient.exceptions as novaexc import time import sys himutils.is_virtual_env() # Default value for date: today + 5 days at 14:00 today = datetime.today() date = datetime(today.year, today.month, today.day, 14, 0) + timedelta(days=5) # Load parser config from config/parser/* parser = Parser() parser.update_default('-m', date.strftime('%Y-%m-%d around %H:00')) options = parser.parse_args() ksclient = Keystone(options.config, debug=options.debug) logger = ksclient.get_logger() novaclient = Nova(options.config, debug=options.debug, log=logger) domain = 'Dataporten' zone = '%s-default-1' % ksclient.region msg_file = 'misc/notify_reboot.txt' if 'host' in options and options.host: if '.' in options.host: host = options.host else: domain = ksclient.get_config('openstack', 'domain')
mq = MQclient(himlarcli_config, debug=options.debug, log=logger) channel = mq.get_channel('access') channel.basic_consume(process_action, queue='access') logger.info('start consuming rabbitmq') channel.start_consuming() if __name__ == "__main__": # Name sname = 'access-service' # Set up parser parser = Parser(name=sname, description='access service daemon', autoload=False) parser.toggle_show('dry-run') parser.toggle_show('format') parser.toggle_show('config') parser.add_actions({'start': 'start', 'stop': 'stop', 'restart': 'restart', 'status': 'status'}) parser.add_opt_args({'-f': {'sub': 'start', 'dest': 'foreground', 'const': True, 'default': False, 'action': 'store_const'}}) options = parser.parse_args()
#!/usr/bin/env python from himlarcli.keystone import Keystone from himlarcli.nova import Nova from himlarcli.cinder import Cinder from himlarcli.neutron import Neutron from himlarcli.parser import Parser from himlarcli.printer import Printer from himlarcli import utils as himutils from datetime import datetime himutils.is_virtual_env() parser = Parser() parser.set_autocomplete(True) options = parser.parse_args() printer = Printer(options.format) ksclient = Keystone(options.config, debug=options.debug) ksclient.set_dry_run(options.dry_run) logger = ksclient.get_logger() #novaclient = Nova(options.config, debug=options.debug, log=logger) if hasattr(options, 'region'): regions = ksclient.find_regions(region_name=options.region) else: regions = ksclient.find_regions() if not regions: himutils.sys_error('no regions found!') def action_create():
#!/usr/bin/env python from himlarcli.parser import Parser from himlarcli.printer import Printer from himlarcli.foremanclient import ForemanClient parser = Parser() parser.toggle_show('dry-run') parser.set_default_format('json') options = parser.parse_args() printer = Printer(options.format) foreman = ForemanClient(options.config, options.debug) hosts = options.hosts mapping = {} for host in hosts: fact = foreman.get_fact(host, options.fact) mapping[host] = fact printer.output_dict(mapping)
#!/usr/bin/env python """ Setup designate DNS """ import utils import re from himlarcli.keystone import Keystone from himlarcli.designate import Designate from himlarcli import utils as himutils from himlarcli.parser import Parser from himlarcli.printer import Printer from collections import OrderedDict from prettytable import PrettyTable himutils.is_virtual_env() parser = Parser() parser.set_autocomplete(True) options = parser.parse_args() printer = Printer(options.format) kc= Keystone(options.config, debug=options.debug) kc.set_domain(options.domain) kc.set_dry_run(options.dry_run) logger = kc.get_logger() dns = Designate(options.config, debug=options.debug) if options.action[0] == 'show': if options.dry_run: print 'DRY-RUN: show' else: