コード例 #1
0
ファイル: heat.py プロジェクト: MobileCloudNetworking/imsaas
    def __init__(self, region_name=None):
        heat_args = SysUtil.get_credentials()
        heat_args['token'] = SysUtil.get_token()
        conf = SysUtilObj().get_sys_conf()
        endpoint = SysUtil.get_endpoint(service_type='orchestration', endpoint_type='publicURL', region_name=conf['os_region_name'])

        self.client = HeatClient(version='1', endpoint=endpoint, **heat_args)
コード例 #2
0
ファイル: heat.py プロジェクト: MobileCloudNetworking/maas
    def __init__(self):
        heat_args = SysUtil.get_credentials()
        heat_args["token"] = SysUtil.get_token()
        conf = SysUtilObj().get_sys_conf()
        endpoint = SysUtil.get_endpoint(
            service_type="orchestration", endpoint_type="publicURL", region_name=conf["os_region_name"]
        )

        self.client = HeatClient(version="1", endpoint=endpoint, **heat_args)
コード例 #3
0
ファイル: heat.py プロジェクト: Cloudxtreme/maas
    def __init__(self):
        heat_args = SysUtil.get_credentials()
        heat_args['token'] = SysUtil.get_token()
        conf = SysUtilObj().get_sys_conf()
        endpoint = SysUtil.get_endpoint(service_type='orchestration',
                                        endpoint_type='publicURL',
                                        region_name=conf['os_region_name'])

        self.client = HeatClient(version='1', endpoint=endpoint, **heat_args)
コード例 #4
0
ファイル: RuntimeAgent.py プロジェクト: Cloudxtreme/maas
 def __init__(self, topology):
     super(CheckerThread, self).__init__()
     self.heatclient = HeatClient()
     self.topology = topology
     self.db = DatabaseManager()
     self.is_stopped = False
     self.is_dns_configured = False
     self.novac = NovaClient()
     #self.dns_configurator = ImsDnsClient()
     self.neutronc = NeutronClient(
         utilSys.get_endpoint(
             'network',
             region_name=SysUtil().get_sys_conf()['os_region_name']),
         utilSys.get_token())
コード例 #5
0
 def __init__(self, topology):
     super(CheckerThread, self).__init__()
     self.heatclient = HeatClient()
     self.topology = topology
     self.db = DatabaseManager()
     self.is_stopped = False
     self.is_dns_configured = False
     self.novac = NovaClient()
     #self.dns_configurator = ImsDnsClient()
     self.neutronc = NeutronClient(utilSys.get_endpoint('network', region_name=SysUtil().get_sys_conf()['os_region_name']), utilSys.get_token())
コード例 #6
0
    def dump_to_dict(self):
        resource = {}
        software_config_config = {}
        software_config_config['type'] = self.type

        properties = {}
        if self.config:
            _config = ''
            for command in self.config:
                _config += "%s\n" % command.command
            properties['config'] = SysUtil.literal_unicode((_config))
        if self.group: properties['group'] = self.group
        if self.inputs:
            _inputs = []
            for input in self.inputs:
                _inputs.append({'name': input})
            properties['inputs'] = _inputs
        if self.outputs:
            properties['outputs'] = self.outputs
        else:
            properties['outputs'] = [{'name': 'result'}]
        software_config_config['properties'] = properties
        resource[self.name] = software_config_config
        return resource
コード例 #7
0
    def dump_to_dict(self):
        resource = {}
        software_config_config = {}
        software_config_config['type'] = self.type

        properties = {}
        if self.config:
            _config = ''
            for command in self.config:
                _config += "%s\n" % command.command
            properties['config'] = SysUtil.literal_unicode((_config))
        if self.group: properties['group'] = self.group
        if self.inputs:
            _inputs = []
            for input in self.inputs:
                _inputs.append({'name':input})
            properties['inputs'] = _inputs
        if self.outputs:
            properties['outputs'] = self.outputs
        else:
            properties['outputs'] = [{'name':'result'}]
        software_config_config['properties']= properties
        resource[self.name] = software_config_config
        return resource
