예제 #1
0
 def _deployid_show(self, dep_id):
     result = dp.Deployment().get(dep_id)
     if result:
         x = prettytable.PrettyTable()
         x.field_names = ["App Name", "App Version", "Cloud", "Status", "App Info"]
         pretty_table = common.artifact_depid_show(result, x)
         self.app.stdout.write("%s\n" % pretty_table)
예제 #2
0
 def _app_logs(self, deploy_id):
     result = dp.Deployment().logs(deploy_id)
     x = prettytable.PrettyTable()
     x.field_names = ["App Name", "App Version", "Cloud", "Log location"]
     if result:
         pretty_table = common.artifact_logs_show(result, x)
         self.app.stdout.write("%s\n" % pretty_table)
예제 #3
0
 def _app_name_show(self, appname):
     result = dp.Deployment().get_app_info(appname)
     if result:
         x = prettytable.PrettyTable()
         x.field_names = ["Deploy ID", "App Version", "Cloud", "Status", "App Info"]
         pretty_table = common.artifact_name_show(result, x)
         self.app.stdout.write("%s\n" % pretty_table)
예제 #4
0
    def _service_list(self):
        result = dp.Deployment().get_all_services()
        x = prettytable.PrettyTable()
        x.field_names = [
            "Deploy ID", "Service Name", "Service Version", "Cloud", "Status"
        ]

        if result:
            pretty_table = common.artifact_list_show(result, x)

        self.app.stdout.write("%s\n" % pretty_table)
예제 #5
0
    def _deploy_id_show(self, deploy_id):
        result = dp.Deployment().get_service_info_from_id(deploy_id)
        x = prettytable.PrettyTable()
        x.field_names = [
            "Deploy ID", "Service Version", "Cloud", "Status", "Service Info"
        ]

        if result:
            pretty_table = common.artifact_name_show(result, x)

        self.app.stdout.write("%s\n" % pretty_table)
예제 #6
0
    def __init__(self, smtp_server=default_smtp_server):
        """Creates an AssetMailer object

        :return: None
        """
        self.cls_logger = mod_logger + '.AssetMailer'
        self.smtp_server = smtp_server
        self.dep = deployment.Deployment()
        self.cons3rt_agent_log_dir = self.dep.cons3rt_agent_log_dir
        self.run_name = self.dep.get_value('cons3rt.deploymentRun.name')
        self.run_id = self.dep.get_value('cons3rt.deploymentRun.id')
        self.recipient_email = self.dep.get_value('cons3rt.user.email')
        if self.recipient_email is None:
            self.recipient_email = default_recipient_email
        self.subject = 'pycons3rt Asset Mailer for Run {n}[{i}]: '.format(
            n=self.run_name, i=self.run_id)
예제 #7
0
 def deployment(self,
                component,
                version,
                hosts,
                status='start',
                owner=None,
                env=None):
     """
     Return a new Deployment object associated with this client.
     
     Refer to bigpanda.Deployment for more help.
     """
     return deployment.Deployment(component,
                                  version,
                                  hosts,
                                  status,
                                  owner,
                                  env,
                                  client=self)
예제 #8
0
    def __init__(self, slack_url):
        self.cls_logger = mod_logger + '.Cons3rtSlacker'
        self.slack_url = slack_url
        self.dep = deployment.Deployment()
        self.slack_channel = self.dep.get_value('SLACK_CHANNEL')
        self.deployment_run_name = self.dep.get_value(
            'cons3rt.deploymentRun.name')
        self.deployment_run_id = self.dep.get_value('cons3rt.deploymentRun.id')

        # Build the Slack message text
        self.slack_text = 'Run: ' + self.deployment_run_name + ' (ID: ' + self.deployment_run_id + ')' + '\nHost: *' + \
                          self.dep.cons3rt_role_name + '*'

        # Initialize the SlackMessage
        try:
            SlackMessage.__init__(self,
                                  webhook_url=self.slack_url,
                                  text=self.slack_text,
                                  channel=self.slack_channel)
        except ValueError:
            raise
