def getVCenterConnectionDetails(self, session, vCenter_resource_details):
        """
        Return a dictionary with vCenter connection details. Methods receives a ResourceDetails object of a vCenter resource
        and retrieves the connection details from its attributes.

        :param vCenter_resource_details:   the ResourceDetails object of a vCenter resource
        :param session:                    the cloushell api session, its needed in order to decrypt the password
        """
        user = first_or_default(vCenter_resource_details.ResourceAttributes, lambda att: att.Name == "User").Value
        encryptedPass = first_or_default(
            vCenter_resource_details.ResourceAttributes, lambda att: att.Name == "Password"
        ).Value
        vcenter_url = vCenter_resource_details.Address
        password = session.DecryptPassword(encryptedPass).Value
        return {"user": user, "password": password, "vCenter_url": vcenter_url}
    def getVCenterConnectionDetails(self, session, vCenter_resource_details):
        """
        Return a dictionary with vCenter connection details. Methods receives a ResourceDetails object of a vCenter resource
        and retrieves the connection details from its attributes.

        :param vCenter_resource_details:   the ResourceDetails object of a vCenter resource
        :param session:                    the cloushell api session, its needed in order to decrypt the password
        """
        user = first_or_default(vCenter_resource_details.ResourceAttributes,
                                lambda att: att.Name == "User").Value
        encryptedPass = first_or_default(
            vCenter_resource_details.ResourceAttributes,
            lambda att: att.Name == "Password").Value
        vcenter_url = vCenter_resource_details.Address
        password = session.DecryptPassword(encryptedPass).Value
        return {"user": user, "password": password, "vCenter_url": vcenter_url}
Example #3
0
    def replace_app_resource_with_vm_resource(self, data_holder, deploy_result):
        app_name = data_holder.resource_context.name
        self.create_resource_for_deployed_vm(data_holder, deploy_result)

        reservation_id = helpers.get_reservation_context_details().id
        session = helpers.get_api_session()

        services_position = session.GetReservationServicesPositions(reservation_id)
        app_poistion = first_or_default(services_position.ResourceDiagramLayouts, lambda x: x.ResourceName == app_name)

        session.RemoveServicesFromReservation(reservation_id, app_name)
        session.SetReservationResourcePosition(reservation_id, deploy_result.vm_name, app_poistion.X, app_poistion.Y)