Exemplo n.º 1
0
    def list(self, params):
        """Print all available releases:
                fuel release --list

           Print release with specific id=1:
                fuel release --rel 1
        """
        acceptable_keys = (
            "id",
            "name",
            "state",
            "operating_system",
            "version"
        )
        if params.release:
            release = Release(params.release)
            data = [release.get_fresh_data()]
        else:
            data = Release.get_all_data()
        self.serializer.print_to_output(
            data,
            format_table(
                data,
                acceptable_keys=acceptable_keys
            )
        )
Exemplo n.º 2
0
 def list(self, params):
     """Print all available roles and their
        conflicts for some release with id=1:
             fuel role --rel 1
     """
     release = Release(params.release, params=params)
     data = release.get_fresh_data()
     acceptable_keys = ("name", "conflicts")
     roles = [
         {"name": role_name, "conflicts": ", ".join(metadata.get("conflicts", ["-"]))}
         for role_name, metadata in data["roles_metadata"].iteritems()
     ]
     self.serializer.print_to_output(roles, format_table(roles, acceptable_keys=acceptable_keys))
Exemplo n.º 3
0
 def list(self, params):
     """Print all available roles and their
        conflicts for some release with id=1:
             fuel role --rel 1
     """
     release = Release(params.release, params=params)
     data = release.get_fresh_data()
     acceptable_keys = ("name", "conflicts")
     roles = [{
         "name": role_name,
         "conflicts": ", ".join(metadata.get("conflicts", ["-"]))
     } for role_name, metadata in data["roles_metadata"].iteritems()]
     self.serializer.print_to_output(
         roles, format_table(roles, acceptable_keys=acceptable_keys))
Exemplo n.º 4
0
    def list(self, params):
        """Print all available releases:
                fuel release --list

           Print release with specific id=1:
                fuel release --rel 1
        """
        acceptable_keys = ("id", "name", "state", "operating_system",
                           "version")
        if params.release:
            release = Release(params.release)
            data = [release.get_fresh_data()]
        else:
            data = Release.get_all_data()
        self.serializer.print_to_output(
            data, format_table(data, acceptable_keys=acceptable_keys))
Exemplo n.º 5
0
    def configure_release(self, params):
        """To configure RedHat release:
                fuel rel --rel <id of RedHat release> \\
                -c -U <username> -P <password>

           To configure RedHat release with satellite server:
                fuel rel --rel <...> -c -U <...> -P <...> \\
                --satellite-server-hostname <hostname> --activation-key <key>
        """
        release = Release(params.release)
        release_response = release.configure(params.username,
                                             params.password,
                                             satellite_server_hostname=None,
                                             activation_key=None)

        self.serializer.print_to_output(
            release_response, "Credentials for release with id={0}"
            " were modified.".format(release.id))
Exemplo n.º 6
0
 def network(self, params):
     """Modify release networks configuration.
     fuel rel --rel 1 --network --download
     fuel rel --rel 2 --network --upload
     """
     release = Release(params.release)
     dir_path = self.full_path_directory(
         params.dir, 'release_{0}'.format(params.release))
     full_path = '{0}/networks'.format(dir_path)
     if params.download:
         networks = release.get_networks()
         self.serializer.write_to_file(full_path, networks)
         print("Networks for release {0} "
               "downloaded into {1}.yaml".format(release.id, full_path))
     elif params.upload:
         networks = self.serializer.read_from_file(full_path)
         release.update_networks(networks)
         print("Networks for release {0} uploaded from {1}.yaml".format(
             release.id, full_path))
Exemplo n.º 7
0
 def deployment_tasks(self, params):
     """Modify deployment_tasks for release.
     fuel rel --rel 1 --deployment-tasks --download
     fuel rel --rel 1 --deployment-tasks --upload
     """
     release = Release(params.release)
     dir_path = self.full_path_directory(
         params.dir, 'release_{0}'.format(params.release))
     full_path = '{0}/deployment_tasks'.format(dir_path)
     if params.download:
         tasks = release.get_deployment_tasks()
         self.serializer.write_to_path(full_path, tasks)
         print("Deployment tasks for release {0} "
               "downloaded into {1}.yaml.".format(release.id, full_path))
     elif params.upload:
         tasks = self.serializer.read_from_file(full_path)
         release.update_deployment_tasks(tasks)
         print("Deployment tasks for release {0}"
               " uploaded from {1}.yaml".format(release.id, dir_path))