예제 #9
0
    def _cloud_show(self, cloud):
        result = dp.Deployment().get_cloud_info(cloud)
        x = prettytable.PrettyTable()
        x.field_names = ["Deploy ID", "App Name", "App Version", "App URL"]

        if result:
            status_json = json.loads(result)
            app_status_list = status_json['app_data']

            logging.debug(app_status_list)

            for line in app_status_list:
                dep_id = line['dep_id']
                app_name = line['app_name']
                version = line['app_version']
                app_url = line['url']

                row = [dep_id, app_name, version, app_url]
                x.add_row(row)

        self.app.stdout.write("%s\n" % x)
예제 #10
0
    def _deploy_id_show_bak(self, deploy_id):
        if deploy_id:
            result = dp.Deployment().get(deploy_id)

            status_json = json.loads(result)
            status_val = status_json['app_data']

            status_val_list = status_val.split(',')

            x = prettytable.PrettyTable()
            x.field_names = ["App Name", "Deploy ID", "Status", "Cloud", "App URL"]

            app_name = ''
            app_deploy_id = deploy_id
            app_deploy_time = ''
            app_status = ''
            app_url = ''
            cloud = ''
            for stat in status_val_list:
                stat = stat.rstrip().lstrip()
                if stat.lower().find("name::") >= 0:
                    l = stat.split("::")
                    app_name = l[2]
                elif stat.lower().find("deploy_id::") >= 0:
                    l = stat.split("::")
                    app_deploy_id = l[1]
                elif stat.lower().find("cloud::") >= 0:
                    l = stat.split("::")
                    cloud = l[2]
                elif stat.lower().find("status::") >= 0:
                    l = stat.split("::")
                    app_status = l[1]
                elif stat.lower().find("url::") >= 0:
                    l = stat.split("::")
                    app_url = l[1]

            row = [app_name, app_deploy_id, app_status, cloud, app_url]
            x.add_row(row)
            self.app.stdout.write("%s\n" % x)
예제 #11
0
 def _app_delete(self, deploy_id):
     result = dp.Deployment().delete(deploy_id)
     self.log.debug("App delete result:%s" % result)
예제 #12
0
 def _service_secure(self, deploy_id):
     result = dp.Deployment().service_secure(deploy_id)
     self.log.debug("Service secure result:%s" % result)
예제 #13
0
    def take_action(self, parsed_args):
        self.log.debug('Deploying application. Passed args:%s' % parsed_args)

        service = parsed_args.service
        dest = parsed_args.cloud
        common.verify_inputs(service, dest)
        common.verify_yaml_file()

        project_location = os.getcwd()
        self.log.debug("App directory:%s" % project_location)

        cloud_info = common.read_cloud_info()
        if not cloud_info:
            if dest:
                self.log.debug("Destination:%s" % dest)
            else:
                dest = raw_input("Please enter Cloud deployment target>")
                common.verify_inputs(service, dest)
            if dest.lower() == common.AWS:
                common.setup_aws()
                cloud_info['type'] = common.AWS
            if dest.lower() == common.GOOGLE:
                project_id = ''
                user_email = ''
                common.setup_google()
                project_id, user_email = common.get_google_project_user_details(
                    project_location)
                cloud_info['type'] = common.GOOGLE
                cloud_info['project_id'] = project_id
                cloud_info['user_email'] = user_email
            if dest.lower() == common.LOCAL_DOCKER:
                cloud_info['type'] = common.LOCAL_DOCKER
                cloud_info['app_port'] = '5000'
        else:
            if dest and cloud_info['type'] != dest:
                print(
                    "Looks like there is cld.yaml present in the directory and the value of the cloud flag differs between command line and cld.yaml."
                )
                print("Using values in cld.yaml.")

        app_info = common.read_app_info()
        if not app_info:
            app_info = self._get_app_details()

        service_info = common.read_service_info()

        if not service_info:
            if service:
                self.log.debug("Service:%s" % service)
                service_info = self._get_service_details(service)
                app_info = self._get_app_service_details(app_info)

        self.dep_track_url = dp.Deployment().post(project_location, app_info,
                                                  service_info, cloud_info)
        self.log.debug("App tracking url:%s" % self.dep_track_url)

        k = project_location.rfind("/")
        app_name = project_location[k + 1:]

        l = self.dep_track_url.rfind("/")
        dep_id = self.dep_track_url[l + 1:]

        x = prettytable.PrettyTable()
        x.field_names = ["App Name", "Deploy ID", "Cloud"]

        x.add_row([app_name, dep_id, cloud_info['type']])
        self.app.stdout.write("%s\n" % x)
        self.log.debug(x)
