Exemplo n.º 1
0
    def configure_event(self, content):
        """
        This method handles a configure event.
        """

        # During the config event, the FSM will write the received input
        # to a file
        cirros_username = '******'
        cirros_password = '******'

        # Configure each cirros vdu
        for vdu in self.ips:
            for cp in self.ips[vdu]:
                if cp['id'] in ['mgmt', 'management', 'eth0']:
                    mgmt_ip = cp['ip']
                    break

            LOG.info('management ip: ' + str(mgmt_ip))

            ssh_client = ssh.Client(mgmt_ip,
                                    username=cirros_username,
                                    password=cirros_password,
                                    logger=LOG,
                                    retries=10)

            ssh_client.sendCommand("echo " + str(content['message']) +
                                   " > test_configure.txt")

        response = {'status': 'COMPLETED'}
        return response
Exemplo n.º 2
0
    def start_event(self, content):
        """
        This method handles a start event.
        """

        # During the start event, the FSM will write the ip addresses of the
        # vnf to a file

        vnfr = content['vnfr']
        self.ips = tnglib.get_ips_from_vnfr(vnfr)[1]

        LOG.info(yaml.dump(self.ips))

        # Configure each cirros vdu
        for vdu in self.ips:
            for cp in self.ips[vdu]:
                if cp['id'] in ['mgmt', 'management', 'eth0']:
                    mgmt_ip = cp['ip']
                    self.mgmt_ip = mgmt_ip
                    break

            LOG.info('management ip: ' + str(mgmt_ip))

            ssh_client = ssh.Client(mgmt_ip,
                                    username=self.cirros_username,
                                    password=self.cirros_password,
                                    logger=LOG,
                                    retries=20)

            ssh_client.sendCommand("echo " + str(mgmt_ip) +
                                   " > test_start.txt")

        response = {'status': 'COMPLETED'}
        return response
Exemplo n.º 3
0
    def state_event(self, content):
        """
        This method handles a configure event.
        """

        LOG.info("content: " + yaml.dump(content))

        response = {'status': 'COMPLETED'}

        if content['action'] == 'extract':
            ssh_client = ssh.Client(self.mgmt_ip,
                                    username=self.cirros_username,
                                    password=self.cirros_password,
                                    logger=LOG,
                                    retries=10)

            state = ssh_client.sendCommand("cat test_start.txt")
            LOG.info("Obtained state: " + str(state))

            response['persist'] = state
        else:
            ssh_client = ssh.Client(self.mgmt_ip,
                                    username=self.cirros_username,
                                    password=self.cirros_password,
                                    logger=LOG,
                                    retries=10)

            state_message = "echo \"" + str(
                content['state']) + "\" > test_start.txt"
            LOG.info(state_message)
            reply = ssh_client.sendCommand(state_message)
            LOG.info(str(reply))
            response['persist'] = 'finished'

        LOG.info("response: " + yaml.dump(response))
        return response