コード例 #8
0
 def dump_to_dict(self):
     db = DatabaseManager()
     resource = {}
     server_config = {}
     server_config['type'] = self.type
     properties = {}
     properties['name'] = self.name
     properties['image'] = self.image
     properties['flavor'] = self.flavor
     if self.key_name is not None: properties['key_name'] = self.key_name
     if self.availability_zone is not None: properties['availability_zone'] = self.availability_zone
     if self.network_ports is not None:
         networks = []
         LOG.debug(self.network_ports)
         for network_port in self.network_ports:
             networks.append({'port': { 'get_resource' : network_port.name}})
         properties['networks'] = networks
     if self.user_data:
         properties['user_data_format'] = 'RAW'
         properties['user_data'] = {}
         properties['user_data']['str_replace'] = {}
         properties['user_data']['str_replace']['template'] = ''
         _user_data = ''
         _user_data_list = []
         for command in self.user_data:
             _user_data += "%s\n" % command.command
         properties['user_data']['str_replace']['template'] = SysUtil.literal_unicode((_user_data))
         properties['user_data']['str_replace']['params'] = {'':''}
         if self.requirements:
             params = {}
             for requirement in self.requirements:
                 try:
                     source_service_instances = db.get_by_name(ServiceInstance,requirement.source)
                 except:
                     LOG.debug('ERROR: Entry %s was not found in Table ServiceInstance' % requirement.source)
                     raise
                 source_units = []
                 if source_service_instances:
                     source_service_instance = source_service_instances[0]
                     source_units = source_service_instance.units
                     LOG.debug(source_units)
                     if source_units:
                         if requirement.parameter == 'private_ip' or requirement.parameter == 'public_ip':
                             #Get requested network specified in the requirement
                             _networks = [network for network in source_service_instance.networks if network.name == requirement.obj_name ]
                             _network = None
                             if _networks:
                                 _network_id = _networks[0].private_net
                             else:
                                 LOG.debug('ERROR: obj_name %s was not found in networks of ServiceInstance %s' % (requirement.obj_name,source_service_instance))
                                 raise
                             #Get network name of the specified network id
                             _network_names = [network.name for network in db.get_all(Network) if network.ext_id == _network_id]
                             _network_name = None
                             if _network_names:
                                 _network_name = _network_names[0]
                             else:
                                 LOG.debug('ERROR: Cannot find network with id %s in Table Network' % _network_id)
                             if requirement.parameter == "private_ip":
                                 ip_number = 0
                             elif requirement.parameter == "public_ip":
                                 ip_number = 1
                             #Create the variable
                             _params = {}
                             _first_unit = source_units[0]
                             _template = '$%s' % _first_unit.hostname
                             _params['$%s' % _first_unit.hostname] = {'get_attr': [_first_unit.hostname, 'networks', _network_name, ip_number]}
                             for source_unit in source_units[1:]:
                                 _template += ';$%s' % source_unit.hostname
                                 _params['$%s' % source_unit.hostname] = {'get_attr': [source_unit.hostname, 'networks', _network_name, ip_number]}
                         param = {}
                         param[requirement.name] = {}
                         param[requirement.name]['str_replace'] = {}
                         param[requirement.name]['str_replace']['template'] = _template
                         param[requirement.name]['str_replace']['params'] = _params
                         params.update(param)
                     else:
                         LOG.debug('ERROR: Units for ServiceInstance %s were not found.' % requirement.source)
                         raise Exception
                 else:
                     LOG.debug('ERROR: ServiceInstance %s was not found' % requirement.source)
                     raise Exception
             properties['user_data']['str_replace']['params'] = params
     server_config['properties'] = properties
     resource[self.name] = server_config
     return resource
コード例 #9
0
ファイル: keystone.py プロジェクト: Cloudxtreme/maas
 def __init__(self):
     ks_args = SysUtil.get_credentials()
     self.ksclient = KeystoneClient(**ks_args)
コード例 #10
0
import os
from util import SysUtil

__author__ = 'lto'
from clients.neutron import Client
import logging

PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

if __name__ == '__main__':

    logging.basicConfig(format='%(asctime)s_%(process)d:%(pathname)s:%(lineno)d [%(levelname)s] %(message)s',
                        level=logging.DEBUG)
    logger = logging.getLogger("EMMLogger")
    handler = logging.FileHandler('%s/logs/%s.log' % (PATH, os.path.basename(__file__)))
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s_%(process)d:%(pathname)s:%(lineno)d [%(levelname)s] %(message)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    cl = Client(SysUtil.get_endpoint('network'), SysUtil.get_token())

    cl.list_ports()