예제 #14
0
    def take_action(self, parsed_args):
        #self.log.info('Deploying service')

        service = parsed_args.service_name
        dest = parsed_args.cloud

        common.verify_inputs(service, dest)
        common.verify_yaml_file()

        service_info = common.read_service_info()
        if not service_info:
            service_details = {}
            service_list = []
            service_details['type'] = 'mysql'
            service_info = {}
            service_info['service'] = service_details
            service_list.append(service_info)
            service_info = service_list

        common.verify_service(service_details['type'])

        self._read_service_setup_script(service_info)

        cloud_info = common.read_cloud_info()

        if not cloud_info:
            cloud_info = {}
            dest = parsed_args.cloud
            if not dest:
                dest = raw_input("Please enter Cloud deployment target>")
            common.verify_cloud(dest)
            if dest.lower() == common.LOCAL_DOCKER:
                cloud_info['type'] = common.LOCAL_DOCKER
            if dest.lower() == common.AWS:
                common.setup_aws()
                cloud_info['type'] = common.AWS
            if dest.lower() == common.GOOGLE:
                common.setup_google()
                project_location = os.getcwd()
                project_id = ''
                user_email = ''
                project_id, user_email = common.get_google_project_user_details(
                    project_location)
                print("Using project_id:%s" % project_id)
                print("Using user email:%s" % user_email)
                cloud_info['type'] = common.GOOGLE
                cloud_info['project_id'] = project_id
                cloud_info['user_email'] = user_email
        else:
            if dest:
                if cloud_info['type'].lower() != dest.lower():
                    print(
                        "Looks like there is cld.yaml present in the directory and the value of the cloud flag differs between command line and cld.yaml."
                    )
                    print("Using values in cld.yaml.")
            else:
                dest = raw_input("Please enter destination cloud>")

        print("Deploying instance of %s on %s" %
              (service_details['type'], dest))

        self.dep_track_url = dp.Deployment().create_service_instance(
            service_info, cloud_info)
        self.log.debug("Service deployment tracking url:%s" %
                       self.dep_track_url)

        l = self.dep_track_url.rfind("/")
        dep_id = self.dep_track_url[l + 1:]

        x = prettytable.PrettyTable()
        x.field_names = ["Service Name", "Deploy ID", "Cloud"]

        cloud = cloud_info['type']
        for serv in service_info:
            service_name = serv['service']['type']
            x.add_row([service_name, dep_id, cloud])
            self.app.stdout.write("%s\n" % x)
            self.log.debug(x)
예제 #15
0
import os
import re
import deployment
from remote_hosts_list import __REMOTE_HOSTS_LIST__
from dirs_to_deploy_list import __DIRS_TO_DEPLOY_LIST__

addon_id = re.sub("deploy_", "", os.path.basename(__file__))[:-3]
deployment = deployment.Deployment()
deployment.deploy(__REMOTE_HOSTS_LIST__, [
    next(deploy_dir for deploy_dir in __DIRS_TO_DEPLOY_LIST__
         if deploy_dir["id"] == addon_id)
])