Esempio n. 1
0
File: g5k.py Progetto: ivotron/enos
    def _deploy(self, conf, nodes, vlans, force_deploy=False):
        provider_conf = conf['provider']
        # we put the nodes in the first vlan we have
        vlan = self._get_primary_vlan(vlans)
        # Deploy all the nodes
        logging.info("Deploying %s on %d nodes %s" %
                     (provider_conf['env_name'], len(nodes),
                      '(forced)' if force_deploy else ''))

        deployed, undeployed = EX5.deploy(
            EX5.Deployment(nodes,
                           env_name=provider_conf['env_name'],
                           vlan=vlan[1]),
            check_deployed_command=not force_deploy)

        # Check the deployment
        if len(undeployed) > 0:
            logging.error("%d nodes where not deployed correctly:" %
                          len(undeployed))
            for n in undeployed:
                logging.error(n)

        deployed_nodes_vlan = sorted(self._translate_to_vlan(
            map(lambda n: EX.Host(n), deployed), vlan[1]),
                                     key=lambda n: n.address)

        logging.info(deployed_nodes_vlan)
        # Checking the deployed nodes according to the
        # resource distribution policy
        self._check_nodes(nodes=deployed_nodes_vlan,
                          resources=conf['resources'],
                          mode=conf['provider']['role_distribution'])

        return deployed, deployed_nodes_vlan
Esempio n. 2
0
File: g5k.py Progetto: asimonet/enos
    def _deploy(self):
        # we put the nodes in the first vlan we have
        vlan = self._get_primary_vlan()
        # Deploy all the nodes
        logging.info("Deploying %s on %d nodes %s" %
                     (self.config['env_name'], len(
                         self.nodes), '(forced)' if self.force_deploy else ''))

        deployed, undeployed = EX5.deploy(
            EX5.Deployment(self.nodes,
                           env_name=self.config['env_name'],
                           vlan=vlan[1]),
            check_deployed_command=not self.force_deploy)

        # Check the deployment
        if len(undeployed) > 0:
            logging.error("%d nodes where not deployed correctly:" %
                          len(undeployed))
            for n in undeployed:
                logging.error(n)

        # Updating nodes names with vlans
        self.nodes = sorted(self._translate_to_vlan(self.nodes, vlan[1]),
                            key=lambda n: n.address)
        logging.info(self.nodes)
        self.deployed_nodes = sorted(self._translate_to_vlan(
            map(lambda n: EX.Host(n), deployed), vlan[1]),
                                     key=lambda n: n.address)
        logging.info(self.deployed_nodes)
        self._check_nodes(nodes=self.deployed_nodes,
                          resources=self.config['resources'],
                          mode=self.config['role_distribution'])

        return deployed, undeployed
Esempio n. 3
0
 def start_deploy_server(self):
     """Deploy the server with the given Kadeploy environment.  Blocks until
     deployment is done"""
     # Sort hosts by name and take the first one: this is useful when
     # using a single reservation for all nodes, since we will always
     # pick the same host as server.
     self.server = sorted(g5k.get_oar_job_nodes(*self.server_job),
                          key=lambda node: node.address)[0]
     if os.path.isfile(self.args.server_env):
         deploy_opts = {"env_file": self.args.server_env}
     else:
         deploy_opts = {
             "env_name": self.args.server_env,
             "user": self.args.kadeploy_user
         }
     if self.multi_site():
         deploy_opts["vlan"] = self.global_vlan
         logger.debug(
             "Deploying environment '{}' on server {} in VLAN {}...".format(
                 self.args.server_env, self.server.address,
                 self.global_vlan))
     else:
         logger.debug("Deploying environment '{}' on server {}...".format(
             self.args.server_env, self.server.address))
     d = g5k.Deployment([self.server], **deploy_opts)
     return g5k.kadeploy.Kadeployer(d).start()
Esempio n. 4
0
 def start_deploy_vmhosts(self):
     hosts = g5k.get_oar_job_nodes(*self.vmhosts_job)
     if self.multi_site():
         self.vm_hosts = hosts
     else:
         # Take all but the first host
         self.vm_hosts = sorted(hosts, key=lambda node: node.address)[1:]
     if os.path.isfile(self.args.vmhosts_env):
         deploy_opts = {"env_file": self.args.vmhosts_env}
     else:
         deploy_opts = {
             "env_name": self.args.vmhosts_env,
             "user": self.args.vmhosts_kadeploy_user
         }
     if self.multi_site():
         deploy_opts["vlan"] = self.global_vlan
         logger.debug(
             "Deploying environment '{}' on {} VM hosts in VLAN {}...".
             format(self.args.vmhosts_env, len(self.vm_hosts),
                    self.global_vlan))
     else:
         logger.debug("Deploying environment '{}' on {} VM hosts...".format(
             self.args.vmhosts_env, len(self.vm_hosts)))
     d = g5k.Deployment(self.vm_hosts, **deploy_opts)
     return g5k.kadeploy.Kadeployer(d).start()
Esempio n. 5
0
    def _deploy(self, conf, nodes, vlans, force_deploy=False):
        provider_conf = conf['provider']
        # we put the nodes in the first vlan we have
        vlan = self._get_primary_vlan(vlans)

        kw = {
            'hosts': nodes,
            'vlan': vlan[1],
        }
        if provider_conf.get('env_file'):
            kw.update({'env_file': provider_conf.get('env_file')})
            provider_conf.pop('env_name')
        if provider_conf.get('env_name'):
            kw.update({'env_name': provider_conf.get('env_name')})

        logging.info("%s deploying %s nodes with %s" %
                     ('(forced)' if force_deploy else '', len(nodes), kw))

        deployed, undeployed = EX5.deploy(
            EX5.Deployment(**kw), check_deployed_command=not force_deploy)

        # Check the deployment
        if len(undeployed) > 0:
            logging.error("%d nodes where not deployed correctly:" %
                          len(undeployed))
            for n in undeployed:
                logging.error(n)

        deployed_nodes_vlan = sorted(self._translate_to_vlan(
            map(lambda n: EX.Host(n), deployed), vlan[1]),
                                     key=lambda n: n.address)

        logging.info(deployed_nodes_vlan)
        # Checking the deployed nodes according to the
        # resource distribution policy
        self._check_nodes(nodes=deployed_nodes_vlan,
                          resources=conf['resources'],
                          mode=conf['provider']['role_distribution'])

        return deployed, deployed_nodes_vlan