Exemplo n.º 8
0
    def sync_deployment_tasks(self, params):
        """Upload tasks for different releases based on directories.
        The string identifier for the release(s) to update is expected to be
        found in the path (see `fuel release`), like:

            /etc/puppet/<release>/
            /etc/puppet/liberty-9.0

        fuel rel --sync-deployment-tasks --dir /etc/puppet/liberty-9.0/
        fuel rel --sync-deployment-tasks --fp '*tasks.yaml'

        In case no directory was provided:

        fuel rel --sync-deployment-tasks

        The current directory will be used
        """
        all_rels = Release.get_all_data()
        real_path = os.path.realpath(params.dir)
        serialized_tasks = defaultdict(list)
        versions = set([r['version'] for r in all_rels])

        for file_name in utils.iterfiles(real_path, params.filepattern):
            for version in versions:
                if version in file_name:
                    serialized_tasks[version].extend(
                        self.serializer.read_from_full_path(file_name))

        for rel in all_rels:
            release = Release(rel['id'])
            data = serialized_tasks.get(rel['version'])
            if data:
                release.update_deployment_tasks(data)
                print("Deployment tasks synchronized for release"
                      " {0} of version {1}".format(rel['name'],
                                                   rel['version']))
            else:
                print("No tasks were synchronized for release {0} "
                      "of version {1}.(Hint: nothing matched "
                      "{2}/{1}/{3})".format(rel['name'],
                                            rel['version'],
                                            real_path,
                                            params.filepattern))
Exemplo n.º 9
0
 def deployment_tasks(self, params):
     """Modify deployment_tasks for release.
     fuel rel --rel 1 --deployment-tasks --download
     fuel rel --rel 1 --deployment-tasks --upload
     """
     release = Release(params.release)
     dir_path = self.full_path_directory(
         params.dir, 'release_{0}'.format(params.release))
     full_path = '{0}/deployment_tasks'.format(dir_path)
     if params.download:
         tasks = release.get_deployment_tasks()
         self.serializer.write_to_path(full_path, tasks)
         print("Deployment tasks for release {0} "
               "downloaded into {1}.yaml.".format(release.id, full_path))
     elif params.upload:
         tasks = self.serializer.read_from_file(full_path)
         release.update_deployment_tasks(tasks)
         print("Deployment tasks for release {0}"
               " uploaded from {1}.yaml".format(release.id, dir_path))
Exemplo n.º 10
0
 def network(self, params):
     """Modify release networks configuration.
     fuel rel --rel 1 --network --download
     fuel rel --rel 2 --network --upload
     """
     release = Release(params.release)
     dir_path = self.full_path_directory(
         params.dir, 'release_{0}'.format(params.release))
     full_path = '{0}/networks'.format(dir_path)
     if params.download:
         networks = release.get_networks()
         self.serializer.write_to_path(full_path, networks)
         print("Networks for release {0} "
               "downloaded into {1}.yaml".format(release.id, full_path))
     elif params.upload:
         networks = self.serializer.read_from_file(full_path)
         release.update_networks(networks)
         print("Networks for release {0} uploaded from {1}.yaml".format(
             release.id, full_path))
Exemplo n.º 11
0
    def sync_deployment_tasks(self, params):
        """Upload tasks for different releases based on directories.
        The string identifier for the release(s) to update is expected to be
        found in the path (see `fuel release`), like:

            /etc/puppet/<release>/
            /etc/puppet/liberty-9.0

        fuel rel --sync-deployment-tasks --dir /etc/puppet/liberty-9.0/
        fuel rel --sync-deployment-tasks --fp '*tasks.yaml'

        In case no directory was provided:

        fuel rel --sync-deployment-tasks

        The current directory will be used
        """
        all_rels = Release.get_all_data()
        real_path = os.path.realpath(params.dir)
        serialized_tasks = defaultdict(list)
        versions = set([r['version'] for r in all_rels])

        for file_name in utils.iterfiles(real_path, params.filepattern):
            for version in versions:
                if version in file_name:
                    serialized_tasks[version].extend(
                        self.serializer.read_from_full_path(file_name))

        for rel in all_rels:
            release = Release(rel['id'])
            data = serialized_tasks.get(rel['version'])
            if data:
                release.update_deployment_tasks(data)
                print("Deployment tasks synchronized for release"
                      " {0} of version {1}".format(rel['name'],
                                                   rel['version']))
            else:
                print("No tasks were synchronized for release {0} "
                      "of version {1}.(Hint: nothing matched "
                      "{2}/{1}/{3})".format(rel['name'], rel['version'],
                                            real_path, params.filepattern))
Exemplo n.º 12
0
    def configure_release(self, params):
        """To configure RedHat release:
                fuel rel --rel <id of RedHat release> \\
                -c -U <username> -P <password>

           To configure RedHat release with satellite server:
                fuel rel --rel <...> -c -U <...> -P <...> \\
                --satellite-server-hostname <hostname> --activation-key <key>
        """
        release = Release(params.release)
        release_response = release.configure(
            params.username,
            params.password,
            satellite_server_hostname=None,
            activation_key=None
        )

        self.serializer.print_to_output(
            release_response,
            "Credentials for release with id={0}"
            " were modified."
            .format(release.id)
        )
