Esempio n. 1
0
    def do(self, workflow_dict):
        try:

            databaseinfra = workflow_dict['databaseinfra']

            foxha_credentials = get_credentials_for(
                environment=databaseinfra.environment,
                credential_type=CredentialType.FOXHA)
            dbaas_api = DatabaseAsAServiceApi(databaseinfra=databaseinfra,
                                              credentials=foxha_credentials)

            foxprovider = FoxHAProvider(dbaas_api=dbaas_api)

            LOG.info('Starting foxha on DatabaseInfra {}'.format(
                databaseinfra.name))
            foxprovider.start(group_name=databaseinfra.name)

            LOG.info("Waiting 30 seconds to start VIP")
            sleep(30)

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0013)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
Esempio n. 2
0
    def _get_fox_provider(self, driver):
        databaseinfra = driver.databaseinfra

        foxha_credentials = get_credentials_for(
            environment=databaseinfra.environment,
            credential_type=CredentialType.FOXHA)
        dbaas_api = DatabaseAsAServiceApi(databaseinfra, foxha_credentials)
        return FoxHAProvider(dbaas_api)
Esempio n. 3
0
 def __init__(self, instance):
     super(FoxHA, self).__init__(instance)
     self.mysql_fox_credentials = get_credentials_for(
         self.environment, CredentialType.MYSQL_FOXHA)
     self.mysql_replica_credentials = get_credentials_for(
         self.environment, CredentialType.MYSQL_REPLICA)
     self.foxha_credentials = get_credentials_for(self.environment,
                                                  CredentialType.FOXHA)
     self.dbaas_api = DatabaseAsAServiceApi(self.infra,
                                            self.foxha_credentials)
     self.provider = FoxHAProvider(self.dbaas_api)
    def undo(self, workflow_dict):
        try:
            LOG.info("Running undo...")

            databaseinfra = workflow_dict['databaseinfra']
            foxha_credentials = get_credentials_for(
                environment=databaseinfra.environment,
                credential_type=CredentialType.FOXHA)
            dbaas_api = DatabaseAsAServiceApi(databaseinfra=databaseinfra,
                                              credentials=foxha_credentials)
            foxprovider = FoxHAProvider(dbaas_api=dbaas_api)
            for instance in workflow_dict['instances']:
                LOG.info('Deleting foxah node {}'.format(instance.address))
                foxprovider.delete_node(group_name=databaseinfra.name,
                                        node_ip=instance.address)

            LOG.info('Deleting foxah group {}'.format(databaseinfra.name))
            foxprovider.delete_group(group_name=databaseinfra.name)

            return True

        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0013)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
Esempio n. 5
0
    def do(self, workflow_dict):
        try:

            databaseinfra = workflow_dict['databaseinfra']
            vip = workflow_dict['vip']
            vip_ip = vip.vip_ip
            mysql_fox_credentials = get_credentials_for(
                environment=databaseinfra.environment,
                credential_type=CredentialType.MYSQL_FOXHA)
            mysql_repl_credentials = get_credentials_for(
                environment=databaseinfra.environment,
                credential_type=CredentialType.MYSQL_REPLICA)

            foxha_credentials = get_credentials_for(
                environment=databaseinfra.environment,
                credential_type=CredentialType.FOXHA)
            dbaas_api = DatabaseAsAServiceApi(databaseinfra=databaseinfra,
                                              credentials=foxha_credentials)

            foxprovider = FoxHAProvider(dbaas_api=dbaas_api)

            LOG.info('Adding foxah group {}'.format(databaseinfra.name))
            foxprovider.add_group(
                group_name=databaseinfra.name,
                description=databaseinfra.name,
                vip_address=vip_ip,
                mysql_user=mysql_fox_credentials.user,
                mysql_password=str(mysql_fox_credentials.password),
                repl_user=mysql_repl_credentials.user,
                repl_password=str(mysql_repl_credentials.password))

            for index, instance in enumerate(
                    workflow_dict['target_instances']):

                if index == 0:
                    mode = 'read_write'
                else:
                    mode = 'read_only'

                LOG.info('Adding foxah node {}'.format(instance.dns))
                foxprovider.add_node(group_name=databaseinfra.name,
                                     name=instance.dns,
                                     node_ip=instance.address,
                                     port=instance.port,
                                     mode=mode,
                                     status='enabled')

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0013)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False