Esempio n. 6
0
def _deploy(nodes, force_deploy, options):
    # For testing purpose
    logger.info("Deploying %s with options %s" % (nodes, options))
    dep = ex5.Deployment(nodes, **options)
    return ex5.deploy(dep, check_deployed_command=not force_deploy)
Esempio n. 7
0
    def setup_host(self):
        """Deploy a node, install dependencies and Rally"""

        logger.info('Deploying environment %s on %s' %
                    (style.emph(self.config['env-name']), self.host) +
                    (' (forced)' if self.options.force_deploy else ''))

        deployment = None
        if 'env-user' not in self.config or self.config['env-user'] == '':
            deployment = EX5.Deployment(hosts=[self.host],
                                        env_name=self.config['env-name'])
        else:
            deployment = EX5.Deployment(hosts=[self.host],
                                        env_name=self.config['env-name'],
                                        user=self.config['env-user'])

        deployed_hosts, _ = EX5.deploy(
            deployment, check_deployed_command=not self.options.force_deploy)

        # Test if rally is installed
        test_p = EX.SshProcess('rally version', self.host, {'user': '******'})
        test_p.ignore_exit_code = True
        test_p.nolog_exit_code = True
        test_p.run()

        if test_p.exit_code != 0:
            # Install rally
            self._run_or_abort(
                "curl -sO %s" % RALLY_INSTALL_URL,
                self.host,
                "Could not download Rally install script from %s" %
                RALLY_INSTALL_URL,
                conn_params={'user': '******'})

            logger.info("Installing dependencies on deployed host")
            self._run_or_abort('apt-get update && apt-get -y update',
                               self.host,
                               'Could not update packages on host',
                               conn_params={'user': '******'})

            self._run_or_abort('apt-get -y install python-pip',
                               self.host,
                               'Could not install pip on host',
                               conn_params={'user': '******'})
            self._run_or_abort('pip install --upgrade setuptools',
                               self.host,
                               'Could not upgrade setuptools',
                               conn_params={'user': '******'})

            logger.info("Installing rally from %s" %
                        style.emph(self.config['rally-git']))
            self._run_or_abort("bash install_rally.sh -y --url %s" %
                               self.config['rally-git'],
                               self.host,
                               'Could not install Rally on host',
                               conn_params={'user': '******'})
        else:
            logger.info("Rally %s is already installed" %
                        test_p.stdout.rstrip())

        # Setup the deployment file
        vars = {
            "controller": self.config['os-services']['controller'],
            "os_region": self.config['authentication']['os-region'],
            "os_username": self.config['authentication']['os-username'],
            "os_password": self.config['authentication']['os-password'],
            "os_tenant": self.config['authentication']['os-tenant'],
            "os_user_domain": self.config['authentication']['os-user-domain'],
            "os_project_domain":
            self.config['authentication']['os-project-domain']
        }
        rally_deployment = self._render_template(
            'templates/deployment_existing.json', vars)
        EX.Put([self.host], [rally_deployment],
               remote_location='deployment_existing.json',
               connection_params={
                   'user': '******'
               }).run()

        # Create a Rally deployment
        self._run_or_abort(
            "rally deployment create --filename deployment_existing.json "
            "--name %s" % self.config['deployment-name'],
            self.host,
            'Could not create the Rally deployment',
            conn_params={'user': '******'})
        self.rally_deployed = True

        logger.info("Rally has been deployed correctly")
# sites.remove('bordeaux')


EX.logger.setLevel('INFO')
jobs = EX5.get_current_oar_jobs(['reims'])
 
if len(jobs) == 0:
    jobs = EX5.oarsub([( EX5.OarSubmission(resources = "{type=\\'kavlan\\'}/vlan=1+/nodes=2", walltime="3:00:00", job_type ='deploy'), "reims")])
    EX5.wait_oar_job_start( oar_job_id=jobs[0][0], frontend=jobs[0][1])  

print jobs
hosts = EX5.get_oar_job_nodes(jobs[0][0], jobs[0][1])
print hosts
kavlan_id = EX5.get_oar_job_kavlan(jobs[0][0], jobs[0][1])
print kavlan_id
deployment = EX5.Deployment( hosts = hosts, env_file= "ubuntu-x64-1204", vlan = kavlan_id) 

deployed_hosts, undeployed_hosts = EX5.deploy(deployment)
#deployed_hosts, undeployed_hosts = EX5.deploy(deployment, num_tries=0,check_deployed_command=True)

if kavlan_id is not None:
        hosts = [ EX5.get_kavlan_host_name(host, kavlan_id) for host in deployed_hosts ]
print hosts[0]


def get_kavlan_network(kavlan, site):
    """Retrieve the network parameters for a given kavlan from the API"""
    network, mask_size = None, None
    equips = EX5.get_resource_attributes('/sites/' + site + '/network_equipments/')
    for equip in equips['items']:
        if 'vlans' in equip and len(equip['vlans']) > 2:
Esempio n. 9
0
def deploy(host):
    return ex5.deploy(ex5.Deployment([host], env_name=ENV_NAME))