コード例 #11
0
 def dump_to_dict(self):
     db = DatabaseManager()
     resource = {}
     server_config = {}
     server_config["type"] = self.type
     properties = {}
     properties["name"] = self.name
     properties["image"] = self.image
     properties["flavor"] = self.flavor
     if self.key_name is not None:
         properties["key_name"] = self.key_name
     if self.availability_zone is not None:
         properties["availability_zone"] = self.availability_zone
     if self.network_ports is not None:
         networks = []
         logger.debug(self.network_ports)
         for network_port in self.network_ports:
             networks.append({"port": {"get_resource": network_port.name}})
         properties["networks"] = networks
     if self.user_data:
         properties["user_data_format"] = "RAW"
         properties["user_data"] = {}
         properties["user_data"]["str_replace"] = {}
         properties["user_data"]["str_replace"]["template"] = ""
         _user_data = ""
         _user_data_list = []
         for command in self.user_data:
             _user_data += "%s\n" % command.command
         properties["user_data"]["str_replace"]["template"] = SysUtil.literal_unicode((_user_data))
         properties["user_data"]["str_replace"]["params"] = {"": ""}
         if self.requirements:
             params = {}
             for requirement in self.requirements:
                 try:
                     source_service_instances = db.get_by_name(ServiceInstance, requirement.source)
                 except:
                     logger.debug("ERROR: Entry %s was not found in Table ServiceInstance" % requirement.source)
                     raise
                 source_units = []
                 if source_service_instances:
                     source_service_instance = source_service_instances[0]
                     source_units = source_service_instance.units
                     logger.debug(source_units)
                     if source_units:
                         if requirement.parameter == "private_ip" or requirement.parameter == "public_ip":
                             # Get requested network specified in the requirement
                             _networks = [
                                 network
                                 for network in source_service_instance.networks
                                 if network.name == requirement.obj_name
                             ]
                             _network = None
                             if _networks:
                                 _network_id = _networks[0].private_net
                             else:
                                 logger.debug(
                                     "ERROR: obj_name %s was not found in networks of ServiceInstance %s"
                                     % (requirement.obj_name, source_service_instance)
                                 )
                                 raise
                             # Get network name of the specified network id
                             _network_names = [
                                 network.name for network in db.get_all(Network) if network.ext_id == _network_id
                             ]
                             _network_name = None
                             if _network_names:
                                 _network_name = _network_names[0]
                             else:
                                 logger.debug("ERROR: Cannot find network with id %s in Table Network" % _network_id)
                             if requirement.parameter == "private_ip":
                                 ip_number = 0
                             elif requirement.parameter == "public_ip":
                                 ip_number = 1
                             # Create the variable
                             _params = {}
                             _first_unit = source_units[0]
                             _template = "$%s" % _first_unit.hostname
                             _params["$%s" % _first_unit.hostname] = {
                                 "get_attr": [_first_unit.hostname, "networks", _network_name, ip_number]
                             }
                             for source_unit in source_units[1:]:
                                 _template += ";$%s" % source_unit.hostname
                                 _params["$%s" % source_unit.hostname] = {
                                     "get_attr": [source_unit.hostname, "networks", _network_name, ip_number]
                                 }
                         param = {}
                         param[requirement.name] = {}
                         param[requirement.name]["str_replace"] = {}
                         param[requirement.name]["str_replace"]["template"] = _template
                         param[requirement.name]["str_replace"]["params"] = _params
                         params.update(param)
                     else:
                         logger.debug("ERROR: Units for ServiceInstance %s were not found." % requirement.source)
                         raise Exception
                 else:
                     logger.debug("ERROR: ServiceInstance %s was not found" % requirement.source)
                     raise Exception
             properties["user_data"]["str_replace"]["params"] = params
     server_config["properties"] = properties
     resource[self.name] = server_config
     return resource
