Ejemplo n.º 1
0
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:
    if '.' in options.host:
        host = options.host
    else:
        domain = ksclient.get_config('openstack', 'domain')
        host = options.host + '.' + domain
else:
    host = None

def action_show():
    aggregate = novaclient.get_aggregate(options.aggregate)
    print '\nMETADATA:'
    for key, value in aggregate.metadata.iteritems():
        print "%s = %s" % (key, value)
    print '\nHOSTS:'
    for h in aggregate.hosts:
        services = novaclient.get_service(h)
        print '%s (%s)' % (h, services[0].status)

def action_list():
Ejemplo n.º 2
0
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')
        host = options.host + '.' + domain
else:
    host = None


def action_show():
    aggregate = novaclient.get_aggregate(options.aggregate)
    print '\nMETADATA:'
    for key, value in aggregate.metadata.iteritems():
        print "%s = %s" % (key, value)
    print '\nHOSTS:'
    for h in aggregate.hosts:
        services = novaclient.get_service(h)
        print '%s (%s)' % (h, services[0].status)
Ejemplo n.º 3
0
#!/usr/bin/env python
import utils
import sys
#from himlarcli.nova import Nova
from himlarcli.keystone import Keystone
#import himlarcli.foremanclient as foreman
from himlarcli.foremanclient import Client
from himlarcli import utils as himutils

desc = 'Setup compute resources and profiles'
options = utils.get_options(desc, hosts=False, dry_run=True)
keystone = Keystone(options.config, debug=options.debug)
logger = keystone.get_logger()
domain = keystone.get_config('openstack', 'domain')

client = Client(options.config, options.debug, log=logger)
foreman = client.get_client()

# Add compute resources
resource_config = himutils.load_config('config/compute_resources.yaml')
if keystone.region not in resource_config:
    num_resources = resource_config['default']['num_resources']
else:
    num_resources = resource_config[keystone.region]['num_resources']
logger.debug("=> number of compute resources for %s: %s" %
             (keystone.region, num_resources))
resources = foreman.index_computeresources()
found_resources = dict({})
for r in resources['results']:
    found_resources[r['name']] = r['id']
Ejemplo n.º 4
0
#!/usr/bin/env python
import utils
from himlarcli.keystone import Keystone
from himlarcli.foremanclient import ForemanClient
from himlarcli import utils as himutils

# Fix foreman functions and logger not-callable
# pylint: disable=E1101,E1102

desc = 'Setup Foreman for himlar'
options = utils.get_options(desc, hosts=False)
keystone = Keystone(options.config, debug=options.debug)
logger = keystone.get_logger()
domain = keystone.get_config('openstack', 'domain')

foreman = ForemanClient(options.config, options.debug, log=logger)
client = foreman.get_client()

# create foreman domain based on config
# get domain id

# get smart proxy id for tftp

# create subnet
# mgmt network + netmask from config
# domain_ids = domain_id
# tftp_ids = proxy_id
# dns-primary, dns-secondary, gateway is blank
# get subnet id

# Glabal parameters
Ejemplo n.º 5
0
keystoneclient = Keystone(options.config, options.debug)
projects_count = keystoneclient.get_project_count('dataporten')
users_count = keystoneclient.get_user_count('dataporten')
logger = keystoneclient.get_logger()

stats = dict()
stats['projects'] = {}
stats['instances'] = {}
stats['instances']['total'] = {'count': 0, 'error': 0}
stats['users'] = {}
stats['projects'][keystoneclient.region] = {}
stats['projects'][keystoneclient.region]['count'] = projects_count
stats['users'][keystoneclient.region] = {}
stats['users'][keystoneclient.region]['count'] = users_count

server = keystoneclient.get_config('statsd', 'server')
port = keystoneclient.get_config('statsd', 'port')

# Regions
regions = himutils.load_region_config('config/stats',
                                      region=keystoneclient.region,
                                      log=logger)

# Instances
for name, info in sorted(regions['regions'].iteritems()):
    logger.debug('=> count region %s' % name)
    novaclient = Nova(options.config, debug=options.debug, region=name)
    novastats = novaclient.get_stats()
    stats['instances'][name] = {}
    stats['instances'][name]['count'] = novastats['count']
    stats['instances'][name]['error'] = novastats['error']