Exemplo n.º 13
0
    def sync_deployment_tasks(self, params):
        """Upload tasks for different releases based on directories.
        Unique identifier of the release should in the path, like:

            /etc/puppet/2014.2-6.0/

        fuel rel --sync-deployment-tasks --dir /etc/puppet/2014.2-6.0/
        fuel rel --sync-deployment-tasks --fp '*tasks.yaml'

        In case no directory will be provided:

        fuel rel --sync-deployment-tasks

        Current directory will be used
        """
        all_rels = Release.get_all_data()
        real_path = os.path.realpath(params.dir)
        serialized_tasks = defaultdict(list)
        versions = set([r['version'] for r in all_rels])

        for file_name in utils.iterfiles(real_path, params.filepattern):
            for version in versions:
                if version in file_name:
                    serialized_tasks[version].extend(
                        self.serializer.read_from_full_path(file_name))

        for rel in all_rels:
            release = Release(rel['id'])
            data = serialized_tasks.get(rel['version'])
            if data:
                release.update_deployment_tasks(data)
                print("Deployment tasks syncronized for release"
                      " {0} of version {1}".format(rel['name'],
                                                   rel['version']))
            else:
                print("No tasks found for release {0} "
                      "of version {1}".format(rel['name'], rel['version']))
Exemplo n.º 14
0
    def sync_deployment_tasks(self, params):
        """Upload tasks for different releases based on directories.
        Unique identifier of the release should in the path, like:

            /etc/puppet/2014.2-6.0/

        fuel rel --sync-deployment-tasks --dir /etc/puppet/2014.2-6.0/
        fuel rel --sync-deployment-tasks --fp '*tasks.yaml'

        In case no directory will be provided:

        fuel rel --sync-deployment-tasks

        Current directory will be used
        """
        all_rels = Release.get_all_data()
        real_path = os.path.realpath(params.dir)
        serialized_tasks = defaultdict(list)
        versions = set([r['version'] for r in all_rels])

        for file_name in utils.iterfiles(real_path, params.filepattern):
            for version in versions:
                if version in file_name:
                    serialized_tasks[version].extend(
                        self.serializer.read_from_full_path(file_name))

        for rel in all_rels:
            release = Release(rel['id'])
            data = serialized_tasks.get(rel['version'])
            if data:
                release.update_deployment_tasks(data)
                print("Deployment tasks synchronized for release"
                      " {0} of version {1}".format(rel['name'],
                                                   rel['version']))
            else:
                print("No tasks found for release {0} "
                      "of version {1}".format(rel['name'], rel['version']))
Exemplo n.º 15
0
delete all restrictions, which NSXv component checks.
"""

import sys

from fuelclient.objects.release import Release
from fuelclient.objects.role import Role

incompatible_roles = ["compute", "ironic", "cinder", "cinder-block-device"]
restrictions = {u"condition": u"'network:neutron:core:nsx' in cluster:components", u"action": u"hide"}
role_available_state = "available"
nsx_component_name = u"network:neutron:core:nsx"
clean = True if (len(sys.argv) > 1) else False

try:
    for release in Release.get_all_data():
        if release["state"] == role_available_state:
            for role in Role.get_all(release["id"]):
                if role["name"] in incompatible_roles:
                    meta = role["meta"]
                    if "restrictions" in meta.keys():
                        for restriction in meta["restrictions"]:
                            if nsx_component_name in restriction["condition"]:
                                if len(meta["restrictions"]) == 1 and clean:
                                    del meta["restrictions"]
                                else:
                                    meta["restrictions"].remove(restriction)
                        if not clean:
                            meta["restrictions"].append(restrictions)
                    else:
                        if not clean:
Exemplo n.º 16
0
import sys

from fuelclient.objects.release import Release
from fuelclient.objects.role import Role

incompatible_roles = ["compute", "ironic", "cinder", "cinder-block-device"]
restrictions = {
    u"condition": u"'network:neutron:core:nsx' in cluster:components",
    u"action": u"hide"
}
role_available_state = "available"
nsx_component_name = u"network:neutron:core:nsx"
clean = True if (len(sys.argv) > 1) else False

try:
    for release in Release.get_all_data():
        if release["state"] == role_available_state:
            for role in Role.get_all(release["id"]):
                if role["name"] in incompatible_roles:
                    meta = role["meta"]
                    if "restrictions" in meta.keys():
                        for restriction in meta["restrictions"]:
                            if nsx_component_name in restriction["condition"]:
                                if len(meta["restrictions"]) == 1 and clean:
                                    del meta["restrictions"]
                                else:
                                    meta["restrictions"].remove(restriction)
                        if not clean:
                            meta["restrictions"].append(restrictions)
                    else:
                        if not clean: