Exemple #1
0
    def setNetworking(self, iurl):
        """
            Create management bridge.
            This class will try to create a management bridge.
            Note: expected input format: http://www.redhat.com/a/b/c or:
            ftp://10.0.0.23/d/e/f
        """
        self.status = "OK"
        self.rc = True
        self.message = "Created management bridge."

        if rhel6based:
            deployUtil.setService("messagebus", "start")
            deployUtil.setService("libvirtd", "start")

        if deployUtil.preventDuplicate(bridgeName=self._bridgeName):
            self.message = "Bridge management already exists. Skipping " \
                "bridge creation."
            logging.debug(self.message)
        else:
            url, port = deployUtil.getAddress(iurl)
            if url is None:
                self.message = "Failed to parse manager URL!"
                self.status = "FAIL"
                logging.error(self.message)
                #Do not set rc to allow changes from Engine
            else:
                if not self._addNetwork(url, port):
                    self.status = "FAIL"
                    self.rc = False

        self._xmlOutput('SetNetworking', self.status, None, None, self.message)
        return self.rc
Exemple #2
0
    def setNetworking(self, iurl):
        """
            Create management bridge.
            This class will try to create a management bridge.
            Note: expected input format: http://www.redhat.com/a/b/c or:
            ftp://10.0.0.23/d/e/f
        """
        self.status = "OK"
        self.rc = True
        self.message = "Created management bridge."

        if rhel6based:
            deployUtil.setService("messagebus", "start")
            deployUtil.setService("libvirtd", "start")

        if deployUtil.preventDuplicate(bridgeName=self._bridgeName):
            self.message = "Bridge management already exists. Skipping " \
                "bridge creation."
            logging.debug(self.message)
        else:
            url, port = deployUtil.getAddress(iurl)
            if url is None:
                self.message = "Failed to parse manager URL!"
                self.status = "FAIL"
                logging.error(self.message)
                # Do not set rc to allow changes from Engine
            else:
                if not self._addNetwork(url, port):
                    self.status = "FAIL"
                    self.rc = False

        self._xmlOutput('SetNetworking', self.status, None, None, self.message)
        return self.rc
Exemple #3
0
    def setSSHAccess(self, url):
        """
            Sets ssh access for this host from the managment server.
        """
        self.message = "SUCCESS"
        self.status = "OK"
        self.rc = True
        strKey = None
        vdcAddress = None
        vdcPort = None

        vdcAddress, vdcPort = deployUtil.getAddress(url)
        if vdcAddress is not None:
            strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort)
            if strKey is None:
                self.rc = False
                self.message = "Failed to retrieve server SSH key."
        else:
            self.message = "Failed to extract server address."
            self.rc = False

        if self.rc:
            if not deployUtil.handleSSHKey(strKey):
                self.rc = False
                self.message = "Failed to write server's SSH key."

        if not self.rc:
            self.status = "FAIL"
        self._xmlOutput('SetSSHAccess', self.status, None, None, self.message)
        return self.rc
Exemple #4
0
    def setNetworking(self, iurl):
        """
            Create rhevm bridge.
            This class will try to create a managment bridge named "rehvm". Class
            always succeeds to allow network configuration from managment server
            even in case this class will fail to set the rhevm bridge.
            Note: expected input format: http://www.redhat.com/a/b/c or: ftp://10.0.0.23/d/e/f
        """
        self.status = "OK"
        self.rc = True
        self.message = "Created rhevm bridge."

        if deployUtil.preventDuplicate():
            self.message = "Bridge rhevm already exists. Skipping bridge creation."
            logging.debug(self.message)
        else:
            url, port = deployUtil.getAddress(iurl)
            if url is None:
                self.message = "Failed to parse manager URL!"
                self.status = "FAIL"
                logging.error(self.message)
                #Do not set rc to allow changes from rhev-m.
            else:
                self._addNetwork(url, port)

        self._xmlOutput('SetNetworking', self.status, None, None, self.message)
        return self.rc
Exemple #5
0
    def setSSHAccess(self, url):
        """
            Sets ssh access for this host from the managment server.
        """
        self.message = "SUCCESS"
        self.status = "OK"
        self.rc = True
        strKey = None
        vdcAddress = None
        vdcPort = None

        vdcAddress, vdcPort = deployUtil.getAddress(url)
        if vdcAddress is not None:
            strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort)
            if strKey is None:
                self.rc = False
                self.message = "Failed to retrieve server SSH key."
        else:
            self.message = "Failed to extract server address."
            self.rc = False

        if self.rc:
            if not deployUtil.handleSSHKey(strKey):
                self.rc = False
                self.message = "Failed to write server's SSH key."

        if not self.rc:
            self.status = "FAIL"
        self._xmlOutput('SetSSHAccess', self.status, None, None, self.message)
        return self.rc
Exemple #6
0
    def setNetworking(self, iurl):
        """
            Create rhevm bridge.
            This class will try to create a managment bridge named "rehvm". Class
            always succeeds to allow network configuration from managment server
            even in case this class will fail to set the rhevm bridge.
            Note: expected input format: http://www.redhat.com/a/b/c or: ftp://10.0.0.23/d/e/f
        """
        self.status = "OK"
        self.rc = True
        self.message = "Created rhevm bridge."

        if deployUtil.preventDuplicate():
            self.message = "Bridge rhevm already exists. Skipping bridge creation."
            logging.debug(self.message)
        else:
            url, port = deployUtil.getAddress(iurl)
            if url is None:
                self.message = "Failed to parse manager URL!"
                self.status = "FAIL"
                logging.error(self.message)
                #Do not set rc to allow changes from rhev-m.
            else:
                self._addNetwork(url, port)

        self._xmlOutput('SetNetworking', self.status, None, None, self.message)
        return self.rc
Exemple #7
0
    def setSSHAccess(self, url, engine_ssh_key):
        """
            Sets ssh access for this host from the managment server.
        """
        self.message = "SUCCESS"
        self.status = "OK"
        self.rc = True
        strKey = None

        # TODO remove legacy
        if deployUtil.getBootstrapInterfaceVersion() == 1 and \
                engine_ssh_key is None:
            vdcAddress = None
            vdcPort = None

            vdcAddress, vdcPort = deployUtil.getAddress(url)
            if vdcAddress is not None:
                strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort)
                if strKey is None:
                    self.rc = False
                    self.message = "Failed to retrieve server SSH key."
            else:
                self.message = "Failed to extract server address."
                self.rc = False
        else:
            try:
                with open(engine_ssh_key) as key:
                    strKey = key.read()
            except Exception as e:
                self.message = "Failed to read SSH key file " + str(e)
                self.rc = False

        if self.rc:
            if not deployUtil.handleSSHKey(strKey):
                self.rc = False
                self.message = "Failed to write server's SSH key."

        if not self.rc:
            self.status = "FAIL"
        self._xmlOutput('SetSSHAccess', self.status, None, None, self.message)
        return self.rc
Exemple #8
0
    def setSSHAccess(self, url, engine_ssh_key):
        """
            Sets ssh access for this host from the managment server.
        """
        self.message = "SUCCESS"
        self.status = "OK"
        self.rc = True
        strKey = None

        # TODO remove legacy
        if deployUtil.getBootstrapInterfaceVersion() == 1 and \
                engine_ssh_key is None:
            vdcAddress = None
            vdcPort = None

            vdcAddress, vdcPort = deployUtil.getAddress(url)
            if vdcAddress is not None:
                strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort)
                if strKey is None:
                    self.rc = False
                    self.message = "Failed to retrieve server SSH key."
            else:
                self.message = "Failed to extract server address."
                self.rc = False
        else:
            try:
                strKey = file(engine_ssh_key).read()
            except Exception as e:
                self.message = "Failed to read SSH key file " + str(e)
                self.rc = False

        if self.rc:
            if not deployUtil.handleSSHKey(strKey):
                self.rc = False
                self.message = "Failed to write server's SSH key."

        if not self.rc:
            self.status = "FAIL"
        self._xmlOutput('SetSSHAccess', self.status, None, None, self.message)
        return self.rc