예제 #1
0
 def _rebuild_and_reformat(self, node):
     # type: (Node) -> None
     """
     Reformats the node and rebuilds it in Openstack
     :param node: The node to rebuild and reformat
     """
     Openstack.rebuild_node(self.deploy, node)
     unmount(node, self.deploy.cluster.ssh_user, self.deploy.cluster.private_key)
예제 #2
0
def install(config_file):
    """ 
    Coordinates the cluster deployment from start to finish.
    :param: config_file - Path to main configuration file
    :return: None
    """
    logger.info("Beginning the deployment of a cluster")

    # Create a Deploy object
    deploy = Deploy(config_file)

    # Update logging handler to reflect process configuration
    logger.setLevel(deploy.log_level)

    # Build blueprints for ambari
    blueprint_builder = BlueprintBuilder(deploy)
    blueprint_builder.create_all()

    # Create deployment directory
    environment = Environment(deploy)
    environment.create()

    # OST phase
    openstack = Openstack(deploy)

    if deploy.use_existing_openstack:
        openstack.rebuild()
    else:
        openstack.build()

    # Log out the cluster thus far
    with open(os.path.join(deploy.installation_directory, 'cluster.json'),
              'w') as cluster_json_file:
        logger.info(deploy.cluster.to_json())
        cluster_json_file.write(deploy.cluster.to_json())

    # Chef phase
    chef = Chef(deploy)
    chef.converge()

    # Ambari phase
    ambari = Ambari(deploy)
    ambari.install()

    logger.info('REDstack install completed - Ambari: https://{0}:8443'.format(
        deploy.cluster.master_node.floating_ip))
예제 #3
0
 def models(self):
     self.openstacks = Openstack(self.config)
예제 #4
0
class Controller(Parent):

    def models(self):
        self.openstacks = Openstack(self.config)

    # BELOW THIS LINE ARE ALL CONTROLLER ACTIONS

    def handshake(self, data, resp):

        class HeartBeater(threading.Thread):
            def __init__(self, clientID, heartbeatInterval):
                self.clientID = clientID
                self.heartbeatInterval = heartbeatInterval

            def run(self):
                while(1):
                   time.sleep(self.heartbeatInterval)
                   self.logger.debug("Sending HeartBeat")
                   message = {}
                   message['action'] = "HEARTBEAT" 
                   message['to'] = "AgentManager"
                   message['from'] = self.clientID
                   message['data'] = {}
                   message['machineID'] = get_mac()
                   self.publisher.publish(message,"agents"+self.clientID+".heartbeat")

        self.clientID = data.UUID
        self.heartbeater = HeartBeater(self.clientID, self.config['Agent']['heartbeatInterval'])
        self.heartbeater.start()
        self.logger.debug("Agent Initialised")
        resp.respond("Heartbeater beating")

    def createOpenStack(self, data, resp):

        openstack = self.openstacks.new()

        keystone = ksclient.Client(auth_url="http://"+data.keystoneIPPort+"/v2.0",
            username=data.login,
            password=data.password,
            tenant_name=data.tenantName)

        ceilometer_endpoint = keystone.service_catalog.url_for(service_type='metering',
                                                               endpoint_type='adminURL')

        ceilometer = ceiloclient.Client('1', endpoint=ceilometer_endpoint, token=keystone.token-get())

        openstack.UUID = str(uuid.uuid4())
        openstack.IP = keystoneIPPort
        openstack.LOGIN = login
        openstack.PASSWORD = password
        openstack.TENANT = tenantName
        openstack.AUTHTOKEN = keystone.token-get()
        openstack.CEILOENDPOINT = ceilometer_endpoint
        openstack = self.openstacks.save(openstack)

        resp.respond(openstack.to_hash())

    def removeOpenStack(self, data, resp):
        print data.keystoneIP
        resp.respond(data.keystoneIP)

    def getOpenStacks(self, data, resp):
        openstackList = self.openstacks.findAll()
        resp.respond(openstackList)

    def getmeters(self, data, resp):
        openstack = self.openstacks.find(body['data']['UUID'])
        ceilometer = ceiloclient.Client(endpoint=openstack['data']['CEILOENDPOINT'], token=openstack['data']['AUTHTOKEN'])
        meters = ceilometer.meters.list()
        resp.respond(meters)

    def setMeterListener(self, data, resp):
        openstack = self.openstacks.find(body['data']['UUID'])
        ceilometer = ceiloclient.Cleint(endpoint=openstack['data']['CEILOENDPOINT'], token=openstack['data']['AUTHTOKEN'])
        meter = data.meterName
        sampleRate = data.sampleRate

        class MeterListener(threading.Thread):
            def __init__(self, ceilometer, meter, sampleRate):
                self.ceilometer = ceilometer
                self.meter = meter
                self.sampleRate = sampleRate

            def run(self):
                while(1):
                    time.sleep(self.sampleRate)
                    self.logger.debug("Sending Meter Samples")
                    
                    payload = {}
                    payload['CONTENT'] = ceilometer.meters.getMeter(meter)
                    payload['TYPE'] = "meter "+meter
                    payload['EVENTTIMESTAMP'] = time.time()
                    payload['METADATA'] = {}
                    
                    message = {}
                    message['action'] = "DATA"
                    message['to'] = "HoneyComb"
                    message['from'] = self.clientID
                    message['data'] = payload
                    message['machineID'] = get_mac()
                    
                    self.publisher.publish(message,"agents."+self.clientID+".data")

        meterListener = MeterListener(ceilometer, meter, sampleRate)
        meterListener.start()

        resp.respond("Done")

    def removeListener(self, listenerID):
        resp.respond("listenerID")