コード例 #12
0
ファイル: TemplateManager.py プロジェクト: Cloudxtreme/maas
 def dump_to_dict(self):
     db = DatabaseManager()
     resource = {}
     server_config = {}
     server_config['type'] = self.type
     properties = {}
     properties['name'] = self.name
     properties['image'] = self.image
     properties['flavor'] = self.flavor
     if self.key_name is not None: properties['key_name'] = self.key_name
     if self.availability_zone is not None:
         properties['availability_zone'] = self.availability_zone
     if self.network_ports is not None:
         networks = []
         LOG.debug(self.network_ports)
         for network_port in self.network_ports:
             networks.append({'port': {'get_resource': network_port.name}})
         properties['networks'] = networks
     if self.user_data:
         properties['user_data_format'] = 'RAW'
         properties['user_data'] = {}
         properties['user_data']['str_replace'] = {}
         properties['user_data']['str_replace']['template'] = ''
         _user_data = ''
         _user_data_list = []
         for command in self.user_data:
             _user_data += "%s\n" % command.command
         properties['user_data']['str_replace'][
             'template'] = SysUtil.literal_unicode((_user_data))
         properties['user_data']['str_replace']['params'] = {'': ''}
         if self.requirements:
             params = {}
             for requirement in self.requirements:
                 try:
                     source_service_instances = db.get_by_name(
                         ServiceInstance, requirement.source)
                 except:
                     LOG.debug(
                         'ERROR: Entry %s was not found in Table ServiceInstance'
                         % requirement.source)
                     raise
                 source_units = []
                 if source_service_instances:
                     source_service_instance = source_service_instances[0]
                     source_units = source_service_instance.units
                     LOG.debug(source_units)
                     if source_units:
                         if requirement.parameter == 'private_ip' or requirement.parameter == 'public_ip':
                             #Get requested network specified in the requirement
                             _networks = [
                                 network for network in
                                 source_service_instance.networks
                                 if network.name == requirement.obj_name
                             ]
                             _network = None
                             if _networks:
                                 _network_id = _networks[0].private_net
                             else:
                                 LOG.debug(
                                     'ERROR: obj_name %s was not found in networks of ServiceInstance %s'
                                     % (requirement.obj_name,
                                        source_service_instance))
                                 raise
                             #Get network name of the specified network id
                             _network_names = [
                                 network.name
                                 for network in db.get_all(Network)
                                 if network.ext_id == _network_id
                             ]
                             _network_name = None
                             if _network_names:
                                 _network_name = _network_names[0]
                             else:
                                 LOG.debug(
                                     'ERROR: Cannot find network with id %s in Table Network'
                                     % _network_id)
                             if requirement.parameter == "private_ip":
                                 ip_number = 0
                             elif requirement.parameter == "public_ip":
                                 ip_number = 1
                             #Create the variable
                             _params = {}
                             _first_unit = source_units[0]
                             _template = '$%s' % _first_unit.hostname
                             _params['$%s' % _first_unit.hostname] = {
                                 'get_attr': [
                                     _first_unit.hostname, 'networks',
                                     _network_name, ip_number
                                 ]
                             }
                             for source_unit in source_units[1:]:
                                 _template += ';$%s' % source_unit.hostname
                                 _params['$%s' % source_unit.hostname] = {
                                     'get_attr': [
                                         source_unit.hostname, 'networks',
                                         _network_name, ip_number
                                     ]
                                 }
                         param = {}
                         param[requirement.name] = {}
                         param[requirement.name]['str_replace'] = {}
                         param[requirement.
                               name]['str_replace']['template'] = _template
                         param[requirement.
                               name]['str_replace']['params'] = _params
                         params.update(param)
                     else:
                         LOG.debug(
                             'ERROR: Units for ServiceInstance %s were not found.'
                             % requirement.source)
                         raise Exception
                 else:
                     LOG.debug('ERROR: ServiceInstance %s was not found' %
                               requirement.source)
                     raise Exception
             properties['user_data']['str_replace']['params'] = params
     server_config['properties'] = properties
     resource[self.name] = server_config
     return resource
コード例 #13
0
 def __init__(self):
     creds = SysUtil.get_credentials()
     creds['os_auth_token'] = SysUtil.get_token()
     #creds['token'] = util.get_token()
     #creds['ceilometer_url'] = util.get_endpoint(service_type='metering',endpoint_type='publicURL')
     self.cmclient = client.get_client('2', **creds)
コード例 #14
0
ファイル: ceilometer.py プロジェクト: Cloudxtreme/maas
 def __init__(self):
     creds = SysUtil.get_credentials()
     creds['os_auth_token'] = SysUtil.get_token()
     #creds['token'] = util.get_token()
     #creds['ceilometer_url'] = util.get_endpoint(service_type='metering',endpoint_type='publicURL')
     self.cmclient = client.get_client('2', **creds)
コード例 #15
0
ファイル: test_neutron.py プロジェクト: Cloudxtreme/maas
import os
from util import SysUtil

__author__ = 'lto'
from clients.neutron import Client
import logging

PATH = os.path.abspath(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))

if __name__ == '__main__':

    logging.basicConfig(
        format=
        '%(asctime)s_%(process)d:%(pathname)s:%(lineno)d [%(levelname)s] %(message)s',
        level=logging.DEBUG)
    logger = logging.getLogger("EMMLogger")
    handler = logging.FileHandler('%s/logs/%s.log' %
                                  (PATH, os.path.basename(__file__)))
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
        '%(asctime)s_%(process)d:%(pathname)s:%(lineno)d [%(levelname)s] %(message)s'
    )
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    cl = Client(SysUtil.get_endpoint('network'), SysUtil.get_token())

    cl.list_ports()