コード例 #1
0
    def take_action(self, parsed_args):
        env_id = parsed_args.env
        if not env_id:
            repo_id = parsed_args.repo
            repos = fc_client.get_request('/clusters/git-repos/')
            env_id = [repo['env_id'] for repo in repos
                      if repo['id'] == repo_id][0]

        env = Environment(env_id)
        # Due to how Nailgun handles such tasks, returned
        # one will not contain any deployment-related data.
        # So we'll have to fetch the last noop task with progress < 100
        env.redeploy_changes(noop_run=True)
        for retry in xrange(TASK_RETRIES):
            tasks = Task.get_all()
            try:
                task = filter(lambda t: t.data['status'] == 'running' and
                              t.data['name'] == 'dry_run_deployment',
                              tasks).pop()
                break
            except IndexError:
                time.sleep(TASK_RETRY_DELAY)
                continue
        data = {'task_id': task.id}
        data = data_utils.get_display_data_multi(self.columns, [data])
        return (self.columns, data)
コード例 #2
0
    def create(self, params):
        """Create a new node group
               fuel --env 1 nodegroup --create --name "group 1"
        """
        env_id = int(params.env)
        data = NodeGroup.create(params.name, env_id)
        env = Environment(env_id)
        network_data = env.get_network_data()
        seg_type = network_data['networking_parameters'].get(
            'segmentation_type'
        )
        if seg_type == 'vlan':
            six.print_("WARNING: In VLAN segmentation type, there will be no "
                       "connectivity over private network between instances "
                       "running on hypervisors in different segments and that "
                       "it's a user's responsibility to handle this "
                       "situation.",
                       file=sys.stderr)

        self.serializer.print_to_output(
            data,
            u"Node group '{name}' with id={id} "
            u"in environment {env} was created!"
            .format(env=env_id, **data)
        )
コード例 #3
0
def remove_from_env(env_id, name):
    """Removes a repository with the given name from the env settings"""
    env_obj = Environment(env_id)
    settings = env_obj.get_settings_data()

    old_repos = settings['editable']['repo_setup']['repos']['value']
    new_repos = [x for x in old_repos if x['name'] != name]
    settings['editable']['repo_setup']['repos']['value'] = new_repos

    env_obj.set_settings_data(settings)
コード例 #4
0
    def fuel_connection(self):
        if self._fuel_connection:
            return self._fuel_connection

        env = Environment(self.options.env)
        attrs_json = env.get_vmware_settings_data()

        try:
            attrs_json = attrs_json['editable']['value']['availability_zones'][
                0]
        except:
            self.debug('Could not parse vmware data from API')
        self._fuel_connection = attrs_json
        return self._fuel_connection
コード例 #5
0
 def client(self):
     """
     The instance of the Fuel Client for this cluster
     :rtype: fuelclient.objects.environment.Environment
     """
     if self._client:
         return self._client
     self._client = Environment(self.options.env)
     return self._client
コード例 #6
0
    def create(self, params):
        """Create a new node group
               fuel --env 1 nodegroup --create --name "group 1"
        """
        env_id = int(params.env)
        data = NodeGroup.create(params.name, env_id)
        env = Environment(env_id)
        network_data = env.get_network_data()
        seg_type = network_data['networking_parameters'].get(
            'segmentation_type')
        if seg_type == 'vlan':
            six.print_(
                "WARNING: In VLAN segmentation type, there will be no "
                "connectivity over private network between instances "
                "running on hypervisors in different segments and that "
                "it's a user's responsibility to handle this "
                "situation.",
                file=sys.stderr)

        self.serializer.print_to_output(
            data, u"Node group '{name}' with id={id} "
            u"in environment {env} was created!".format(env=env_id, **data))
コード例 #7
0
def get_fuel_environment():
    """
    As FUEL can have multiple environments configured we expect environment
    identifier is set as FUEL_ENV_ID environment variable otherwise the first
    operational environment is used.
    """
    env_id = os.environ.get('FUEL_ENV_ID')

    try:
        envs = [Environment(int(env_id))] if env_id else Environment.get_all()
        operational_envs = [e for e in envs if e.status == 'operational']
    except ValueError:
        sys.stderr.write("ERROR: FUEL_ENV_ID is invalid\n")
        sys.exit(1)
    except HTTPError as e:
        sys.stderr.write("ERROR: {error}\n".format(error=e.response))
        sys.exit(1)

    if not operational_envs:
        sys.stderr.write("ERROR: environment is not operational\n")
        sys.exit(1)

    return operational_envs[0]
コード例 #8
0
#
#    By [email protected]

import yaml
import sys, os
import logging
from fuelclient.objects import Environment
from subprocess import call

try:
    cluster_id = sys.argv[1]
except Exception:
    logging.warning('Provide cluster id as first parameter')
    sys.exit(1)

env = Environment(cluster_id)
data = env.get_settings_data()

try:
    tor_configurations = data['editable']['contrail']['metadata']['versions'][
        0]['tor_agents_configurations']['value']
except Exception:
    logging.warning('Cannot read tor agents configuration')
    sys.exit(2)

certificate_path = '/var/lib/fuel/certificates'

if not os.path.exists(certificate_path):
    os.makedirs(certificate_path)

directory = certificate_path + '/' + cluster_id + '/'