Revision 4c818bb2

b/ci/new_config
19 19
# Configuration of git (on remote server)
20 20
git_config_name = Buildbot
21 21
git_config_mail = synnefo@builder.dev.grnet.gr
22
# Network address from which we allow access to server. If not set, access
23
# to server is not restricted.
24
filter_access_network =
22
# Network address from which we allow access to server.
23
# If not set, access to server is not restricted.
24
accept_ssh_from =
25 25
# Config file to save temporary options (eg IPs, passwords etc)
26 26
temporary_config = /tmp/ci_temp_conf
27 27

  
......
36 36
flavor_id = 639
37 37
# Image to use (name must contain this)
38 38
image_name = OldStable
39
# File containing the ssh keys to upload/install to server
40
# If not set, no ssh keys will be installed
41
ssh_keys =
39 42

  
40 43

  
41 44
[Burnin]
b/ci/snf-ci
60 60
                      help="Name of flavor to use for the server.")
61 61
    parser.add_option("-i", "--image", dest="image", default=None,
62 62
                      help="UUID of image to use for the server.")
63
    parser.add_option("--ssh-keys", dest="ssh_keys", default=None,
64
                      help="Upload/Install the public ssh keys contained"
65
                           " in this file to the server")
63 66
    parser.add_option("--fetch-packages", dest="fetch_packages",
64 67
                      default=None,
65 68
                      help="Download the debian packages that were created"
......
102 105

  
103 106
    if getattr(options, CREATE_SERVER_CMD, False):
104 107
        synnefo_ci.create_server(flavor_id=options.flavor,
105
                                 image_id=options.image)
108
                                 image_id=options.image,
109
                                 ssh_keys=options.ssh_keys)
106 110
        synnefo_ci.clone_repo()
107 111
    if getattr(options, BUILD_SYNNEFO_CMD, False):
108 112
        synnefo_ci.build_synnefo()
b/ci/utils.py
36 36
        return fabric.run(cmd)
37 37

  
38 38

  
39
def _put(local, remote):
40
    """Run fabric put command without output"""
41
    with fabric.quiet():
42
        fabric.put(local, remote)
43

  
44

  
39 45
def _red(msg):
40 46
    """Red color"""
41 47
    #return "\x1b[31m" + str(msg) + "\x1b[0m"
......
226 232
            self._wait_transition(server_id, "ACTIVE", "DELETED")
227 233

  
228 234
    @_check_kamaki
229
    def create_server(self, image_id=None, flavor_id=None):
235
    def create_server(self, image_id=None, flavor_id=None, ssh_keys=None):
230 236
        """Create slave server"""
231 237
        self.logger.info("Create a new server..")
232 238
        if image_id is None:
......
251 257

  
252 258
        server = self._wait_transition(server_id, "BUILD", "ACTIVE")
253 259
        self._get_server_ip_and_port(server)
254
        self._copy_ssh_keys()
260
        self._copy_ssh_keys(ssh_keys)
255 261

  
256 262
        self.setup_fabric()
257 263
        self.logger.info("Setup firewall")
258
        accept_ssh_from = self.config.get('Global', 'filter_access_network')
264
        accept_ssh_from = self.config.get('Global', 'accept_ssh_from')
259 265
        if accept_ssh_from != "":
260 266
            self.logger.debug("Block ssh except from %s" % accept_ssh_from)
261 267
            cmd = """
......
300 306
        self.logger.debug("Server's IPv4 is %s" % _green(server_ip))
301 307
        self.write_config('server_port', server_port)
302 308
        self.logger.debug("Server's ssh port is %s" % _green(server_port))
309
        self.logger.debug("Access server using \"ssh -p %s %s@%s\"" %
310
                          (server_port, fabric.env.user, server_ip))
303 311

  
304 312
    @_check_fabric
305
    def _copy_ssh_keys(self):
313
    def _copy_ssh_keys(self, ssh_keys):
306 314
        """Upload/Install ssh keys to server"""
307
        if not self.config.has_option("Deployment", "ssh_keys"):
308
            return
309
        authorized_keys = self.config.get("Deployment",
310
                                          "ssh_keys")
311
        if authorized_keys != "" and os.path.exists(authorized_keys):
315
        self.logger.debug("Check for authentication keys to upload")
316
        if ssh_keys is None:
317
            ssh_keys = self.config.get("Deployment", "ssh_keys")
318

  
319
        if ssh_keys != "" and os.path.exists(ssh_keys):
312 320
            keyfile = '/tmp/%s.pub' % fabric.env.user
313 321
            _run('mkdir -p ~/.ssh && chmod 700 ~/.ssh', False)
314
            fabric.put(authorized_keys, keyfile)
322
            _put(ssh_keys, keyfile)
315 323
            _run('cat %s >> ~/.ssh/authorized_keys' % keyfile, False)
316 324
            _run('rm %s' % keyfile, False)
317 325
            self.logger.debug("Uploaded ssh authorized keys")
......
506 514
            raise ValueError("Unknown schema: %s" % schema)
507 515

  
508 516
        self.logger.debug("Upload schema files to server")
509
        with fabric.quiet():
510
            fabric.put(os.path.join(schema_dir, "*"), "/etc/snf-deploy/")
517
        _put(os.path.join(schema_dir, "*"), "/etc/snf-deploy/")
511 518

  
512 519
        self.logger.debug("Change password in nodes.conf file")
513 520
        cmd = """
......
536 543

  
537 544
        self.logger.debug("Upload tests.sh file")
538 545
        unit_tests_file = os.path.join(self.ci_dir, "tests.sh")
539
        with fabric.quiet():
540
            fabric.put(unit_tests_file, ".")
546
        _put(unit_tests_file, ".")
541 547

  
542 548
        self.logger.debug("Run unit tests")
543 549
        cmd = """

Also available in: Unified diff