<commit_before># -*- coding: utf-8 -*-
import logging
from base import BaseStep
from dbaas_nfsaas.provider import NfsaasProvider


LOG = logging.getLogger(__name__)


class CreateNfs(BaseStep):

    def __unicode__(self):
        return "Requesting NFS volume..."

    def do(self, workflow_dict):
        try:

            workflow_dict['disks'] = []

            for host in workflow_dict['hosts']:

                LOG.info("Creating nfsaas disk...")

                disk = NfsaasProvider(
                ).create_disk(environment=workflow_dict['environment'],
                              plan=workflow_dict[
                              'plan'],
                              host=host)

                if not disk:
                    return False

                workflow_dict['disks'].append(disk)

            return True

        except Exception, e:
            print e
            return False

    def undo(self, workflow_dict):
        try:
            for host in workflow_dict['hosts']:
                LOG.info("Destroying nfsaas disk...")

                disk = NfsaasProvider().destroy_disk(
                    environment=workflow_dict['environment'], plan=workflow_dict['plan'], host=host)

                if not disk:
                    return False

            return True
        except Exception, e:
            print e
            return False
<commit_msg>Loop for instance instead host and do not create NFS for arbiter<commit_after># -*- coding: utf-8 -*-
import logging
from base import BaseStep
from physical.models import Instance
from dbaas_nfsaas.provider import NfsaasProvider


LOG = logging.getLogger(__name__)


class CreateNfs(BaseStep):

    def __unicode__(self):
        return "Requesting NFS volume..."

    def do(self, workflow_dict):
        try:

            workflow_dict['disks'] = []

            for instance in workflow_dict['instances']:
                host = instance.hostname
                
                if instance.is_arbiter:
                    LOG.info("Do not creat nfsaas disk for Arbiter...")
                    continue

                LOG.info("Creating nfsaas disk...")

                disk = NfsaasProvider(
                ).create_disk(environment=workflow_dict['environment'],
                              plan=workflow_dict[
                              'plan'],
                              host=host)

                if not disk:
                    return False

                workflow_dict['disks'].append(disk)

            return True

        except Exception, e:
            print e
            return False

    def undo(self, workflow_dict):
        try:
            for host in workflow_dict['hosts']:
                LOG.info("Destroying nfsaas disk...")

                disk = NfsaasProvider().destroy_disk(
                    environment=workflow_dict['environment'], plan=workflow_dict['plan'], host=host)

                if not disk:
                    return False

            return True
        except Exception, e:
            print e
            return False

{'fraction_non_alphanumeric': 0.0834144758195391, 'fraction_numerical': 0.0006491398896462187, 'mean_word_length': 1.4363636363636363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1060713', 'n_tokens_mistral': 816, 'n_tokens_neox': 741, 'n_words': 199}